MDL-37396 Enrollmen: pass $perpage as optional_param and set default perpage variable...
authorRossiani Wijaya <rwijaya@moodle.com>
Mon, 18 Feb 2013 05:22:07 +0000 (13:22 +0800)
committerRossiani Wijaya <rwijaya@moodle.com>
Mon, 18 Feb 2013 05:22:07 +0000 (13:22 +0800)
enrol/manual/ajax.php
enrol/manual/yui/quickenrolment/quickenrolment.js

index 2a43871..ea4acd8 100644 (file)
@@ -68,7 +68,7 @@ switch ($action) {
         $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) {
index 1fa40cc..8362185 100644 (file)
@@ -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
             }
         }
     });