MDL-31465 core_user: Incorporate user suspension into webservices
This commit is contained in:
committed by
Simey Lameze
parent
6a69cda97d
commit
511db62153
@@ -452,6 +452,8 @@ class core_user_external extends external_api {
|
||||
'auth' =>
|
||||
new external_value(core_user::get_property_type('auth'), 'Auth plugins include manual, ldap, imap, etc', VALUE_OPTIONAL, '',
|
||||
NULL_NOT_ALLOWED),
|
||||
'suspended' =>
|
||||
new external_value(core_user::get_property_type('suspended'), 'Suspend user account, either false to enable user login or true to disable it', VALUE_OPTIONAL),
|
||||
'idnumber' =>
|
||||
new external_value(core_user::get_property_type('idnumber'), 'An arbitrary ID code number perhaps from the institution',
|
||||
VALUE_OPTIONAL),
|
||||
@@ -572,6 +574,9 @@ class core_user_external extends external_api {
|
||||
set_user_preference($preference['type'], $preference['value'], $user['id']);
|
||||
}
|
||||
}
|
||||
if (isset($user['suspended']) and $user['suspended']) {
|
||||
\core\session\manager::kill_user_sessions($user['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
@@ -1016,6 +1021,7 @@ class core_user_external extends external_api {
|
||||
'firstaccess' => new external_value(core_user::get_property_type('firstaccess'), 'first access to the site (0 if never)', VALUE_OPTIONAL),
|
||||
'lastaccess' => new external_value(core_user::get_property_type('lastaccess'), 'last access to the site (0 if never)', VALUE_OPTIONAL),
|
||||
'auth' => new external_value(core_user::get_property_type('auth'), 'Auth plugins include manual, ldap, imap, etc', VALUE_OPTIONAL),
|
||||
'suspended' => new external_value(core_user::get_property_type('suspended'), 'Suspend user account, either false to enable user login or true to disable it', VALUE_OPTIONAL),
|
||||
'confirmed' => new external_value(core_user::get_property_type('confirmed'), 'Active user: 1 if confirmed, 0 otherwise', VALUE_OPTIONAL),
|
||||
'lang' => new external_value(core_user::get_property_type('lang'), 'Language code such as "en", must exist on server', VALUE_OPTIONAL),
|
||||
'calendartype' => new external_value(core_user::get_property_type('calendartype'), 'Calendar type such as "gregorian", must exist on server', VALUE_OPTIONAL),
|
||||
|
||||
+4
-1
@@ -231,7 +231,7 @@ function user_get_default_fields() {
|
||||
'institution', 'interests', 'firstaccess', 'lastaccess', 'auth', 'confirmed',
|
||||
'idnumber', 'lang', 'theme', 'timezone', 'mailformat', 'description', 'descriptionformat',
|
||||
'city', 'url', 'country', 'profileimageurlsmall', 'profileimageurl', 'customfields',
|
||||
'groups', 'roles', 'preferences', 'enrolledcourses'
|
||||
'groups', 'roles', 'preferences', 'enrolledcourses', 'suspended'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -443,6 +443,9 @@ function user_get_user_details($user, $course = null, array $userfields = array(
|
||||
if (in_array('msn', $userfields) && $user->msn && (!isset($hiddenfields['msnid']) or $isadmin)) {
|
||||
$userdetails['msn'] = $user->msn;
|
||||
}
|
||||
if (in_array('suspended', $userfields) && (!isset($hiddenfields['suspended']) or $isadmin)) {
|
||||
$userdetails['suspended'] = $user->suspended;
|
||||
}
|
||||
|
||||
if (in_array('firstaccess', $userfields) && (!isset($hiddenfields['firstaccess']) or $isadmin)) {
|
||||
if ($user->firstaccess) {
|
||||
|
||||
Reference in New Issue
Block a user