assertion.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Show information about a new assertion
  5. * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  6. * @package chamilo.badge
  7. */
  8. header('Content-Type: application/json');
  9. //require_once '../inc/global.inc.php';
  10. $userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
  11. $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
  12. $courseId = isset($_GET['course']) ? intval($_GET['course']) : 0;
  13. $sessionId = isset($_GET['session']) ? intval($_GET['session']) : 0;
  14. if ($userId === 0 || $skillId === 0) {
  15. exit;
  16. }
  17. $objSkill = new Skill();
  18. if (!$objSkill->user_has_skill($userId, $skillId, $courseId, $sessionId)) {
  19. exit;
  20. }
  21. $objSkillRelUser = new SkillRelUser();
  22. $userSkill = $objSkillRelUser->getByUserAndSkill($userId, $skillId, $courseId, $sessionId);
  23. if ($userSkill == false) {
  24. exit;
  25. }
  26. $user = api_get_user_info($userSkill['user_id']);
  27. $json = array(
  28. 'uid' => $userSkill['id'],
  29. 'recipient' => array(
  30. 'type' => 'email',
  31. 'hashed' => false,
  32. 'identity' => $user['email']
  33. ),
  34. 'issuedOn' => strtotime($userSkill['acquired_skill_at']),
  35. 'badge' => api_get_path(WEB_CODE_PATH) . "badge/class.php?id=$skillId",
  36. 'verify' => array(
  37. 'type' => 'hosted',
  38. 'url' => api_get_path(WEB_CODE_PATH) . "badge/assertion.php?" . http_build_query(array(
  39. 'user' => $userId,
  40. 'skill' => $skillId,
  41. 'course' => $courseId,
  42. 'session' => $sessionId
  43. ))
  44. )
  45. );
  46. echo json_encode($json);