Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-23532 enrol - fixed regressions after latest weekly and improved …

…moodle_page handling
  • Loading branch information...
commit 076995bf9121a5d2b1b45ee49850566166c6e610 1 parent cf855c0
@samhemelryk samhemelryk authored
View
2  enrol/ajax.php
@@ -52,7 +52,7 @@
echo $OUTPUT->header(); // send headers
-$manager = new course_enrolment_manager($course);
+$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass;
$outcome->success = true;
View
2  enrol/cohort/ajax.php
@@ -52,7 +52,7 @@
echo $OUTPUT->header(); // send headers
-$manager = new course_enrolment_manager($course);
+$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass;
$outcome->success = true;
View
5 enrol/cohort/lib.php
@@ -144,13 +144,10 @@ public function course_updated($inserted, $course, $data) {
* This function also adds a quickenrolment JS ui to the page so that users can be enrolled
* via AJAX.
*
- * @global moodle_page $PAGE
* @param course_enrolment_manager $manager
* @return enrol_user_button
*/
public function get_manual_enrol_button(course_enrolment_manager $manager) {
- global $PAGE;
-
$course = $manager->get_course();
if (!$this->can_add_new_instances($course->id)) {
return false;
@@ -173,7 +170,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
$arguments = array(
'courseid' => $course->id,
'ajaxurl' => '/enrol/cohort/ajax.php',
- 'url' => $PAGE->url->out(false),
+ 'url' => $manager->get_moodlepage()->url->out(false),
'manualEnrolment' => $hasmanualinstance);
$button->require_yui_module($modules, $function, array($arguments));
View
18 enrol/locallib.php
@@ -79,6 +79,12 @@ class course_enrolment_manager {
*/
protected $totalotherusers = null;
+ /**
+ * The current moodle_page object
+ * @var moodle_page
+ */
+ protected $moodlepage = null;
+
/**#@+
* These variables are used to cache the information this class uses
* please never use these directly instead use their get_ counterparts.
@@ -98,16 +104,26 @@ class course_enrolment_manager {
/**
* Constructs the course enrolment manager
*
+ * @param moodle_page $moodlepage
* @param stdClass $course
* @param string $instancefilter
*/
- public function __construct($course, $instancefilter = null) {
+ public function __construct(moodle_page $moodlepage, $course, $instancefilter = null) {
+ $this->moodlepage = $moodlepage;
$this->context = get_context_instance(CONTEXT_COURSE, $course->id);
$this->course = $course;
$this->instancefilter = $instancefilter;
}
/**
+ * Returns the current moodle page
+ * @return moodle_page
+ */
+ public function get_moodlepage() {
+ return $this->moodlepage;
+ }
+
+ /**
* Returns the total number of enrolled users in the course.
*
* If a filter was specificed this will be the total number of users enrolled
View
2  enrol/manual/ajax.php
@@ -51,7 +51,7 @@
echo $OUTPUT->header(); // send headers
-$manager = new course_enrolment_manager($course);
+$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass;
$outcome->success = true;
View
5 enrol/manual/lib.php
@@ -178,13 +178,10 @@ public function add_instance($course, array $fields = NULL) {
* This function also adds a quickenrolment JS ui to the page so that users can be enrolled
* via AJAX.
*
- * @global moodle_page $PAGE
* @param course_enrolment_manager $manager
* @return enrol_user_button
*/
public function get_manual_enrol_button(course_enrolment_manager $manager) {
- global $PAGE;
-
$instance = null;
$instances = array();
foreach ($manager->get_enrolment_instances() as $tempinstance) {
@@ -217,7 +214,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
'instances' => $instances,
'courseid' => $instance->courseid,
'ajaxurl' => '/enrol/manual/ajax.php',
- 'url' => $PAGE->url->out(false),
+ 'url' => $manager->get_moodlepage()->url->out(false),
'optionsStartDate' => $startdateoptions,
'defaultRole' => $instance->roleid
);
View
2  enrol/otherusers.php
@@ -44,7 +44,7 @@
$PAGE->set_pagelayout('admin');
-$manager = new course_enrolment_manager($course, $filter);
+$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_other_users_table($manager, $PAGE);
$PAGE->set_url('/enrol/otherusers.php', $manager->get_url_params()+$table->get_url_params());
View
32 enrol/renderer.php
@@ -340,12 +340,6 @@ class course_enrolment_table extends html_table implements renderable {
public $perpage = 0;
/**
- * The URL of the page for this table
- * @var moodle_page
- */
- public $moodlepage;
-
- /**
* The sort field for this table, should be one of course_enrolment_table::$sortablefields
* @var string
*/
@@ -399,10 +393,9 @@ class course_enrolment_table extends html_table implements renderable {
*
* @param course_enrolment_manager $manager
*/
- public function __construct(course_enrolment_manager $manager, moodle_page $moodlepage) {
+ public function __construct(course_enrolment_manager $manager) {
$this->manager = $manager;
- $this->moodlepage = $moodlepage;
$this->page = optional_param(self::PAGEVAR, 0, PARAM_INT);
$this->perpage = optional_param(self::PERPAGEVAR, self::DEFAULTPERPAGE, PARAM_INT);
@@ -460,7 +453,7 @@ public function set_fields($fields, $output) {
$this->head = array();
$this->colclasses = array();
$this->align = array();
- $url = $this->moodlepage->url;
+ $url = $this->manager->get_moodlepage()->url;
foreach ($fields as $name => $label) {
$newlabel = '';
if (is_array($label)) {
@@ -546,7 +539,7 @@ public function set_users(array $users) {
public function initialise_javascript() {
if (has_capability('moodle/role:assign', $this->manager->get_context())) {
- $this->moodlepage->requires->strings_for_js(array(
+ $this->manager->get_moodlepage()->requires->strings_for_js(array(
'assignroles',
'confirmunassign',
'confirmunassigntitle',
@@ -560,7 +553,7 @@ public function initialise_javascript() {
'userIds'=>array_keys($this->users),
'courseId'=>$this->manager->get_course()->id,
'otherusers'=>isset($this->otherusers));
- $this->moodlepage->requires->yui_module($modules, $function, array($arguments));
+ $this->manager->get_moodlepage()->requires->yui_module($modules, $function, array($arguments));
}
}
@@ -571,7 +564,7 @@ public function initialise_javascript() {
*/
public function get_paging_bar() {
if ($this->pagingbar == null) {
- $this->pagingbar = new paging_bar($this->totalusers, $this->page, $this->perpage, $this->moodlepage->url, self::PAGEVAR);
+ $this->pagingbar = new paging_bar($this->totalusers, $this->page, $this->perpage, $this->manager->get_moodlepage()->url, self::PAGEVAR);
}
return $this->pagingbar;
}
@@ -631,7 +624,7 @@ class course_enrolment_users_table extends course_enrolment_table {
* @return single_select
*/
public function get_enrolment_type_filter() {
- $selector = new single_select($this->moodlepage->url, 'ifilter', array(0=>get_string('all')) + (array)$this->manager->get_enrolment_instance_names(), $this->manager->get_enrolment_filter(), array());
+ $selector = new single_select($this->manager->get_moodlepage()->url, 'ifilter', array(0=>get_string('all')) + (array)$this->manager->get_enrolment_instance_names(), $this->manager->get_enrolment_filter(), array());
$selector->set_label( get_string('enrolmentinstances', 'enrol'));
return $selector;
}
@@ -653,10 +646,9 @@ class course_enrolment_other_users_table extends course_enrolment_table {
* Constructs the table
*
* @param course_enrolment_manager $manager
- * @param moodle_page $moodlepage
*/
- public function __construct(course_enrolment_manager $manager, moodle_page $moodlepage) {
- parent::__construct($manager, $moodlepage);
+ public function __construct(course_enrolment_manager $manager) {
+ parent::__construct($manager);
$this->attributes = array('class'=>'userenrolment otheruserenrolment');
}
@@ -677,7 +669,7 @@ public function get_user_search_button() {
$control = new single_button($url, get_string('assignroles', 'role'), 'get');
$control->class = 'singlebutton assignuserrole instance'.$count;
if ($count == 1) {
- $this->moodlepage->requires->strings_for_js(array(
+ $this->manager->get_moodlepage()->requires->strings_for_js(array(
'ajaxoneuserfound',
'ajaxxusersfound',
'ajaxnext25',
@@ -692,15 +684,15 @@ public function get_user_search_button() {
'startdatetoday',
'durationdays',
'enrolperiod'), 'enrol');
- $this->moodlepage->requires->string_for_js('assignrole', 'role');
+ $this->manager->get_moodlepage()->requires->string_for_js('assignrole', 'role');
$modules = array('moodle-enrol-otherusersmanager', 'moodle-enrol-otherusersmanager-skin');
$function = 'M.enrol.otherusersmanager.init';
$arguments = array(
'courseId'=> $this->manager->get_course()->id,
'ajaxUrl' => '/enrol/ajax.php',
- 'url' => $this->moodlepage->url->out(false));
- $this->moodlepage->requires->yui_module($modules, $function, array($arguments));
+ 'url' => $this->manager->get_moodlepage()->url->out(false));
+ $this->manager->get_moodlepage()->requires->yui_module($modules, $function, array($arguments));
}
return $control;
}
View
2  enrol/users.php
@@ -44,7 +44,7 @@
require_capability('moodle/course:enrolreview', $context);
$PAGE->set_pagelayout('admin');
-$manager = new course_enrolment_manager($course, $filter);
+$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_users_table($manager, $PAGE);
$PAGE->set_url('/enrol/users.php', $manager->get_url_params()+$table->get_url_params());
Please sign in to comment.
Something went wrong with that request. Please try again.