@@ 5162-5185 (lines=24) @@ | ||
5159 | * @param string $lastname Lastname to search |
|
5160 | * @return array The user list |
|
5161 | */ |
|
5162 | public static function getUserByName($firstname, $lastname) |
|
5163 | { |
|
5164 | $firstname = Database::escape_string($firstname); |
|
5165 | $lastname = Database::escape_string($lastname); |
|
5166 | ||
5167 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
5168 | ||
5169 | $sql = <<<SQL |
|
5170 | SELECT id, username, lastname, firstname |
|
5171 | FROM $userTable |
|
5172 | WHERE firstname LIKE '$firstname%' AND |
|
5173 | lastname LIKE '$lastname%' |
|
5174 | SQL; |
|
5175 | ||
5176 | $result = Database::query($sql); |
|
5177 | ||
5178 | $users = []; |
|
5179 | ||
5180 | while ($resultData = Database::fetch_object($result)) { |
|
5181 | $users[] = $resultData; |
|
5182 | } |
|
5183 | ||
5184 | return $users; |
|
5185 | } |
|
5186 | ||
5187 | /** |
|
5188 | * @param int $optionSelected |
@@ 3325-3347 (lines=23) @@ | ||
3322 | * @param int Session id |
|
3323 | * @return array Courses list |
|
3324 | */ |
|
3325 | public static function get_courses_list_from_session($session_id) |
|
3326 | { |
|
3327 | $session_id = intval($session_id); |
|
3328 | ||
3329 | // table definition |
|
3330 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
3331 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
3332 | ||
3333 | $sql = "SELECT DISTINCT code, c_id |
|
3334 | FROM $tbl_session_course sc |
|
3335 | INNER JOIN $courseTable c |
|
3336 | ON sc.c_id = c.id |
|
3337 | WHERE session_id= $session_id"; |
|
3338 | ||
3339 | $result = Database::query($sql); |
|
3340 | ||
3341 | $courses = array(); |
|
3342 | while ($row = Database::fetch_array($result)) { |
|
3343 | $courses[$row['code']] = $row; |
|
3344 | } |
|
3345 | ||
3346 | return $courses; |
|
3347 | } |
|
3348 | ||
3349 | /** |
|
3350 | * Count the number of documents that an user has uploaded to a course |