| @@ 3282-3304 (lines=23) @@ | ||
| 3279 | * @param int Session id |
|
| 3280 | * @return array Courses list |
|
| 3281 | */ |
|
| 3282 | public static function get_courses_list_from_session($session_id) |
|
| 3283 | { |
|
| 3284 | $session_id = intval($session_id); |
|
| 3285 | ||
| 3286 | // table definition |
|
| 3287 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
| 3288 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 3289 | ||
| 3290 | $sql = "SELECT DISTINCT code, c_id |
|
| 3291 | FROM $tbl_session_course sc |
|
| 3292 | INNER JOIN $courseTable c |
|
| 3293 | ON sc.c_id = c.id |
|
| 3294 | WHERE session_id= $session_id"; |
|
| 3295 | ||
| 3296 | $result = Database::query($sql); |
|
| 3297 | ||
| 3298 | $courses = array(); |
|
| 3299 | while ($row = Database::fetch_array($result)) { |
|
| 3300 | $courses[$row['code']] = $row; |
|
| 3301 | } |
|
| 3302 | ||
| 3303 | return $courses; |
|
| 3304 | } |
|
| 3305 | ||
| 3306 | /** |
|
| 3307 | * Count the number of documents that an user has uploaded to a course |
|
| @@ 5047-5070 (lines=24) @@ | ||
| 5044 | * @param string $lastname Lastname to search |
|
| 5045 | * @return array The user list |
|
| 5046 | */ |
|
| 5047 | public static function getUserByName($firstname, $lastname) |
|
| 5048 | { |
|
| 5049 | $firstname = Database::escape_string($firstname); |
|
| 5050 | $lastname = Database::escape_string($lastname); |
|
| 5051 | ||
| 5052 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
| 5053 | ||
| 5054 | $sql = <<<SQL |
|
| 5055 | SELECT id, username, lastname, firstname |
|
| 5056 | FROM $userTable |
|
| 5057 | WHERE firstname LIKE '$firstname%' AND |
|
| 5058 | lastname LIKE '$lastname%' |
|
| 5059 | SQL; |
|
| 5060 | ||
| 5061 | $result = Database::query($sql); |
|
| 5062 | ||
| 5063 | $users = []; |
|
| 5064 | ||
| 5065 | while ($resultData = Database::fetch_object($result)) { |
|
| 5066 | $users[] = $resultData; |
|
| 5067 | } |
|
| 5068 | ||
| 5069 | return $users; |
|
| 5070 | } |
|
| 5071 | ||
| 5072 | /** |
|
| 5073 | * @param int $optionSelected |
|