my_career.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. if (api_get_configuration_value('allow_career_diagram') == false) {
  5. api_not_allowed(true);
  6. }
  7. $htmlHeadXtra[] = api_get_js('jsplumb2.js');
  8. $sessionCategories = UserManager::get_sessions_by_category(api_get_user_id(), false);
  9. $content = '';
  10. $extraFieldValue = new ExtraFieldValue('session');
  11. $extraFieldValueCareer = new ExtraFieldValue('career');
  12. $career = new Career();
  13. foreach ($sessionCategories as $category) {
  14. $sessions = $category['sessions'];
  15. foreach ($sessions as $session) {
  16. $sessionId = $session['session_id'];
  17. // Getting session extra field 'external_career_id'
  18. $item = $extraFieldValue->get_values_by_handler_and_field_variable(
  19. $sessionId,
  20. 'external_career_id'
  21. );
  22. if ($item && isset($item['value']) && !empty($item['value'])) {
  23. // External career id
  24. $externalCareerId = $item['value'];
  25. // Getting career id from external career id
  26. $itemCareer = $extraFieldValueCareer->get_item_id_from_field_variable_and_field_value(
  27. 'external_career_id',
  28. $externalCareerId
  29. );
  30. if ($itemCareer && !empty($itemCareer['item_id'])) {
  31. $careerId = $itemCareer['item_id'];
  32. $careerInfo = $career->find($careerId);
  33. if (!empty($careerInfo)) {
  34. $diagram = $extraFieldValueCareer->get_values_by_handler_and_field_variable(
  35. $careerId,
  36. 'career_diagram'
  37. );
  38. if ($diagram && !empty($diagram['value'])) {
  39. $graph = unserialize($diagram['value']);
  40. $content .= Career::renderDiagram($careerInfo, $graph);
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. $view = new Template('');
  48. $view->assign('content', $content);
  49. $view->display_one_col_template();