Skip to content
Browse files

MDL-37396 Enrollmen: pass $perpage as optional_param and set default …

…perpage variable in quickenrolment.js
  • Loading branch information...
1 parent 53a054c commit 408609793509057d64c9b9869c1812566cbe8ee4 @rwijaya rwijaya committed
Showing with 10 additions and 4 deletions.
  1. +1 −1 enrol/manual/ajax.php
  2. +9 −3 enrol/manual/yui/quickenrolment/quickenrolment.js
View
2 enrol/manual/ajax.php
@@ -68,7 +68,7 @@
$search = optional_param('search', '', PARAM_RAW);
$page = optional_param('page', 0, PARAM_INT);
$addedenrollment = optional_param('enrolcount', 0, PARAM_INT);
- $perpage = 25; // This value is hard-coded to 25 in quickenrolment.js
+ $perpage = optional_param('perpage', 25, PARAM_INT); // This value is hard-coded to 25 in quickenrolment.js
$outcome->response = $manager->get_potential_users($enrolid, $search, $searchanywhere, $page, $perpage, $addedenrollment);
$extrafields = get_extra_user_fields($context);
foreach ($outcome->response['users'] as &$user) {
View
12 enrol/manual/yui/quickenrolment/quickenrolment.js
@@ -24,7 +24,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
ASSIGNABLEROLES : 'assignableRoles',
DISABLEGRADEHISTORY : 'disableGradeHistory',
RECOVERGRADESDEFAULT : 'recoverGradesDefault',
- ENROLCOUNT : 'enrolCount'
+ ENROLCOUNT : 'enrolCount',
+ PERPAGE : 'perPage'
};
/** CSS classes for nodes in structure **/
var CSS = {
@@ -311,6 +312,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
params['search'] = this.get(UEP.SEARCH).get('value');
params['page'] = this.get(UEP.PAGE);
params['enrolcount'] = this.get(UEP.ENROLCOUNT);
+ params['perpage'] = this.get(UEP.PERPAGE);
if (this.get(UEP.MULTIPLE)) {
alert('oh no there are multiple');
@@ -379,7 +381,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
var content = create('<div class="'+CSS.SEARCHRESULTS+'"></div>')
.append(create('<div class="'+CSS.TOTALUSERS+'">'+usersstr+'</div>'))
.append(users);
- if (result.response.totalusers > (this.get(UEP.PAGE)+1)*25) {
+ if (result.response.totalusers > (this.get(UEP.PAGE)+1)*this.get(UEP.PERPAGE)) {
var fetchmore = create('<div class="'+CSS.MORERESULTS+'"><a href="#">'+M.str.enrol.ajaxnext25+'</a></div>');
fetchmore.on('click', this.search, this, true);
content.append(fetchmore)
@@ -387,7 +389,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
this.setContent(content);
Y.delegate("click", this.enrolUser, users, '.'+CSS.USER+' .'+CSS.ENROL, this, args);
} else {
- if (result.response.totalusers <= (this.get(UEP.PAGE)+1)*25) {
+ if (result.response.totalusers <= (this.get(UEP.PAGE)+1)*this.get(UEP.PERPAGE)) {
this.get(UEP.BASE).one('.'+CSS.MORERESULTS).remove();
}
}
@@ -541,6 +543,10 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
enrolCount : {
value : 0,
validator : Y.Lang.isNumber
+ },
+ perPage : {
+ value: 25,
+ Validator: Y.Lang.isNumber
}
}
});

0 comments on commit 4086097

Please sign in to comment.
Something went wrong with that request. Please try again.