Skip to content

Commit 747dac6

Browse files
committed
MDL-37812 user: added defaults for user preferences
1 parent 7a0bf1b commit 747dac6

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

admin/settings/users.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,46 @@
2424
$ADMIN->add('accounts', new admin_externalpage('editusers', new lang_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
2525
$ADMIN->add('accounts', new admin_externalpage('userbulk', new lang_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete')));
2626
$ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
27+
28+
// "User default preferences" settingpage.
29+
$temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin'));
30+
if ($ADMIN->fulltree) {
31+
$choices = array();
32+
$choices['0'] = new lang_string('emaildisplayno');
33+
$choices['1'] = new lang_string('emaildisplayyes');
34+
$choices['2'] = new lang_string('emaildisplaycourse');
35+
$temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
36+
'', 2, $choices));
37+
38+
$choices = array();
39+
$choices['0'] = new lang_string('textformat');
40+
$choices['1'] = new lang_string('htmlformat');
41+
$temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices));
42+
43+
$choices = array();
44+
$choices['0'] = new lang_string('emaildigestoff');
45+
$choices['1'] = new lang_string('emaildigestcomplete');
46+
$choices['2'] = new lang_string('emaildigestsubjects');
47+
$temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'),
48+
new lang_string('emaildigest_help'), 0, $choices));
49+
50+
51+
$choices = array();
52+
$choices['1'] = new lang_string('autosubscribeyes');
53+
$choices['0'] = new lang_string('autosubscribeno');
54+
$temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'),
55+
'', 1, $choices));
56+
57+
if (!empty($CFG->forum_trackreadposts)) {
58+
$choices = array();
59+
$choices['0'] = new lang_string('trackforumsno');
60+
$choices['1'] = new lang_string('trackforumsyes');
61+
$temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'),
62+
'', 0, $choices));
63+
}
64+
}
65+
$ADMIN->add('accounts', $temp);
66+
2767
$ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
2868
$ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
2969

lang/en/admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@
11251125
$string['user'] = 'User';
11261126
$string['userbulk'] = 'Bulk user actions';
11271127
$string['userlist'] = 'Browse list of users';
1128+
$string['userdefaultpreferences'] = 'User default preferences';
11281129
$string['userpreference'] = 'User preference';
11291130
$string['userpolicies'] = 'User policies';
11301131
$string['users'] = 'Users';

user/editlib.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ function useredit_shared_definition_preferences($user, &$mform, $editoroptions =
359359
$choices['1'] = get_string('emaildisplayyes');
360360
$choices['2'] = get_string('emaildisplaycourse');
361361
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
362-
$mform->setDefault('maildisplay', 2);
362+
$mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
363363

364364
$choices = array();
365365
$choices['0'] = get_string('textformat');
366366
$choices['1'] = get_string('htmlformat');
367367
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
368-
$mform->setDefault('mailformat', 1);
368+
$mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
369369

370370
if (!empty($CFG->allowusermailcharset)) {
371371
$choices = array();
@@ -384,21 +384,21 @@ function useredit_shared_definition_preferences($user, &$mform, $editoroptions =
384384
$choices['1'] = get_string('emaildigestcomplete');
385385
$choices['2'] = get_string('emaildigestsubjects');
386386
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
387-
$mform->setDefault('maildigest', 0);
387+
$mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
388388
$mform->addHelpButton('maildigest', 'emaildigest');
389389

390390
$choices = array();
391391
$choices['1'] = get_string('autosubscribeyes');
392392
$choices['0'] = get_string('autosubscribeno');
393393
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
394-
$mform->setDefault('autosubscribe', 1);
394+
$mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
395395

396396
if (!empty($CFG->forum_trackreadposts)) {
397397
$choices = array();
398398
$choices['0'] = get_string('trackforumsno');
399399
$choices['1'] = get_string('trackforumsyes');
400400
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
401-
$mform->setDefault('trackforums', 0);
401+
$mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
402402
}
403403

404404
$editors = editors_get_enabled();

0 commit comments

Comments
 (0)