| @@ 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 |
|
| @@ 1324-1339 (lines=16) @@ | ||
| 1321 | * @param int $group_id id |
|
| 1322 | * @return int Number of students in the given group. |
|
| 1323 | */ |
|
| 1324 | public static function number_of_students($group_id, $course_id = null) |
|
| 1325 | { |
|
| 1326 | $table_group_user = Database::get_course_table(TABLE_GROUP_USER); |
|
| 1327 | $group_id = intval($group_id); |
|
| 1328 | if (empty($course_id)) { |
|
| 1329 | $course_id = api_get_course_int_id(); |
|
| 1330 | } else { |
|
| 1331 | $course_id = intval($course_id); |
|
| 1332 | } |
|
| 1333 | $sql = "SELECT COUNT(*) AS number_of_students |
|
| 1334 | FROM $table_group_user |
|
| 1335 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1336 | $result = Database::query($sql); |
|
| 1337 | $db_object = Database::fetch_object($result); |
|
| 1338 | ||
| 1339 | return $db_object->number_of_students; |
|
| 1340 | } |
|
| 1341 | ||
| 1342 | /** |
|
| @@ 1760-1782 (lines=23) @@ | ||
| 1757 | * @todo use the function user_has_access that includes this function |
|
| 1758 | * @author Patrick Cool <[email protected]>, Ghent University |
|
| 1759 | */ |
|
| 1760 | public static function is_tutor_of_group($user_id, $groupInfo) |
|
| 1761 | { |
|
| 1762 | if (empty($groupInfo)) { |
|
| 1763 | return false; |
|
| 1764 | } |
|
| 1765 | ||
| 1766 | $table_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR); |
|
| 1767 | $user_id = intval($user_id); |
|
| 1768 | $group_id = intval($groupInfo['id']); |
|
| 1769 | $course_id = api_get_course_int_id(); |
|
| 1770 | ||
| 1771 | $sql = "SELECT * FROM $table_group_tutor |
|
| 1772 | WHERE |
|
| 1773 | c_id = $course_id AND |
|
| 1774 | user_id = $user_id AND |
|
| 1775 | group_id = $group_id"; |
|
| 1776 | $result = Database::query($sql); |
|
| 1777 | if (Database::num_rows($result) > 0) { |
|
| 1778 | return true; |
|
| 1779 | } else { |
|
| 1780 | return false; |
|
| 1781 | } |
|
| 1782 | } |
|
| 1783 | ||
| 1784 | /** |
|
| 1785 | * Is the user part of this group? This can be a tutor or a normal member |
|
| @@ 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 |
|
| @@ 1586-1604 (lines=19) @@ | ||
| 1583 | * @param int $course_id |
|
| 1584 | * @return bool |
|
| 1585 | */ |
|
| 1586 | public static function is_user_filled_survey($user_id, $survey_id, $course_id) |
|
| 1587 | { |
|
| 1588 | $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
| 1589 | $user_id = intval($user_id); |
|
| 1590 | $course_id = intval($course_id); |
|
| 1591 | $survey_id = intval($survey_id); |
|
| 1592 | ||
| 1593 | $sql = "SELECT DISTINCT user |
|
| 1594 | FROM $table_survey_answer |
|
| 1595 | WHERE |
|
| 1596 | c_id = $course_id AND |
|
| 1597 | user = $user_id AND |
|
| 1598 | survey_id = $survey_id"; |
|
| 1599 | $result = Database::query($sql); |
|
| 1600 | if (Database::num_rows($result)) { |
|
| 1601 | return true; |
|
| 1602 | } |
|
| 1603 | return false; |
|
| 1604 | } |
|
| 1605 | ||
| 1606 | /** |
|
| 1607 | * This function gets all the persons who have filled the survey |
|
| @@ 940-967 (lines=28) @@ | ||
| 937 | * @param int $annoucement_id |
|
| 938 | * @return array |
|
| 939 | */ |
|
| 940 | public static function get_by_id($course_id, $annoucement_id) |
|
| 941 | { |
|
| 942 | $annoucement_id = intval($annoucement_id); |
|
| 943 | $course_id = $course_id ? intval($course_id) : api_get_course_int_id(); |
|
| 944 | ||
| 945 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
| 946 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
| 947 | ||
| 948 | $sql = "SELECT DISTINCT |
|
| 949 | announcement.id, |
|
| 950 | announcement.title, |
|
| 951 | announcement.content |
|
| 952 | FROM $tbl_announcement announcement |
|
| 953 | INNER JOIN $tbl_item_property ip |
|
| 954 | ON |
|
| 955 | announcement.id = ip.ref AND |
|
| 956 | announcement.c_id = ip.c_id |
|
| 957 | WHERE |
|
| 958 | announcement.c_id = $course_id AND |
|
| 959 | ip.tool='announcement' AND |
|
| 960 | announcement.id = $annoucement_id |
|
| 961 | "; |
|
| 962 | $result = Database::query($sql); |
|
| 963 | if (Database::num_rows($result)) { |
|
| 964 | return Database::fetch_array($result); |
|
| 965 | } |
|
| 966 | return []; |
|
| 967 | } |
|
| 968 | ||
| 969 | /** |
|
| 970 | * this function gets all the groups of the course, |
|
| @@ 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 |
|