dokeos-admin
[ class tree: dokeos-admin ] [ index: dokeos-admin ] [ all elements ]

Source for file ldap_users_list.php

Documentation is available at ldap_users_list.php

  1. <?php //$id: $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2008 Dokeos SPRL
  7.     Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard)
  8.  
  9.     For a full list of contributors, see "credits.txt".
  10.     The full license can be read in "license.txt".
  11.  
  12.     This program is free software; you can redistribute it and/or
  13.     modify it under the terms of the GNU General Public License
  14.     as published by the Free Software Foundation; either version 2
  15.     of the License, or (at your option) any later version.
  16.  
  17.     See the GNU General Public License for more details.
  18.  
  19.     Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23. ==============================================================================
  24.     @author Mustapha Alouani
  25. *    @package dokeos.admin
  26. ==============================================================================
  27. */
  28.  
  29. // name of the language file that needs to be included
  30. $language_file['registration';
  31. $language_file['admin';
  32. $cidReset true;
  33. require('../inc/global.inc.php');
  34. require_once(api_get_path(LIBRARY_PATH).'sortabletable.class.php');
  35. require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  36. require_once(api_get_path(LIBRARY_PATH).'security.lib.php');
  37. require('../auth/ldap/authldap.php');
  38. $this_section SECTION_PLATFORM_ADMIN;
  39.  
  40.  
  41. /**
  42. ==============================================================================
  43.         INIT SECTION
  44. ==============================================================================
  45. */
  46. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  47. $action $_GET["action"];
  48. $login_as_user_id $_GET["user_id"];
  49.     
  50. // Login as ...
  51. if ($_GET['action'== "login_as" && isset ($login_as_user_id))
  52. {
  53.     login_user($login_as_user_id);
  54. }
  55.  
  56. //if we already have a session id and a user...
  57. /*
  58. if (($_GET['action']=="add_user") && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && $_GET['id_session']>0 ){
  59.     header('Location: ldap_import_students_to_session.php?id_session='.$_GET['id_session'].'&ldap_user='.$_GET['id']);
  60. }
  61. */
  62.  
  63. $interbreadcrumb[array ("url" => 'index.php'"name" => get_lang('PlatformAdmin'));
  64. $tool_name get_lang('SearchLDAPUsers');
  65. //Display :: display_header($tool_name); //cannot display now as we need to redirect
  66. //api_display_tool_title($tool_name);
  67.  
  68. if (isset ($_GET['action']))
  69. {
  70.     $check Security::check_token('get');
  71.     if($check)
  72.     {
  73.         switch ($_GET['action'])
  74.         {
  75.             case 'show_message' :
  76.                 Display :: display_header($tool_name);
  77.                 Display :: display_normal_message($_GET['message']);
  78.                 break;
  79.             case 'delete_user' :
  80.                 Display :: display_header($tool_name);
  81.                 if ($user_id != $_user['user_id'&& UserManager :: delete_user($_GET['user_id']))
  82.                 {
  83.                     Display :: display_normal_message(get_lang('UserDeleted'));
  84.                 }
  85.                 else
  86.                 {
  87.                     Display :: display_error_message(get_lang('CannotDeleteUser'));
  88.                 }
  89.                 break;
  90.             case 'lock' :
  91.                 Display :: display_header($tool_name);
  92.                 $message=lock_unlock_user('lock',$_GET['user_id']);
  93.                 Display :: display_normal_message($message);
  94.                 break;
  95.             case 'unlock';
  96.                 Display :: display_header($tool_name);
  97.                 $message=lock_unlock_user('unlock',$_GET['user_id']);
  98.                 Display :: display_normal_message($message);
  99.                 break;
  100.             case 'add_user';
  101.                 $id=$_GET['id'];
  102.                 $UserList=array();
  103.                 $userid_match_login array();
  104.                 foreach ($id as $user_id{
  105.                     $tmp ldap_add_user($user_id);
  106.                     $UserList[]$tmp;
  107.                     $userid_match_login[$tmp$user_id;
  108.                 }
  109.                 if (isset($_GET['id_session']&& ($_GET['id_session'== strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) {
  110.                     ldap_add_user_to_session($UserList$_GET['id_session']);
  111.                     header('Location: resume_session.php?id_session='.$_GET['id_session']);
  112.                 else {
  113.                     Display :: display_header($tool_name);
  114.                     if(count($userid_match_login)>0)
  115.                     {
  116.                         $message=get_lang('LDAPUsersAddedOrUpdated').':<br />';
  117.                         foreach($userid_match_login as $user_id => $login)
  118.                         {
  119.                             $message .= '- '.$login.'<br />';
  120.                         }
  121.                     }
  122.                     else
  123.                     {
  124.                         $message=get_lang('NoUserAdded');
  125.                     }
  126.                     Display :: display_normal_message($message,false);
  127.                 }
  128.                 break;
  129.             default 
  130.                 Display :: display_header($tool_name);
  131.         }
  132.         Security::clear_token();
  133.     }
  134.     else
  135.     {
  136.         Display::display_header($tool_name);
  137.     }
  138. }
  139. else
  140. {
  141.     Display::display_header($tool_name);
  142. }
  143. if (isset ($_POST['action']))
  144. {
  145.     $check Security::check_token('get');
  146.     if($check)
  147.     {
  148.         switch ($_POST['action'])
  149.         {
  150.             case 'delete' :
  151.                 $number_of_selected_users count($_POST['id']);
  152.                 $number_of_deleted_users 0;
  153.                 foreach ($_POST['id'as $index => $user_id)
  154.                 {
  155.                     if($user_id != $_user['user_id'])
  156.                     {
  157.                         if(UserManager :: delete_user($user_id))
  158.                         {
  159.                             $number_of_deleted_users++;
  160.                         }
  161.                     }
  162.                 }
  163.                 if($number_of_selected_users == $number_of_deleted_users)
  164.                 {
  165.                     Display :: display_normal_message(get_lang('SelectedUsersDeleted'));
  166.                 }
  167.                 else
  168.                 {
  169.                     Display :: display_error_message(get_lang('SomeUsersNotDeleted'));
  170.                 }
  171.                 break;
  172.             case 'add_user' :
  173.                 $number_of_selected_users count($_POST['id']);
  174.                 $number_of_added_users 0;
  175.                 $UserList=array();
  176.                 foreach ($_POST['id'as $index => $user_id)
  177.                 {
  178.                     if($user_id != $_user['user_id'])
  179.                     {
  180.                         $UserList[ldap_add_user($user_id);
  181.                     }
  182.                 }
  183.                 if (isset($_GET['id_session']&& (trim($_GET['id_session'])!=""))
  184.                     addUserToSession($UserList$_GET['id_session']);
  185.                 if(count($UserList)>0)
  186.                 {
  187.                     Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded'));
  188.                 }
  189.                 else
  190.                 {
  191.                     Display :: display_normal_message(get_lang('NoUserAdded'));
  192.                 }                
  193.                 break;
  194.                 
  195.         }
  196.         Security::clear_token();
  197.     }
  198. }
  199.  
  200. $form new FormValidator('advanced_search','get');
  201. $form->add_textfield('keyword_username',get_lang('LoginName'),false);
  202. $form->add_textfield('keyword_lastname',get_lang('LastName'),false);
  203. $form->add_textfield('keyword_firstname',get_lang('FirstName'),false);
  204. if (isset($_GET['id_session'])) 
  205.     $form->addElement('hidden','id_session',$_GET['id_session']);
  206.  
  207. $type array();
  208. $type["all"get_lang('All');
  209. $type["employee"]  get_lang('Teacher');
  210. $type["student"get_lang('Student');
  211.  
  212. $form->addElement('select','keyword_type',get_lang('Status'),$type);
  213. // Structure a rajouer ??
  214. $form->addElement('submit','submit',get_lang('Ok'));
  215. //$defaults['keyword_active'] = 1;
  216. //$defaults['keyword_inactive'] = 1;
  217. //$form->setDefaults($defaults);
  218. $form->display();
  219.  
  220.  
  221.  
  222. $parameters['keyword_username'$_GET['keyword_username'];
  223. $parameters['keyword_firstname'$_GET['keyword_firstname'];
  224. $parameters['keyword_lastname'$_GET['keyword_lastname'];
  225. $parameters['keyword_email'$_GET['keyword_email'];
  226. if (isset($_GET['id_session'])) 
  227.     $parameters['id_session'$_GET['id_session'];
  228. // Create a sortable table with user-data
  229.  
  230. $parameters['sec_token'Security::get_token();
  231. $table new SortableTable('users''ldap_get_number_of_users''ldap_get_user_data',2);
  232. $table->set_additional_parameters($parameters);
  233. $table->set_header(0''false);
  234. $table->set_header(1get_lang('LoginName'));
  235. $table->set_header(2get_lang('LastName'));
  236. $table->set_header(3get_lang('FirstName'));
  237. $table->set_header(4get_lang('Email'));
  238. $table->set_header(5get_lang('Actions'));
  239. //$table->set_column_filter(5, 'email_filter');
  240. //$table->set_column_filter(5, 'active_filter');
  241. $table->set_column_filter(5'modify_filter');
  242. $table->set_form_actions(array ('add_user' => get_lang('AddLDAPUsers')));
  243. $table->display();
  244.  
  245. /*
  246. ==============================================================================
  247.         FOOTER
  248. ==============================================================================
  249. */
  250. ?>

Documentation generated on Thu, 12 Jun 2008 13:54:39 -0500 by phpDocumentor 1.4.1