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