Dokeos PHP Cross Reference Learning Management Systems

Source: /main/user/user.php - 609 lines - 26890 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /* For licensing terms, see /dokeos_license.txt */
   4  
   5  /**
   6  ==============================================================================
   7  *    @package dokeos.user
   8  ==============================================================================
   9  */
  10  
  11  // name of the language file that needs to be included
  12  $language_file = array('registration', 'admin', 'userInfo');
  13  
  14  // including the global Dokeos file
  15  require_once  '../inc/global.inc.php';
  16  
  17  // the section (for the tabs)
  18  $this_section = SECTION_COURSES;
  19  
  20  // including additional libraries
  21  require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
  22  require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  23  require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  24  require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  25  require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  26  require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  27  require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  28  require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  29  
  30  $use_anonymous = true;
  31  
  32  // notice for unauthorized people.
  33  api_protect_course_script(true);
  34  
  35  //CHECK KEYS
  36  if (!isset ($_cid)) {
  37      header('location: '.$_configuration['root_web']);
  38  }
  39  
  40  //adding additional javascript and css
  41  // Load jquery library
  42  $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-1.4.2.min.js" language="javascript"></script>';
  43  $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js"></script>';
  44  $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="screen" />';
  45  // Save the message for the chat invitation 
  46  $htmlHeadXtra[] = '<script>
  47    $(document).ready(function (){
  48      $(".chat_with_me").click(function(){
  49          var id = $(this).attr("id");
  50          var user_data = new Array();
  51          var user_info = id.split("chat_with_");
  52          _user_receiver_id = user_info[1];// Get the user(receiver) ID
  53          $.ajax({
  54              type: "GET",
  55              url: "user_ajax_requests.php?'.api_get_cidreq().'&action=send&user_receiver_id="+_user_receiver_id,
  56              success: function(msg){}
  57          })
  58      });
  59    });
  60  </script>';
  61  $is_western_name_order = api_is_western_name_order();
  62  $sort_by_first_name = api_sort_by_first_name();
  63  
  64  /*--------------------------------------
  65      Unregistering a user section
  66  --------------------------------------
  67  */
  68  if (api_is_allowed_to_edit()) {
  69      if (isset($_POST['action'])) {
  70          switch ($_POST['action']) {
  71              case 'unsubscribe' :
  72                  // Make sure we don't unsubscribe current user from the course
  73  
  74                  if (is_array($_POST['user'])) {
  75                      $user_ids = array_diff($_POST['user'], array($_user['user_id']));
  76                      if (count($user_ids) > 0) {
  77                          CourseManager::unsubscribe_user($user_ids, $_SESSION['_course']['sysCode']);
  78                          $message = get_lang('UsersUnsubscribed');
  79                      }
  80                  }
  81          }
  82      }
  83  }
  84  
  85  if (api_is_allowed_to_edit()) {
  86  
  87      if ( isset ($_GET['action'])) {
  88          switch ($_GET['action']) {
  89              case 'makeTeacherStudent':
  90                  $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  91                  $sql = "UPDATE ".$table_course_user." SET status=5 WHERE user_id=".Database::escape_string(Security::Remove_XSS($_GET['user_id']))." AND course_code='". api_get_course_id()."'";
  92                  Database::query($sql);
  93                  break;
  94              case 'makeStudentTeacher':
  95                  $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  96                  $sql = "UPDATE ".$table_course_user." SET status=1 WHERE user_id=".Database::escape_string(Security::Remove_XSS($_GET['user_id']))." AND course_code='". api_get_course_id()."'";
  97                  Database::query($sql);
  98                  break;
  99              case 'export' :
 100                  $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
 101                  $table_users = Database::get_main_table(TABLE_MAIN_USER);
 102                  $session_id = 0;
 103                  $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
 104  
 105                  $data = array();
 106                  $a_users = array();
 107  
 108                  // users subscribed to the course through a session
 109                  if (api_get_setting('use_session_mode') == 'true') {
 110                      $session_id = intval($_SESSION['id_session']);
 111                      $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 112                      $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", user.email, user.official_code
 113                          FROM $table_session_course_user as session_course_user, $table_users as user
 114                          WHERE `course_code` = '".Database::escape_string($_course['sysCode'])."' AND session_course_user.id_user = user.user_id ";
 115  
 116                      if ($session_id != 0) {
 117                          $sql_query .= ' AND id_session = '.$session_id;
 118                      }
 119                      $sql_query .= $sort_by_first_name ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname';
 120                      $rs = Database::query($sql_query, __FILE__, __LINE__);
 121                      while ($user = Database:: fetch_array($rs, 'ASSOC')) {
 122                          $data[] = $user;
 123                          //$user_infos = Database :: get_user_info_from_id($user['user_id']);
 124                          $a_users[$user['user_id']] = $user;
 125                      }
 126                  }
 127  
 128                  if ($session_id == 0) {
 129                      // users directly subscribed to the course
 130                      $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 131                      $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", user.email, user.official_code
 132                          FROM $table_course_user as course_user, $table_users as user WHERE `course_code` = '".Database::escape_string($_course['sysCode'])."' AND course_user.user_id = user.user_id ".($sort_by_first_name ? "ORDER BY user.firstname, user.lastname" : "ORDER BY user.lastname, user.firstname");
 133                      $rs = Database::query($sql_query, __FILE__, __LINE__);
 134                      while ($user = Database::fetch_array($rs, 'ASSOC')) {
 135                          $data[] = $user;
 136                          $a_users[$user['user_id']] = $user;
 137                      }
 138                  }
 139  
 140                  switch ($_GET['type']) {
 141                      case 'csv' :
 142                          Export::export_table_csv($a_users);
 143                      case 'xls' :
 144                          Export::export_table_xls($a_users);
 145                  }
 146          }
 147      }
 148  } // end if allowed to edit
 149  
 150  if (api_is_allowed_to_edit()) {
 151      // Unregister user from course
 152      if ($_REQUEST['unregister']) {
 153          if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $_GET['user_id'] != $_user['user_id']) {
 154              $tbl_user                    = Database::get_main_table(TABLE_MAIN_USER);
 155              $tbl_session_rel_course        = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 156              $tbl_session_rel_user        = Database::get_main_table(TABLE_MAIN_SESSION_USER);
 157  
 158              $sql = 'SELECT '.$tbl_user.'.user_id
 159                      FROM '.$tbl_user.' user
 160                      INNER JOIN '.$tbl_session_rel_user.' reluser
 161                      ON user.user_id = reluser.id_user
 162                      INNER JOIN '.$tbl_session_rel_course.' rel_course
 163                      ON rel_course.id_session = reluser.id_session
 164                      WHERE user.user_id = "'.Database::escape_string(Security::Remove_XSS($_GET['user_id'])).'"
 165                      AND rel_course.course_code = "'.Database::escape_string($_course['sysCode']).'"';
 166  
 167              $result = Database::query($sql, __FILE__ ,__LINE__);
 168              $row = Database::fetch_array($result, 'ASSOC');
 169              if ($row['user_id'] == $user_id || $row['user_id'] == "") {
 170                  CourseManager::unsubscribe_user($_GET['user_id'], $_SESSION['_course']['sysCode']);
 171                  $message = get_lang('UserUnsubscribed');
 172              } else {
 173                  $message = get_lang('ThisStudentIsSubscribeThroughASession');
 174              }
 175          }
 176      }
 177  } // end if allowed to edit
 178  
 179  
 180  /*
 181  ==============================================================================
 182          FUNCTIONS
 183  ==============================================================================
 184  */
 185  
 186  function display_user_search_form() {
 187      echo '<form method="get" action="user.php">';
 188      echo get_lang("SearchForUser") . "&nbsp;&nbsp;";
 189      echo '<input type="text" name="keyword" value="'.Security::Remove_XSS($_GET['keyword']).'"/>';
 190      echo '<input type="submit" value="'.get_lang('SearchButton').'"/>';
 191      echo '</form>';
 192  }
 193  /**
 194  *    This function displays a list if users for each virtual course linked to the current
 195  *    real course.
 196  *
 197  *    defines globals
 198  *
 199  *    @version 1.0
 200  *    @author Roan Embrechts
 201  *    @todo users from virtual courses always show "-" for the group related output. Edit and statistics columns are disabled *    for these users, for now.
 202  */
 203  function show_users_in_virtual_courses() {
 204      global $_course, $_user, $origin;
 205      $real_course_code = $_course['sysCode'];
 206      $real_course_info = Database::get_course_info($real_course_code);
 207      $user_subscribed_virtual_course_list = CourseManager::get_list_of_virtual_courses_for_specific_user_and_real_course($_user['user_id'], $real_course_code);
 208      $number_of_virtual_courses = count($user_subscribed_virtual_course_list);
 209      $row = 0;
 210      $column_header[$row++] = "ID";
 211      $column_header[$row++] = get_lang("FullUserName");
 212      $column_header[$row++] = get_lang("Role");
 213      $column_header[$row++] = get_lang("Group");
 214      if (api_is_allowed_to_edit()) {
 215          $column_header[$row++] = get_lang("Tutor");
 216      }
 217      if (api_is_allowed_to_edit()) {
 218          $column_header[$row++] = get_lang("CourseManager");
 219      }
 220  
 221      if (!is_array($user_subscribed_virtual_course_list)) {
 222          return;
 223      }
 224  
 225      foreach ($user_subscribed_virtual_course_list as $virtual_course) {
 226          $virtual_course_code = $virtual_course["code"];
 227          $virtual_course_user_list = CourseManager::get_user_list_from_course_code($virtual_course_code);
 228          $message = get_lang("RegisteredInVirtualCourse")." ".$virtual_course["title"]."&nbsp;&nbsp;(".$virtual_course["code"].")";
 229          echo "<br/>";
 230          echo "<h4>".$message."</h4>";
 231          $properties["width"] = "100%";
 232          $properties["cellspacing"] = "1";
 233          Display::display_complex_table_header($properties, $column_header);
 234          foreach ($virtual_course_user_list as $this_user) {
 235              $user_id = $this_user["user_id"];
 236              $loginname = $this_user["username"];
 237              $lastname = $this_user["lastname"];
 238              $firstname = $this_user["firstname"];
 239              $status = $this_user["status"];
 240              $role = $this_user["role"];
 241              if ($status == "1") {
 242                  $status = get_lang("CourseManager");
 243              } else {
 244                  $status = " - ";
 245              }
 246  
 247              $full_name = api_get_person_name($firstname, $lastname);
 248              if ($lastname == '' || $firstname == '') {
 249                  $full_name = $loginname;
 250              }
 251  
 252              $user_info_hyperlink = "<a href=\"userInfo.php?".api_get_cidreq()."&origin=".$origin."&uInfo=".$user_id."&virtual_course=".$virtual_course["code"]."\">".$full_name."</a>";
 253              $row = 0;
 254              $table_row[$row++] = $user_id;
 255              $table_row[$row++] = $user_info_hyperlink; //Full name
 256              $table_row[$row++] = $role; //Description
 257              $table_row[$row++] = " - "; //Group, for the moment groups don't work for students in virtual courses
 258              if (api_is_allowed_to_edit()) {
 259                  $table_row[$row ++] = " - "; //Tutor column
 260                  $table_row[$row ++] = $status; //Course Manager column
 261              }
 262              Display::display_table_row(null, $table_row, true);
 263          }
 264          Display::display_table_footer();
 265      }
 266  }
 267  
 268  if (!$is_allowed_in_course) {
 269      api_not_allowed(true);
 270  }
 271  
 272  // Display the header
 273  Display::display_tool_header($tool_name, "User");
 274  
 275  if (isset($message)) {
 276      Display::display_confirmation_message($message);
 277  }
 278  
 279  //tracking
 280  event_access_tool(TOOL_USER);
 281  
 282  
 283  // Access restriction
 284  $is_allowed_to_track = (api_is_allowed_to_edit() || $is_courseTutor) && $_configuration['tracking_enabled'];
 285  
 286  
 287  // Tool introduction
 288  Display::display_introduction_section(TOOL_USER, 'left');
 289  
 290  
 291  if ( api_is_allowed_to_edit()) {
 292      echo "<div class=\"actions\">";
 293  
 294      // the action links
 295      //$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.Display::return_icon('csv.gif', get_lang('ExportAsCSV')).'&nbsp;'.get_lang('ExportAsCSV').'</a> ';
 296      $actions .= '<a href="subscribe_user.php?'.api_get_cidreq().'">'.Display::return_icon('pixel.gif', get_lang('AddLearners'), array('class' => 'toolactionplaceholdericon tooladdlearner')).get_lang("AddLearners").'</a> ';
 297      //$actions .= "<a href=\"subscribe_user.php?".api_get_cidreq()."&type=teacher\">".Display::return_icon('add_teacher_big.gif', get_lang("SubscribeUserToCourseAsTeacher"))."&nbsp;".get_lang("SubscribeUserToCourseAsTeacher")."</a> ";
 298      //$actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".Display::return_icon('classes32.png', get_lang("ManageClasses"))."&nbsp;".get_lang("ManageClasses")."</a>";
 299      if (api_get_setting('use_session_mode') == 'false') {
 300          $actions .= ' <a href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
 301      }
 302  
 303      // Build search-form
 304      $form = new FormValidator('search_user', 'get', '', '', null, false);
 305      $renderer = & $form->defaultRenderer();
 306      $renderer->setElementTemplate('<span>{element}</span> ');
 307      $form->addElement('static', 'additionalactions', null, $actions);
 308      $form->addElement('static', 'div_float_right', null, '<div style="float:right;">');
 309      $form->add_textfield('keyword', '', false);
 310      $form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
 311      $form->addElement('static', 'div_float_right_end', null, '</div>');
 312      $form->display();
 313      echo '</div>';
 314  }
 315  /*
 316  if (1) // platform setting api_get_setting('subscribe_user_by_coach') {
 317      if (!api_is_allowed_to_edit() && $is_courseTutor) {
 318          echo "<div align=\"right\">";
 319          echo '<a href="subscribe_user.php?'.api_get_cidreq().'">'.Display::return_icon('add_user_big.gif',get_lang("SubscribeUserToCourse")).'&nbsp;'.get_lang("SubscribeUserToCourse").'</a>';
 320          echo "</div>";
 321      }
 322  }*/
 323  
 324  // start the content div
 325  echo '<div id="content">';
 326  
 327  /*
 328  --------------------------------------
 329      DISPLAY USERS LIST
 330  --------------------------------------
 331      Also shows a "next page" button if there are
 332      more than 50 users.
 333  
 334      There's a bug in here somewhere - some users count as more than one if they are in more than one group
 335      --> code for > 50 users should take this into account
 336      (Roan, Feb 2004)
 337  */
 338  if (CourseManager::has_virtual_courses_from_code($course_id, $user_id)) {
 339      $real_course_code = $_course['sysCode'];
 340      $real_course_info = Database::get_course_info($real_course_code);
 341      $message = get_lang("RegisteredInRealCourse")." ".$real_course_info["title"]."&nbsp;&nbsp;(".$real_course_info["official_code"].")";
 342      echo "<h4>".$message."</h4>";
 343  }
 344  
 345  /*
 346  ==============================================================================
 347          DISPLAY LIST OF USERS
 348  ==============================================================================
 349  */
 350  /**
 351   *  * Get the users to display on the current page.
 352   */
 353  function get_number_of_users() {
 354      $counter = 0;
 355      if (!empty($_SESSION["id_session"])){
 356          $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session']);
 357      } else {
 358          $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true);
 359      }
 360      foreach ($a_course_users as $user_id => $o_course_user) {
 361          if ((isset($_GET['keyword']) && search_keyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
 362              $counter++;
 363          }
 364      }
 365      return $counter;
 366  }
 367  
 368  function search_keyword($firstname, $lastname, $username, $official_code, $keyword) {
 369      if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) {
 370          return true;
 371      } else {
 372          return false;
 373      }
 374  }
 375  
 376  
 377  /**
 378   * Get the users to display on the current page.
 379   */
 380  function get_user_data($from, $number_of_items, $column, $direction) {
 381  
 382      global $origin,$_user;
 383      global $is_western_name_order;
 384      global $sort_by_first_name;
 385      $a_users = array();
 386  
 387      // limit
 388      if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
 389          $limit = 'LIMIT '.intval($from).','.intval($number_of_items);
 390      }
 391  
 392      if (!in_array($direction, array('ASC', 'DESC'))) {
 393          $direction = 'ASC';
 394      }
 395  
 396      // order by
 397      if (api_is_allowed_to_edit()) {
 398          $column--;
 399      }
 400      switch ($column) {
 401          case 1:
 402          case 2:
 403              $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
 404              break;
 405          case 5:
 406              $order_by = 'ORDER BY user.official_code '.$direction;
 407              break;
 408          default:
 409              $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
 410              break;
 411      }
 412  
 413      if (!empty($_SESSION["id_session"])) {
 414          $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session'], $limit, $order_by);
 415      } else {
 416          $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, 0, $limit, $order_by);
 417          $user_list = Who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), api_get_course_id());
 418          $online_users_list = array();
 419          foreach ($user_list as $user_online) {
 420              $online_users_list[] = $user_online['0'];
 421          }
 422      }
 423  
 424      foreach ($a_course_users as $user_id => $o_course_user) {
 425          if ((isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
 426              
 427              $session_name = UserManager::get_user_last_session_name_in_course($user_id, $_SESSION['_course']['id']);
 428              $is_course_coach = SessionManager::is_course_in_session_coach($user_id, $_SESSION['_course']['id']);
 429              
 430              if (api_is_allowed_to_edit()) {
 431                  $temp = array();
 432  
 433                  $temp[] = $user_id;
 434                  $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
 435                  $user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, 'small_', ' width="22" height="22" ');
 436                  if (!api_is_anonymous()) {
 437                      $image_array=UserManager::get_user_picture_path_by_id($user_id,'web',false,false);
 438                      if ($image_array['file']!='') {
 439                          $photo = '<center><a class="thickbox" href="'.$image_array['dir'].$image_array['file'].'" title="'.get_lang('Info').'"  >
 440                                      <img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />
 441                                    </a></center>';
 442                      }
 443                      else{
 444                      //    $photo = '<center><img src="'.api_get_path(WEB_IMG_PATH).'unknown.png" '.$user_profile['style'].'></center>';
 445                          $photo = '<center>'.Display::return_icon('pixel.gif','',array('class' => 'actionplaceholdericon actionunknown')).'</center>';
 446                      }
 447                  } else {
 448                      $photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
 449                  }
 450                  $temp[] = $photo;
 451                  if (in_array($user_id, $online_users_list) && $user_id != api_get_user_id()) { // If is online
 452                    $temp[] = '<div class="chat_with_me" id="chat_with_'.$user_id.'"><center><a href="javascript:void(0)" onclick="try{popup_window.close();}catch(e){};popup_window = window.open(\''.api_get_path(WEB_PATH).'main/chat/chat.php?'.api_get_cidreq().'&send_invitation=true&to_user='.$user_id.'\',\'window_chat'.api_get_course_id().'\',config=\'height=500, width=925, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')"><img src="'.api_get_path(WEB_IMG_PATH).'internet-group-chat22.png" /></a></center></div>';
 453                  } else {
 454                    // No display chat image if user is not connected
 455                    //$temp[] = '<center><img src="'.api_get_path(WEB_IMG_PATH).'internet-group-chat22.png" /></center>';
 456                    $temp[] = '<center>&nbsp;</center>';
 457                  }
 458                  $temp[] = $o_course_user['lastname'];
 459                  $temp[] = $o_course_user['firstname'];
 460                  
 461                  $temp[] = $session_name;
 462                  if($o_course_user['active'] == 0){
 463                      $temp[] = '<div style="text-align:center;"><img src="'.api_get_path(WEB_IMG_PATH).'dialog-error.png" /></div>';
 464                  }
 465                  else{
 466                      if (CourseManager::is_course_teacher($user_id, $_SESSION['_course']['id'])) {
 467                          $temp[] = '<div style="text-align:center;"><a href="user.php?'.api_get_cidreq().'&action=makeTeacherStudent&user_id='.$user_id.'">'.Display::return_icon('pixel.gif',get_lang('Trainer'),array('class' => 'actionplaceholdericon actiontrainer')).'</a></div>';
 468                      }
 469                      elseif($is_course_coach){
 470                          $temp[] = '<div style="text-align:center;">'.Display::return_icon('pixel.gif',get_lang('Coach'),array('class' => 'actionplaceholdericon actioncoach')).'</div>';
 471                      }
 472                      else{
 473                          $temp[] = '<div style="text-align:center;"><a href="user.php?'.api_get_cidreq().'&action=makeStudentTeacher&user_id='.$user_id.'">'.Display::return_icon('pixel.gif',get_lang('User'),array('class' => 'actionplaceholdericon actionuser')).'</a></div>';
 474                      }
 475                  }
 476  
 477                  $temp[] = $user_id;
 478              } else {
 479                  $temp = array();
 480  
 481                  $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
 482                  $image_repository = $image_path['dir'];
 483                  $existing_image = $image_path['file'];
 484                  if (!api_is_anonymous()) {
 485                      $photo= '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a></center>';
 486                  } else {
 487                      $photo= '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></center>';
 488                  }
 489                  $temp[] = $photo;
 490                  
 491                  if (in_array($user_id, $online_users_list) && $user_id != api_get_user_id()) { // If is online
 492                    $temp[] = '<div class="chat_with_me" id="chat_with_'.$user_id.'"><center><a href="javascript:void(0)" onclick="try{popup_window.close();}catch(e){};popup_window = window.open(\''.api_get_path(WEB_PATH).'main/chat/chat.php?'.api_get_cidreq().'&send_invitation=true&to_user='.$user_id.'\',\'window_chat'.api_get_course_id().'\',config=\'height=500, width=925, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')"><img src="'.api_get_path(WEB_IMG_PATH).'internet-group-chat22.png" /></a></center></div>';
 493                  } else {
 494                    // No display chat image if user is not connected
 495                    //$temp[] = '<center><img src="'.api_get_path(WEB_IMG_PATH).'internet-group-chat22.png" /></center>';
 496                    $temp[] = '<center>&nbsp;</center>';
 497                  }
 498  
 499                  
 500                  $temp[] = $o_course_user['lastname'];
 501                  $temp[] = $o_course_user['firstname'];
 502                  $temp[] = ""; //sessions
 503                  if (api_is_allowed_to_edit()) {
 504                      $temp[] = $user_id;
 505                  }
 506              }
 507              $a_users[$user_id] = $temp;
 508          }
 509      }
 510      return $a_users;
 511  }
 512  
 513  
 514  /**
 515   * Build the active-column of the table to lock or unlock a certain user
 516   * lock = the user can no longer use this account
 517   * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 518   * @param int $active the current state of the account
 519   * @param int $user_id The user id
 520   * @param string $url_params
 521   * @return string Some HTML-code with the lock/unlock button
 522   */
 523  function active_filter($active, $url_params, $row) {
 524      global $_user;
 525      if ($active=='1') {
 526          $action='AccountActive';
 527          $image='right';
 528      }
 529      if ($active=='0') {
 530          $action='AccountInactive';
 531          $image='wrong';
 532      }
 533      if ($row['0']<>$_user['user_id']) {  // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
 534          $result = '<center><img src="../img/'.$image.'.gif" border="0" style="vertical-align: middle;" alt="'.get_lang(ucfirst($action)).'" title="'.get_lang(ucfirst($action)).'"/></center>';
 535      }
 536      return $result;
 537  }
 538  
 539  
 540  /**
 541   * Build the modify-column of the table
 542   * @param int $user_id The user id
 543   * @return string Some HTML-code
 544   */
 545  function modify_filter($user_id) {
 546      global $origin, $_user, $_course, $is_allowed_to_track, $charset;
 547  
 548      $result="<div style='text-align: center'>";
 549  
 550      if ($is_allowed_to_track) {
 551          $result .= '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&student='.$user_id.'&amp;details=true&amp;course='.$_course['id'].'&amp;origin=user_course&amp;id_session='.$_SESSION["id_session"].'" title="'.get_lang('Tracking').'"  >'.Display::return_icon('pixel.gif',get_lang('Tracking'),array('class' => 'actionplaceholdericon actiontracking')).'</a>&nbsp;';
 552      }
 553      $result .= "</div>";
 554      return $result;
 555  }
 556  
 557  $default_column = ($is_western_name_order xor $sort_by_first_name) ? 3 : 2;
 558  $default_column = api_is_allowed_to_edit() ? 3 : 2;
 559  
 560  $table = new SortableTable('users', 'get_number_of_users', 'get_user_data', $default_column);
 561  $parameters['keyword'] = $_GET['keyword'];
 562  $table->set_additional_parameters($parameters);
 563  $header_nr = 0;
 564  
 565  if (api_is_allowed_to_edit()) {
 566      $table->set_header($header_nr++, get_lang('Remove'), false);
 567  }
 568  $table->set_header($header_nr++, get_lang('Photo'), false);
 569  $table->set_header($header_nr++, get_lang('Chat'), false);
 570  $table->set_header($header_nr++, get_lang('LastName'));
 571  $table->set_header($header_nr++, get_lang('FirstName'));
 572  //$table->set_header($header_nr++, get_lang('Description'), false);
 573  $table->set_header($header_nr++, get_lang('Session'), false);
 574  //$table->set_header($header_nr++, get_lang('OfficialCode'));
 575  
 576  if (api_is_allowed_to_edit()) {
 577      // deprecated feature
 578      $table->set_header($header_nr++, get_lang('Role'), false);
 579      //actions column
 580      $table->set_header($header_nr++, get_lang('Report'), false);
 581      $table->set_column_filter($header_nr-1, 'modify_filter');
 582       if (api_is_allowed_to_edit()) {
 583          $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user');
 584      }
 585  }
 586  
 587  // display the table
 588  $table->display();
 589  
 590  // end the content div
 591  echo '</div>';
 592  
 593  // secondary actions
 594  if (api_is_allowed_to_edit()) {    
 595      echo '<div class="actions"><a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.Display::return_icon('pixel.gif',get_lang('Export'),array('class' => 'actionplaceholdericon actionexport')).'&nbsp;'.get_lang('Export').'</a></div>';
 596  }
 597  
 598  if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
 599      $keyword_name = Security::remove_XSS($_GET['keyword']);
 600      echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
 601  }
 602  
 603  if (api_get_setting('allow_user_headings') == 'true' && $is_courseAdmin && api_is_allowed_to_edit() && $origin != 'learnpath') { // only course administrators see this line
 604      echo "<div align=\"right\">", "<form method=\"post\" action=\"userInfo.php\">", get_lang("CourseAdministratorOnly"), " : ", "<input type=\"submit\" name=\"viewDefList\" value=\"".get_lang("DefineHeadings")."\" />", "</form>", "</div>\n";
 605  }
 606  
 607  // display the footer
 608  Display::display_footer();
 609  ?>

title

Description

title

Description

title

Description

title

title

Body