Skip to content

Commit

Permalink
MDL-41810 badges: Remove hardcoded references to backpack.openbadges.org
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliya Bozhko committed Jan 8, 2014
1 parent bbb291b commit 343534a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions badges/backpack_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function definition() {
$mform->addElement('html', html_writer::tag('span', '', array('class' => 'notconnected', 'id' => 'connection-error')));
$mform->addElement('header', 'backpackheader', get_string('backpackconnection', 'badges'));
$mform->addHelpButton('backpackheader', 'backpackconnection', 'badges');
$mform->addElement('static', 'url', get_string('url'), BADGE_BACKPACKURL);
$mform->addElement('static', 'url', get_string('url'), 'http://' . BADGE_BACKPACKURL);
$status = html_writer::tag('span', get_string('notconnected', 'badges'),
array('class' => 'notconnected', 'id' => 'connection-status'));
$mform->addElement('static', 'status', get_string('status'), $status);
Expand All @@ -67,7 +67,7 @@ public function definition() {
$mform->addElement('hidden', 'userid', $USER->id);
$mform->setType('userid', PARAM_INT);

$mform->addElement('hidden', 'backpackurl', BADGE_BACKPACKURL);
$mform->addElement('hidden', 'backpackurl', 'http://' . BADGE_BACKPACKURL);
$mform->setType('backpackurl', PARAM_URL);

}
Expand Down Expand Up @@ -118,7 +118,7 @@ public function definition() {

$mform->addElement('header', 'backpackheader', get_string('backpackconnection', 'badges'));
$mform->addHelpButton('backpackheader', 'backpackconnection', 'badges');
$mform->addElement('static', 'url', get_string('url'), BADGE_BACKPACKURL);
$mform->addElement('static', 'url', get_string('url'), 'http://' . BADGE_BACKPACKURL);

$status = html_writer::tag('span', get_string('connected', 'badges'), array('class' => 'connected'));
$mform->addElement('static', 'status', get_string('status'), $status);
Expand Down
5 changes: 3 additions & 2 deletions badges/backpackconnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->dirroot . '/badges/lib/backpacklib.php');
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/badgeslib.php');

require_sesskey();
require_login();
Expand Down Expand Up @@ -86,7 +87,7 @@

// Make sure email matches a backpack.
$check = new stdClass();
$check->backpackurl = BADGE_BACKPACKURL;
$check->backpackurl = 'http://' . BADGE_BACKPACKURL;
$check->email = $data->email;

$bp = new OpenBadgesBackpackHandler($check);
Expand All @@ -105,7 +106,7 @@
$obj = new stdClass();
$obj->userid = $USER->id;
$obj->email = $data->email;
$obj->backpackurl = BADGE_BACKPACKURL;
$obj->backpackurl = 'http://' . BADGE_BACKPACKURL;
$obj->backpackuid = $backpackuid;
$obj->autosync = 0;
$obj->password = '';
Expand Down
6 changes: 0 additions & 6 deletions badges/lib/backpacklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@

defined('MOODLE_INTERNAL') || die();

/*
* URL of backpack. Currently only the Open Badges backpack
* is supported.
*/
define('BADGE_BACKPACKURL', 'http://backpack.openbadges.org');

global $CFG;
require_once($CFG->libdir . '/filelib.php');

Expand Down
3 changes: 3 additions & 0 deletions badges/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ information provided here is intended especially for developers.

* New optional parameter $filtered in review() allows to indicate that some expensive checks can be skipped
if the list of users has been initially filtered based on met criteria.

* BADGE_BACKPACKURL constant has been moved from badges/lib/backpacklib.php to lib/badgeslib.php, and URI scheme
name ('http://') has been removed.
11 changes: 8 additions & 3 deletions lib/badgeslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
define('BADGE_MESSAGE_WEEKLY', 3);
define('BADGE_MESSAGE_MONTHLY', 4);

/*
* URL of backpack. Currently only the Open Badges backpack is supported.
*/
define('BADGE_BACKPACKURL', 'backpack.openbadges.org');

/**
* Class that represents badge.
*
Expand Down Expand Up @@ -1145,15 +1150,15 @@ function badges_check_backpack_accessibility() {
// Using fake assertion url to check whether backpack can access the web site.
$fakeassertion = new moodle_url('/badges/assertion.php', array('b' => 'abcd1234567890'));

// Curl request to http://backpack.openbadges.org/baker.
// Curl request to backpack baker.
$curl = new curl();
$options = array(
'FRESH_CONNECT' => true,
'RETURNTRANSFER' => true,
'HEADER' => 0,
'CONNECTTIMEOUT' => 2,
);
$location = 'http://backpack.openbadges.org/baker';
$location = 'http://' . BADGE_BACKPACKURL . '/baker';
$out = $curl->get($location, array('assertion' => $fakeassertion->out(false)), $options);

$data = json_decode($out);
Expand Down Expand Up @@ -1222,7 +1227,7 @@ function badges_setup_backpack_js() {
if (!empty($CFG->badges_allowexternalbackpack)) {
$PAGE->requires->string_for_js('error:backpackproblem', 'badges');
$protocol = (strpos($CFG->wwwroot, 'https://') === 0) ? 'https://' : 'http://';
$PAGE->requires->js(new moodle_url($protocol . 'backpack.openbadges.org/issuer.js'), true);
$PAGE->requires->js(new moodle_url($protocol . BADGE_BACKPACKURL . '/issuer.js'), true);
$PAGE->requires->js('/badges/backpack.js', true);
}
}

0 comments on commit 343534a

Please sign in to comment.