| @@ 475-492 (lines=18) @@ | ||
| 472 | * @return array link info |
|
| 473 | * |
|
| 474 | **/ |
|
| 475 | public static function get_link_info($id) |
|
| 476 | { |
|
| 477 | $tbl_link = Database:: get_course_table(TABLE_LINK); |
|
| 478 | $course_id = api_get_course_int_id(); |
|
| 479 | ||
| 480 | if (empty($id) || empty($course_id)) { |
|
| 481 | return []; |
|
| 482 | } |
|
| 483 | ||
| 484 | $sql = "SELECT * FROM $tbl_link |
|
| 485 | WHERE c_id = $course_id AND id='" . intval($id) . "' "; |
|
| 486 | $result = Database::query($sql); |
|
| 487 | $data = array(); |
|
| 488 | if (Database::num_rows($result)) { |
|
| 489 | $data = Database::fetch_array($result); |
|
| 490 | } |
|
| 491 | return $data; |
|
| 492 | } |
|
| 493 | ||
| 494 | /** |
|
| 495 | * @param int $id |
|
| @@ 1752-1767 (lines=16) @@ | ||
| 1749 | * @param int $id |
|
| 1750 | * @return array |
|
| 1751 | */ |
|
| 1752 | public static function getCategory($id) |
|
| 1753 | { |
|
| 1754 | $table = Database::get_course_table(TABLE_LINK_CATEGORY); |
|
| 1755 | $id = intval($id); |
|
| 1756 | $courseId = api_get_course_int_id(); |
|
| 1757 | ||
| 1758 | if (empty($id) || empty($courseId)) { |
|
| 1759 | return []; |
|
| 1760 | } |
|
| 1761 | $sql = "SELECT * FROM $table |
|
| 1762 | WHERE id = $id AND c_id = $courseId"; |
|
| 1763 | $result = Database::query($sql); |
|
| 1764 | $category = Database::fetch_array($result, 'ASSOC'); |
|
| 1765 | ||
| 1766 | return $category; |
|
| 1767 | } |
|
| 1768 | ||
| 1769 | /** |
|
| 1770 | * Move a link inside its category (display_order field) |
|
| @@ 6264-6292 (lines=29) @@ | ||
| 6261 | * @param int $sessionId The session id |
|
| 6262 | * @return array |
|
| 6263 | */ |
|
| 6264 | public static function getTotalUserCoursesInSession($sessionId) |
|
| 6265 | { |
|
| 6266 | $tableUser = Database::get_main_table(TABLE_MAIN_USER); |
|
| 6267 | $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
| 6268 | ||
| 6269 | if (empty($sessionId)) { |
|
| 6270 | return []; |
|
| 6271 | } |
|
| 6272 | ||
| 6273 | $sql = "SELECT |
|
| 6274 | COUNT(u.id) as count, |
|
| 6275 | u.id, |
|
| 6276 | scu.status status_in_session, |
|
| 6277 | u.status user_status |
|
| 6278 | FROM $table scu |
|
| 6279 | INNER JOIN $tableUser u |
|
| 6280 | ON scu.user_id = u.id |
|
| 6281 | WHERE scu.session_id = " . intval($sessionId) ." |
|
| 6282 | GROUP BY u.id"; |
|
| 6283 | ||
| 6284 | $result = Database::query($sql); |
|
| 6285 | ||
| 6286 | $list = array(); |
|
| 6287 | while ($data = Database::fetch_assoc($result)) { |
|
| 6288 | $list[] = $data; |
|
| 6289 | } |
|
| 6290 | ||
| 6291 | return $list; |
|
| 6292 | } |
|
| 6293 | ||
| 6294 | ||
| 6295 | /** |
|