Example #1
0
function unapprove_post($postid, $countposts, $dolog = true, $postinfo = NULL, $threadinfo = NULL, $counterupdate = true)
{
	global $vbulletin, $vbphrase;

	// Valid postinfo array will contain: postid, threadid, visible, userid
	// Invalid post or post is not deleted
	if (!$postinfo AND !$postinfo = fetch_postinfo($postid))
	{
		return;
	}

	// Valid threadinfo array will contain: threadid, forumid, visible, firstpostid
	if (!$threadinfo AND !$threadinfo = fetch_threadinfo($postinfo['threadid']))
	{
		return;
	}

	if ($threadinfo['firstpostid'] == $postid)
	{
		// unapprove_thread
		unapprove_thread($threadinfo['threadid'], $countposts, $dolog, $threadinfo);
		return;
	}

	// Post is already moderated
	if (!$postinfo['visible'])
	{
		return;
	}

	// Only decrement post for a visible post and visible thread in a counting forum
	if ($countposts AND $postinfo['userid'] AND $threadinfo['visible'] == 1 AND $postinfo['visible'] == 1)
	{
		$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
		$userdata->set_existing($postinfo);
		$userdata->set('posts', 'IF(posts > 1, posts - 1, 0)', false);
		$userdata->set_ladder_usertitle_relative(-1);
		$userdata->save();
		unset($userdata);
	}

	if ($postinfo['visible'] == 2)
	{
		$deletiondata =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
		$deletioninfo = array('type' => 'post', 'primaryid' => $postinfo['postid']);
		$deletiondata->set_existing($deletioninfo);
		$deletiondata->delete();
		unset($deletiondata, $deletioninfo);
	}

	// Insert Moderation record
	$vbulletin->db->query_write("
		INSERT IGNORE INTO " . TABLE_PREFIX . "moderation
		(primaryid, type, dateline)
		VALUES
		($postinfo[postid], 'reply', " . TIMENOW . ")
	");

	$postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
	$postman->set_existing($postinfo);
	$postman->set('visible', 0);
	$postman->save();

	if ($counterupdate)
	{
		build_thread_counters($postinfo['threadid']);
		build_forum_counters($threadinfo['forumid']);
	}

	fetch_phrase_group('threadmanage');
	$postinfo['forumid'] = $threadinfo['forumid'];

	require_once(DIR . '/includes/functions_log_error.php');
	log_moderator_action($postinfo, 'unapproved_post');
}
Example #2
0
        $vbulletin->url = fetch_seo_url('thread', $threadinfo);
    }
    print_standard_redirect('redirect_post_manage');
}
// ############################### start moderate thread ###############################
if ($_POST['do'] == 'moderatethread') {
    if (!can_moderate($threadinfo['forumid'], 'canmoderateposts')) {
        print_no_permission();
    }
    if ($threadinfo['open'] != 10) {
        if ($threadinfo['visible'] == 0) {
            approve_thread($threadid, $foruminfo['countposts'], true, $threadinfo);
            build_forum_counters($threadinfo['forumid']);
            print_standard_redirect('thread_approved');
        } else {
            unapprove_thread($threadid, $foruminfo['countposts'], true, $threadinfo);
            build_forum_counters($threadinfo['forumid']);
            print_standard_redirect('thread_unapproved');
        }
    }
}
// ############################### all done, do shell template ###############################
if (!empty($page_templater)) {
    // draw navbar
    $navbar = render_navbar_template($navbits);
    ($hook = vBulletinHook::fetch_hook('threadmanage_complete')) ? eval($hook) : false;
    $templater = vB_Template::create('THREADADMIN');
    $templater->register_page_templates();
    $templater->register('HTML', $page_templater->render());
    $templater->register('navbar', $navbar);
    $templater->register('onload', $onload);