/** * Delete all messages in a chatroom. * * @param AUTO_LINK The chat room ID */ function delete_chatroom_messages($id) { delete_chat_messages(array('room_id' => $id)); log_it('DELETE_ALL_MESSAGES', strval($id)); decache('side_shoutbox'); }
/** * The actualiser for deleting all the ticked messages in a room. * * @return tempcode The UI. */ function _chat_delete_many_messages() { breadcrumb_set_self(do_lang_tempcode('DONE')); $title = get_page_title('DELETE_SOME_MESSAGES'); $room_id = get_param_integer('room_id'); check_chatroom_access($room_id); $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $room_details[0]; $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms'); if (!$has_mod_access) { access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content'); } // Actualiser $count = 0; foreach (array_keys($_REQUEST) as $key) { if (substr($key, 0, 4) == 'del_') { delete_chat_messages(array('room_id' => $room_id, 'id' => intval(substr($key, 4)))); $count++; } } if ($count == 0) { warn_exit(do_lang_tempcode('NOTHING_SELECTED')); } decache('side_shoutbox'); $num_remaining = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id)); if ($num_remaining == 0) { $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); } else { $url = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => $room_id, 'start' => get_param_integer('start'), 'max' => get_param_integer('max')), '_SELF'); } // Redirect return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Prune timed-out private chatrooms. * * @param array The row of the chat room to possibly prune * @return boolean Whether the room was pruned */ function handle_chatroom_pruning($row) { $deletion_time = intval(get_option('chat_private_room_deletion_time')); if ($deletion_time == 0) { return false; } if ($row['allow_list'] != '' || !is_null($row['room_owner'])) { // As this is a private chatroom, we need to delete it if it has been idle for too long ;-) $message = $GLOBALS['SITE_DB']->query_select('chat_messages', array('date_and_time'), array('room_id' => $row['id']), 'ORDER BY date_and_time DESC', 1); if (isset($message[0]) && $message[0]['date_and_time'] + $deletion_time * 60 <= time()) { // Delete the room and its messages $GLOBALS['SITE_DB']->query_delete('chat_rooms', array('id' => $row['id']), '', 1); require_code('chat2'); delete_chat_messages(array('room_id' => $row['id'])); return true; } } return false; }