@@ 5143-5166 (lines=24) @@ | ||
5140 | * @param string $lastname Lastname to search |
|
5141 | * @return array The user list |
|
5142 | */ |
|
5143 | public static function getUserByName($firstname, $lastname) |
|
5144 | { |
|
5145 | $firstname = Database::escape_string($firstname); |
|
5146 | $lastname = Database::escape_string($lastname); |
|
5147 | ||
5148 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
5149 | ||
5150 | $sql = <<<SQL |
|
5151 | SELECT id, username, lastname, firstname |
|
5152 | FROM $userTable |
|
5153 | WHERE firstname LIKE '$firstname%' AND |
|
5154 | lastname LIKE '$lastname%' |
|
5155 | SQL; |
|
5156 | ||
5157 | $result = Database::query($sql); |
|
5158 | ||
5159 | $users = []; |
|
5160 | ||
5161 | while ($resultData = Database::fetch_object($result)) { |
|
5162 | $users[] = $resultData; |
|
5163 | } |
|
5164 | ||
5165 | return $users; |
|
5166 | } |
|
5167 | ||
5168 | /** |
|
5169 | * @param int $optionSelected |
@@ 3285-3307 (lines=23) @@ | ||
3282 | * @param int Session id |
|
3283 | * @return array Courses list |
|
3284 | */ |
|
3285 | public static function get_courses_list_from_session($session_id) |
|
3286 | { |
|
3287 | $session_id = intval($session_id); |
|
3288 | ||
3289 | // table definition |
|
3290 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
3291 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
3292 | ||
3293 | $sql = "SELECT DISTINCT code, c_id |
|
3294 | FROM $tbl_session_course sc |
|
3295 | INNER JOIN $courseTable c |
|
3296 | ON sc.c_id = c.id |
|
3297 | WHERE session_id= $session_id"; |
|
3298 | ||
3299 | $result = Database::query($sql); |
|
3300 | ||
3301 | $courses = array(); |
|
3302 | while ($row = Database::fetch_array($result)) { |
|
3303 | $courses[$row['code']] = $row; |
|
3304 | } |
|
3305 | ||
3306 | return $courses; |
|
3307 | } |
|
3308 | ||
3309 | /** |
|
3310 | * Count the number of documents that an user has uploaded to a course |