| @@ 327-340 (lines=14) @@ | ||
| 324 | * |
|
| 325 | * @return array |
|
| 326 | */ |
|
| 327 | public static function getChildren($categoryCode) |
|
| 328 | { |
|
| 329 | $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); |
|
| 330 | $categoryCode = Database::escape_string($categoryCode); |
|
| 331 | $result = Database::query("SELECT code, id FROM $tbl_category WHERE parent_id = '$categoryCode'"); |
|
| 332 | $children = array(); |
|
| 333 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 334 | $children[] = $row; |
|
| 335 | $subChildren = self::getChildren($row['code']); |
|
| 336 | $children = array_merge($children, $subChildren); |
|
| 337 | } |
|
| 338 | ||
| 339 | return $children; |
|
| 340 | } |
|
| 341 | ||
| 342 | /** |
|
| 343 | * @param string $categoryCode |
|
| @@ 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 |
|
| @@ 5152-5175 (lines=24) @@ | ||
| 5149 | * @param string $lastname Lastname to search |
|
| 5150 | * @return array The user list |
|
| 5151 | */ |
|
| 5152 | public static function getUserByName($firstname, $lastname) |
|
| 5153 | { |
|
| 5154 | $firstname = Database::escape_string($firstname); |
|
| 5155 | $lastname = Database::escape_string($lastname); |
|
| 5156 | ||
| 5157 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
| 5158 | ||
| 5159 | $sql = <<<SQL |
|
| 5160 | SELECT id, username, lastname, firstname |
|
| 5161 | FROM $userTable |
|
| 5162 | WHERE firstname LIKE '$firstname%' AND |
|
| 5163 | lastname LIKE '$lastname%' |
|
| 5164 | SQL; |
|
| 5165 | ||
| 5166 | $result = Database::query($sql); |
|
| 5167 | ||
| 5168 | $users = []; |
|
| 5169 | ||
| 5170 | while ($resultData = Database::fetch_object($result)) { |
|
| 5171 | $users[] = $resultData; |
|
| 5172 | } |
|
| 5173 | ||
| 5174 | return $users; |
|
| 5175 | } |
|
| 5176 | ||
| 5177 | /** |
|
| 5178 | * @param int $optionSelected |
|
| @@ 5672-5687 (lines=16) @@ | ||
| 5669 | * @author Julio Montoya <[email protected]> |
|
| 5670 | * @return int user id |
|
| 5671 | */ |
|
| 5672 | function api_get_access_url_from_user($user_id) { |
|
| 5673 | $user_id = intval($user_id); |
|
| 5674 | $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
| 5675 | $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
| 5676 | $sql = "SELECT access_url_id |
|
| 5677 | FROM $table_url_rel_user url_rel_user |
|
| 5678 | INNER JOIN $table_url u |
|
| 5679 | ON (url_rel_user.access_url_id = u.id) |
|
| 5680 | WHERE user_id = ".intval($user_id); |
|
| 5681 | $result = Database::query($sql); |
|
| 5682 | $url_list = array(); |
|
| 5683 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 5684 | $url_list[] = $row['access_url_id']; |
|
| 5685 | } |
|
| 5686 | return $url_list; |
|
| 5687 | } |
|
| 5688 | ||
| 5689 | /** |
|
| 5690 | * Gets the status of a user in a course |
|