function sp_delete_post($postid, $topicid, $forumid, $show = true, $poster = 0) { global $spThisUser; if (!$postid || !$topicid || !$forumid) { return ''; } if (sp_get_auth('delete_any_post', $forumid) || sp_get_auth('delete_own_posts', $forumid) && $spThisUser->ID == $poster) { # Check post actually exsists - might be a browsser refresh! $target = spdb_table(SFPOSTS, "post_id={$postid}", 'row'); if (empty($target)) { if ($show) { sp_notify(SPSUCCESS, sp_text('Post already deleted')); } return; } # if just one post then remove topic as well $pcount = spdb_table(SFTOPICS, "topic_id={$topicid}", 'post_count'); if ($pcount == 1) { sp_delete_topic($topicid, $forumid, $show); } else { if (spdb_query('DELETE FROM ' . SFPOSTS . " WHERE post_id={$postid}") == false) { if ($show) { sp_notify(SPFAILURE, sp_text('Deletion failed')); } } else { if ($show) { sp_notify(SPSUCCESS, sp_text('Post deleted')); } } # adjust post count if needed $adjust = sp_get_option('post_count_delete'); if ($adjust) { $count = sp_get_member_item($target->user_id, 'posts') - 1; sp_update_member_item($target->user_id, 'posts', $count); } # re number post index sp_build_post_index($topicid); sp_build_forum_index($forumid); # post delete hook do_action('sph_post_delete', $target, $spThisUser->ID); # flush and rebuild topic cache (since one or more posts approved) sp_rebuild_topic_cache(); } # need to look in sfwaiting to see if it's in there... sp_remove_from_waiting(true, $topicid, $postid); sp_delete_notice('post_id', $postid); } else { if (!is_user_logged_in()) { $msg = sp_text('Access denied - are you logged in?'); } else { $msg = sp_text('Access denied - you do not have permission'); } sp_notify(SPFAILURE, $msg); } }
function sp_topic_delete() { sp_delete_topic(sp_esc_int($_GET['killtopic']), sp_esc_int($_GET['killtopicforum']), false); $view = sp_esc_str($_GET['view']); if ($view == 'topic') { $forumslug = spdb_table(SFFORUMS, 'forum_id=' . sp_esc_int($_GET['killtopicforum']), 'forum_slug'); $returnURL = sp_build_url($forumslug, '', 0); echo $returnURL; } else { if ($_GET['count'] == 1) { $forumslug = spdb_table(SFFORUMS, 'forum_id=' . sp_esc_int($_GET['killtopicforum']), 'forum_slug'); $page = sp_esc_int($_GET['page']); if ($page == 1) { $returnURL = sp_build_url($forumslug, '', 0); } else { $page = $page - 1; $returnURL = sp_build_url($forumslug, '', $page); } echo $returnURL; } } die; }
function spa_save_forums_delete_group() { check_admin_referer('forum-adminform_groupdelete', 'forum-adminform_groupdelete'); $group_id = sp_esc_int($_POST['group_id']); $cseq = sp_esc_int($_POST['cgroup_seq']); # remove permissions for each forum in group $forums = spa_get_forums_in_group($group_id); if ($forums) { foreach ($forums as $forum) { # remove permissions for this forum $perms = sp_get_forum_permissions($forum->forum_id); if ($perms) { foreach ($perms as $perm) { spa_remove_permission_data($perm->permission_id); } } } } # reset auths and memberships for everyone sp_reset_memberships(); sp_reset_auths(); # select all the forums in the group $forums = spa_get_forums_in_group($group_id); # remove the topics and posts in each forum foreach ($forums as $forum) { # need to delete all topics in the forum using standard routine to clean up behind it $topics = spdb_table(SFTOPICS, "forum_id={$forum->forum_id}"); if ($topics) { foreach ($topics as $topic) { sp_delete_topic($topic->topic_id, $forum->forum_id, false); } } } #now remove the forums themselves spdb_query('DELETE FROM ' . SFFORUMS . " WHERE group_id={$group_id}"); # and finaly remove the group spdb_query('DELETE FROM ' . SFGROUPS . " WHERE group_id={$group_id}"); # need to iterate through the groups $groups = spdb_table(SFGROUPS, '', '', 'group_seq'); foreach ($groups as $group) { if ($group->group_seq > $cseq) { spa_bump_group_seq($group->group_id, $group->group_seq - 1); } } # remove the default permissions for the group being deleted spdb_query('DELETE FROM ' . SFDEFPERMISSIONS . " WHERE group_id={$group_id}"); do_action('sph_forum_group_del', $group_id); # clear out group cache tpo enable change_user sp_flush_cache('group'); $mess = spa_text('Group Deleted'); return $mess; }