| @@ 95-107 (lines=13) @@ | ||
| 92 | * @param int Link/Resource ID |
|
| 93 | * @return bool false on error, true on success |
|
| 94 | */ |
|
| 95 | public static function remove_resource_from_course_gradebook($link_id) |
|
| 96 | { |
|
| 97 | if (empty($link_id)) { |
|
| 98 | return false; |
|
| 99 | } |
|
| 100 | ||
| 101 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
|
| 102 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 103 | $sql = "DELETE FROM $l WHERE id = ".(int) $link_id; |
|
| 104 | Database::query($sql); |
|
| 105 | ||
| 106 | return true; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Block students |
|
| @@ 792-803 (lines=12) @@ | ||
| 789 | * |
|
| 790 | * @return boolean true if success |
|
| 791 | * */ |
|
| 792 | public static function deleteUserFromAllUrls($userId) |
|
| 793 | { |
|
| 794 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
| 795 | $result = true; |
|
| 796 | if (!empty($userId)) { |
|
| 797 | $sql = "DELETE FROM $table |
|
| 798 | WHERE user_id = ".intval($userId); |
|
| 799 | Database::query($sql); |
|
| 800 | } |
|
| 801 | ||
| 802 | return $result; |
|
| 803 | } |
|
| 804 | ||
| 805 | /** |
|
| 806 | * Deletes an url and course relationship |
|
| @@ 831-840 (lines=10) @@ | ||
| 828 | * |
|
| 829 | * @return boolean true if success |
|
| 830 | * */ |
|
| 831 | public static function delete_url_rel_usergroup($userGroupId, $urlId) |
|
| 832 | { |
|
| 833 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); |
|
| 834 | $sql = "DELETE FROM $table |
|
| 835 | WHERE usergroup_id = '".intval($userGroupId)."' AND |
|
| 836 | access_url_id = ".intval($urlId); |
|
| 837 | $result = Database::query($sql); |
|
| 838 | ||
| 839 | return $result; |
|
| 840 | } |
|
| 841 | ||
| 842 | /** |
|
| 843 | * Deletes an url and $userGroup relationship |
|
| @@ 176-186 (lines=11) @@ | ||
| 173 | * @param int $url_id |
|
| 174 | * @return array |
|
| 175 | * */ |
|
| 176 | public static function get_url_data_from_id($url_id) |
|
| 177 | { |
|
| 178 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL); |
|
| 179 | $sql = "SELECT id, url, description, active |
|
| 180 | FROM $table |
|
| 181 | WHERE id = ".intval($url_id); |
|
| 182 | $res = Database::query($sql); |
|
| 183 | $row = Database::fetch_array($res); |
|
| 184 | ||
| 185 | return $row; |
|
| 186 | } |
|
| 187 | ||
| 188 | /** |
|
| 189 | * Gets the inner join of users and urls table |
|
| @@ 257-267 (lines=11) @@ | ||
| 254 | * |
|
| 255 | * @return int Database::num_rows($res); |
|
| 256 | **/ |
|
| 257 | public static function getCountUrlRelCourse($courseId) |
|
| 258 | { |
|
| 259 | $courseId = intval($courseId); |
|
| 260 | $tableUrlRelCourse = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
| 261 | $sql = "SELECT * |
|
| 262 | FROM $tableUrlRelCourse |
|
| 263 | WHERE c_id = '$courseId'"; |
|
| 264 | $res = Database::query($sql); |
|
| 265 | ||
| 266 | return Database::num_rows($res); |
|
| 267 | } |
|
| 268 | ||
| 269 | /** |
|
| 270 | * Gets the inner join of access_url and the session table |
|
| @@ 363-371 (lines=9) @@ | ||
| 360 | * @param int $language_id The language id |
|
| 361 | * @return bool |
|
| 362 | */ |
|
| 363 | public static function make_unavailable_language($language_id) |
|
| 364 | { |
|
| 365 | $tbl_admin_languages = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 366 | $sql = "UPDATE $tbl_admin_languages SET available='0' |
|
| 367 | WHERE id = ".intval($language_id).""; |
|
| 368 | $result = Database::query($sql); |
|
| 369 | ||
| 370 | return $result !== false; //only return false on sql error |
|
| 371 | } |
|
| 372 | ||
| 373 | /** |
|
| 374 | * Make available the language |
|
| @@ 378-386 (lines=9) @@ | ||
| 375 | * @param int $language_id language id |
|
| 376 | * @return bool |
|
| 377 | */ |
|
| 378 | public static function make_available_language($language_id) |
|
| 379 | { |
|
| 380 | $tbl_admin_languages = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 381 | $sql = "UPDATE $tbl_admin_languages SET available='1' |
|
| 382 | WHERE id = ".intval($language_id).""; |
|
| 383 | $result = Database::query($sql); |
|
| 384 | ||
| 385 | return $result !== false; //only return false on sql error |
|
| 386 | } |
|
| 387 | ||
| 388 | /** |
|
| 389 | * Set platform language |
|
| @@ 230-238 (lines=9) @@ | ||
| 227 | * |
|
| 228 | * @return array |
|
| 229 | */ |
|
| 230 | public static function getUsersInCategory($categoryId) |
|
| 231 | { |
|
| 232 | $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); |
|
| 233 | $categoryId = intval($categoryId); |
|
| 234 | $sql = "SELECT * FROM $table WHERE category_id = $categoryId"; |
|
| 235 | $result = Database::query($sql); |
|
| 236 | ||
| 237 | return Database::store_result($result); |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * @param int $categoryId |
|
| @@ 243-249 (lines=7) @@ | ||
| 240 | /** |
|
| 241 | * @param int $categoryId |
|
| 242 | */ |
|
| 243 | public static function deleteAllUserInCategory($categoryId) |
|
| 244 | { |
|
| 245 | $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); |
|
| 246 | $categoryId = intval($categoryId); |
|
| 247 | $sql = "DELETE FROM $table WHERE category_id = $categoryId"; |
|
| 248 | Database::query($sql); |
|
| 249 | } |
|
| 250 | ||
| 251 | /** |
|
| 252 | * Get all possible tickets statuses |
|
| @@ 169-175 (lines=7) @@ | ||
| 166 | * @param integer $user_id |
|
| 167 | * @return void |
|
| 168 | */ |
|
| 169 | function LoginDelete($user_id) |
|
| 170 | { |
|
| 171 | $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 172 | $user_id = intval($user_id); |
|
| 173 | $query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id"; |
|
| 174 | Database::query($query); |
|
| 175 | } |
|
| 176 | ||
| 177 | /** |
|
| 178 | * @param int $user_id |
|
| @@ 1710-1721 (lines=12) @@ | ||
| 1707 | * |
|
| 1708 | * @return bool |
|
| 1709 | */ |
|
| 1710 | public static function clear_session_ref_promotion($id) |
|
| 1711 | { |
|
| 1712 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
|
| 1713 | $id = intval($id); |
|
| 1714 | $sql = "UPDATE $tbl_session |
|
| 1715 | SET promotion_id = 0 |
|
| 1716 | WHERE promotion_id = $id"; |
|
| 1717 | if (Database::query($sql)) { |
|
| 1718 | return true; |
|
| 1719 | } else { |
|
| 1720 | return false; |
|
| 1721 | } |
|
| 1722 | } |
|
| 1723 | ||
| 1724 | /** |
|
| @@ 3179-3196 (lines=18) @@ | ||
| 3176 | * @param int $sessionId |
|
| 3177 | * @return bool |
|
| 3178 | */ |
|
| 3179 | public static function removeAllDrhFromSession($sessionId) |
|
| 3180 | { |
|
| 3181 | $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
|
| 3182 | $sessionId = (int) $sessionId; |
|
| 3183 | ||
| 3184 | if (empty($sessionId)) { |
|
| 3185 | return false; |
|
| 3186 | } |
|
| 3187 | ||
| 3188 | $sql = "DELETE FROM $tbl_session_rel_user |
|
| 3189 | WHERE |
|
| 3190 | session_id = $sessionId AND |
|
| 3191 | relation_type =".SESSION_RELATION_TYPE_RRHH; |
|
| 3192 | Database::query($sql); |
|
| 3193 | ||
| 3194 | return true; |
|
| 3195 | } |
|
| 3196 | ||
| 3197 | /** |
|
| 3198 | * Subscribes sessions to human resource manager (Dashboard feature) |
|
| 3199 | * @param array $userInfo Human Resource Manager info |
|
| @@ 1776-1784 (lines=9) @@ | ||
| 1773 | * @param int $id id message to delete. |
|
| 1774 | * @return bool status query |
|
| 1775 | */ |
|
| 1776 | public static function deleteMessage($id) |
|
| 1777 | { |
|
| 1778 | $id = intval($id); |
|
| 1779 | $tblMessage = Database::get_main_table(TABLE_MESSAGE); |
|
| 1780 | $statusMessage = MESSAGE_STATUS_WALL_DELETE; |
|
| 1781 | $sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' "; |
|
| 1782 | ||
| 1783 | return Database::query($sql); |
|
| 1784 | } |
|
| 1785 | ||
| 1786 | /** |
|
| 1787 | * Generate the social block for a user |
|
| @@ 4912-4920 (lines=9) @@ | ||
| 4909 | /** |
|
| 4910 | * @param int $userId |
|
| 4911 | */ |
|
| 4912 | public static function remove_user_admin($userId) |
|
| 4913 | { |
|
| 4914 | $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN); |
|
| 4915 | $userId = intval($userId); |
|
| 4916 | if (self::is_admin($userId)) { |
|
| 4917 | $sql = "DELETE FROM $table_admin WHERE user_id = $userId"; |
|
| 4918 | Database::query($sql); |
|
| 4919 | } |
|
| 4920 | } |
|
| 4921 | ||
| 4922 | /** |
|
| 4923 | * @param string $from |
|