career_diagram.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @package chamilo.admin
  6. */
  7. /*
  8. *
  9. * Requires extra_field_values.value to be longtext to save diagram:
  10. *
  11. UPDATE extra_field_values SET created_at = NULL WHERE CAST(created_at AS CHAR(20)) = '0000-00-00 00:00:00';
  12. UPDATE extra_field_values SET updated_at = NULL WHERE CAST(updated_at AS CHAR(20)) = '0000-00-00 00:00:00';
  13. ALTER TABLE extra_field_values modify column value longtext null;
  14. */
  15. $cidReset = true;
  16. require_once __DIR__.'/../inc/global.inc.php';
  17. if (api_get_configuration_value('allow_career_diagram') == false) {
  18. api_not_allowed(true);
  19. }
  20. $this_section = SECTION_PLATFORM_ADMIN;
  21. api_protect_admin_script();
  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[] = array(
  34. 'url' => 'index.php',
  35. 'name' => get_lang('PlatformAdmin'),
  36. );
  37. $interbreadcrumb[] = array(
  38. 'url' => 'career_dashboard.php',
  39. 'name' => get_lang('CareersAndPromotions'),
  40. );
  41. $interbreadcrumb[] = array(
  42. 'url' => 'careers.php',
  43. 'name' => get_lang('Careers'),
  44. );
  45. $action = isset($_GET['action']) ? $_GET['action'] : null;
  46. $check = Security::check_token('request');
  47. $token = Security::get_token();
  48. if ($action == 'add') {
  49. $interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
  50. $toolName = get_lang('Add');
  51. } elseif ($action == 'edit') {
  52. $interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
  53. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
  54. $toolName = get_lang('Edit');
  55. } else {
  56. $toolName = get_lang('Careers');
  57. }
  58. $extraFieldValue = new ExtraFieldValue('career');
  59. $item = $extraFieldValue->get_values_by_handler_and_field_variable(
  60. $careerId,
  61. 'career_diagram',
  62. false,
  63. false,
  64. false
  65. );
  66. if (!empty($item) && isset($item['value']) && !empty($item['value'])) {
  67. $graph = unserialize($item['value']);
  68. $tpl = new Template(get_lang('Diagram'));
  69. $html = Display::page_subheader2($careerInfo['name']);
  70. $html .= Career::renderDiagram($careerInfo, $graph);
  71. $tpl->assign('content', $html);
  72. $tpl->display_one_col_template();
  73. }