my_certificates.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * List of achieved certificates by the current user.
  5. *
  6. * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  7. *
  8. * @package chamilo.gradebook
  9. */
  10. $cidReset = true;
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. $logInfo = [
  13. 'tool' => 'MyCertificates',
  14. 'tool_id' => 0,
  15. 'tool_id_detail' => 0,
  16. 'action' => '',
  17. 'action_details' => '',
  18. ];
  19. Event::registerLog($logInfo);
  20. if (api_is_anonymous()) {
  21. api_not_allowed(true);
  22. }
  23. $userId = api_get_user_id();
  24. $courseList = GradebookUtils::getUserCertificatesInCourses($userId);
  25. $sessionList = GradebookUtils::getUserCertificatesInSessions($userId);
  26. if (empty($courseList) && empty($sessionList)) {
  27. Display::addFlash(
  28. Display::return_message(get_lang('You have not achieved any certificate just yet. Continue on your learning path to get one!'), 'warning')
  29. );
  30. }
  31. $template = new Template(get_lang('My certificates'));
  32. $template->assign('course_list', $courseList);
  33. $template->assign('session_list', $sessionList);
  34. $templateName = $template->get_template('gradebook/my_certificates.tpl');
  35. $content = $template->fetch($templateName);
  36. if (api_get_setting('allow_public_certificates') === 'true') {
  37. $template->assign(
  38. 'actions',
  39. Display::toolbarButton(
  40. get_lang('Search certificates'),
  41. api_get_path(WEB_CODE_PATH).'gradebook/search.php',
  42. 'search',
  43. 'info'
  44. )
  45. );
  46. }
  47. $template->assign('content', $content);
  48. $template->display_one_col_template();