@@ 5145-5168 (lines=24) @@ | ||
5142 | * @param string $lastname Lastname to search |
|
5143 | * @return array The user list |
|
5144 | */ |
|
5145 | public static function getUserByName($firstname, $lastname) |
|
5146 | { |
|
5147 | $firstname = Database::escape_string($firstname); |
|
5148 | $lastname = Database::escape_string($lastname); |
|
5149 | ||
5150 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
5151 | ||
5152 | $sql = <<<SQL |
|
5153 | SELECT id, username, lastname, firstname |
|
5154 | FROM $userTable |
|
5155 | WHERE firstname LIKE '$firstname%' AND |
|
5156 | lastname LIKE '$lastname%' |
|
5157 | SQL; |
|
5158 | ||
5159 | $result = Database::query($sql); |
|
5160 | ||
5161 | $users = []; |
|
5162 | ||
5163 | while ($resultData = Database::fetch_object($result)) { |
|
5164 | $users[] = $resultData; |
|
5165 | } |
|
5166 | ||
5167 | return $users; |
|
5168 | } |
|
5169 | ||
5170 | /** |
|
5171 | * @param int $optionSelected |
@@ 3315-3337 (lines=23) @@ | ||
3312 | * @param int Session id |
|
3313 | * @return array Courses list |
|
3314 | */ |
|
3315 | public static function get_courses_list_from_session($session_id) |
|
3316 | { |
|
3317 | $session_id = intval($session_id); |
|
3318 | ||
3319 | // table definition |
|
3320 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
3321 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
3322 | ||
3323 | $sql = "SELECT DISTINCT code, c_id |
|
3324 | FROM $tbl_session_course sc |
|
3325 | INNER JOIN $courseTable c |
|
3326 | ON sc.c_id = c.id |
|
3327 | WHERE session_id= $session_id"; |
|
3328 | ||
3329 | $result = Database::query($sql); |
|
3330 | ||
3331 | $courses = array(); |
|
3332 | while ($row = Database::fetch_array($result)) { |
|
3333 | $courses[$row['code']] = $row; |
|
3334 | } |
|
3335 | ||
3336 | return $courses; |
|
3337 | } |
|
3338 | ||
3339 | /** |
|
3340 | * Count the number of documents that an user has uploaded to a course |