|
|
|
@ -4,9 +4,6 @@ |
|
|
|
|
* @author Mustapha Alouani |
|
|
|
|
* @package chamilo.admin |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Init |
|
|
|
|
*/ |
|
|
|
|
$cidReset = true; |
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
|
require('../auth/ldap/authldap.php'); |
|
|
|
@ -38,26 +35,21 @@ $tool_name = get_lang('SearchLDAPUsers'); |
|
|
|
|
if (isset ($_GET['action'])) |
|
|
|
|
{ |
|
|
|
|
$check = Security::check_token('get'); |
|
|
|
|
if ($check) |
|
|
|
|
{ |
|
|
|
|
switch ($_GET['action']) |
|
|
|
|
{ |
|
|
|
|
case 'show_message' : |
|
|
|
|
if ($check) { |
|
|
|
|
switch ($_GET['action']) { |
|
|
|
|
case 'show_message': |
|
|
|
|
Display::addFlash(Display::return_message($_GET['message'], 'normal')); |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
break; |
|
|
|
|
case 'delete_user' : |
|
|
|
|
if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id'])) |
|
|
|
|
{ |
|
|
|
|
case 'delete_user': |
|
|
|
|
if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id'])) { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('UserDeleted'), 'normal')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('CannotDeleteUser'), 'error')); |
|
|
|
|
} |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
break; |
|
|
|
|
case 'lock' : |
|
|
|
|
case 'lock': |
|
|
|
|
$message = lock_unlock_user('lock', $_GET['user_id']); |
|
|
|
|
Display::addFlash(Display::return_message($message, 'normal')); |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
@ -81,16 +73,12 @@ if (isset ($_GET['action'])) |
|
|
|
|
header('Location: resume_session.php?id_session='.intval($_GET['id_session'])); |
|
|
|
|
} else { |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
if (count($userid_match_login) > 0) |
|
|
|
|
{ |
|
|
|
|
if (count($userid_match_login) > 0) { |
|
|
|
|
$message = get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
|
|
|
|
foreach ($userid_match_login as $user_id => $login) |
|
|
|
|
{ |
|
|
|
|
foreach ($userid_match_login as $user_id => $login) { |
|
|
|
|
$message .= '- '.$login.'<br />'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
$message = get_lang('NoUserAdded'); |
|
|
|
|
} |
|
|
|
|
Display::addFlash(Display::return_message($message, 'normal', false)); |
|
|
|
@ -101,64 +89,50 @@ if (isset ($_GET['action'])) |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
} |
|
|
|
|
Security::clear_token(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
Display::display_header($tool_name); |
|
|
|
|
} |
|
|
|
|
if (isset ($_POST['action'])) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (isset($_POST['action'])) { |
|
|
|
|
$check = Security::check_token('get'); |
|
|
|
|
if ($check) |
|
|
|
|
{ |
|
|
|
|
switch ($_POST['action']) |
|
|
|
|
{ |
|
|
|
|
case 'delete' : |
|
|
|
|
if ($check) { |
|
|
|
|
switch ($_POST['action']) { |
|
|
|
|
case 'delete': |
|
|
|
|
$number_of_selected_users = count($_POST['id']); |
|
|
|
|
$number_of_deleted_users = 0; |
|
|
|
|
foreach ($_POST['id'] as $index => $user_id) |
|
|
|
|
{ |
|
|
|
|
if ($user_id != $_user['user_id']) |
|
|
|
|
{ |
|
|
|
|
if (UserManager::delete_user($user_id)) |
|
|
|
|
{ |
|
|
|
|
foreach ($_POST['id'] as $index => $user_id) { |
|
|
|
|
if ($user_id != $_user['user_id']) { |
|
|
|
|
if (UserManager::delete_user($user_id)) { |
|
|
|
|
$number_of_deleted_users++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($number_of_selected_users == $number_of_deleted_users) |
|
|
|
|
{ |
|
|
|
|
if ($number_of_selected_users == $number_of_deleted_users) { |
|
|
|
|
echo Display::return_message(get_lang('SelectedUsersDeleted'), 'normal'); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
echo Display::return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'add_user' : |
|
|
|
|
case 'add_user': |
|
|
|
|
$number_of_selected_users = count($_POST['id']); |
|
|
|
|
$number_of_added_users = 0; |
|
|
|
|
$UserList = array(); |
|
|
|
|
foreach ($_POST['id'] as $index => $user_id) |
|
|
|
|
{ |
|
|
|
|
if ($user_id != $_user['user_id']) |
|
|
|
|
{ |
|
|
|
|
foreach ($_POST['id'] as $index => $user_id) { |
|
|
|
|
if ($user_id != $_user['user_id']) { |
|
|
|
|
$UserList[] = ldap_add_user($user_id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isset($_GET['id_session']) && (trim($_GET['id_session']) != "")) |
|
|
|
|
if (isset($_GET['id_session']) && (trim($_GET['id_session']) != "")) { |
|
|
|
|
addUserToSession($UserList, $_GET['id_session']); |
|
|
|
|
if (count($UserList) > 0) |
|
|
|
|
{ |
|
|
|
|
echo Display::return_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (count($UserList) > 0) { |
|
|
|
|
echo Display::return_message( |
|
|
|
|
count($UserList)." ".get_lang('LDAPUsersAdded') |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
echo Display::return_message(get_lang('NoUserAdded')); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -170,18 +144,16 @@ if (isset ($_POST['action'])) |
|
|
|
|
|
|
|
|
|
$form = new FormValidator('advanced_search', 'get'); |
|
|
|
|
$form->addText('keyword_username', get_lang('LoginName'), false); |
|
|
|
|
if (api_is_western_name_order()) |
|
|
|
|
{ |
|
|
|
|
if (api_is_western_name_order()) { |
|
|
|
|
$form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
|
|
|
$form->addText('keyword_lastname', get_lang('LastName'), false); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
$form->addText('keyword_lastname', get_lang('LastName'), false); |
|
|
|
|
$form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
|
|
|
} |
|
|
|
|
if (isset($_GET['id_session'])) |
|
|
|
|
if (isset($_GET['id_session'])) { |
|
|
|
|
$form->addElement('hidden', 'id_session', $_GET['id_session']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$type = array(); |
|
|
|
|
$type["all"] = get_lang('All'); |
|
|
|
@ -195,19 +167,22 @@ $form->addElement('submit', 'submit', get_lang('Ok')); |
|
|
|
|
//$defaults['keyword_inactive'] = 1; |
|
|
|
|
//$form->setDefaults($defaults); |
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parameters['keyword_username'] = @$_GET['keyword_username'] ?: null; |
|
|
|
|
$parameters['keyword_firstname'] = @$_GET['keyword_firstname'] ?: null; |
|
|
|
|
$parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null; |
|
|
|
|
$parameters['keyword_email'] = @$_GET['keyword_email'] ?: null; |
|
|
|
|
if (isset($_GET['id_session'])) |
|
|
|
|
if (isset($_GET['id_session'])) { |
|
|
|
|
$parameters['id_session'] = $_GET['id_session']; |
|
|
|
|
} |
|
|
|
|
// Create a sortable table with user-data |
|
|
|
|
|
|
|
|
|
$parameters['sec_token'] = Security::get_token(); |
|
|
|
|
$table = new SortableTable('users', 'ldap_get_number_of_users', 'ldap_get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2); |
|
|
|
|
$table = new SortableTable( |
|
|
|
|
'users', |
|
|
|
|
'ldap_get_number_of_users', |
|
|
|
|
'ldap_get_user_data', |
|
|
|
|
(api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2 |
|
|
|
|
); |
|
|
|
|
$table->set_additional_parameters($parameters); |
|
|
|
|
$table->set_header(0, '', false); |
|
|
|
|
$table->set_header(1, get_lang('LoginName')); |
|
|
|
@ -226,9 +201,4 @@ $table->set_column_filter(5, 'modify_filter'); |
|
|
|
|
$table->set_form_actions(array('add_user' => get_lang('AddLDAPUsers'))); |
|
|
|
|
$table->display(); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
============================================================================== |
|
|
|
|
FOOTER |
|
|
|
|
============================================================================== |
|
|
|
|
*/ |
|
|
|
|
Display::display_footer(); |
|
|
|
|