career_diagram.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. /*
  7. *
  8. * Requires extra_field_values.value to be longtext to save diagram:
  9. *
  10. UPDATE extra_field_values SET created_at = NULL WHERE CAST(created_at AS CHAR(20)) = '0000-00-00 00:00:00';
  11. UPDATE extra_field_values SET updated_at = NULL WHERE CAST(updated_at AS CHAR(20)) = '0000-00-00 00:00:00';
  12. ALTER TABLE extra_field_values modify column value longtext null;
  13. */
  14. $cidReset = true;
  15. require_once __DIR__.'/../inc/global.inc.php';
  16. if (api_get_configuration_value('allow_career_diagram') == false) {
  17. api_not_allowed(true);
  18. }
  19. $this_section = SECTION_PLATFORM_ADMIN;
  20. $allowCareer = api_get_configuration_value('allow_session_admin_read_careers');
  21. api_protect_admin_script($allowCareer);
  22. $htmlHeadXtra[] = api_get_js('jsplumb2.js');
  23. $careerId = isset($_GET['id']) ? $_GET['id'] : 0;
  24. if (empty($careerId)) {
  25. api_not_allowed(true);
  26. }
  27. $career = new Career();
  28. $careerInfo = $career->get($careerId);
  29. if (empty($careerInfo)) {
  30. api_not_allowed(true);
  31. }
  32. // setting breadcrumbs
  33. $interbreadcrumb[] = [
  34. 'url' => 'index.php',
  35. 'name' => get_lang('Administration'),
  36. ];
  37. $interbreadcrumb[] = [
  38. 'url' => 'career_dashboard.php',
  39. 'name' => get_lang('Careers and promotions'),
  40. ];
  41. $interbreadcrumb[] = [
  42. 'url' => 'careers.php',
  43. 'name' => get_lang('Careers'),
  44. ];
  45. $action = isset($_GET['action']) ? $_GET['action'] : '';
  46. if ($action == 'add') {
  47. $interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
  48. $toolName = get_lang('Add');
  49. } elseif ($action == 'edit') {
  50. $interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
  51. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
  52. $toolName = get_lang('Edit');
  53. } else {
  54. $toolName = get_lang('Careers');
  55. }
  56. $extraFieldValue = new ExtraFieldValue('career');
  57. // Check urls
  58. $itemUrls = $extraFieldValue->get_values_by_handler_and_field_variable(
  59. $careerId,
  60. 'career_urls',
  61. false,
  62. false,
  63. 0
  64. );
  65. $urlToString = '';
  66. if (!empty($itemUrls) && !empty($itemUrls['value'])) {
  67. $urls = explode(',', $itemUrls['value']);
  68. $urlToString = '&nbsp;&nbsp;';
  69. if (!empty($urls)) {
  70. foreach ($urls as $urlData) {
  71. $urlData = explode('@', $urlData);
  72. if (isset($urlData[1])) {
  73. $urlToString .= Display::url($urlData[0], $urlData[1]).'&nbsp;';
  74. } else {
  75. $urlToString .= $urlData[0].'&nbsp;';
  76. }
  77. }
  78. }
  79. }
  80. $tpl = new Template(get_lang('Diagram'));
  81. $html = Display::page_subheader2($careerInfo['name'].$urlToString);
  82. $diagram = Career::renderDiagramByColumn($careerInfo, $tpl);
  83. if (!empty($diagram)) {
  84. $html .= $diagram;
  85. } else {
  86. Display::addFlash(
  87. Display::return_message(
  88. sprintf(get_lang('Career %s doesn\'t have a diagram.'), $careerInfo['name']),
  89. 'warning'
  90. )
  91. );
  92. }
  93. $tpl->assign('content', $html);
  94. $layout = $tpl->get_template('career/diagram.tpl');
  95. $tpl->display($layout);