MDL-44484 admin: Allow theme field in upload users tool
This commit is contained in:
committed by
Mathew May
parent
a411b499b9
commit
09df597597
@@ -71,6 +71,8 @@ $struserauthunsupported = get_string('userauthunsupported', 'error');
|
||||
$stremailduplicate = get_string('useremailduplicate', 'error');
|
||||
|
||||
$strinvalidpasswordpolicy = get_string('invalidpasswordpolicy', 'error');
|
||||
$strinvalidtheme = get_string('invalidtheme', 'error');
|
||||
|
||||
$errorstr = get_string('error');
|
||||
|
||||
$stryes = get_string('yes');
|
||||
@@ -93,6 +95,7 @@ $STD_FIELDS = array('id', 'username', 'email',
|
||||
'auth', // watch out when changing auth type or using external auth plugins!
|
||||
'oldusername', // use when renaming users - this is the original username
|
||||
'suspended', // 1 means suspend user account, 0 means activate user account, nothing means keep as is for existing users
|
||||
'theme', // Define a theme for user when 'allowuserthemes' is enabled.
|
||||
'deleted', // 1 means delete user
|
||||
'mnethostid', // Can not be used for adding, updating or deleting of users - only for enrolments, groups, cohorts and suspending.
|
||||
'interests',
|
||||
@@ -208,6 +211,8 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
$cir->init();
|
||||
$linenum = 1; //column header is first line
|
||||
|
||||
$themes = get_list_of_themes();
|
||||
|
||||
// init upload progress tracker
|
||||
$upt = new uu_progress_tracker();
|
||||
$upt->start(); // start table
|
||||
@@ -355,6 +360,24 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
$upt->track('username', s($user->username), 'normal', false);
|
||||
}
|
||||
|
||||
// Validate theme.
|
||||
if (!$CFG->allowuserthemes) {
|
||||
$upt->track('status', get_string('invalidtheme', 'error', 'theme'), 'error');
|
||||
$upt->track('theme', $errorstr, 'error');
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($user->theme)) {
|
||||
if (!isset($themes[$user->theme])) {
|
||||
$user->theme = '';
|
||||
$upt->track('status', get_string('invalidfieldvalue', 'error', 'theme'), 'error');
|
||||
$upt->track('theme', $errorstr, 'error');
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// add default values for remaining fields
|
||||
$formdefaults = array();
|
||||
if (!$existinguser || ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES)) {
|
||||
@@ -1243,4 +1266,3 @@ if ($noerror) {
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
|
||||
@@ -56,7 +56,13 @@ define('UU_PWRESET_ALL', 2);
|
||||
*/
|
||||
class uu_progress_tracker {
|
||||
private $_row;
|
||||
public $columns = array('status', 'line', 'id', 'username', 'firstname', 'lastname', 'email', 'password', 'auth', 'enrolments', 'suspended', 'deleted');
|
||||
|
||||
/**
|
||||
* The columns shown on the table.
|
||||
* @var array
|
||||
*/
|
||||
public $columns = array('status', 'line', 'id', 'username', 'firstname', 'lastname', 'email',
|
||||
'password', 'auth', 'enrolments', 'suspended', 'theme', 'deleted');
|
||||
|
||||
/**
|
||||
* Print table header.
|
||||
@@ -77,6 +83,7 @@ class uu_progress_tracker {
|
||||
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('authentication').'</th>';
|
||||
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('enrolments', 'enrol').'</th>';
|
||||
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('suspended', 'auth').'</th>';
|
||||
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('theme').'</th>';
|
||||
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('delete').'</th>';
|
||||
echo '</tr>';
|
||||
$this->_row = null;
|
||||
|
||||
@@ -326,6 +326,7 @@ $string['invalidentry'] = 'This is not valid entry!';
|
||||
$string['invalidevent'] = 'Invalid event';
|
||||
$string['invalidfieldname'] = '"{$a}" is not a valid field name';
|
||||
$string['invalidfiletype'] = '"{$a}" is not a valid file type';
|
||||
$string['invalidfieldvalue'] = 'Field "{$a}" has an invalid value';
|
||||
$string['invalidformatpara'] = 'Incorrect format for choose parameter';
|
||||
$string['invalidformdata'] = 'Incorrect form data';
|
||||
$string['invalidfunction'] = 'Incorrect function';
|
||||
@@ -359,6 +360,7 @@ $string['invalidsesskey'] = 'Your session has most likely timed out. Please log
|
||||
$string['invalidshortname'] = 'That\'s an invalid short course name';
|
||||
$string['invalidstatedetected'] = 'Something has gone wrong: {$a}. This should never normally happen.';
|
||||
$string['invalidsourcefield'] = 'Draft file\'s source field is invalid';
|
||||
$string['invalidtheme'] = 'Invalid theme column found. User themes are disabled.';
|
||||
$string['invalidurl'] = 'Invalid URL';
|
||||
$string['invaliduser'] = 'Invalid user';
|
||||
$string['invaliduserid'] = 'Invalid user id';
|
||||
|
||||
Reference in New Issue
Block a user