my_career.php 2.1 KB

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