mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-36395: Converted hard-coded MAX_USER_PER_PAGE to config setting
course, cohort, enrol, role, groups and forum used to use hard-coded MAX_USERS_PER_PAGE=100 for rendering user list. This has been converted to $CFG->maxusersperpage.
This commit is contained in:
parent
8673a98d1d
commit
9a51c3d95c
@ -1089,8 +1089,6 @@ class override_permissions_table_advanced extends capability_table_with_risks {
|
||||
* Base class to avoid duplicating code.
|
||||
*/
|
||||
abstract class role_assign_user_selector_base extends user_selector_base {
|
||||
const MAX_USERS_PER_PAGE = 100;
|
||||
|
||||
protected $roleid;
|
||||
protected $context;
|
||||
|
||||
@ -1159,7 +1157,7 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > role_assign_user_selector_base::MAX_USERS_PER_PAGE) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
@ -1187,9 +1185,6 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
*/
|
||||
class role_check_users_selector extends user_selector_base {
|
||||
const MAX_ENROLLED_PER_PAGE = 100;
|
||||
const MAX_POTENTIAL_PER_PAGE = 100;
|
||||
|
||||
/** @var bool limit listing of users to enrolled only */
|
||||
var $onlyenrolled;
|
||||
|
||||
@ -1270,7 +1265,7 @@ class role_check_users_selector extends user_selector_base {
|
||||
|
||||
if ($sql1) {
|
||||
$enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this::MAX_ENROLLED_PER_PAGE) {
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this->maxusersperpage) {
|
||||
$result[$groupname1] = array();
|
||||
$toomany = $this->too_many_results($search, $enrolleduserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
@ -1287,7 +1282,7 @@ class role_check_users_selector extends user_selector_base {
|
||||
}
|
||||
if ($sql2) {
|
||||
$otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
|
||||
if (!$this->is_validating() and $otheruserscount > $this::MAX_POTENTIAL_PER_PAGE) {
|
||||
if (!$this->is_validating() and $otheruserscount > $this->maxusersperpage) {
|
||||
$result[$groupname2] = array();
|
||||
$toomany = $this->too_many_results($search, $otheruserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
@ -1340,7 +1335,7 @@ class potential_assignees_course_and_above extends role_assign_user_selector_bas
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > role_assign_user_selector_base::MAX_USERS_PER_PAGE) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
@ -1765,7 +1760,7 @@ class admins_potential_selector extends user_selector_base {
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialcount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialcount > 100) {
|
||||
if ($potentialcount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialcount);
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ if ($hassiteconfig
|
||||
'department' => new lang_string('department'),
|
||||
'institution' => new lang_string('institution'),
|
||||
)));
|
||||
$temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ require_once($CFG->dirroot . '/user/selector/lib.php');
|
||||
* either all the other Moodle users.
|
||||
*/
|
||||
class service_user_selector extends user_selector_base {
|
||||
const MAX_USERS_PER_PAGE = 100;
|
||||
|
||||
protected $serviceid;
|
||||
protected $displayallowedusers; //set to true if the selector displays the
|
||||
//allowed users on this service
|
||||
@ -85,7 +83,7 @@ class service_user_selector extends user_selector_base {
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > service_user_selector::MAX_USERS_PER_PAGE) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class cohort_candidate_selector extends user_selector_base {
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > 100) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class enrol_manual_potential_participant extends user_selector_base {
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > 100) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ class enrol_manual_current_participant extends user_selector_base {
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > 100) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
@ -687,6 +687,8 @@ from a STABLE branch of the Moodle code. See Moodle Docs for more details.';
|
||||
$string['maxbytes'] = 'Maximum uploaded file size';
|
||||
$string['maxconsecutiveidentchars'] = 'Consecutive identical characters';
|
||||
$string['maxeditingtime'] = 'Maximum time to edit posts';
|
||||
$string['maxusersperpage'] = ' Maximum users per page';
|
||||
$string['configmaxusersperpage'] = 'Maximum number of users displayed within user selector in course, group, cohort, webservice etc.';
|
||||
$string['mbstringrecommended'] = 'Installing the optional MBSTRING library is highly recommended in order to improve site performance, particularly if your site is supporting non-Latin languages.';
|
||||
$string['mediapluginavi'] = 'Enable .avi filter';
|
||||
$string['mediapluginflv'] = 'Enable .flv filter';
|
||||
|
@ -7894,8 +7894,6 @@ abstract class forum_subscriber_selector_base extends user_selector_base {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class forum_potential_subscriber_selector extends forum_subscriber_selector_base {
|
||||
const MAX_USERS_PER_PAGE = 100;
|
||||
|
||||
/**
|
||||
* If set to true EVERYONE in this course is force subscribed to this forum
|
||||
* @var bool
|
||||
@ -7983,7 +7981,7 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > self::MAX_USERS_PER_PAGE) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,8 @@ abstract class user_selector_base {
|
||||
array('none', 'moodle')
|
||||
));
|
||||
|
||||
/** @var int this is used to define maximum number of users visible in list */
|
||||
public $maxusersperpage = 100;
|
||||
|
||||
// Public API ==============================================================
|
||||
|
||||
@ -120,6 +122,10 @@ abstract class user_selector_base {
|
||||
$this->preserveselected = $this->initialise_option('userselector_preserveselected', $this->preserveselected);
|
||||
$this->autoselectunique = $this->initialise_option('userselector_autoselectunique', $this->autoselectunique);
|
||||
$this->searchanywhere = $this->initialise_option('userselector_searchanywhere', $this->searchanywhere);
|
||||
|
||||
if (!empty($CFG->maxusersperpage)) {
|
||||
$this->maxusersperpage = $CFG->maxusersperpage;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -751,8 +757,6 @@ class group_members_selector extends groups_user_selector_base {
|
||||
* Used on the add group members page.
|
||||
*/
|
||||
class group_non_members_selector extends groups_user_selector_base {
|
||||
const MAX_USERS_PER_PAGE = 100;
|
||||
|
||||
/**
|
||||
* An array of user ids populated by find_users() used in print_user_summaries()
|
||||
*/
|
||||
@ -860,7 +864,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql("SELECT COUNT(DISTINCT u.id) $sql", $params);
|
||||
if ($potentialmemberscount > group_non_members_selector::MAX_USERS_PER_PAGE) {
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013030800.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2013031200.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user