$strinvalidpasswordpolicy = get_string('invalidpasswordpolicy', 'error');
$errorstr = get_string('error');
+$stryes = get_string('yes');
+$strno = get_string('no');
+$stryesnooptions = array(0=>$strno, 1=>$stryes);
+
$returnurl = new moodle_url('/admin/tool/uploaduser/index.php');
$bulknurl = new moodle_url('/admin/user/user_bulk.php');
'url', 'description', 'descriptionformat', 'password',
'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
'deleted', // 1 means delete user
);
$updatepasswords = (!empty($formdata->uupasswordold) and $optype != UU_USER_ADDNEW and $optype != UU_USER_ADDINC and ($updatetype == UU_UPDATE_FILEOVERRIDE or $updatetype == UU_UPDATE_ALLOVERRIDE));
$allowrenames = (!empty($formdata->uuallowrenames) and $optype != UU_USER_ADDNEW and $optype != UU_USER_ADDINC);
$allowdeletes = (!empty($formdata->uuallowdeletes) and $optype != UU_USER_ADDNEW and $optype != UU_USER_ADDINC);
+ $allowsuspends = (!empty($formdata->uuallowsuspends));
$bulk = $formdata->uubulk;
$noemailduplicates = $formdata->uunoemailduplicates;
$standardusernames = $formdata->uustandardusernames;
$user->id = $existinguser->id;
$upt->track('username', html_writer::link(new moodle_url('/user/profile.php', array('id'=>$existinguser->id)), s($existinguser->username)), 'normal', false);
+ $upt->track('suspended', $stryesnooptions[$existinguser->suspended] , 'normal', false);
if (is_siteadmin($user->id)) {
$upt->track('status', $strusernotupdatedadmin, 'error');
$upt->track('auth', $existinguser->auth, 'normal', false);
$doupdate = false;
+ $dologout = false;
if ($updatetype != UU_UPDATE_NOCHANGES) {
if (!empty($user->auth) and $user->auth !== $existinguser->auth) {
$upt->track('auth', $struserauthunsupported, 'warning');
}
$doupdate = true;
+ if ($existinguser->auth === 'nologin') {
+ $dologout = true;
+ }
}
$allcolumns = array_merge($STD_FIELDS, $PRF_FIELDS);
foreach ($allcolumns as $column) {
- if ($column === 'username' or $column === 'password' or $column === 'auth') {
+ if ($column === 'username' or $column === 'password' or $column === 'auth' or $column === 'suspended') {
// these can not be changed here
continue;
}
}
$isinternalauth = $auth->is_internal();
+ // deal with suspending and activating of accounts
+ if ($allowsuspends and isset($user->suspended) and $user->suspended !== '') {
+ $user->suspended = $user->suspended ? 1 : 0;
+ if ($existinguser->suspended != $user->suspended) {
+ $upt->track('suspended', '', 'normal', false);
+ $upt->track('suspended', $stryesnooptions[$existinguser->suspended].'-->'.$stryesnooptions[$user->suspended], 'info', false);
+ $existinguser->suspended = $user->suspended;
+ $doupdate = true;
+ if ($existinguser->suspended) {
+ $dologout = true;
+ }
+ }
+ }
+
// changing of passwords is a special case
// do not force password changes for external auth plugins!
$oldpw = $existinguser->password;
}
}
+ if ($dologout) {
+ session_kill_user($existinguser->id);
+ }
+
} else {
// save the new user to the database
$user->confirmed = 1;
$user->timecreated = time();
$user->mnethostid = $CFG->mnet_localhost_id; // we support ONLY local accounts here, sorry
+ if (!isset($user->suspended) or $user->suspended === '') {
+ $user->suspended = 0;
+ } else {
+ $user->suspended = $user->suspended ? 1 : 0;
+ }
+ $upt->track('suspended', $stryesnooptions[$user->suspended], 'normal', false);
+
if (empty($user->auth)) {
$user->auth = 'manual';
}
*/
class uu_progress_tracker {
private $_row;
- public $columns = array('status', 'line', 'id', 'username', 'firstname', 'lastname', 'email', 'password', 'auth', 'enrolments', 'deleted');
+ public $columns = array('status', 'line', 'id', 'username', 'firstname', 'lastname', 'email', 'password', 'auth', 'enrolments', 'suspended', 'deleted');
/**
* Print table header.
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('password').'</th>';
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('delete').'</th>';
echo '</tr>';
$this->_row = null;
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDNEW);
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDINC);
+ $mform->addElement('selectyesno', 'uuallowsuspends', get_string('allowsuspends', 'tool_uploaduser'));
+ $mform->setDefault('uuallowsuspends', 1);
+ $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDNEW);
+ $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDINC);
+
$mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser'));
$mform->setDefault('uunoemailduplicates', 1);