/** * Delete a CEDI post * * @param AUTO_LINK The post ID * @param ?MEMBER The member doing the action (NULL: current member) */ function cedi_delete_post($post_id, $member = NULL) { if (is_null($member)) { $member = get_member(); } $original_poster = $GLOBALS['SITE_DB']->query_value('seedy_posts', 'the_user', array('id' => $post_id)); $_message = $GLOBALS['SITE_DB']->query_value('seedy_posts', 'the_message', array('id' => $post_id)); require_code('attachments2'); require_code('attachments3'); delete_lang_comcode_attachments($_message, 'cedi_post', strval($post_id)); $GLOBALS['SITE_DB']->query_delete('seedy_posts', array('id' => $post_id), '', 1); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'seedy_post', 'rating_for_id' => $post_id)); $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_DELETE_POST', 'the_page' => $post_id, 'ip' => get_ip_address(), 'the_user' => $member, 'date_and_time' => time())); // Stat update_stat('num_seedy_posts', -1); }
/** * Delete a news entry. * * @param AUTO_LINK The ID of the news to edit */ function delete_news($id) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $title = $rows[0]['title']; $news = $rows[0]['news']; $news_article = $rows[0]['news_article']; $_title = get_translated_text($title); log_it('DELETE_NEWS', strval($id), $_title); require_code('files2'); delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id); $GLOBALS['SITE_DB']->query_delete('news', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'news', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'news', 'trackback_for_id' => $id)); delete_lang($title); delete_lang($news); require_code('attachments2'); require_code('attachments3'); if (!is_null($news_article)) { delete_lang_comcode_attachments($news_article, 'news', strval($id)); } require_code('seo2'); seo_meta_erase_storage('news', strval($id)); decache('main_news'); decache('side_news'); decache('side_news_archive'); decache('bottom_news'); }
/** * Delete a calendar event. * * @param AUTO_LINK The ID of the event */ function delete_calendar_event($id) { $myrows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('e_title', 'e_content'), array('id' => $id), '', 1); $myrow = $myrows[0]; $e_title = get_translated_text($myrow['e_title']); $GLOBALS['SITE_DB']->query_delete('calendar_events', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('calendar_jobs', array('j_event_id' => $id)); $GLOBALS['SITE_DB']->query_delete('calendar_reminders', array('e_id' => $id)); require_code('seo2'); seo_meta_erase_storage('event', strval($id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'events', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'events', 'trackback_for_id' => $id)); delete_lang($myrow['e_title']); require_code('attachments2'); require_code('attachments3'); if (!is_null($myrow['e_content'])) { delete_lang_comcode_attachments($myrow['e_content'], 'e_content', strval($id)); } decache('side_calendar'); log_it('DELETE_CALENDAR_EVENT', strval($id), $e_title); }
/** * Delete a member. * * @param AUTO_LINK The ID of the member. */ function ocf_delete_member($member_id) { $username = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_username'); $signature = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_signature'); require_code('attachments2'); require_code('attachments3'); delete_lang_comcode_attachments($signature, 'signature', strval($member_id), $GLOBALS['FORUM_DB']); $GLOBALS['FORUM_DB']->query_delete('f_members', array('id' => $member_id), '', 1); $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id)); $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => get_member()), array('g_group_leader' => $member_id)); $GLOBALS['FORUM_DB']->query_delete('sessions', array('the_user' => $member_id)); require_code('fields'); // Delete custom profile fields $cpfs = $GLOBALS['FORUM_DB']->query_select('f_custom_fields'); $fields_row = $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('*'), array('mf_member_id' => $member_id), '', 1); foreach ($cpfs as $field) { $l = $fields_row[0]['field_' . strval($field['id'])]; $object = get_fields_hook($field['cf_type']); list(, , $storage_type) = $object->get_field_value_row_bits($field); if (method_exists($object, 'cleanup')) { $object->cleanup($l); } if (strpos($storage_type, '_trans') !== false && !is_null($l)) { if (true) { require_code('attachments2'); require_code('attachments3'); delete_lang_comcode_attachments($l, 'null', strval($member_id), $GLOBALS['FORUM_DB']); } else { delete_lang($l, $GLOBALS['FORUM_DB']); } } } $GLOBALS['FORUM_DB']->query_delete('f_member_custom_fields', array('mf_member_id' => $member_id), '', 1); // Cleanup images $old = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_avatar_url'); if (url_is_local($old) && (substr($old, 0, 20) == 'uploads/ocf_avatars/' || substr($old, 0, 16) == 'uploads/avatars/')) { @unlink(get_custom_file_base() . '/' . rawurldecode($old)); sync_file(rawurldecode($old)); } $old = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_photo_url'); if (url_is_local($old) && (substr($old, 0, 19) == 'uploads/ocf_photos/' || substr($old, 0, 15) == 'uploads/photos/')) { @unlink(get_custom_file_base() . '/' . rawurldecode($old)); sync_file(rawurldecode($old)); } log_it('DELETE_MEMBER', strval($member_id), $username); }
/** * Delete posts from a topic. * * @param AUTO_LINK The ID of the topic we're deleting posts from. * @param array A list of posts to delete. * @param LONG_TEXT The reason for this action. * @return boolean Whether the topic was deleted, due to all posts in said topic being deleted. */ function ocf_delete_posts_topic($topic_id, $posts, $reason) { // Info about source $info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $info[0]['t_forum_id']; $or_list = ''; foreach ($posts as $post) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'id=' . strval((int) $post); } // Check access $_postdetails = $GLOBALS['FORUM_DB']->query('SELECT id,p_post,p_poster,p_time,p_intended_solely_for,p_validated FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $or_list); $num_posts_counted = 0; foreach ($_postdetails as $post) { if (is_null($post['p_intended_solely_for']) && $post['p_validated'] == 1) { $num_posts_counted++; } $post_owner = $post['p_poster']; if (!ocf_may_delete_post_by($post_owner, $forum_id)) { access_denied('I_ERROR'); } } // Save in history foreach ($_postdetails as $post) { $GLOBALS['FORUM_DB']->query_insert('f_post_history', array('h_create_date_and_time' => $post['p_time'], 'h_action_date_and_time' => time(), 'h_owner_member_id' => $post['p_poster'], 'h_alterer_member_id' => get_member(), 'h_post_id' => $post['id'], 'h_topic_id' => $topic_id, 'h_before' => get_translated_text($post['p_post'], $GLOBALS['FORUM_DB']), 'h_action' => 'DELETE_POST')); } // Update member post counts $post_counts = is_null($forum_id) ? 1 : $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_post_count_increment', array('id' => $forum_id)); if ($post_counts == 1) { $sql = 'SELECT p_poster FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE (' . $or_list . ')'; if (addon_installed('unvalidated')) { $sql .= ' AND p_validated=1'; } $_member_post_counts = $GLOBALS['FORUM_DB']->query($sql); $member_post_counts = array(); foreach ($_member_post_counts as $_member_post_count) { $_member = $_member_post_count['p_poster']; if (!array_key_exists($_member, $member_post_counts)) { $member_post_counts[$_member] = 0; } $member_post_counts[$_member]++; } foreach ($member_post_counts as $member_id => $member_post_count) { if (!is_null($forum_id)) { ocf_force_update_member_post_count($member_id, -$member_post_count); } } } // Clean up lang require_code('attachments2'); require_code('attachments3'); foreach ($_postdetails as $post) { delete_lang_comcode_attachments($post['p_post'], 'ocf_post', $post['id'], $GLOBALS['FORUM_DB']); } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $or_list); $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'review_supplement WHERE ' . str_replace('id=', 'r_post_id=', $or_list)); $test = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)', array('p_topic_id' => $topic_id)); if ($test == 0) { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_delete_topic($topic_id, do_lang('DELETE_POSTS')); $ret = true; } else { $ret = false; // Update cacheing ocf_force_update_topic_cacheing($topic_id, -$num_posts_counted, true, true); } if (!is_null($forum_id)) { ocf_force_update_forum_cacheing($forum_id, 0, -$num_posts_counted); } require_code('ocf_general_action2'); if (count($posts) == 1) { ocf_mod_log_it('DELETE_POST', strval($topic_id), strval($posts[0]), $reason); } else { ocf_mod_log_it('DELETE_POSTS', strval($topic_id), strval(count($posts)), $reason); } if (!is_null($forum_id)) { ocf_decache_ocp_blocks($forum_id); } else { decache('side_ocf_personal_topics'); decache('_new_pp'); } return $ret; }
/** * Delete a catalogue entry. * * @param AUTO_LINK The ID of the entry to delete */ function actual_delete_catalogue_entry($id) { $old_category_id = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'cc_id', array('id' => $id)); $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'c_name', array('id' => $id)); require_code('fields'); require_code('catalogues'); $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name)); $title = NULL; foreach ($fields as $field) { $object = get_fields_hook($field['cf_type']); list(, , $storage_type) = $object->get_field_value_row_bits($field); $value = _get_catalogue_entry_field($field['id'], $id, $storage_type); if (method_exists($object, 'cleanup')) { $object->cleanup($value); } if (is_null($title)) { if ($storage_type == 'long_trans' || $storage_type == 'short_trans') { $title = get_translated_text(intval($value)); } else { $title = $value; } } } $lang1 = $GLOBALS['SITE_DB']->query_select('catalogue_efv_long_trans', array('cv_value'), array('ce_id' => $id)); $lang2 = $GLOBALS['SITE_DB']->query_select('catalogue_efv_short_trans', array('cv_value'), array('ce_id' => $id)); $lang = array_merge($lang1, $lang2); foreach ($lang as $lang_to_delete) { if (true) { require_code('attachments2'); require_code('attachments3'); delete_lang_comcode_attachments($lang_to_delete['cv_value'], 'catalogue_entry', strval($id)); } else { delete_lang($lang_to_delete['cv_value']); } } $GLOBALS['SITE_DB']->query_delete('catalogue_efv_long_trans', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_efv_short_trans', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_efv_long', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_efv_short', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_efv_float', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_efv_integer', array('ce_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_entries', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'catalogues', 'trackback_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'catalogues', 'rating_for_id' => $id)); require_code('seo2'); seo_meta_erase_storage('catalogue_entry', strval($id)); calculate_category_child_count_cache($old_category_id); decache('main_recent_cc_entries'); decache('main_cc_embed'); if ($catalogue_name[0] != '_') { log_it('DELETE_CATALOGUE_ENTRY', strval($id), $title); } }