Merge branch 'MDL-42072_master' of https://github.com/totara/openbadges
authorSam Hemelryk <sam@moodle.com>
Mon, 7 Oct 2013 02:40:48 +0000 (15:40 +1300)
committerSam Hemelryk <sam@moodle.com>
Mon, 7 Oct 2013 02:40:48 +0000 (15:40 +1300)
Conflicts:
badges/assertion.php

1  2 
badges/assertion.php

   * @author     Yuliya Bozhko <yuliya.bozhko@totaralms.com>
   */
  
+ define('AJAX_SCRIPT', true);
  require_once(dirname(dirname(__FILE__)) . '/config.php');
 -require_once($CFG->libdir . '/badgeslib.php');
  
  if (empty($CFG->enablebadges)) {
      print_error('badgesdisabled', 'badges');
  }
  
 -$hash = required_param('b', PARAM_ALPHANUM);
 +$hash = required_param('b', PARAM_ALPHANUM); // Issued badge unique hash for badge assertion.
 +$action = optional_param('action', null, PARAM_BOOL); // Generates badge class if true.
 +
 +$assertion = new core_badges_assertion($hash);
 +
 +if (!is_null($action)) {
 +    // Get badge class or issuer information depending on $action.
 +    $json = ($action) ? $assertion->get_badge_class() : $assertion->get_issuer();
 +} else {
 +    // Otherwise, get badge assertion.
 +    $json = $assertion->get_badge_assertion();
 +}
  
- header('Content-type: application/json; charset=utf-8');
 -$badge = badges_get_issued_badge_info($hash);
  
 -echo json_encode($badge);
+ echo $OUTPUT->header();
 +echo json_encode($json);