Merge branch 'wip-MDL-37812-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Sam Hemelryk 2014-07-15 12:07:05 +12:00
commit 6a91c41a49
8 changed files with 166 additions and 77 deletions

View file

@ -24,6 +24,46 @@ if ($hassiteconfig
$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'))); $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')));
$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'))); $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')));
$ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
// "User default preferences" settingpage.
$temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin'));
if ($ADMIN->fulltree) {
$choices = array();
$choices['0'] = new lang_string('emaildisplayno');
$choices['1'] = new lang_string('emaildisplayyes');
$choices['2'] = new lang_string('emaildisplaycourse');
$temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
'', 2, $choices));
$choices = array();
$choices['0'] = new lang_string('textformat');
$choices['1'] = new lang_string('htmlformat');
$temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices));
$choices = array();
$choices['0'] = new lang_string('emaildigestoff');
$choices['1'] = new lang_string('emaildigestcomplete');
$choices['2'] = new lang_string('emaildigestsubjects');
$temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'),
new lang_string('emaildigest_help'), 0, $choices));
$choices = array();
$choices['1'] = new lang_string('autosubscribeyes');
$choices['0'] = new lang_string('autosubscribeno');
$temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'),
'', 1, $choices));
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = new lang_string('trackforumsno');
$choices['1'] = new lang_string('trackforumsyes');
$temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'),
'', 0, $choices));
}
}
$ADMIN->add('accounts', $temp);
$ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
$ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view'))); $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));

View file

@ -11,6 +11,7 @@ Feature: Forms manipulation
When I set the field "First name" to "Field value" When I set the field "First name" to "Field value"
And I set the field "Text editor" to "Plain text area" And I set the field "Text editor" to "Plain text area"
And I set the field "Unmask" to "1" And I set the field "Unmask" to "1"
And I expand all fieldsets
Then the field "First name" matches value "Field value" Then the field "First name" matches value "Field value"
And the "Text editor" select box should contain "Plain text area" And the "Text editor" select box should contain "Plain text area"
And the field "Unmask" matches value "1" And the field "Unmask" matches value "1"

View file

@ -221,21 +221,21 @@ class admin_uploaduser_form2 extends moodleform {
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse')); $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2); $mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
$choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat')); $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1); $mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
$mform->setAdvanced('mailformat'); $mform->setAdvanced('mailformat');
$choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects')); $choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects'));
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0); $mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
$mform->setAdvanced('maildigest'); $mform->setAdvanced('maildigest');
$choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno')); $choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno'));
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1); $mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
$mform->setType('city', PARAM_TEXT); $mform->setType('city', PARAM_TEXT);

View file

@ -1124,6 +1124,7 @@ $string['useexternalyui'] = 'Use online YUI libraries';
$string['user'] = 'User'; $string['user'] = 'User';
$string['userbulk'] = 'Bulk user actions'; $string['userbulk'] = 'Bulk user actions';
$string['userlist'] = 'Browse list of users'; $string['userlist'] = 'Browse list of users';
$string['userdefaultpreferences'] = 'User default preferences';
$string['userpreference'] = 'User preference'; $string['userpreference'] = 'User preference';
$string['userpolicies'] = 'User policies'; $string['userpolicies'] = 'User policies';
$string['users'] = 'Users'; $string['users'] = 'Users';

View file

@ -219,7 +219,23 @@ EOD;
} }
if (!isset($record['maildisplay'])) { if (!isset($record['maildisplay'])) {
$record['maildisplay'] = 1; $record['maildisplay'] = $CFG->defaultpreference_maildisplay;
}
if (!isset($record['mailformat'])) {
$record['mailformat'] = $CFG->defaultpreference_mailformat;
}
if (!isset($record['maildigest'])) {
$record['maildigest'] = $CFG->defaultpreference_maildigest;
}
if (!isset($record['autosubscribe'])) {
$record['autosubscribe'] = $CFG->defaultpreference_autosubscribe;
}
if (!isset($record['trackforums'])) {
$record['trackforums'] = $CFG->defaultpreference_trackforums;
} }
if (!isset($record['deleted'])) { if (!isset($record['deleted'])) {

View file

@ -218,72 +218,6 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
$mform->setType('email', PARAM_EMAIL); $mform->setType('email', PARAM_EMAIL);
} }
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
} else {
$choices['0'] = get_string('site').' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0);
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', 0);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT); $mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) { if (!empty($CFG->defaultcity)) {
@ -306,9 +240,6 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
$mform->setDefault('timezone', '99'); $mform->setDefault('timezone', '99');
} }
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $CFG->lang);
// Multi-Calendar Support - see MDL-18375. // Multi-Calendar Support - see MDL-18375.
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types(); $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
// We do not want to show this option unless there is more than one calendar type to display. // We do not want to show this option unless there is more than one calendar type to display.
@ -333,6 +264,9 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
$mform->setType('description_editor', PARAM_CLEANHTML); $mform->setType('description_editor', PARAM_CLEANHTML);
$mform->addHelpButton('description_editor', 'userdescription'); $mform->addHelpButton('description_editor', 'userdescription');
$mform->addElement('header', 'moodle_userpreferences', get_string('preferences'));
useredit_shared_definition_preferences($user, $mform, $editoroptions, $filemanageroptions);
if (empty($USER->newadminuser)) { if (empty($USER->newadminuser)) {
$mform->addElement('header', 'moodle_picture', get_string('pictureofuser')); $mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
@ -409,6 +343,88 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
$mform->setType('address', PARAM_TEXT); $mform->setType('address', PARAM_TEXT);
} }
/**
* Adds user preferences elements to user edit form.
*
* @param stdClass $user
* @param moodleform $mform
* @param array|null $editoroptions
* @param array|null $filemanageroptions
*/
function useredit_shared_definition_preferences($user, &$mform, $editoroptions = null, $filemanageroptions = null) {
global $CFG;
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
} else {
$choices['0'] = get_string('site').' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $CFG->lang);
}
/** /**
* Return required user name fields for forms. * Return required user name fields for forms.
* *
@ -482,5 +498,3 @@ function useredit_get_disabled_name_fields($enabledadditionalusernames = null) {
array_merge(array('firstname', 'lastname'), $enabledadditionalusernames)); array_merge(array('firstname', 'lastname'), $enabledadditionalusernames));
return $nonusednamefields; return $nonusednamefields;
} }

View file

@ -72,6 +72,23 @@ function user_create_user($user, $updatepassword = true, $triggerevent = true) {
$user->calendartype = $CFG->calendartype; $user->calendartype = $CFG->calendartype;
} }
// Apply default values for user preferences that are stored in users table.
if (!isset($user->maildisplay)) {
$user->maildisplay = $CFG->defaultpreference_maildisplay;
}
if (!isset($user->mailformat)) {
$user->mailformat = $CFG->defaultpreference_mailformat;
}
if (!isset($user->maildigest)) {
$user->maildigest = $CFG->defaultpreference_maildigest;
}
if (!isset($user->autosubscribe)) {
$user->autosubscribe = $CFG->defaultpreference_autosubscribe;
}
if (!isset($user->trackforums)) {
$user->trackforums = $CFG->defaultpreference_trackforums;
}
$user->timecreated = time(); $user->timecreated = time();
$user->timemodified = $user->timecreated; $user->timemodified = $user->timecreated;

View file

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$version = 2014071100.00; // YYYYMMDD = weekly release date of this DEV branch. $version = 2014071500.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches. // RR = release increments - 00 in DEV branches.
// .XX = incremental changes. // .XX = incremental changes.