Dokeos PHP Cross Reference Learning Management Systems

Source: /main/admin/session_import.php - 1012 lines - 42792 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  
   4  /**
   5  * @package dokeos.admin
   6  */
   7  
   8  // name of the language file that needs to be included
   9  $language_file = array ('registration','admin');
  10  
  11  // resetting the course id
  12  $cidReset = true;
  13  
  14  // setting the help
  15  $help_content = 'platformadministrationsessionimport';
  16  
  17  // including the global Dokeos file
  18  require_once  '../inc/global.inc.php';
  19  
  20  // including additional libraries
  21  require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  22  require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  23  require api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
  24  require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
  25  require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  26  require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  27  require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  28  
  29  // setting the section (for the tabs)
  30  $this_section = SECTION_PLATFORM_ADMIN;
  31  
  32  // Access restrictions
  33  api_protect_admin_script(true);
  34  
  35  // setting breadcrumbs
  36  $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
  37  
  38  // Database Table Definitions
  39  $tbl_user                    = Database::get_main_table(TABLE_MAIN_USER);
  40  $tbl_course                    = Database::get_main_table(TABLE_MAIN_COURSE);
  41  $tbl_course_user            = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  42  $tbl_session                = Database::get_main_table(TABLE_MAIN_SESSION);
  43  $tbl_session_user            = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  44  $tbl_session_course            = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  45  $tbl_session_course_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  46  
  47  // variable initialisation
  48  $form_sent = 0;
  49  $error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
  50  $tool_name = get_lang('ImportSessionListXMLCSV');
  51  
  52  set_time_limit(0);
  53  
  54  // Set this option to true to enforce strict purification for usenames.
  55  $purification_option_for_usernames = false;
  56  
  57  $inserted_in_course = array();
  58  
  59  if ($_POST['formSent']) {
  60      if (isset($_FILES['import_file']['tmp_name'])) {
  61          $form_sent = $_POST['formSent'];
  62          $file_type = $_POST['file_type'];
  63          $send_mail = $_POST['sendMail'] ? 1 : 0;
  64          //$updatesession = $_POST['updatesession'] ? 1 : 0;
  65          $updatesession = 0;
  66          $sessions = array();
  67  
  68          $session_counter = 0;
  69  
  70          if ($file_type == 'xml') {
  71  
  72              ///////////////////////
  73              //XML/////////////////
  74              /////////////////////
  75  
  76              // SimpleXML for PHP5 deals with various encodings, but how many they are, what are version issues, do we need to waste time with configuration options?
  77              // For avoiding complications we go some sort of "PHP4 way" - we convert the input xml-file into UTF-8 before passing it to the parser.
  78              // Instead of:
  79              // $root = @simplexml_load_file($_FILES['import_file']['tmp_name']);
  80              // we may use the following construct:
  81              // $root = @simplexml_load_string(api_utf8_encode_xml(file_get_contents($_FILES['import_file']['tmp_name'])));
  82              // To ease debugging let us use:
  83              $content = file_get_contents($_FILES['import_file']['tmp_name']);
  84              
  85              $content = api_utf8_encode_xml($content);
  86              $root = @simplexml_load_string($content);
  87              unset($content);
  88  
  89              if (is_object($root)) {
  90                  if (count($root->Users->User) > 0) {
  91  
  92                      // Creating/updating users from <Sessions> <Users> base node.
  93                      foreach ($root->Users->User as $node_user) {
  94                          $username = $username_old = trim(api_utf8_decode($node_user->Username));
  95                              $username = UserManager::purify_username($username, $purification_option_for_usernames);
  96                          if (UserManager::is_username_available($username)) {
  97                              if (UserManager::is_username_too_long($username_old)) {
  98                                  $error_message .= get_lang('UsernameTooLongWasCut').' '.get_lang('From').' '.$username_old.' '.get_lang('To').' '.$username.' <br />';
  99                              }
 100                              $lastname = trim(api_utf8_decode($node_user->Lastname));
 101                              $firstname = trim(api_utf8_decode($node_user->Firstname));
 102                              $password = api_utf8_decode($node_user->Password);
 103                              if (empty($password)) {
 104                                  $password = api_generate_password();
 105                              }
 106                              $email = trim(api_utf8_decode($node_user->Email));
 107                              $official_code = trim(api_utf8_decode($node_user->OfficialCode));
 108                              $phone = trim(api_utf8_decode($node_user->Phone));
 109                              $status = trim(api_utf8_decode($node_user->Status));
 110                              switch ($status) {
 111                                  case 'student' : $status = 5; break;
 112                                  case 'teacher' : $status = 1; break;
 113                                  default : $status = 5; $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
 114                              }
 115  
 116                              // Adding the current user to the platform.
 117                              $sql = "INSERT INTO $tbl_user SET
 118                                      username = '".Database::escape_string($username)."',
 119                                      lastname = '".Database::escape_string($lastname)."',
 120                                      firstname = '".Database::escape_string($firstname)."',
 121                                      password = '".(api_get_encrypted_password($password))."',
 122                                      email = '".Database::escape_string($email)."',
 123                                      official_code = '".Database::escape_string($official_code)."',
 124                                      phone = '".Database::escape_string($phone)."',
 125                                      status = '".Database::escape_string($status)."'";
 126  
 127                              // When it is applicable, adding the access_url rel user relationship too.
 128                              Database::query($sql, __FILE__, __LINE__);
 129                              $return = Database::insert_id();
 130                              global $_configuration;
 131                              require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
 132                              if ($_configuration['multiple_access_urls']) {
 133                                  if (api_get_current_access_url_id() != -1) {
 134                                      UrlManager::add_user_to_url($return, api_get_current_access_url_id());
 135                                  } else {
 136                                      UrlManager::add_user_to_url($return, 1);
 137                                  }
 138                              } else {
 139                                  // We add by default in the access_url_user table with access_url_id = 1.
 140                                  UrlManager::add_user_to_url($return, 1);
 141                              }
 142                              // Sending email to the current user.
 143                              if ($send_mail) {
 144                                  $recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
 145                                  $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
 146                                  $emailbody = "[NOTE:] ".get_lang('ThisIsAutomaticEmailNoReply').".\n\n".get_lang('langDear')." ".api_get_person_name($firstname, $lastname).",\n\n".get_lang('langYouAreReg')." ".api_get_setting('siteName') ." ".get_lang('langSettings')." $username\n". get_lang('langPass')." : $password\n\n".get_lang('langAddress') ." ". get_lang('langIs') ." ". $serverAddress ."\n\n".get_lang('YouWillSoonReceiveMailFromCoach')."\n\n". get_lang('langProblem'). "\n\n". get_lang('langFormula');
 147                                  $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 148                                  $email_admin = api_get_setting('emailAdministrator');
 149                                  @api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
 150                              }
 151                          } else {
 152                              $lastname = trim(api_utf8_decode($node_user->Lastname));
 153                              $firstname = trim(api_utf8_decode($node_user->Firstname));
 154                              $password = api_utf8_decode($node_user->Password);
 155                              $email = trim(api_utf8_decode($node_user->Email));
 156                              $official_code = trim(api_utf8_decode($node_user->OfficialCode));
 157                              $phone = trim(api_utf8_decode($node_user->Phone));
 158                              $status = trim(api_utf8_decode($node_user->Status));
 159                              switch ($status) {
 160                                  case 'student' : $status = 5; break;
 161                                  case 'teacher' : $status = 1; break;
 162                                  default : $status = 5; $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
 163                              }
 164  
 165                              $sql = "UPDATE $tbl_user SET
 166                                      lastname = '".Database::escape_string($lastname)."',
 167                                      firstname = '".Database::escape_string($firstname)."',
 168                                      ".(empty($password) ? "" : "password = '".(api_get_encrypted_password($password))."',")."
 169                                      email = '".Database::escape_string($email)."',
 170                                      official_code = '".Database::escape_string($official_code)."',
 171                                      phone = '".Database::escape_string($phone)."',
 172                                      status = '".Database::escape_string($status)."'
 173                                  WHERE username = '".Database::escape_string($username)."'";
 174  
 175                              Database::query($sql, __FILE__, __LINE__);
 176                          }
 177                      }
 178                  }
 179  
 180                  // Creating  courses from <Sessions> <Courses> base node.
 181                  if (count($root->Courses->Course) > 0) {
 182                      foreach ($root->Courses->Course as $courseNode) {
 183                          $course_code = trim(api_utf8_decode($courseNode->CourseCode));
 184                          $title = trim(api_utf8_decode($courseNode->CourseTitle));
 185                          $description = trim(api_utf8_decode($courseNode->CourseDescription));
 186                          $language = api_get_valid_language(api_utf8_decode($courseNode->CourseLanguage));
 187                          $username = trim(api_utf8_decode($courseNode->CourseTeacher));
 188  
 189                          // Looking up for the teacher.
 190                          $sql = "SELECT user_id, lastname, firstname FROM $tbl_user WHERE username='$username'";
 191                          $rs = Database::query($sql, __FILE__, __LINE__);
 192                          list($user_id, $lastname, $firstname) = Database::fetch_array($rs);
 193                          global $_configuration;
 194                          $keys = define_course_keys($course_code, '', $_configuration['db_prefix']);
 195  
 196                          if (sizeof($keys)) {
 197                              $current_course_code = $keys['visual_code'];
 198                              $current_course_id = $keys['currentCourseId'];
 199                              if (empty($current_course_code)) {
 200                                  $current_course_code = $current_course_id;
 201                              }
 202                              $current_course_db_name = $keys['currentCourseDbName'];
 203                              $current_course_repository = $keys['currentCourseRepository'];
 204  
 205                              // Course creation.
 206                              if ($current_course_id == api_strtoupper($course_code)) {
 207                                  if (empty ($title)) {
 208                                      $title = $keys['currentCourseCode'];
 209                                  }
 210  
 211                                  prepare_course_repository($current_course_repository, $current_course_id);
 212                                  update_Db_course($current_course_db_name);
 213                                  $pictures_array = fill_course_repository($current_course_repository);
 214  
 215                                  //fill_Db_course($current_course_db_name, $current_course_repository, 'english', $pictures_array);
 216                                  //register_course($current_course_id, $current_course_code, $current_course_repository, $current_course_db_name, "$lastname $firstname", $course['unit_code'], addslashes($course['FR']['title']), $language, $user_id);
 217                                  fill_Db_course($current_course_db_name, $current_course_repository, $language, $pictures_array);
 218                                  register_course($current_course_id, $current_course_code, $current_course_repository, $current_course_db_name, api_get_person_name($firstname, $lastname, null, null, $language), null, addslashes($title), $language, $user_id);
 219  
 220                                  $sql = "INSERT INTO ".$tbl_course." SET
 221                                          code = '".$current_course_id."',
 222                                          db_name = '".$current_course_db_name."',
 223                                          directory = '".$current_course_repository."',
 224                                          course_language = '".$language."',
 225                                          title = '".$title."',
 226                                          description = '".lang2db($description)."',
 227                                          category_code = '',
 228                                          visibility = '".$defaultVisibilityForANewCourse."',
 229                                          show_score = '',
 230                                          disk_quota = NULL,
 231                                          creation_date = now(),
 232                                          expiration_date = NULL,
 233                                          last_edit = now(),
 234                                          last_visit = NULL,
 235                                          tutor_name = '".api_get_person_name($firstname, $lastname, null, null, $language)."',
 236                                          visual_code = '".$current_course_code."'";
 237  
 238                                  Database::query($sql, __FILE__, __LINE__);
 239  
 240                                  $sql = "INSERT INTO ".$tbl_course_user." SET
 241                                          course_code = '".$current_course_id."',
 242                                          user_id = '".$user_id."',
 243                                          status = '1',
 244                                          role = '".lang2db('Professor')."',
 245                                          tutor_id='1',
 246                                          sort='". ($sort + 1)."',
 247                                          user_course_cat='0'";
 248  
 249                                  Database::query($sql, __FILE__, __LINE__);
 250                              }
 251                          }
 252                      }
 253                  }
 254  
 255                  // Creating sessions from <Sessions> base node.
 256                  if (count($root->Session) > 0) {
 257                      
 258                      foreach ($root->Session as $node_session) {
 259  
 260                          $course_counter = 0;
 261                          $user_counter = 0;
 262  
 263                          $session_name = trim(api_utf8_decode($node_session->SessionName));
 264                          $coach = UserManager::purify_username(api_utf8_decode($node_session->Coach), $purification_option_for_usernames);
 265  
 266                          if (!empty($coach)) {
 267                              $coach_id = UserManager::get_user_id_from_username($coach);
 268                              if ($coach_id === false) {
 269                                  $error_message .= get_lang('UserDoesNotExist').' : '.$coach.'<br />';
 270                                  // Forcing the coach id if user does not exist.
 271                                  $coach_id = api_get_user_id();
 272                              }
 273                          } else {
 274                              // Forcing the coach id.
 275                              $coach_id = api_get_user_id();
 276                          }
 277  
 278                          $date_start = trim(api_utf8_decode($node_session->DateStart)); // Just in case - encoding conversion.
 279  
 280                          if (!empty($date_start)) {
 281                              list($year_start, $month_start, $day_start) = explode('-', $date_start);
 282                              if(empty($year_start) || empty($month_start) || empty($day_start)) {
 283                                  $error_message .= get_lang('WrongDate').' : '.$date_start.'<br />';
 284                                  break;
 285                              } else {
 286                                  $time_start = mktime(0, 0, 0, $month_start, $day_start, $year_start);
 287                              }
 288  
 289                              $date_end = trim(api_utf8_decode($node_session->DateEnd));
 290                              if (!empty($date_start)) {
 291                                  list($year_end, $month_end, $day_end) = explode('-', $date_end);
 292                                  if (empty($year_end) || empty($month_end) || empty($day_end)) {
 293                                      $error_message .= get_lang('WrongDate').' : '.$date_end.'<br />';
 294                                      break;
 295                                  } else {
 296                                      $time_end = mktime(0, 0, 0, $month_end, $day_end, $year_end);
 297                                  }
 298                              }
 299                              if ($time_end - $time_start < 0) {
 300                                  $error_message .= get_lang('StartDateShouldBeBeforeEndDate').' : '.$date_end.'<br />';
 301                              }
 302                          }
 303  
 304                          $visibility = trim(api_utf8_decode($node_session->Visibility));
 305                          $session_category_id = trim(api_utf8_decode($node_session->SessionCategory));
 306  
 307                          if (!$updatesession) {
 308                              // Always create a session.
 309                              $unique_name = false; // This MUST be initializead.
 310                              $i = 0;
 311                              // Change session name, verify that session doesn't exist.
 312                              while (!$unique_name) {
 313                                  if ($i > 1) {
 314                                      $suffix = ' - '.$i;
 315                                  }
 316                                  $sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name.$suffix).'"';
 317                                  $rs = Database::query($sql, __FILE__, __LINE__);
 318                                  if (Database::result($rs, 0, 0)) {
 319                                      $i++;
 320                                  } else {
 321                                      $unique_name = true;
 322                                      $session_name .= $suffix;
 323                                  }
 324                              }
 325                              // Creating the session.
 326                              $sql_session = "INSERT IGNORE INTO $tbl_session SET
 327                                      name = '".Database::escape_string($session_name)."',
 328                                      id_coach = '$coach_id',
 329                                      date_start = '$date_start',
 330                                      date_end = '$date_end',
 331                                      visibility = '$visibility',
 332                                      session_category_id = '$session_category_id',        
 333                                      session_admin_id=".intval($_user['user_id']);
 334                              $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 335                              $session_id = Database::insert_id();
 336                              $session_counter++;
 337  
 338                          } else {
 339                              // Update the session if it is needed.
 340                              $my_session_result = SessionManager::get_session_by_name($session_name);
 341                              if ($my_session_result === false) {
 342                                  // Creating the session.
 343                                  $sql_session = "INSERT IGNORE INTO $tbl_session SET
 344                                          name = '".Database::escape_string($session_name)."',
 345                                          id_coach = '$coach_id',
 346                                          date_start = '$date_start',
 347                                          date_end = '$date_end',
 348                                          visibility = '$visibility',
 349                                          session_category_id = '$session_category_id',        
 350                                          session_admin_id=".intval($_user['user_id']);
 351                                  $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 352                                  $session_id = Database::insert_id();
 353                                  $session_counter++;
 354                              } else {
 355                                  // if the session already exists - update it.
 356                                  $sql_session = "UPDATE $tbl_session SET
 357                                          id_coach = '$coach_id',
 358                                          date_start = '$date_start',
 359                                          date_end = '$date_end',
 360                                          visibility = '$visibility',
 361                                          session_category_id = '$session_category_id'        
 362                                      WHERE name = '$session_name'";
 363                                  $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 364                                  $session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
 365                                  list($session_id) = Database::fetch_array($session_id);
 366                                  Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'", __FILE__, __LINE__);
 367                                  Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'", __FILE__, __LINE__);
 368                                  Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'", __FILE__, __LINE__);
 369                              }
 370                          }
 371  
 372                          // Associate the session with access_url.
 373                          global $_configuration;
 374                          require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
 375                          if ($_configuration['multiple_access_urls']) {
 376                              $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 377                              $access_url_id = api_get_current_access_url_id();
 378                              UrlManager::add_session_to_url($session_id, $access_url_id);
 379                          } else {
 380                              // We fill by default the access_url_rel_session table.
 381                              UrlManager::add_session_to_url($session_id, 1);
 382                          }
 383  
 384  
 385                          // Adding users to the new session.
 386                          foreach ($node_session->User as $node_user) {
 387                              $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
 388                              $user_id = UserManager::get_user_id_from_username($username);
 389                              if ($user_id !== false) {
 390                                  $sql = "INSERT IGNORE INTO $tbl_session_user SET
 391                                          id_user='$user_id',
 392                                          id_session = '$session_id'";
 393                                  $rs_user = Database::query($sql, __FILE__, __LINE__);
 394                                  $user_counter++;
 395                              }
 396                          }
 397  
 398  
 399                          // Adding courses to a session.
 400                          
 401                          
 402                          
 403                          foreach ($node_session->Course as $node_course) {
 404                              $course_code = Database::escape_string(trim(api_utf8_decode($node_course->CourseCode)));
 405                              // Verify that the course pointed by the course code node exists.
 406                              if (CourseManager::course_exists($course_code)) {
 407                                  // If the course exists we continue.
 408                                  $course_info = CourseManager::get_course_information($course_code);
 409                              
 410                                  $session_course_relation = SessionManager::relation_session_course_exist($session_id, $course_code);
 411                                  if (!$session_course_relation) {
 412                                      $sql_course = "INSERT INTO $tbl_session_course SET
 413                                              course_code = '$course_code',                                            
 414                                              id_session='$session_id'";
 415                                      $rs_course = Database::query($sql_course, __FILE__, __LINE__);
 416                                  }
 417                                  
 418                                  $course_coachs = explode(",",$node_course->Coach);
 419                                                                  
 420                                  // adding coachs to session course user                            
 421                                  foreach ($course_coachs as $course_coach) {
 422                                      $coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
 423                                      $coach_id = UserManager::get_user_id_from_username($course_coach);
 424                                      if ($coach_id !== false) {
 425                                          $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 426                                                  id_user='$coach_id',
 427                                                  course_code='$course_code',
 428                                                  id_session = '$session_id',
 429                                                  status = 2 ";
 430                                          $rs_coachs = Database::query($sql, __FILE__, __LINE__);
 431                                      } else {
 432                                          $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 433                                      }
 434                                  }
 435                                  
 436                                  // adding users
 437                                  $course_counter++;
 438                                  $users_in_course_counter = 0;                                    
 439                                  foreach ($node_course->User as $node_user) {
 440                                      $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
 441                                      $user_id = UserManager::get_user_id_from_username($username);
 442                                      if ($user_id !== false) {
 443                                          // Adding to session_rel_user table.
 444                                          $sql = "INSERT IGNORE INTO $tbl_session_user SET
 445                                                  id_user='$user_id',
 446                                                  id_session = '$session_id'";
 447                                          $rs_user = Database::query($sql, __FILE__, __LINE__);
 448                                          $user_counter++;
 449                                          // Adding to session_rel_user_rel_course table.
 450                                          $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 451                                                  id_user='$user_id',
 452                                                  course_code='$course_code',
 453                                                  id_session = '$session_id'";
 454                                          $rs_users = Database::query($sql, __FILE__, __LINE__);
 455                                          $users_in_course_counter++;
 456                                      } else {
 457                                          $error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
 458                                      }
 459                                  }
 460                                  $update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
 461                                  Database::query($update_session_course, __FILE__, __LINE__);
 462                                  $inserted_in_course[$course_code] = $course_info['title'];
 463  
 464                              }
 465  
 466                              if (CourseManager::course_exists($course_code, true)) {
 467                                  // If the course exists we continue.
 468                                  // Also subscribe to virtual courses through check on visual code.
 469                                  $list = CourseManager :: get_courses_info_from_visual_code($course_code);
 470                                  foreach ($list as $vcourse) {
 471                                      if ($vcourse['code'] == $course_code) {
 472                                          // Ignore, this has already been inserted.
 473                                      } else {
 474                                          
 475                                          $sql_course = "INSERT INTO $tbl_session_course SET
 476                                                  course_code = '".$vcourse['code']."',
 477                                                  id_session='$session_id'";
 478                                          $rs_course = Database::query($sql_course, __FILE__, __LINE__);
 479                                          
 480                                          $course_coachs = explode(",",$node_course->Coach);
 481                                                                  
 482                                          // adding coachs to session course user                            
 483                                          foreach ($course_coachs as $course_coach) {
 484                                              $coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
 485                                              $coach_id = UserManager::get_user_id_from_username($course_coach);
 486                                              if ($coach_id !== false) {
 487                                                  $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 488                                                          id_user='$coach_id',
 489                                                          course_code='{$vcourse['code']}',
 490                                                          id_session = '$session_id',
 491                                                          status = 2 ";
 492                                                  $rs_coachs = Database::query($sql, __FILE__, __LINE__);
 493                                              } else {
 494                                                  $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 495                                              }
 496                                          }
 497                                  
 498                                          // adding users
 499                                          $course_counter++;
 500                                          $users_in_course_counter = 0;                                    
 501                                          foreach ($node_course->User as $node_user) {
 502                                              $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
 503                                              $user_id = UserManager::get_user_id_from_username($username);
 504                                              if ($user_id !== false) {
 505                                                  // Adding to session_rel_user table.
 506                                                  $sql = "INSERT IGNORE INTO $tbl_session_user SET
 507                                                          id_user='$user_id',
 508                                                          id_session = '$session_id'";
 509                                                  $rs_user = Database::query($sql, __FILE__, __LINE__);
 510                                                  $user_counter++;
 511                                                  // Adding to session_rel_user_rel_course table.
 512                                                  $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 513                                                          id_user='$user_id',
 514                                                          course_code='{$vcourse['code']}',
 515                                                          id_session = '$session_id'";
 516                                                  $rs_users = Database::query($sql, __FILE__, __LINE__);
 517                                                  $users_in_course_counter++;
 518                                              } else {
 519                                                  $error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
 520                                              }
 521                                          }
 522                                          $update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
 523                                          Database::query($update_session_course, __FILE__, __LINE__);
 524                                          $inserted_in_course[$course_code] = $course_info['title'];
 525  
 526                                      }
 527                                      $inserted_in_course[$vcourse['code']] = $vcourse['title'];
 528                                  }
 529  
 530                              } else {
 531                                  // Tthe course does not exist.
 532                                  $error_message .= get_lang('CourseDoesNotExist').' : '.$course_code.'<br />';
 533                              }
 534                          }
 535                          Database::query("UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'", __FILE__, __LINE__);
 536                      }
 537  
 538                  }
 539                  if (empty($root->Users->User) && empty($root->Courses->Course) && empty($root->Session)) {
 540                      $error_message = get_lang('NoNeededData');
 541                  }
 542              } else {
 543                  $error_message .= get_lang('XMLNotValid');
 544              }
 545          } else {
 546  
 547              /////////////////////
 548              // CSV /////////////
 549              ///////////////////
 550  
 551              $content = file($_FILES['import_file']['tmp_name']);
 552  
 553              if (!api_strstr($content[0], ';')) {
 554                  $error_message = get_lang('NotCSV');
 555              } else {
 556                  $tag_names = array();
 557  
 558                  foreach ($content as $key => $enreg) {
 559                      $enreg = explode(';', trim($enreg));
 560                      if ($key) {
 561                          foreach ($tag_names as $tag_key => $tag_name) {
 562                              $sessions[$key - 1][$tag_name] = $enreg[$tag_key];
 563                          }
 564                      } else {
 565                          foreach ($enreg as $tag_name) {
 566                              $tag_names[] = api_eregi_replace('[^a-z0-9_-]', '', $tag_name);
 567                          }
 568                          if (!in_array('SessionName', $tag_names) || !in_array('DateStart', $tag_names) || !in_array('DateEnd', $tag_names)) {
 569                              $error_message = get_lang('NoNeededData');
 570                              break;
 571                          }
 572                      }
 573                  }
 574                  
 575                  // looping the sessions
 576                  foreach ($sessions as $enreg) {
 577                      $user_counter = 0;
 578                      $course_counter = 0;
 579  
 580                      $session_name = $enreg['SessionName'];
 581                      $date_start = $enreg['DateStart'];
 582                      $date_end = $enreg['DateEnd'];
 583                      $visibility = $enreg['Visibility'];
 584                      $session_category_id = $enreg['SessionCategory'];
 585  
 586                      // searching a coach
 587                      if (!empty($enreg['Coach'])) {
 588                          $coach_id = UserManager::get_user_id_from_username($enreg['Coach']);
 589                          if ($coach_id === false) {
 590                              // If the coach-user does not exist - I'm the coach.
 591                              $coach_id = api_get_user_id();
 592                          }
 593                      } else {
 594                          $coach_id = api_get_user_id();
 595                      }
 596  
 597                      if (!$updatesession) {
 598                          // Always create a session.
 599                          $unique_name = false; // This MUST be initializead.
 600                          $i = 0;
 601                          // Change session name, verify that session doesn't exist
 602                          while (!$unique_name) {
 603                              if ($i > 1) {
 604                                  $suffix = ' - '.$i;
 605                              }
 606                              $sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name.$suffix).'"';
 607                              $rs = Database::query($sql, __FILE__, __LINE__);
 608  
 609                              if (Database::result($rs, 0, 0)) {
 610                                  $i++;
 611                              } else {
 612                                  $unique_name = true;
 613                                  $session_name .= $suffix;
 614                              }
 615                          }
 616  
 617                          // Creating the session.
 618                          $sql_session = "INSERT IGNORE INTO $tbl_session SET
 619                                  name = '".Database::escape_string($session_name)."',
 620                                  id_coach = '$coach_id',
 621                                  date_start = '$date_start',
 622                                  date_end = '$date_end',
 623                                  visibility = '$visibility',
 624                                  session_category_id = '$session_category_id',                
 625                                  session_admin_id=".intval($_user['user_id']);
 626                          $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 627                          $session_id = Database::insert_id();
 628                          $session_counter++;
 629                      } else {
 630                          $my_session_result = SessionManager::get_session_by_name($session_name);
 631                          if ($my_session_result === false) {
 632  
 633                              // Creating a session.
 634                              $sql_session = "INSERT IGNORE INTO $tbl_session SET
 635                                      name = '$session_name',
 636                                      id_coach = '$coach_id',
 637                                      date_start = '$date_start',
 638                                      date_end = '$date_end',
 639                                      visibility = '$visibility',
 640                                      session_category_id = '$session_category_id'";
 641                                  
 642                              $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 643                              // We get the last insert id.
 644                              $my_session_result = SessionManager::get_session_by_name($session_name);
 645                              $session_id = $my_session_result['id'];
 646                              //echo '<br>';
 647                          } else {
 648                              // The session already exists, update it then.
 649                              $sql_session = "UPDATE $tbl_session SET
 650                                      id_coach = '$coach_id',
 651                                      date_start = '$date_start',
 652                                      date_end = '$date_end',
 653                                      visibility = '$visibility',
 654                                      session_category_id = '$session_category_id'        
 655                                  WHERE name = '$session_name'";
 656                              $rs_session = Database::query($sql_session, __FILE__, __LINE__);
 657                              $session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
 658                              list($session_id) = Database::fetch_array($session_id);
 659                              Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'", __FILE__, __LINE__);
 660                              Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'", __FILE__, __LINE__);
 661                              Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'", __FILE__, __LINE__);
 662                          }
 663                          $session_counter++;
 664                      }
 665  
 666                      $users = explode('|', $enreg['Users']);
 667  
 668                      // Adding the relationship "Session - User".
 669                      if (is_array($users)) {
 670                          foreach ($users as $user) {
 671                              $user_id = UserManager::get_user_id_from_username($user);
 672                              if ($user_id !== false) {
 673                                  // Insert new users.
 674                                  $sql = "INSERT IGNORE INTO $tbl_session_user SET
 675                                          id_user='$user_id',
 676                                          id_session = '$session_id'";
 677                                  $rs_user = Database::query($sql, __FILE__, __LINE__);
 678                                  $user_counter++;
 679                              }
 680                          }
 681                      }
 682  
 683                      $courses = explode('|', $enreg['Courses']);
 684  
 685                      foreach ($courses as $course) {
 686                          $course_code = api_strtoupper(api_substr($course, 0, api_strpos($course, '[')));
 687  
 688                          if (CourseManager::course_exists($course_code)) {
 689  
 690                              // If the course exists we continue
 691                              $course_info = CourseManager::get_course_information($course_code);
 692  
 693                              $coach = api_strstr($course, '[');
 694                              $coach = api_substr($coach, 1, api_strpos($coach,']') - 1);
 695  
 696                              if (!empty($coach)) {
 697                                  $coach_id = UserManager::get_user_id_from_username($coach);
 698                                  if ($coach_id === false) {
 699                                      $coach_id = '';
 700                                  }
 701                              } else {
 702                                  $coach = '';
 703                              }
 704                              // Adding the course to a session
 705                              $sql_course = "INSERT IGNORE INTO $tbl_session_course SET
 706                                      course_code = '$course_code',                                    
 707                                      id_session='$session_id'";
 708                              $rs_course = Database::query($sql_course, __FILE__, __LINE__);
 709                              $course_counter++;
 710  
 711                              $course_split = array();                            
 712                              $tok = strtok($course, "[]");                            
 713                              while ($tok !== false) {
 714                                  $course_split[] = $tok;
 715                                  $tok = strtok("[]");
 716                              }
 717                              
 718                              $course_coachs = explode(",",$course_split[1]);
 719                              $course_users = explode(",",$course_split[2]);
 720                              
 721                              // adding coachs to session course user                            
 722                              foreach ($course_coachs as $course_coach) {
 723                                  $coach_id = UserManager::get_user_id_from_username($course_coach);
 724                                  if ($coach_id !== false) {
 725                                      $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 726                                              id_user='$coach_id',
 727                                              course_code='$course_code',
 728                                              id_session = '$session_id',
 729                                              status = 2 ";
 730                                      $rs_coachs = Database::query($sql, __FILE__, __LINE__);
 731                                  } else {
 732                                      $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 733                                  }
 734                              }
 735                                                          
 736                              $users_in_course_counter = 0;
 737                              // Adding the relationship "Session - Course - User".
 738                              foreach ($course_users as $user) {
 739                                  $user_id = UserManager::get_user_id_from_username($user);
 740                                  if ($user_id !== false) {
 741                                      $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 742                                              id_user='$user_id',
 743                                              course_code='$course_code',
 744                                              id_session = '$session_id'";
 745                                      $rs_users = Database::query($sql, __FILE__, __LINE__);
 746                                      $users_in_course_counter++;
 747                                  } else {
 748                                      $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 749                                  }
 750                              }
 751                              $sql = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
 752                              Database::query($sql,__FILE__,__LINE__);
 753  
 754                              $course_info = CourseManager::get_course_information($course_code);
 755                              $inserted_in_course[$course_code] = $course_info['title'];
 756                          } else {
 757                              // TODO: We should create the course as in the XML import.
 758                          }
 759  
 760                          if (CourseManager::course_exists($course_code, true)) {
 761  
 762                              $list = CourseManager :: get_courses_info_from_visual_code($course_code);
 763                              
 764                              foreach ($list as $vcourse) {
 765                                  if ($vcourse['code'] == $course_code) {                                    
 766                                      // Ignore, this has already been inserted.
 767                                  } else {
 768                                      
 769                                      $coach = api_strstr($course, '[');
 770                                      $coach = api_substr($coach, 1, api_strpos($coach,']') - 1);
 771                                                                          
 772                                      // Adding the relationship "Session - Course".
 773                                      $sql_course = "INSERT IGNORE INTO $tbl_session_course SET
 774                                                      course_code = '".$vcourse['code']."',
 775                                                      id_session='$session_id'";
 776                                      
 777                                      $rs_course = Database::query($sql_course, __FILE__, __LINE__);
 778                                      
 779                                      // adding coachs to session course user                            
 780                                      foreach ($course_coachs as $course_coach) {
 781                                          $coach_id = UserManager::get_user_id_from_username($course_coach);
 782                                          if ($coach_id !== false) {
 783                                              $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 784                                                      id_user='$coach_id',
 785                                                      course_code='{$vcourse['code']}',
 786                                                      id_session = '$session_id',
 787                                                      status = 2 ";
 788                                              $rs_coachs = Database::query($sql, __FILE__, __LINE__);
 789                                          } else {
 790                                              $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 791                                          }
 792                                      }
 793                                                                  
 794                                      $users_in_course_counter = 0;
 795                                      // Adding the relationship "Session - Course - User".
 796                                      foreach ($course_users as $user) {
 797                                          $user_id = UserManager::get_user_id_from_username($user);
 798                                          if ($user_id !== false) {
 799                                              $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
 800                                                      id_user='$user_id',
 801                                                      course_code='{$vcourse['code']}',
 802                                                      id_session = '$session_id'";
 803                                              $rs_users = Database::query($sql, __FILE__, __LINE__);
 804                                              $users_in_course_counter++;
 805                                          } else {
 806                                              $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
 807                                          }
 808                                      }
 809                                      Database::query("UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='".$vcourse['code']."'", __FILE__, __LINE__);    
 810                                  }
 811                              }
 812                              $inserted_in_course[$vcourse['code']] = $vcourse['title'];
 813                          }
 814                      }
 815                                                  
 816                      $sql_update_users = "UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'";
 817                      Database::query($sql_update_users, __FILE__, __LINE__);
 818                  }
 819              }
 820          }
 821          if (!empty($error_message)) {
 822              $error_message = get_lang('ButProblemsOccured').' :<br />'.$error_message;
 823          }
 824  
 825          if (count($inserted_in_course) > 1) {
 826              $warn = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode').': ';
 827              foreach ($inserted_in_course as $code => $title) {
 828                  $warn .= ' '.$title.' ('.$code.'),';
 829              }
 830              $warn = substr($warn, 0, -1);
 831          }
 832          if ($session_counter == 1) {
 833              header('Location: resume_session.php?id_session='.$session_id.'&warn='.urlencode($warn));
 834              exit;
 835          } else {
 836              header('Location: session_list.php?action=show_message&message='.urlencode(get_lang('FileImported').' '.$error_message).'&warn='.urlencode($warn));
 837              exit;
 838          }
 839      } else {
 840          $error_message = get_lang('NoInputFile');
 841      }
 842  }
 843  
 844  // display the header
 845  Display::display_header($tool_name);
 846  
 847  echo '<div class="actions">';
 848  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/catalogue_management.php">' . Display::return_icon('pixel.gif',get_lang('Catalogue'), array('class' => 'toolactionplaceholdericon toolactioncatalogue')) . get_lang('Catalogue') . '</a>';
 849  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/topic_list.php">' . Display :: return_icon('pixel.gif', get_lang('Topics'),array('class' => 'toolactionplaceholdericon toolactiontopic')) . get_lang('Topics') . '</a>';
 850  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/programme_list.php">' . Display :: return_icon('pixel.gif', get_lang('Programmes'),array('class' => 'toolactionplaceholdericon toolactionprogramme')) . get_lang('Programmes') . '</a>';
 851  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display :: return_icon('pixel.gif', get_lang('AddSession'),array('class' => 'toolactionplaceholdericon toolactionadd')).get_lang('AddSession').'</a>';
 852  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_list.php">' . Display :: return_icon('pixel.gif', get_lang('SessionList'),array('class' => 'toolactionplaceholdericon toolactionsession')) . get_lang('SessionList') . '</a>';        
 853  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_export.php">'.Display::return_icon('pixel.gif',get_lang('ExportSessionListXMLCSV'),array('class' => 'toolactionplaceholdericon toolactionexportcourse')).get_lang('ExportSessionListXMLCSV').'</a>';
 854  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_import.php">'.Display::return_icon('pixel.gif',get_lang('ImportSessionListXMLCSV'),array('class' => 'toolactionplaceholdericon toolactionimportcourse')).get_lang('ImportSessionListXMLCSV').'</a>';            
 855  echo '<a href="'.api_get_path(WEB_CODE_PATH).'coursecopy/copy_course_session.php">'.Display::return_icon('pixel.gif',get_lang('CopyFromCourseInSessionToAnotherSession'),array('class' => 'toolactionplaceholdericon toolsettings')).get_lang('CopyFromCourseInSessionToAnotherSession').'</a>';    
 856  echo '</div>';
 857  
 858  // start the content div
 859  echo '<div id="content">';
 860  
 861  // display the tool title
 862  // api_display_tool_title($tool_name);
 863  
 864  if (count($inserted_in_course) > 1) {
 865      $msg = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode').': ';
 866      foreach ($inserted_in_course as $code => $title) {
 867          $msg .= ' '.$title.' ('.$title.'),';
 868      }
 869      $msg = substr($msg, 0, -1);
 870      Display::display_warning_message($msg);
 871  }
 872  
 873  /*
 874  
 875   update session by default is true
 876   <tr>
 877    <td nowrap="nowrap" valign="top"><?php echo get_lang('UpdateSession'); ?> :</td>
 878    <td>
 879      <input class="checkbox" type="checkbox" name="updatesession" id="updatesession" value="true" />
 880    </td>
 881  </tr>
 882  
 883  
 884    */
 885  ?>
 886  
 887  <form method="post" action="<?php echo api_get_self(); ?>" enctype="multipart/form-data" style="margin: 0px;">
 888  <input type="hidden" name="formSent" value="1">
 889  <div class="row"><div class="form_header"><?php echo $tool_name; ?></div></div>
 890  <table border="0" cellpadding="5" cellspacing="0">
 891  
 892  <?php
 893  if (!empty($error_message)) {
 894  ?>
 895  <tr>
 896    <td colspan="2">
 897  <?php
 898      Display::display_normal_message($error_message, false);
 899  ?>
 900    </td>
 901  </tr>
 902  <?php
 903  }
 904  ?>
 905  <tr>
 906    <td nowrap="nowrap"><?php echo get_lang('ImportFileLocation'); ?> :</td>
 907    <td><input type="file" name="import_file" size="30"></td>
 908  </tr>
 909  <tr>
 910    <td nowrap="nowrap" valign="top"><?php echo get_lang('FileType'); ?> :</td>
 911    <td>
 912      <input class="checkbox" type="radio" name="file_type" id="file_type_xml" value="xml" checked="checked" /> <label for="file_type_xml">XML</label> (<a href="example_session.xml" target="_blank"><?php echo get_lang('ExampleXMLFile'); ?></a>)<br>
 913      <input class="checkbox" type="radio" name="file_type" id="file_type_csv"  value="csv" <?php if ($form_sent && $file_type == 'csv') echo 'checked="checked"'; ?>> <label for="file_type_csv">CSV</label> (<a href="example_session.csv" target="_blank"><?php echo get_lang('ExampleCSVFile'); ?></a>)<br>
 914    </td>
 915  </tr>
 916  <tr>
 917    <td nowrap="nowrap" valign="top"><?php echo get_lang('SendMailToUsers'); ?> :</td>
 918    <td>
 919      <input class="checkbox" type="checkbox" name="sendMail" id="sendMail" value="true" />
 920    </td>
 921  </tr>
 922  
 923  
 924  
 925  
 926  <tr>
 927    <td>&nbsp;</td>
 928    <td>
 929    <button class="save" type="submit" name="name" value="<?php echo get_lang('ImportSession'); ?>"><?php echo get_lang('ImportSession'); ?></button>
 930    </td>
 931  </tr>
 932  </table>
 933  </form>
 934  
 935  <font color="gray">
 936  <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
 937  
 938  <blockquote>
 939  <pre>
 940  <b>SessionName</b>;Coach;<b>DateStart</b>;<b>DateEnd</b>;Users;Courses
 941  <b>xxx1</b>;xxx;<b>xxx;xxx</b>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
 942  <b>xxx2</b>;xxx;<b>xxx;xxx</b>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
 943  </pre>
 944  </blockquote>
 945  
 946  <p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
 947  
 948  <blockquote>
 949  <pre>
 950  &lt;?xml version=&quot;1.0&quot; encoding=&quot;<?php echo api_refine_encoding_id(api_get_system_encoding()); ?>&quot;?&gt;
 951  &lt;Sessions&gt;
 952      &lt;Users&gt;
 953          &lt;User&gt;
 954              &lt;Username&gt;<b>username1</b>&lt;/Username&gt;
 955              &lt;Lastname&gt;xxx&lt;/Lastname&gt;
 956              &lt;Firstname&gt;xxx&lt;/Firstname&gt;
 957              &lt;Password&gt;xxx&lt;/Password&gt;
 958              &lt;Email&gt;xxx@xx.xx&lt;/Email&gt;
 959              &lt;OfficialCode&gt;xxx&lt;/OfficialCode&gt;
 960              &lt;Phone&gt;xxx&lt;/Phone&gt;
 961              &lt;Status&gt;student|teacher&lt;/Status&gt;
 962          &lt;/User&gt;
 963      &lt;/Users&gt;
 964      &lt;Courses&gt;
 965          &lt;Course&gt;
 966              &lt;CourseCode&gt;<b>xxx</b>&lt;/CourseCode&gt;
 967              &lt;CourseTeacher&gt;xxx&lt;/CourseTeacher&gt;
 968              &lt;CourseLanguage&gt;xxx&lt;/CourseLanguage&gt;
 969              &lt;CourseTitle&gt;xxx&lt;/CourseTitle&gt;
 970              &lt;CourseDescription&gt;xxx&lt;/CourseDescription&gt;
 971          &lt;/Course&gt;
 972      &lt;/Courses&gt;
 973      &lt;Session&gt;
 974          <b>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</b>
 975          &lt;Coach&gt;xxx&lt;/Coach&gt;
 976          <b>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</b>
 977          <b>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</b>
 978          &lt;User&gt;xxx&lt;/User&gt;
 979          &lt;User&gt;xxx&lt;/User&gt;
 980          &lt;Course&gt;
 981              &lt;CourseCode&gt;coursecode1&lt;/CourseCode&gt;
 982              &lt;Coach&gt;coach1&lt;/Coach&gt;
 983          &lt;User&gt;username1&lt;/User&gt;
 984          &lt;User&gt;username2&lt;/User&gt;
 985          &lt;/Course&gt;
 986      &lt;/Session&gt;
 987  
 988      &lt;Session&gt;
 989          <b>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</b>
 990          &lt;Coach&gt;xxx&lt;/Coach&gt;
 991          <b>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</b>
 992          <b>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</b>
 993          &lt;User&gt;xxx&lt;/User&gt;
 994          &lt;User&gt;xxx&lt;/User&gt;
 995          &lt;Course&gt;
 996              &lt;CourseCode&gt;coursecode1&lt;/CourseCode&gt;
 997              &lt;Coach&gt;coach1&lt;/Coach&gt;
 998          &lt;User&gt;username1&lt;/User&gt;
 999          &lt;User&gt;username2&lt;/User&gt;
1000          &lt;/Course&gt;
1001      &lt;/Session&gt;
1002  &lt;/Sessions&gt;
1003  </pre>
1004  </blockquote>
1005  </font>
1006  <?php
1007  // close the content div
1008  echo '</div>';
1009  
1010  // display the footer
1011  Display::display_footer();
1012  ?>

title

Description

title

Description

title

Description

title

title

Body