'index.php', "name" => get_lang('PlatformAdmin')); Display :: display_header($tool_name); //api_display_tool_title($tool_name); /* ============================================================================== MAIN CODE ============================================================================== */ /* ----------------------------------------------------------- React on POSTed request ----------------------------------------------------------- */ if ($_POST['formSent']) { $form_sent = $_POST['formSent']; $users = is_array($_POST['UserList']) ? $_POST['UserList'] : array() ; $courses = is_array($_POST['CourseList']) ? $_POST['CourseList'] : array() ; $first_letter_user = $_POST['firstLetterUser']; $first_letter_course = $_POST['firstLetterCourse']; foreach($users as $key => $value) { $users[$key] = intval($value); } if ($form_sent == 1) { if ( count($users) == 0 || count($courses) == 0) { Display :: display_error_message(get_lang('AtLeastOneUserAndOneCourse')); } else { foreach ($courses as $course_code) { foreach ($users as $user_id) { CourseManager::subscribe_user($user_id,$course_code); } } Display :: display_normal_message(get_lang('UsersAreSubscibedToCourse')); } } } /* ----------------------------------------------------------- Display GUI ----------------------------------------------------------- */ if(empty($first_letter_user)) { $sql = "SELECT count(*) as nb_users FROM $tbl_user"; $result = api_sql_query($sql, __FILE__, __LINE__); $num_row = Database::fetch_array($result); if($num_row['nb_users']>1000) {//if there are too much users to gracefully handle with the HTML select list, // assign a default filter on users names $first_letter_user = 'A'; } unset($result); } $sql = "SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE lastname LIKE '".$first_letter_user."%' ORDER BY ". (count($users) > 0 ? "(user_id IN(".implode(',', $users).")) DESC," : "")." lastname"; $result = api_sql_query($sql, __FILE__, __LINE__); $db_users = api_store_result($result); unset($result); $sql = "SELECT code,visual_code,title FROM $tbl_course WHERE visual_code LIKE '".$first_letter_course."%' ORDER BY ". (count($courses) > 0 ? "(code IN('".implode("','", $courses)."')) DESC," : "")." visual_code"; $result = api_sql_query($sql, __FILE__, __LINE__); $db_courses = api_store_result($result); unset($result); ?>