当前位置: 首页>>代码示例>>PHP>>正文


PHP removeTopics函数代码示例

本文整理汇总了PHP中removeTopics函数的典型用法代码示例。如果您正苦于以下问题:PHP removeTopics函数的具体用法?PHP removeTopics怎么用?PHP removeTopics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了removeTopics函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tearDown

 /**
  * Cleanup data we no longer need at the end of the tests in this class.
  * tearDown() is run automatically by the testing framework after each test method.
  */
 function tearDown()
 {
     // remove temporary test data
     require_once SUBSDIR . '/Topic.subs.php';
     removeTopics($this->id_topic);
     // it should remove the likes too
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:11,代码来源:TestLike.subs.php

示例2: mergePosts

/**
 * Take a load of messages from one place and stick them in a topic.
 */
function mergePosts($msgs = array(), $from_topic, $target_topic)
{
    global $context, $smcFunc, $modSettings, $sourcedir;
    //!!! This really needs to be rewritten to take a load of messages from ANY topic, it's also inefficient.
    // Is it an array?
    if (!is_array($msgs)) {
        $msgs = array($msgs);
    }
    // Lets make sure they are int.
    foreach ($msgs as $key => $msg) {
        $msgs[$key] = (int) $msg;
    }
    // Get the source information.
    $request = $smcFunc['db_query']('', '
		SELECT t.id_board, t.id_first_msg, t.num_replies, t.unapproved_posts
		FROM {db_prefix}topics AS t
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
		WHERE t.id_topic = {int:from_topic}', array('from_topic' => $from_topic));
    list($from_board, $from_first_msg, $from_replies, $from_unapproved_posts) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // Get some target topic and board stats.
    $request = $smcFunc['db_query']('', '
		SELECT t.id_board, t.id_first_msg, t.num_replies, t.unapproved_posts, b.count_posts
		FROM {db_prefix}topics AS t
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
		WHERE t.id_topic = {int:target_topic}', array('target_topic' => $target_topic));
    list($target_board, $target_first_msg, $target_replies, $target_unapproved_posts, $count_posts) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // Lets see if the board that we are returning to has post count enabled.
    if (empty($count_posts)) {
        // Lets get the members that need their post count restored.
        $request = $smcFunc['db_query']('', '
			SELECT id_member
			FROM {db_prefix}messages
			WHERE id_msg IN ({array_int:messages})
				AND approved = {int:is_approved}', array('messages' => $msgs, 'is_approved' => 1));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            updateMemberData($row['id_member'], array('posts' => '+'));
        }
    }
    // Time to move the messages.
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}messages
		SET
			id_topic = {int:target_topic},
			id_board = {int:target_board},
			icon = {string:icon}
		WHERE id_msg IN({array_int:msgs})', array('target_topic' => $target_topic, 'target_board' => $target_board, 'icon' => $target_board == $modSettings['recycle_board'] ? 'recycled' : 'xx', 'msgs' => $msgs));
    // Fix the id_first_msg and id_last_msg for the target topic.
    $target_topic_data = array('num_replies' => 0, 'unapproved_posts' => 0, 'id_first_msg' => 9999999999);
    $request = $smcFunc['db_query']('', '
		SELECT MIN(id_msg) AS id_first_msg, MAX(id_msg) AS id_last_msg, COUNT(*) AS message_count, approved
		FROM {db_prefix}messages
		WHERE id_topic = {int:target_topic}
		GROUP BY id_topic, approved
		ORDER BY approved ASC
		LIMIT 2', array('target_topic' => $target_topic));
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) {
            $target_topic_data['id_first_msg'] = $row['id_first_msg'];
        }
        $target_topic_data['id_last_msg'] = $row['id_last_msg'];
        if (!$row['approved']) {
            $target_topic_data['unapproved_posts'] = $row['message_count'];
        } else {
            $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1);
        }
    }
    $smcFunc['db_free_result']($request);
    // We have a new post count for the board.
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}boards
		SET
			num_posts = num_posts + {int:diff_replies},
			unapproved_posts = unapproved_posts + {int:diff_unapproved_posts}
		WHERE id_board = {int:target_board}', array('diff_replies' => $target_topic_data['num_replies'] - $target_replies, 'diff_unapproved_posts' => $target_topic_data['unapproved_posts'] - $target_unapproved_posts, 'target_board' => $target_board));
    // In some cases we merged the only post in a topic so the topic data is left behind in the topic table.
    $request = $smcFunc['db_query']('', '
		SELECT id_topic
		FROM {db_prefix}messages
		WHERE id_topic = {int:from_topic}', array('from_topic' => $from_topic));
    // Remove the topic if it doesn't have any messages.
    $topic_exists = true;
    if ($smcFunc['db_num_rows']($request) == 0) {
        removeTopics($from_topic, false, true);
        $topic_exists = false;
    }
    $smcFunc['db_free_result']($request);
    // Recycled topic.
    if ($topic_exists == true) {
        // Fix the id_first_msg and id_last_msg for the source topic.
        $source_topic_data = array('num_replies' => 0, 'unapproved_posts' => 0, 'id_first_msg' => 9999999999);
        $request = $smcFunc['db_query']('', '
			SELECT MIN(id_msg) AS id_first_msg, MAX(id_msg) AS id_last_msg, COUNT(*) AS message_count, approved, subject
			FROM {db_prefix}messages
			WHERE id_topic = {int:from_topic}
			GROUP BY id_topic, approved
//.........这里部分代码省略.........
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:101,代码来源:RemoveTopic.php

示例3: deleteAccount2

function deleteAccount2($profile_vars, $post_errors, $memID)
{
    global $user_info, $sourcedir, $context, $cur_profile, $modSettings, $smcFunc;
    // Try get more time...
    @set_time_limit(600);
    // !!! Add a way to delete pms as well?
    if (!$context['user']['is_owner']) {
        isAllowedTo('profile_remove_any');
    } elseif (!allowedTo('profile_remove_any')) {
        isAllowedTo('profile_remove_own');
    }
    checkSession();
    $old_profile =& $cur_profile;
    // Too often, people remove/delete their own only account.
    if (in_array(1, explode(',', $old_profile['additional_groups'])) || $old_profile['id_group'] == 1) {
        // Are you allowed to administrate the forum, as they are?
        isAllowedTo('admin_forum');
        $request = $smcFunc['db_query']('', '
			SELECT id_member
			FROM {db_prefix}members
			WHERE (id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0)
				AND id_member != {int:selected_member}
			LIMIT 1', array('admin_group' => 1, 'selected_member' => $memID));
        list($another) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
        if (empty($another)) {
            fatal_lang_error('at_least_one_admin', 'critical');
        }
    }
    // This file is needed for the deleteMembers function.
    require_once $sourcedir . '/Subs-Members.php';
    // Do you have permission to delete others profiles, or is that your profile you wanna delete?
    if ($memID != $user_info['id']) {
        isAllowedTo('profile_remove_any');
        // Now, have you been naughty and need your posts deleting?
        // !!! Should this check board permissions?
        if ($_POST['remove_type'] != 'none' && allowedTo('moderate_forum')) {
            // Include RemoveTopics - essential for this type of work!
            require_once $sourcedir . '/RemoveTopic.php';
            // First off we delete any topics the member has started - if they wanted topics being done.
            if ($_POST['remove_type'] == 'topics') {
                // Fetch all topics started by this user within the time period.
                $request = $smcFunc['db_query']('', '
					SELECT t.id_topic
					FROM {db_prefix}topics AS t
					WHERE t.id_member_started = {int:selected_member}', array('selected_member' => $memID));
                $topicIDs = array();
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $topicIDs[] = $row['id_topic'];
                }
                $smcFunc['db_free_result']($request);
                // Actually remove the topics.
                // !!! This needs to check permissions, but we'll let it slide for now because of moderate_forum already being had.
                removeTopics($topicIDs);
            }
            // Now delete the remaining messages.
            $request = $smcFunc['db_query']('', '
				SELECT m.id_msg
				FROM {db_prefix}messages AS m
					INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic
						AND t.id_first_msg != m.id_msg)
				WHERE m.id_member = {int:selected_member}', array('selected_member' => $memID));
            // This could take a while... but ya know it's gonna be worth it in the end.
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                if (function_exists('apache_reset_timeout')) {
                    @apache_reset_timeout();
                }
                removeMessage($row['id_msg']);
            }
            $smcFunc['db_free_result']($request);
        }
        // Only delete this poor members account if they are actually being booted out of camp.
        if (isset($_POST['deleteAccount'])) {
            deleteMembers($memID);
        }
    } elseif (empty($post_errors) && !empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) {
        // Setup their account for deletion ;)
        updateMemberData($memID, array('is_activated' => 4));
        // Another account needs approval...
        updateSettings(array('unapprovedMembers' => true), true);
    } elseif (empty($post_errors)) {
        deleteMembers($memID);
        require_once $sourcedir . '/LogInOut.php';
        LogOut(true);
        redirectExit();
    }
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:87,代码来源:Profile-Actions.php

示例4: removeMessages

/**
 * Remove a batch of messages (or topics)
 *
 * @param int[] $messages
 * @param mixed[] $messageDetails
 * @param string $type = replies
 */
function removeMessages($messages, $messageDetails, $type = 'replies')
{
    global $modSettings;
    // @todo something's not right, removeMessage() does check permissions,
    // removeTopics() doesn't
    if ($type == 'topics') {
        removeTopics($messages);
        // and tell the world about it
        foreach ($messages as $topic) {
            // Note, only log topic ID in native form if it's not gone forever.
            logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$topic]['board'] ? 'topic' : 'old_topic_id' => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board']));
        }
    } else {
        require_once SUBSDIR . '/Messages.subs.php';
        foreach ($messages as $post) {
            removeMessage($post);
            logAction('delete', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$post]['board'] ? 'topic' : 'old_topic_id' => $messageDetails[$post]['topic'], 'subject' => $messageDetails[$post]['subject'], 'member' => $messageDetails[$post]['member'], 'board' => $messageDetails[$post]['board']));
        }
    }
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:27,代码来源:Topic.subs.php

示例5: mob_m_delete_topic

function mob_m_delete_topic($rpcmsg)
{
    global $mobdb, $context, $sourcedir, $topic, $board, $user_info;
    require_once $sourcedir . '/RemoveTopic.php';
    require_once $sourcedir . '/Subs-Post.php';
    $topicinfo = get_topicinfo($rpcmsg->getScalarValParam(0));
    if (empty($topicinfo)) {
        mob_error('topic not found');
    }
    $topic = $topicinfo['id_topic'];
    $board = $topicinfo['id_board'];
    loadBoard();
    loadPermissions();
    // Check for permissions
    if (!(allowedTo('remove_any') || $topicinfo['id_member_started'] == $user_info['id'] && allowedTo('remove_own'))) {
        mob_error('cannot remove topic');
    }
    // Remove the topic
    logAction('remove', array('topic' => $topic));
    sendNotifications($topic, 'remove');
    removeTopics(array($topic));
    return new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean')), 'struct'));
}
开发者ID:keweiliu6,项目名称:test_smf1,代码行数:23,代码来源:moderation.php

示例6: deleteBoards

function deleteBoards($boards_to_remove, $moveChildrenTo = null)
{
    global $sourcedir, $boards, $smcFunc;
    // No boards to delete? Return!
    if (empty($boards_to_remove)) {
        return;
    }
    getBoardTree();
    // If $moveChildrenTo is set to null, include the children in the removal.
    if ($moveChildrenTo === null) {
        // Get a list of the child boards that will also be removed.
        $child_boards_to_remove = array();
        foreach ($boards_to_remove as $board_to_remove) {
            recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
        }
        // Merge the children with their parents.
        if (!empty($child_boards_to_remove)) {
            $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
        }
    } else {
        foreach ($boards_to_remove as $id_board) {
            // !!! Separate category?
            if ($moveChildrenTo === 0) {
                fixChildren($id_board, 0, 0);
            } else {
                fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
            }
        }
    }
    // Delete ALL topics in the selected boards (done first so topics can't be marooned.)
    $request = $smcFunc['db_query']('', '
		SELECT id_topic
		FROM {db_prefix}topics
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    $topics = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $topics[] = $row['id_topic'];
    }
    $smcFunc['db_free_result']($request);
    require_once $sourcedir . '/RemoveTopic.php';
    removeTopics($topics, false);
    // Delete the board's logs.
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}log_mark_read
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}log_boards
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}log_notify
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    // Delete this board's moderators.
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}moderators
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    // Delete any extra events in the calendar.
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}calendar
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    // Delete any message icons that only appear on these boards.
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}message_icons
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    // Delete the boards.
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}boards
		WHERE id_board IN ({array_int:boards_to_remove})', array('boards_to_remove' => $boards_to_remove));
    // Latest message/topic might not be there anymore.
    updateStats('message');
    updateStats('topic');
    updateSettings(array('calendar_updated' => time()));
    // Plus reset the cache to stop people getting odd results.
    updateSettings(array('settings_updated' => time()));
    // Clean the cache as well.
    clean_cache('data');
    // Let's do some serious logging.
    foreach ($boards_to_remove as $id_board) {
        logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
    }
    reorderBoards();
}
开发者ID:valek0972,项目名称:hackits,代码行数:81,代码来源:Subs-Boards.php

示例7: deleteAccount2

function deleteAccount2($profile_vars, $post_errors, $memID)
{
    global $ID_MEMBER, $user_info, $sourcedir, $context, $db_prefix, $user_profile, $modSettings;
    // !!! Add a way to delete pms as well?
    if (!$context['user']['is_owner']) {
        isAllowedTo('profile_remove_any');
    } elseif (!allowedTo('profile_remove_any')) {
        isAllowedTo('profile_remove_own');
    }
    checkSession();
    $old_profile =& $user_profile[$memID];
    // Too often, people remove/delete their own only account.
    if (in_array(1, explode(',', $old_profile['additionalGroups'])) || $old_profile['ID_GROUP'] == 1) {
        // Are you allowed to administrate the forum, as they are?
        isAllowedTo('admin_forum');
        $request = db_query("\n\t\t\tSELECT ID_MEMBER\n\t\t\tFROM {$db_prefix}members\n\t\t\tWHERE (ID_GROUP = 1 OR FIND_IN_SET(1, additionalGroups))\n\t\t\t\tAND ID_MEMBER != {$memID}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
        list($another) = mysql_fetch_row($request);
        mysql_free_result($request);
        if (empty($another)) {
            fatal_lang_error('at_least_one_admin');
        }
    }
    // This file is needed for the deleteMembers function.
    require_once $sourcedir . '/Subs-Members.php';
    // Do you have permission to delete others profiles, or is that your profile you wanna delete?
    if ($memID != $ID_MEMBER) {
        isAllowedTo('profile_remove_any');
        // Now, have you been naughty and need your posts deleting?
        // !!! Should this check board permissions?
        if ($_POST['remove_type'] != 'none' && allowedTo('moderate_forum')) {
            // Include RemoveTopics - essential for this type of work!
            require_once $sourcedir . '/RemoveTopic.php';
            // First off we delete any topics the member has started - if they wanted topics being done.
            if ($_POST['remove_type'] == 'topics') {
                // Fetch all topics started by this user within the time period.
                $request = db_query("\n\t\t\t\t\tSELECT t.ID_TOPIC\n\t\t\t\t\tFROM {$db_prefix}topics AS t\n\t\t\t\t\tWHERE t.ID_MEMBER_STARTED = {$memID}", __FILE__, __LINE__);
                $topicIDs = array();
                while ($row = mysql_fetch_assoc($request)) {
                    $topicIDs[] = $row['ID_TOPIC'];
                }
                mysql_free_result($request);
                // Actually remove the topics.
                // !!! This needs to check permissions, but we'll let it slide for now because of moderate_forum already being had.
                removeTopics($topicIDs);
            }
            // Now delete the remaining messages.
            $request = db_query("\n\t\t\t\tSELECT m.ID_MSG\n\t\t\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)\n\t\t\t\tWHERE m.ID_MEMBER = {$memID}\n\t\t\t\t\tAND m.ID_TOPIC = t.ID_TOPIC\n\t\t\t\t\tAND t.ID_FIRST_MSG != m.ID_MSG", __FILE__, __LINE__);
            // This could take a while... but ya know it's gonna be worth it in the end.
            while ($row = mysql_fetch_assoc($request)) {
                removeMessage($row['ID_MSG']);
            }
            mysql_free_result($request);
        }
        // Only delete this poor members account if they are actually being booted out of camp.
        if (isset($_POST['deleteAccount'])) {
            deleteMembers($memID);
        }
    } elseif (empty($post_errors) && !empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) {
        // Setup their account for deletion ;)
        updateMemberData($memID, array('is_activated' => 4));
        // Another account needs approval...
        updateSettings(array('unapprovedMembers' => true), true);
    } elseif (empty($post_errors)) {
        deleteMembers($memID);
    }
}
开发者ID:alencarmo,项目名称:OCF,代码行数:66,代码来源:Profile.php

示例8: removeMessages

function removeMessages($messages, $messageDetails, $current_view = 'replies')
{
    global $sourcedir, $modSettings;
    require_once $sourcedir . '/RemoveTopic.php';
    if ($current_view == 'topics') {
        removeTopics($messages);
        // and tell the world about it
        foreach ($messages as $topic) {
            // Note, only log topic ID in native form if it's not gone forever.
            logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$topic]['board'] ? 'topic' : 'old_topic_id' => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board']));
        }
    } else {
        foreach ($messages as $post) {
            removeMessage($post);
            logAction('delete', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$post]['board'] ? 'topic' : 'old_topic_id' => $messageDetails[$post]['topic'], 'subject' => $messageDetails[$post]['subject'], 'member' => $messageDetails[$post]['member'], 'board' => $messageDetails[$post]['board']));
        }
    }
}
开发者ID:norv,项目名称:EosAlpha,代码行数:18,代码来源:PostModeration.php

示例9: removeMessage


//.........这里部分代码省略.........
        }
        if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) {
            isAllowedTo('approve_posts');
        }
    }
    // Delete the *whole* topic, but only if the topic consists of one message.
    if ($row['id_first_msg'] == $message) {
        if (empty($board) || $row['id_board'] != $board) {
            $remove_any = boardsAllowedTo('remove_any');
            $remove_any = in_array(0, $remove_any) || in_array($row['id_board'], $remove_any);
            if (!$remove_any) {
                $remove_own = boardsAllowedTo('remove_own');
                $remove_own = in_array(0, $remove_own) || in_array($row['id_board'], $remove_own);
            }
            if ($row['id_member'] != $user_info['id'] && !$remove_any) {
                fatal_lang_error('cannot_remove_any', 'permission');
            } elseif (!$remove_any && !$remove_own) {
                fatal_lang_error('cannot_remove_own', 'permission');
            }
        } else {
            // Check permissions to delete a whole topic.
            if ($row['id_member'] != $user_info['id']) {
                isAllowedTo('remove_any');
            } elseif (!allowedTo('remove_any')) {
                isAllowedTo('remove_own');
            }
        }
        // ...if there is only one post.
        if (!empty($row['num_replies'])) {
            fatal_lang_error('delFirstPost', false);
        }
        // This needs to be included for topic functions
        require_once SUBSDIR . '/Topic.subs.php';
        removeTopics($row['id_topic']);
        return true;
    }
    // Deleting a recycled message can not lower anyone's post count.
    if ($row['icon'] == 'recycled') {
        $decreasePostCount = false;
    }
    // This is the last post, update the last post on the board.
    if ($row['id_last_msg'] == $message) {
        // Find the last message, set it, and decrease the post count.
        $request = $db->query('', '
			SELECT id_msg, id_member
			FROM {db_prefix}messages
			WHERE id_topic = {int:id_topic}
				AND id_msg != {int:id_msg}
			ORDER BY ' . ($modSettings['postmod_active'] ? 'approved DESC, ' : '') . 'id_msg DESC
			LIMIT 1', array('id_topic' => $row['id_topic'], 'id_msg' => $message));
        $row2 = $db->fetch_assoc($request);
        $db->free_result($request);
        $db->query('', '
			UPDATE {db_prefix}topics
			SET
				id_last_msg = {int:id_last_msg},
				id_member_updated = {int:id_member_updated}' . (!$modSettings['postmod_active'] || $row['approved'] ? ',
				num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : ',
				unapproved_posts = CASE WHEN unapproved_posts = {int:no_unapproved} THEN 0 ELSE unapproved_posts - 1 END') . '
			WHERE id_topic = {int:id_topic}', array('id_last_msg' => $row2['id_msg'], 'id_member_updated' => $row2['id_member'], 'no_replies' => 0, 'no_unapproved' => 0, 'id_topic' => $row['id_topic']));
    } else {
        $db->query('', '
			UPDATE {db_prefix}topics
			SET ' . ($row['approved'] ? '
				num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : '
				unapproved_posts = CASE WHEN unapproved_posts = {int:no_unapproved} THEN 0 ELSE unapproved_posts - 1 END') . '
开发者ID:Ralkage,项目名称:Elkarte,代码行数:67,代码来源:Messages.subs.php

示例10: DeleteDownload

function DeleteDownload()
{
    global $boarddir, $user_info, $smcFunc, $sourcedir, $adkFolder;
    //Check the session
    checkSession('get');
    if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
        $id = (int) $_REQUEST['id'];
    } else {
        fatal_lang_error('adkfatal_require_id_file', false);
    }
    //Select some important info
    $sql = $smcFunc['db_query']('', '
		SELECT id_cat, id_member, id_topic
		FROM {db_prefix}adk_down_file
		WHERE id_file = {int:file}', array('file' => $id));
    $row = $smcFunc['db_fetch_assoc']($sql);
    $id_cat = $row['id_cat'];
    $id_topic = $row['id_topic'];
    $smcFunc['db_free_result']($sql);
    //mmm May be you don't have the right permissions to delete this.
    if ($user_info['id'] != $row['id_member'] && !allowedTo('adk_downloads_manage')) {
        fatal_lang_error('adkfatal_not_permission', false);
    }
    //Delete entry from adk_down_file
    deleteEntry('adk_down_file', 'id_file = {int:file}', array('file' => $id));
    //Let's load filenames
    $sql = $smcFunc['db_query']('', '
		SELECT filename FROM {db_prefix}adk_down_attachs
		WHERE id_file = {int:file}', array('file' => $id));
    //Unlink if file_exists
    while ($row = $smcFunc['db_fetch_assoc']($sql)) {
        if (file_exists($adkFolder['eds'] . '/' . $row['filename'])) {
            @unlink($adkFolder['eds'] . '/' . $row['filename']);
        }
    }
    //Delete attachs
    deleteEntry('adk_down_attachs', 'id_file = {int:file}', array('file' => $id));
    //Delete topic
    if (!empty($id_topic)) {
        //Load Main File to removeTopic
        require_once $sourcedir . '/RemoveTopic.php';
        //Ajam.... it's done
        removeTopics(array($id_topic));
    }
    //Update category
    TotalCategoryUpdate($id_cat);
    redirectexit('action=downloads;cat=' . $id_cat);
}
开发者ID:lucasruroken,项目名称:adkportal,代码行数:48,代码来源:Adk-Downloads.php

示例11: removeMessage

function removeMessage($message, $decreasePostCount = true)
{
    global $db_prefix, $board, $sourcedir, $modSettings, $ID_MEMBER, $user_info;
    if (empty($message) || !is_numeric($message)) {
        return false;
    }
    $request = db_query("\n\t\tSELECT\n\t\t\tm.ID_MEMBER, m.icon, m.posterTime, m.subject," . (empty($modSettings['search_custom_index_config']) ? '' : ' m.body,') . "\n\t\t\tt.ID_TOPIC, t.ID_FIRST_MSG, t.ID_LAST_MSG, t.numReplies, t.ID_BOARD,\n\t\t\tt.ID_MEMBER_STARTED AS ID_MEMBER_POSTER,\n\t\t\tb.countPosts\n\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)\n\t\tWHERE m.ID_MSG = {$message}\n\t\t\tAND t.ID_TOPIC = m.ID_TOPIC\n\t\t\tAND b.ID_BOARD = t.ID_BOARD\n\t\tLIMIT 1", __FILE__, __LINE__);
    if (mysql_num_rows($request) == 0) {
        return false;
    }
    $row = mysql_fetch_assoc($request);
    mysql_free_result($request);
    if (empty($board) || $row['ID_BOARD'] != $board) {
        $delete_any = boardsAllowedTo('delete_any');
        if (!in_array(0, $delete_any) && !in_array($row['ID_BOARD'], $delete_any)) {
            $delete_own = boardsAllowedTo('delete_own');
            $delete_own = in_array(0, $delete_own) || in_array($row['ID_BOARD'], $delete_own);
            $delete_replies = boardsAllowedTo('delete_replies');
            $delete_replies = in_array(0, $delete_replies) || in_array($row['ID_BOARD'], $delete_replies);
            if ($row['ID_MEMBER'] == $ID_MEMBER) {
                if (!$delete_own) {
                    if ($row['ID_MEMBER_POSTER'] == $ID_MEMBER) {
                        if (!$delete_replies) {
                            fatal_lang_error('cannot_delete_replies');
                        }
                    } else {
                        fatal_lang_error('cannot_delete_own');
                    }
                } elseif (($row['ID_MEMBER_POSTER'] != $ID_MEMBER || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['posterTime'] + $modSettings['edit_disable_time'] * 60 < time()) {
                    fatal_lang_error('modify_post_time_passed', false);
                }
            } elseif ($row['ID_MEMBER_POSTER'] == $ID_MEMBER) {
                if (!$delete_replies) {
                    fatal_lang_error('cannot_delete_replies');
                }
            } else {
                fatal_lang_error('cannot_delete_any');
            }
        }
    } else {
        // Check permissions to delete this message.
        if ($row['ID_MEMBER'] == $ID_MEMBER) {
            if (!allowedTo('delete_own')) {
                if ($row['ID_MEMBER_POSTER'] == $ID_MEMBER && !allowedTo('delete_any')) {
                    isAllowedTo('delete_replies');
                } elseif (!allowedTo('delete_any')) {
                    isAllowedTo('delete_own');
                }
            } elseif (!allowedTo('delete_any') && ($row['ID_MEMBER_POSTER'] != $ID_MEMBER || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['posterTime'] + $modSettings['edit_disable_time'] * 60 < time()) {
                fatal_lang_error('modify_post_time_passed', false);
            }
        } elseif ($row['ID_MEMBER_POSTER'] == $ID_MEMBER && !allowedTo('delete_any')) {
            isAllowedTo('delete_replies');
        } else {
            isAllowedTo('delete_any');
        }
    }
    // Delete the *whole* topic, but only if the topic consists of one message.
    if ($row['ID_FIRST_MSG'] == $message) {
        if (empty($board) || $row['ID_BOARD'] != $board) {
            $remove_any = boardsAllowedTo('remove_any');
            $remove_any = in_array(0, $remove_any) || in_array($row['ID_BOARD'], $remove_any);
            if (!$remove_any) {
                $remove_own = boardsAllowedTo('remove_own');
                $remove_own = in_array(0, $remove_own) || in_array($row['ID_BOARD'], $remove_own);
            }
            if ($row['ID_MEMBER'] != $ID_MEMBER && !$remove_any) {
                fatal_lang_error('cannot_remove_any');
            } elseif (!$remove_any && !$remove_own) {
                fatal_lang_error('cannot_remove_own');
            }
        } else {
            // Check permissions to delete a whole topic.
            if ($row['ID_MEMBER'] != $ID_MEMBER) {
                isAllowedTo('remove_any');
            } elseif (!allowedTo('remove_any')) {
                isAllowedTo('remove_own');
            }
        }
        // ...if there is only one post.
        if (!empty($row['numReplies'])) {
            fatal_lang_error('delFirstPost', false);
        }
        removeTopics($row['ID_TOPIC']);
        return true;
    }
    // Default recycle to false.
    $recycle = false;
    // If recycle topics has been set, make a copy of this message in the recycle board.
    // Make sure we're not recycling messages that are already on the recycle board.
    if (!empty($modSettings['recycle_enable']) && $row['ID_BOARD'] != $modSettings['recycle_board'] && $row['icon'] != 'recycled') {
        // Check if the recycle board exists and if so get the read status.
        $request = db_query("\n\t\t\tSELECT (IFNULL(lb.ID_MSG, 0) >= b.ID_MSG_UPDATED) AS isSeen\n\t\t\tFROM {$db_prefix}boards AS b\n\t\t\t\tLEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = {$ID_MEMBER})\n\t\t\tWHERE b.ID_BOARD = {$modSettings['recycle_board']}", __FILE__, __LINE__);
        if (mysql_num_rows($request) == 0) {
            fatal_lang_error('recycle_no_valid_board');
        }
        list($isRead) = mysql_fetch_row($request);
        mysql_free_result($request);
        // Insert a new topic in the recycle board.
        db_query("\n\t\t\tINSERT INTO {$db_prefix}topics\n\t\t\t\t(ID_BOARD, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_FIRST_MSG, ID_LAST_MSG)\n\t\t\tVALUES ({$modSettings['recycle_board']}, {$row['ID_MEMBER']}, {$row['ID_MEMBER']}, {$message}, {$message})", __FILE__, __LINE__);
//.........这里部分代码省略.........
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:RemoveTopic.php

示例12: deleteBoards

function deleteBoards($boards_to_remove, $moveChildrenTo = null)
{
    global $db_prefix, $sourcedir, $boards, $modSettings;
    // No boards to delete? Return!
    if (empty($boards_to_remove)) {
        return;
    }
    getBoardTree();
    // If $moveChildrenTo is set to null, include the children in the removal.
    if ($moveChildrenTo === null) {
        // Get a list of the child boards that will also be removed.
        $child_boards_to_remove = array();
        foreach ($boards_to_remove as $board_to_remove) {
            recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
        }
        // Merge the children with their parents.
        if (!empty($child_boards_to_remove)) {
            $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
        }
    } else {
        foreach ($boards_to_remove as $id_board) {
            // !!! Separate category?
            if ($moveChildrenTo === 0) {
                fixChildren($id_board, 0, 0);
            } else {
                fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
            }
        }
    }
    // Delete ALL topics in the selected boards (done first so topics can't be marooned.)
    $request = db_query("\n\t\tSELECT ID_TOPIC\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    $topics = array();
    while ($row = mysql_fetch_assoc($request)) {
        $topics[] = $row['ID_TOPIC'];
    }
    mysql_free_result($request);
    require_once $sourcedir . '/RemoveTopic.php';
    removeTopics($topics, false);
    // Delete the board's logs.
    db_query("\n\t\tDELETE FROM {$db_prefix}log_mark_read\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    db_query("\n\t\tDELETE FROM {$db_prefix}log_boards\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    db_query("\n\t\tDELETE FROM {$db_prefix}log_notify\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    // Delete this board's moderators.
    db_query("\n\t\tDELETE FROM {$db_prefix}moderators\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    // Delete any extra events in the calendar.
    db_query("\n\t\tDELETE FROM {$db_prefix}calendar\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    // Delete any permissions associated with these boards.
    db_query("\n\t\tDELETE FROM {$db_prefix}board_permissions\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    // Delete any message icons that only appear on these boards.
    db_query("\n\t\tDELETE FROM {$db_prefix}message_icons\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ')', __FILE__, __LINE__);
    // Delete the boards.
    db_query("\n\t\tDELETE FROM {$db_prefix}boards\n\t\tWHERE ID_BOARD IN (" . implode(', ', $boards_to_remove) . ")\n\t\tLIMIT " . count($boards_to_remove), __FILE__, __LINE__);
    // Latest message/topic might not be there anymore.
    updateStats('message');
    updateStats('topic');
    updateStats('calendar');
    // Did they by chance delete the recycle board?  If so deal with that!
    if (!empty($modSettings['recycle_board']) && in_array($modSettings['recycle_board'], $boards_to_remove)) {
        updateSettings(array('recycle_board' => 0, 'recycle_enable' => 0));
    }
    reorderBoards();
}
开发者ID:alencarmo,项目名称:OCF,代码行数:62,代码来源:Subs-Boards.php

示例13: remove_topic_redirect

    /**
     * Check for move topic notices that have past their best by date:
     *
     * - remove them if the time has expired.
     */
    public function remove_topic_redirect()
    {
        $db = database();
        // Init
        $topics = array();
        // We will need this for lanaguage files
        loadEssentialThemeData();
        // Find all of the old MOVE topic notices that were set to expire
        $request = $db->query('', '
			SELECT id_topic
			FROM {db_prefix}topics
			WHERE redirect_expires <= {int:redirect_expires}
				AND redirect_expires <> 0', array('redirect_expires' => time()));
        while ($row = $db->fetch_row($request)) {
            $topics[] = $row[0];
        }
        $db->free_result($request);
        // Zap, you're gone
        if (count($topics) > 0) {
            require_once SUBSDIR . '/Topic.subs.php';
            removeTopics($topics, false, true);
        }
        return true;
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:29,代码来源:ScheduledTask.class.php

示例14: QuickModeration


//.........这里部分代码省略.........
                $smcFunc['db_free_result']($request);
                // And now update them member's post counts
                foreach ($members as $id_member => $post_adj) {
                    updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
                }
            }
        }
    }
    // Now delete the topics...
    if (!empty($removeCache)) {
        // They can only delete their own topics. (we wouldn't be here if they couldn't do that..)
        $result = $smcFunc['db_query']('', '
			SELECT id_topic, id_board
			FROM {db_prefix}topics
			WHERE id_topic IN ({array_int:removed_topic_ids})' . (!empty($board) && !allowedTo('remove_any') ? '
				AND id_member_started = {int:current_member}' : '') . '
			LIMIT ' . count($removeCache), array('current_member' => $user_info['id'], 'removed_topic_ids' => $removeCache));
        $removeCache = array();
        $removeCacheBoards = array();
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $removeCache[] = $row['id_topic'];
            $removeCacheBoards[$row['id_topic']] = $row['id_board'];
        }
        $smcFunc['db_free_result']($result);
        // Maybe *none* were their own topics.
        if (!empty($removeCache)) {
            // Gotta send the notifications *first*!
            foreach ($removeCache as $topic) {
                // Only log the topic ID if it's not in the recycle board.
                logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $removeCacheBoards[$topic] ? 'topic' : 'old_topic_id' => $topic, 'board' => $removeCacheBoards[$topic]));
                sendNotifications($topic, 'remove');
            }
            require_once $sourcedir . '/RemoveTopic.php';
            removeTopics($removeCache);
        }
    }
    // Approve the topics...
    if (!empty($approveCache)) {
        // We need unapproved topic ids and their authors!
        $request = $smcFunc['db_query']('', '
			SELECT id_topic, id_member_started
			FROM {db_prefix}topics
			WHERE id_topic IN ({array_int:approve_topic_ids})
				AND approved = {int:not_approved}
			LIMIT ' . count($approveCache), array('approve_topic_ids' => $approveCache, 'not_approved' => 0));
        $approveCache = array();
        $approveCacheMembers = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $approveCache[] = $row['id_topic'];
            $approveCacheMembers[$row['id_topic']] = $row['id_member_started'];
        }
        $smcFunc['db_free_result']($request);
        // Any topics to approve?
        if (!empty($approveCache)) {
            // Handle the approval part...
            approveTopics($approveCache);
            // Time for some logging!
            foreach ($approveCache as $topic) {
                logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
            }
        }
    }
    // And (almost) lastly, lock the topics...
    if (!empty($lockCache)) {
        $lockStatus = array();
        // Gotta make sure they CAN lock/unlock these topics...
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:67,代码来源:MessageIndex.php

示例15: UnapprovedPosts

function UnapprovedPosts()
{
    global $txt, $scripturl, $context, $user_info, $sourcedir, $smcFunc;
    $context['current_view'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? 'topics' : 'replies';
    $context['page_title'] = $txt['mc_unapproved_posts'];
    // Work out what boards we can work in!
    $approve_boards = boardsAllowedTo('approve_posts');
    // If we filtered by board remove ones outside of this board.
    //!!! Put a message saying we're filtered?
    if (isset($_REQUEST['brd'])) {
        $filter_board = array((int) $_REQUEST['brd']);
        $approve_boards = $approve_boards == array(0) ? $filter_board : array_intersect($approve_boards, $filter_board);
    }
    if ($approve_boards == array(0)) {
        $approve_query = '';
    } elseif (!empty($approve_boards)) {
        $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
    } else {
        $approve_query = ' AND 0';
    }
    // We also need to know where we can delete topics and/or replies to.
    if ($context['current_view'] == 'topics') {
        $delete_own_boards = boardsAllowedTo('remove_own');
        $delete_any_boards = boardsAllowedTo('remove_any');
        $delete_own_replies = array();
    } else {
        $delete_own_boards = boardsAllowedTo('delete_own');
        $delete_any_boards = boardsAllowedTo('delete_any');
        $delete_own_replies = boardsAllowedTo('delete_own_replies');
    }
    $toAction = array();
    // Check if we have something to do?
    if (isset($_GET['approve'])) {
        $toAction[] = (int) $_GET['approve'];
    } elseif (isset($_GET['delete'])) {
        $toAction[] = (int) $_GET['delete'];
    } elseif (isset($_POST['item'])) {
        foreach ($_POST['item'] as $item) {
            $toAction[] = (int) $item;
        }
    }
    // What are we actually doing.
    if (isset($_GET['approve']) || isset($_POST['do']) && $_POST['do'] == 'approve') {
        $curAction = 'approve';
    } elseif (isset($_GET['delete']) || isset($_POST['do']) && $_POST['do'] == 'delete') {
        $curAction = 'delete';
    }
    // Right, so we have something to do?
    if (!empty($toAction) && isset($curAction)) {
        checkSession('request');
        // Handy shortcut.
        $any_array = $curAction == 'approve' ? $approve_boards : $delete_any_boards;
        // Now for each message work out whether it's actually a topic, and what board it's on.
        $request = $smcFunc['db_query']('', '
			SELECT m.id_msg, m.id_member, m.id_board, t.id_topic, t.id_first_msg, t.id_member_started
			FROM {db_prefix}messages AS m
				INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
			WHERE m.id_msg IN ({array_int:message_list})
				AND m.approved = {int:not_approved}
				AND {query_see_board}', array('message_list' => $toAction, 'not_approved' => 0));
        $toAction = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            // If it's not within what our view is ignore it...
            if ($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics' || $row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies') {
                continue;
            }
            $can_add = false;
            // If we're approving this is simple.
            if ($curAction == 'approve' && ($any_array == array(0) || in_array($row['id_board'], $any_array))) {
                $can_add = true;
            } elseif ($curAction == 'delete') {
                // Own post is easy!
                if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) {
                    $can_add = true;
                } elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) {
                    $can_add = true;
                } elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) {
                    $can_add = true;
                }
            }
            if ($can_add) {
                $toAction[] = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg'];
            }
        }
        $smcFunc['db_free_result']($request);
        // If we have anything left we can actually do the approving (etc).
        if (!empty($toAction)) {
            if ($curAction == 'approve') {
                require_once $sourcedir . '/Subs-Post.php';
                if ($context['current_view'] == 'topics') {
                    approveTopics($toAction);
                } else {
                    approvePosts($toAction);
                }
            } else {
                require_once $sourcedir . '/RemoveTopic.php';
                if ($context['current_view'] == 'topics') {
                    removeTopics($toAction);
                } else {
//.........这里部分代码省略.........
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:PostModeration.php


注:本文中的removeTopics函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。