Commit becb809b authored by Robert Lyon's avatar Robert Lyon

Allowing groupsideblockmaxgroups to be set as blank (Bug #1377371)

Also allow a text field to change from 0 to blank. Currently it doesn't
update the user even though they are different.

Change-Id: I4dcc9dd469ec7525c80c29f0207487d8f26fff34
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 05b2655c
......@@ -224,13 +224,12 @@ function accountprefs_submit(Pieform $form, $values) {
// Set user account preferences
foreach ($expectedprefs as $eprefkey => $epref) {
if (isset($values[$eprefkey]) && $values[$eprefkey] != get_account_preference($USER->get('id'), $eprefkey)) {
if (isset($values[$eprefkey]) && $values[$eprefkey] !== get_account_preference($USER->get('id'), $eprefkey)) {
$USER->set_account_preference($eprefkey, $values[$eprefkey]);
}
}
$returndata = array();
if (isset($values['username']) && $values['username'] != $USER->get('username')) {
$USER->username = $values['username'];
$USER->commit();
......
......@@ -2950,10 +2950,9 @@ function profile_sideblock() {
$data['pendingfriendsmessage'] = $data['pendingfriends'] == 1 ? get_string('pendingfriend') : get_string('pendingfriends');
// Check if we want to limit the displayed groups by the account setting
$limitto = null;
if ($limit = $USER->get_account_preference('groupsideblockmaxgroups')) {
if (!empty($limit)) {
$limitto = intval($limit);
}
$limit = $USER->get_account_preference('groupsideblockmaxgroups');
if (isset($limit) && is_numeric($limit)) {
$limitto = intval($limit);
}
$sort = null;
if ($sortorder = $USER->get_account_preference('groupsideblocksortby')) {
......
......@@ -201,7 +201,7 @@ function expected_account_preferences() {
'addremovecolumns' => 0,
'maildisabled' => 0,
'tagssideblockmaxtags' => get_config('tagssideblockmaxtags'),
'groupsideblockmaxgroups' => 0,
'groupsideblockmaxgroups' => '',
'groupsideblocksortby' => 'alphabetical',
'hiderealname' => 0,
'multipleblogs' => 0,
......@@ -363,7 +363,7 @@ function general_account_prefs_form_elements($prefs) {
'size' => 4,
'title' => get_string('limitto1', 'blocktype.mygroups'),
'description' => get_string('limittodescsideblock1', 'blocktype.mygroups'),
'defaultvalue' => isset($prefs->groupsideblockmaxgroups) ? $prefs->groupsideblockmaxgroups : 0,
'defaultvalue' => isset($prefs->groupsideblockmaxgroups) ? $prefs->groupsideblockmaxgroups : '',
'rules' => array('regex' => '/^[0-9]*$/', 'minvalue' => 0, 'maxvalue' => 1000),
);
$elements['groupsideblocksortby'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment