Add isAdmin option.

1.10.x
Julio Montoya 11 years ago
parent 5f46223f52
commit cb9e5d7b00
  1. 6
      main/admin/user_add.php
  2. 42
      main/inc/lib/usermanager.lib.php

@ -339,7 +339,8 @@ if( $form->validate()) {
$hr_dept_id,
$extra,
null,
$send_mail
$send_mail,
$platform_admin
);
Security::clear_token();
@ -379,9 +380,6 @@ if( $form->validate()) {
foreach ($extra as $key => $value) {
UserManager::update_extra_field_value($user_id, $key, $value);
}
if ($platform_admin) {
UserManager::add_user_as_admin($user_id);
}
$message = get_lang('UserAdded');
}
if (isset($user['submit_plus'])) {

@ -44,22 +44,25 @@ class UserManager
* Creates a new user for the platform
* @author Hugues Peeters <peeters@ipm.ucl.ac.be>,
* @author Roan Embrechts <roan_embrechts@yahoo.com>
* @param string Firstname
* @param string Lastname
* @param int Status (1 for course tutor, 5 for student, 6 for anonymous)
* @param string e-mail address
* @param string Login
* @param string Password
* @param string Any official code (optional)
* @param string User language (optional)
* @param string Phone number (optional)
* @param string Picture URI (optional)
* @param string Authentication source (optional, defaults to 'platform', dependind on constant)
* @param string Account expiration date (optional, defaults to null)
* @param int Whether the account is enabled or disabled by default
* @param int The department of HR in which the user is registered (optional, defaults to 0)
* @param array Extra fields
* @param string Encrypt method used if password is given encrypted. Set to an empty string by default
* @param string Firstname
* @param string Lastname
* @param int Status (1 for course tutor, 5 for student, 6 for anonymous)
* @param string e-mail address
* @param string Login
* @param string Password
* @param string Any official code (optional)
* @param string User language (optional)
* @param string Phone number (optional)
* @param string Picture URI (optional)
* @param string Authentication source (optional, defaults to 'platform', dependind on constant)
* @param string Account expiration date (optional, defaults to null)
* @param int Whether the account is enabled or disabled by default
* @param int The department of HR in which the user is registered (optional, defaults to 0)
* @param array Extra fields
* @param string Encrypt method used if password is given encrypted. Set to an empty string by default
* @param bool $send_mail
* @param bool $isAdmin
*
* @return mixed new user id - if the new user creation succeeds, false otherwise
* @desc The function tries to retrieve user id from the session.
* If it exists, the current user id is the creator id. If a problem arises,
@ -84,7 +87,8 @@ class UserManager
$hr_dept_id = 0,
$extra = null,
$encrypt_method = '',
$send_mail = false
$send_mail = false,
$isAdmin = false
) {
$currentUserId = api_get_user_id();
$hook = HookCreateUser::create();
@ -206,6 +210,10 @@ class UserManager
$sql = "UPDATE $table_user SET user_id = $return WHERE id = $return";
Database::query($sql);
if ($isAdmin) {
UserManager::add_user_as_admin($userId);
}
if (api_get_multiple_access_url()) {
UrlManager::add_user_to_url($return, api_get_current_access_url_id());
} else {

Loading…
Cancel
Save