| @@ 126-147 (lines=22) @@ | ||
| 123 | * |
|
| 124 | * @return bool |
|
| 125 | */ |
|
| 126 | public static function hasVersion($language, $version) |
|
| 127 | { |
|
| 128 | $table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
| 129 | $language = intval($language); |
|
| 130 | $version = intval($version); |
|
| 131 | ||
| 132 | if (empty($language)) { |
|
| 133 | return false; |
|
| 134 | } |
|
| 135 | ||
| 136 | $sql = "SELECT version FROM $table |
|
| 137 | WHERE |
|
| 138 | language_id = '$language' AND |
|
| 139 | version = '$version' |
|
| 140 | LIMIT 1 "; |
|
| 141 | $result = Database::query($sql); |
|
| 142 | if (Database::num_rows($result) > 0) { |
|
| 143 | return true; |
|
| 144 | } else { |
|
| 145 | return false; |
|
| 146 | } |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * @param string $content |
|
| @@ 163-179 (lines=17) @@ | ||
| 160 | * |
|
| 161 | * @return bool |
|
| 162 | */ |
|
| 163 | public static function deleteCategory($id) |
|
| 164 | { |
|
| 165 | $id = intval($id); |
|
| 166 | if (empty($id)) { |
|
| 167 | return false; |
|
| 168 | } |
|
| 169 | ||
| 170 | $table = Database::get_main_table(TABLE_TICKET_TICKET); |
|
| 171 | $sql = "UPDATE $table SET category_id = NULL WHERE category_id = $id"; |
|
| 172 | Database::query($sql); |
|
| 173 | ||
| 174 | $table = Database::get_main_table(TABLE_TICKET_CATEGORY); |
|
| 175 | $sql = "DELETE FROM $table WHERE id = $id"; |
|
| 176 | Database::query($sql); |
|
| 177 | ||
| 178 | return true; |
|
| 179 | } |
|
| 180 | ||
| 181 | /** |
|
| 182 | * @param int $categoryId |
|
| @@ 165-183 (lines=19) @@ | ||
| 162 | * @param bool $use_session |
|
| 163 | * @return int Maximum display order |
|
| 164 | */ |
|
| 165 | public function get_max_thematic_item($use_session = true) |
|
| 166 | { |
|
| 167 | // Database table definition |
|
| 168 | $tbl_thematic = Database::get_course_table(TABLE_THEMATIC); |
|
| 169 | $session_id = api_get_session_id(); |
|
| 170 | if ($use_session) { |
|
| 171 | $condition_session = api_get_session_condition($session_id); |
|
| 172 | } else { |
|
| 173 | $condition_session = ''; |
|
| 174 | } |
|
| 175 | $course_id = api_get_course_int_id(); |
|
| 176 | $sql = "SELECT MAX(display_order) |
|
| 177 | FROM $tbl_thematic |
|
| 178 | WHERE c_id = $course_id AND active = 1 $condition_session"; |
|
| 179 | $rs = Database::query($sql); |
|
| 180 | $row = Database::fetch_array($rs); |
|
| 181 | ||
| 182 | return $row[0]; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * Move a thematic |
|
| @@ 964-991 (lines=28) @@ | ||
| 961 | * @param int $annoucement_id |
|
| 962 | * @return array |
|
| 963 | */ |
|
| 964 | public static function get_by_id($course_id, $annoucement_id) |
|
| 965 | { |
|
| 966 | $annoucement_id = intval($annoucement_id); |
|
| 967 | $course_id = $course_id ? intval($course_id) : api_get_course_int_id(); |
|
| 968 | ||
| 969 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
| 970 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
| 971 | ||
| 972 | $sql = "SELECT DISTINCT |
|
| 973 | announcement.id, |
|
| 974 | announcement.title, |
|
| 975 | announcement.content |
|
| 976 | FROM $tbl_announcement announcement |
|
| 977 | INNER JOIN $tbl_item_property ip |
|
| 978 | ON |
|
| 979 | announcement.id = ip.ref AND |
|
| 980 | announcement.c_id = ip.c_id |
|
| 981 | WHERE |
|
| 982 | announcement.c_id = $course_id AND |
|
| 983 | ip.tool='announcement' AND |
|
| 984 | announcement.id = $annoucement_id |
|
| 985 | "; |
|
| 986 | $result = Database::query($sql); |
|
| 987 | if (Database::num_rows($result)) { |
|
| 988 | return Database::fetch_array($result); |
|
| 989 | } |
|
| 990 | return []; |
|
| 991 | } |
|
| 992 | ||
| 993 | /** |
|
| 994 | * this function gets all the groups of the course, |
|
| @@ 1337-1352 (lines=16) @@ | ||
| 1334 | * @param int $group_id id |
|
| 1335 | * @return int Number of students in the given group. |
|
| 1336 | */ |
|
| 1337 | public static function number_of_students($group_id, $course_id = null) |
|
| 1338 | { |
|
| 1339 | $table_group_user = Database::get_course_table(TABLE_GROUP_USER); |
|
| 1340 | $group_id = intval($group_id); |
|
| 1341 | if (empty($course_id)) { |
|
| 1342 | $course_id = api_get_course_int_id(); |
|
| 1343 | } else { |
|
| 1344 | $course_id = intval($course_id); |
|
| 1345 | } |
|
| 1346 | $sql = "SELECT COUNT(*) AS number_of_students |
|
| 1347 | FROM $table_group_user |
|
| 1348 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1349 | $result = Database::query($sql); |
|
| 1350 | $db_object = Database::fetch_object($result); |
|
| 1351 | ||
| 1352 | return $db_object->number_of_students; |
|
| 1353 | } |
|
| 1354 | ||
| 1355 | /** |
|
| @@ 1777-1799 (lines=23) @@ | ||
| 1774 | * @todo use the function user_has_access that includes this function |
|
| 1775 | * @author Patrick Cool <[email protected]>, Ghent University |
|
| 1776 | */ |
|
| 1777 | public static function is_tutor_of_group($user_id, $groupInfo) |
|
| 1778 | { |
|
| 1779 | if (empty($groupInfo)) { |
|
| 1780 | return false; |
|
| 1781 | } |
|
| 1782 | ||
| 1783 | $table_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR); |
|
| 1784 | $user_id = intval($user_id); |
|
| 1785 | $group_id = intval($groupInfo['id']); |
|
| 1786 | $course_id = api_get_course_int_id(); |
|
| 1787 | ||
| 1788 | $sql = "SELECT * FROM $table_group_tutor |
|
| 1789 | WHERE |
|
| 1790 | c_id = $course_id AND |
|
| 1791 | user_id = $user_id AND |
|
| 1792 | group_id = $group_id"; |
|
| 1793 | $result = Database::query($sql); |
|
| 1794 | if (Database::num_rows($result) > 0) { |
|
| 1795 | return true; |
|
| 1796 | } else { |
|
| 1797 | return false; |
|
| 1798 | } |
|
| 1799 | } |
|
| 1800 | ||
| 1801 | /** |
|
| 1802 | * Is the user part of this group? This can be a tutor or a normal member |
|
| @@ 1599-1617 (lines=19) @@ | ||
| 1596 | * @param int $course_id |
|
| 1597 | * @return bool |
|
| 1598 | */ |
|
| 1599 | public static function is_user_filled_survey($user_id, $survey_id, $course_id) |
|
| 1600 | { |
|
| 1601 | $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
| 1602 | $user_id = intval($user_id); |
|
| 1603 | $course_id = intval($course_id); |
|
| 1604 | $survey_id = intval($survey_id); |
|
| 1605 | ||
| 1606 | $sql = "SELECT DISTINCT user |
|
| 1607 | FROM $table_survey_answer |
|
| 1608 | WHERE |
|
| 1609 | c_id = $course_id AND |
|
| 1610 | user = $user_id AND |
|
| 1611 | survey_id = $survey_id"; |
|
| 1612 | $result = Database::query($sql); |
|
| 1613 | if (Database::num_rows($result)) { |
|
| 1614 | return true; |
|
| 1615 | } |
|
| 1616 | return false; |
|
| 1617 | } |
|
| 1618 | ||
| 1619 | /** |
|
| 1620 | * This function gets all the persons who have filled the survey |
|