| @@ 601-612 (lines=12) @@ | ||
| 598 | * @param int $id The identifier of the announcement that should be |
|
| 599 | * @return bool True on success, false on failure |
|
| 600 | */ |
|
| 601 | public static function delete_announcement($id) |
|
| 602 | { |
|
| 603 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 604 | $id = intval($id); |
|
| 605 | $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
| 606 | $res = Database::query($sql); |
|
| 607 | if ($res === false) { |
|
| 608 | ||
| 609 | return false; |
|
| 610 | } |
|
| 611 | return true; |
|
| 612 | } |
|
| 613 | ||
| 614 | /** |
|
| 615 | * Gets an announcement |
|
| @@ 67-81 (lines=15) @@ | ||
| 64 | * Get the new messages for the current user from the database. |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public static function get_new_messages() |
|
| 68 | { |
|
| 69 | $table = Database::get_main_table(TABLE_MESSAGE); |
|
| 70 | if (!api_get_user_id()) { |
|
| 71 | return false; |
|
| 72 | } |
|
| 73 | $sql = "SELECT * FROM $table |
|
| 74 | WHERE |
|
| 75 | user_receiver_id=".api_get_user_id()." AND |
|
| 76 | msg_status=".MESSAGE_STATUS_UNREAD; |
|
| 77 | $result = Database::query($sql); |
|
| 78 | $i = Database::num_rows($result); |
|
| 79 | ||
| 80 | return $i; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Get the list of user_ids of users who are online. |
|