• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP move_topics函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mcp_move_topic

/**
* Move Topic
*/
function mcp_move_topic($topic_ids)
{
    global $auth, $user, $db, $template, $phpbb_log, $request;
    global $phpEx, $phpbb_root_path;
    // Here we limit the operation to one forum only
    $forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true);
    if ($forum_id === false) {
        return;
    }
    $to_forum_id = $request->variable('to_forum_id', 0);
    $redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));
    $additional_msg = $success_msg = '';
    $s_hidden_fields = build_hidden_fields(array('topic_id_list' => $topic_ids, 'f' => $forum_id, 'action' => 'move', 'redirect' => $redirect));
    if ($to_forum_id) {
        $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');
        if (!sizeof($forum_data)) {
            $additional_msg = $user->lang['FORUM_NOT_EXIST'];
        } else {
            $forum_data = $forum_data[$to_forum_id];
            if ($forum_data['forum_type'] != FORUM_POST) {
                $additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
            } else {
                if (!$auth->acl_get('f_post', $to_forum_id) || !$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)) {
                    $additional_msg = $user->lang['USER_CANNOT_POST'];
                } else {
                    if ($forum_id == $to_forum_id) {
                        $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM'];
                    }
                }
            }
        }
    } else {
        if (isset($_POST['confirm'])) {
            $additional_msg = $user->lang['FORUM_NOT_EXIST'];
        }
    }
    if (!$to_forum_id || $additional_msg) {
        $request->overwrite('confirm', null, \phpbb\request\request_interface::POST);
        $request->overwrite('confirm_key', null);
    }
    if (confirm_box(true)) {
        $topic_data = phpbb_get_topic_data($topic_ids);
        $leave_shadow = isset($_POST['move_leave_shadow']) ? true : false;
        $forum_sync_data = array();
        $forum_sync_data[$forum_id] = current($topic_data);
        $forum_sync_data[$to_forum_id] = $forum_data;
        $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0;
        $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0;
        foreach ($topic_data as $topic_id => $topic_info) {
            if ($topic_info['topic_visibility'] == ITEM_APPROVED) {
                $topics_moved++;
            } else {
                if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) {
                    $topics_moved_unapproved++;
                } else {
                    if ($topic_info['topic_visibility'] == ITEM_DELETED) {
                        $topics_moved_softdeleted++;
                    }
                }
            }
            $posts_moved += $topic_info['topic_posts_approved'];
            $posts_moved_unapproved += $topic_info['topic_posts_unapproved'];
            $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted'];
        }
        $db->sql_transaction('begin');
        // Move topics, but do not resync yet
        move_topics($topic_ids, $to_forum_id, false);
        if ($request->is_set_post('move_lock_topics') && $auth->acl_get('m_lock', $to_forum_id)) {
            $sql = 'UPDATE ' . TOPICS_TABLE . '
				SET topic_status = ' . ITEM_LOCKED . '
				WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
            $db->sql_query($sql);
        }
        $shadow_topics = 0;
        $forum_ids = array($to_forum_id);
        foreach ($topic_data as $topic_id => $row) {
            // Get the list of forums to resync
            $forum_ids[] = $row['forum_id'];
            // We add the $to_forum_id twice, because 'forum_id' is updated
            // when the topic is moved again later.
            $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MOVE', false, array('forum_id' => (int) $to_forum_id, 'topic_id' => (int) $topic_id, $row['forum_name'], $forum_data['forum_name'], (int) $row['forum_id'], (int) $forum_data['forum_id']));
            // Leave a redirection if required and only if the topic is visible to users
            if ($leave_shadow && $row['topic_visibility'] == ITEM_APPROVED && $row['topic_type'] != POST_GLOBAL) {
                $shadow = array('forum_id' => (int) $row['forum_id'], 'icon_id' => (int) $row['icon_id'], 'topic_attachment' => (int) $row['topic_attachment'], 'topic_visibility' => ITEM_APPROVED, 'topic_reported' => 0, 'topic_title' => (string) $row['topic_title'], 'topic_poster' => (int) $row['topic_poster'], 'topic_time' => (int) $row['topic_time'], 'topic_time_limit' => (int) $row['topic_time_limit'], 'topic_views' => (int) $row['topic_views'], 'topic_posts_approved' => (int) $row['topic_posts_approved'], 'topic_posts_unapproved' => (int) $row['topic_posts_unapproved'], 'topic_posts_softdeleted' => (int) $row['topic_posts_softdeleted'], 'topic_status' => ITEM_MOVED, 'topic_type' => POST_NORMAL, 'topic_first_post_id' => (int) $row['topic_first_post_id'], 'topic_first_poster_colour' => (string) $row['topic_first_poster_colour'], 'topic_first_poster_name' => (string) $row['topic_first_poster_name'], 'topic_last_post_id' => (int) $row['topic_last_post_id'], 'topic_last_poster_id' => (int) $row['topic_last_poster_id'], 'topic_last_poster_colour' => (string) $row['topic_last_poster_colour'], 'topic_last_poster_name' => (string) $row['topic_last_poster_name'], 'topic_last_post_subject' => (string) $row['topic_last_post_subject'], 'topic_last_post_time' => (int) $row['topic_last_post_time'], 'topic_last_view_time' => (int) $row['topic_last_view_time'], 'topic_moved_id' => (int) $row['topic_id'], 'topic_bumped' => (int) $row['topic_bumped'], 'topic_bumper' => (int) $row['topic_bumper'], 'poll_title' => (string) $row['poll_title'], 'poll_start' => (int) $row['poll_start'], 'poll_length' => (int) $row['poll_length'], 'poll_max_options' => (int) $row['poll_max_options'], 'poll_last_vote' => (int) $row['poll_last_vote']);
                $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
                // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts
                $shadow_topics++;
            }
        }
        unset($topic_data);
        $sync_sql = array();
        if ($posts_moved) {
            $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved;
            $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved;
        }
        if ($posts_moved_unapproved) {
            $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved;
//.........这里部分代码省略.........
开发者ID:tqangxl,项目名称:phpbb,代码行数:101,代码来源:mcp_main.php


示例2: main


//.........这里部分代码省略.........
                            }
                            if ($forum_info['forum_type'] != FORUM_POST) {
                                trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
                            }
                            // Two stage?
                            // Move topics comprising only posts from this user
                            $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
                            $forum_id_ary = array($new_forum_id);
                            $sql = 'SELECT topic_id, post_visibility, COUNT(post_id) AS total_posts
								FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id, post_visibility";
                            $result = $db->sql_query($sql);
                            while ($row = $db->sql_fetchrow($result)) {
                                $topic_id_ary[$row['topic_id']][$row['post_visibility']] = $row['total_posts'];
                            }
                            $db->sql_freeresult($result);
                            if (sizeof($topic_id_ary)) {
                                $sql = 'SELECT topic_id, forum_id, topic_title, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_attachment
									FROM ' . TOPICS_TABLE . '
									WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) {
                                        $move_topic_ary[] = $row['topic_id'];
                                    } else {
                                        $move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
                                        $move_post_ary[$row['topic_id']]['attach'] = $row['topic_attachment'] ? 1 : 0;
                                    }
                                    $forum_id_ary[] = $row['forum_id'];
                                }
                                $db->sql_freeresult($result);
                            }
                            // Entire topic comprises posts by this user, move these topics
                            if (sizeof($move_topic_ary)) {
                                move_topics($move_topic_ary, $new_forum_id, false);
                            }
                            if (sizeof($move_post_ary)) {
                                // Create new topic
                                // Update post_ids, report_ids, attachment_ids
                                foreach ($move_post_ary as $topic_id => $post_ary) {
                                    // Create new topic
                                    $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array('topic_poster' => $user_id, 'topic_time' => time(), 'forum_id' => $new_forum_id, 'icon_id' => 0, 'topic_visibility' => ITEM_APPROVED, 'topic_title' => $post_ary['title'], 'topic_first_poster_name' => $user_row['username'], 'topic_type' => POST_NORMAL, 'topic_time_limit' => 0, 'topic_attachment' => $post_ary['attach']));
                                    $db->sql_query($sql);
                                    $new_topic_id = $db->sql_nextid();
                                    // Move posts
                                    $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                    $db->sql_query($sql);
                                    if ($post_ary['attach']) {
                                        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                        $db->sql_query($sql);
                                    }
                                    $new_topic_id_ary[] = $new_topic_id;
                                }
                            }
                            $forum_id_ary = array_unique($forum_id_ary);
                            $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary));
                            if (sizeof($topic_id_ary)) {
                                sync('topic_reported', 'topic_id', $topic_id_ary);
                                sync('topic', 'topic_id', $topic_id_ary);
                            }
                            if (sizeof($forum_id_ary)) {
                                sync('forum', 'forum_id', $forum_id_ary, false, true);
                            }
                            $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS', false, array($user_row['username'], $forum_info['forum_name']));
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS_USER', false, array('reportee_id' => $user_id, $forum_info['forum_name']));
                            trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
开发者ID:bantu,项目名称:phpbb,代码行数:67,代码来源:acp_users.php


示例3: phpbb_com_move_queue_topic

function phpbb_com_move_queue_topic($queue_object)
{
    $sql = 'SELECT phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . (int) $queue_object->queue_topic_id;
    $result = phpbb::$db->sql_query($sql);
    $row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    if (!$row['phpbb_topic_id']) {
        return;
    }
    phpbb::_include('functions_admin', 'move_topics');
    move_topics($row['phpbb_topic_id'], phpbb_com_forum_id($row['topic_category'], 'trash'));
}
开发者ID:Gfksx,项目名称:customisation-db,代码行数:13,代码来源:_hook_phpbb.com.php


示例4: main


//.........这里部分代码省略.........
                                $this->page_title = 'USER_ADMIN_MOVE_POSTS';
                                $template->assign_vars(array('S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&amp;action={$action}&amp;u={$user_id}", 'U_BACK' => $this->u_action . "&amp;u={$user_id}", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)));
                                return;
                            }
                            // Two stage?
                            // Move topics comprising only posts from this user
                            $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
                            $forum_id_ary = array($new_forum_id);
                            $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
								FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id";
                            $result = $db->sql_query($sql);
                            while ($row = $db->sql_fetchrow($result)) {
                                $topic_id_ary[$row['topic_id']] = $row['total_posts'];
                            }
                            $db->sql_freeresult($result);
                            if (sizeof($topic_id_ary)) {
                                $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real
									FROM ' . TOPICS_TABLE . '
									WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
                                        $move_topic_ary[] = $row['topic_id'];
                                    } else {
                                        $move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
                                        $move_post_ary[$row['topic_id']]['attach'] = $row['attach'] ? 1 : 0;
                                    }
                                    $forum_id_ary[] = $row['forum_id'];
                                }
                                $db->sql_freeresult($result);
                            }
                            // Entire topic comprises posts by this user, move these topics
                            if (sizeof($move_topic_ary)) {
                                move_topics($move_topic_ary, $new_forum_id, false);
                            }
                            if (sizeof($move_post_ary)) {
                                // Create new topic
                                // Update post_ids, report_ids, attachment_ids
                                foreach ($move_post_ary as $topic_id => $post_ary) {
                                    // Create new topic
                                    $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array('topic_poster' => $user_id, 'topic_time' => time(), 'forum_id' => $new_forum_id, 'icon_id' => 0, 'topic_approved' => 1, 'topic_title' => $post_ary['title'], 'topic_first_poster_name' => $user_row['username'], 'topic_type' => POST_NORMAL, 'topic_time_limit' => 0, 'topic_attachment' => $post_ary['attach']));
                                    $db->sql_query($sql);
                                    $new_topic_id = $db->sql_nextid();
                                    // Move posts
                                    $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                    $db->sql_query($sql);
                                    if ($post_ary['attach']) {
                                        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                        $db->sql_query($sql);
                                    }
                                    $new_topic_id_ary[] = $new_topic_id;
                                }
                            }
                            $forum_id_ary = array_unique($forum_id_ary);
                            $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary));
                            if (sizeof($topic_id_ary)) {
                                sync('reported', 'topic_id', $topic_id_ary);
                                sync('topic', 'topic_id', $topic_id_ary);
                            }
                            if (sizeof($forum_id_ary)) {
                                sync('forum', 'forum_id', $forum_id_ary);
                            }
                            $sql = 'SELECT forum_name
								FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}";
                            $result = $db->sql_query($sql, 3600);
                            $forum_info = $db->sql_fetchrow($result);
开发者ID:yunsite,项目名称:gloryroad,代码行数:67,代码来源:acp_users.php


示例5: move_topics

    /**
     * Moves topics to a new forum after they have been locked
     *
     * @param array $topic_data
     * @param string $action
     */
    public function move_topics($topic_data, $action)
    {
        $first_topic_data = reset($topic_data);
        $is_enabled = (int) $first_topic_data[$action];
        $to_forum_id = (int) $first_topic_data['move_topics_when_locked_to'];
        /**
         * This event allows you to perform additional actions before locked topics are moved.
         *
         * @event kasimi.movetopicswhenlocked.move_topics_before
         * @var	array	topic_data		Array with general topic data
         * @var	string	action			Who triggered the forums to be moved, one of move_topics_when_locked|move_topics_when_locked_solved
         * @var int		is_enabled		Whether or not the forum's ACP settings specify the topics to be moved
         * @var int		to_forum_id		The destination forum
         * @since 1.0.2
         */
        $vars = array('topic_data', 'action', 'is_enabled', 'to_forum_id');
        extract($this->dispatcher->trigger_event('kasimi.movetopicswhenlocked.move_topics_before', compact($vars)));
        // Forum settings are set to not move the topics
        if (!$is_enabled || !$to_forum_id) {
            return;
        }
        $forum_id = (int) $first_topic_data['forum_id'];
        // The topics are already in the destination forum
        if ($forum_id == $to_forum_id) {
            return;
        }
        if (!function_exists('phpbb_get_forum_data')) {
            include $this->root_path . 'includes/functions_mcp.' . $this->php_ext;
        }
        $to_forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');
        // The destination forum does not exist
        if (empty($to_forum_data)) {
            return;
        }
        // The following code is taken from the mcp_move_topic() function in /includes/mpc/mcp_main.php
        $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0;
        $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0;
        foreach ($topic_data as $topic_id => $topic_info) {
            if ($topic_info['topic_visibility'] == ITEM_APPROVED) {
                $topics_moved++;
            } else {
                if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) {
                    $topics_moved_unapproved++;
                } else {
                    if ($topic_info['topic_visibility'] == ITEM_DELETED) {
                        $topics_moved_softdeleted++;
                    }
                }
            }
            $posts_moved += $topic_info['topic_posts_approved'];
            $posts_moved_unapproved += $topic_info['topic_posts_unapproved'];
            $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted'];
        }
        $this->db->sql_transaction('begin');
        if (!function_exists('move_topics')) {
            include $this->root_path . 'includes/functions_admin.' . $this->php_ext;
        }
        // Move topics, but do not resync yet
        move_topics(array_keys($topic_data), $to_forum_id, false);
        foreach ($topic_data as $topic_id => $row) {
            // We add the $to_forum_id twice, because 'forum_id' is updated
            // when the topic is moved again later.
            $this->log->add('mod', $this->user->data['user_id'], $this->user->ip, 'LOG_MOVED_LOCKED_TOPIC', false, array('forum_id' => (int) $to_forum_id, 'topic_id' => (int) $topic_id, $row['topic_title'], $row['forum_name'], $to_forum_data[$to_forum_id]['forum_name']));
        }
        $sync_sql = array();
        if ($posts_moved) {
            $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved;
            $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved;
        }
        if ($posts_moved_unapproved) {
            $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved;
            $sync_sql[$forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved - ' . (int) $posts_moved_unapproved;
        }
        if ($posts_moved_softdeleted) {
            $sync_sql[$to_forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted + ' . (int) $posts_moved_softdeleted;
            $sync_sql[$forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted - ' . (int) $posts_moved_softdeleted;
        }
        if ($topics_moved) {
            $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved;
            if ($topics_moved > 0) {
                $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) $topics_moved;
            }
        }
        if ($topics_moved_unapproved) {
            $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved;
            $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved;
        }
        if ($topics_moved_softdeleted) {
            $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted;
            $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted;
        }
        foreach ($sync_sql as $forum_id_key => $array) {
            $sql = 'UPDATE ' . FORUMS_TABLE . '
				SET ' . implode(', ', $array) . '
//.........这里部分代码省略.........
开发者ID:kasimi,项目名称:phpbb-ext-movetopicswhenlocked,代码行数:101,代码来源:topic_mover.php


示例6: main


//.........这里部分代码省略.........
							while ($row = $db->sql_fetchrow($result))
							{
								$topic_id_ary[$row['topic_id']] = $row['total_posts'];
							}
							$db->sql_freeresult($result);

							if (sizeof($topic_id_ary))
							{
								$sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment
									FROM ' . TOPICS_TABLE . '
									WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
								$result = $db->sql_query($sql);

								while ($row = $db->sql_fetchrow($result))
								{
									if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
									{
										$move_topic_ary[] = $row['topic_id'];
									}
									else
									{
										$move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
										$move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0;
									}

									$forum_id_ary[] = $row['forum_id'];
								}
								$db->sql_freeresult($result);
							}

							// Entire topic comprises posts by this user, move these topics
							if (sizeof($move_topic_ary))
							{
								move_topics($move_topic_ary, $new_forum_id, false);
							}

							if (sizeof($move_post_ary))
							{
								// Create new topic
								// Update post_ids, report_ids, attachment_ids
								foreach ($move_post_ary as $topic_id => $post_ary)
								{
									// Create new topic
									$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
										'topic_poster'				=> $user_id,
										'topic_time'				=> time(),
										'forum_id' 					=> $new_forum_id,
										'icon_id'					=> 0,
										'topic_approved'			=> 1,
										'topic_title' 				=> $post_ary['title'],
										'topic_first_poster_name'	=> $user_row['username'],
										'topic_type'				=> POST_NORMAL,
										'topic_time_limit'			=> 0,
										'topic_attachment'			=> $post_ary['attach'])
									);
									$db->sql_query($sql);

									$new_topic_id = $db->sql_nextid();

									// Move posts
									$sql = 'UPDATE ' . POSTS_TABLE . "
										SET forum_id = $new_forum_id, topic_id = $new_topic_id
										WHERE topic_id = $topic_id
											AND poster_id = $user_id";
									$db->sql_query($sql);
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:66,代码来源:acp_users.php


示例7: mcp_move_topic

/**
* Move Topic
*/
function mcp_move_topic($topic_ids)
{
    global $auth, $user, $db, $template;
    global $phpEx, $phpbb_root_path;
    // Here we limit the operation to one forum only
    $forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true);
    if ($forum_id === false) {
        return;
    }
    $to_forum_id = request_var('to_forum_id', 0);
    $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
    $additional_msg = $success_msg = '';
    $s_hidden_fields = build_hidden_fields(array('topic_id_list' => $topic_ids, 'f' => $forum_id, 'action' => 'move', 'redirect' => $redirect));
    if ($to_forum_id) {
        $forum_data = get_forum_data($to_forum_id, 'f_post');
        if (!sizeof($forum_data)) {
            $additional_msg = $user->lang['FORUM_NOT_EXIST'];
        } else {
            $forum_data = $forum_data[$to_forum_id];
            if ($forum_data['forum_type'] != FORUM_POST) {
                $additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
            } else {
                if (!$auth->acl_get('f_post', $to_forum_id) || !$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)) {
                    $additional_msg = $user->lang['USER_CANNOT_POST'];
                } else {
                    if ($forum_id == $to_forum_id) {
                        $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM'];
                    }
                }
            }
        }
    } else {
        if (isset($_POST['confirm'])) {
            $additional_msg = $user->lang['FORUM_NOT_EXIST'];
        }
    }
    if (!$to_forum_id || $additional_msg) {
        unset($_POST['confirm']);
        unset($_REQUEST['confirm_key']);
    }
    if (confirm_box(true)) {
        $topic_data = get_topic_data($topic_ids);
        $leave_shadow = isset($_POST['move_leave_shadow']) ? true : false;
        $forum_sync_data = array();
        $forum_sync_data[$forum_id] = current($topic_data);
        $forum_sync_data[$to_forum_id] = $forum_data;
        // Real topics added to target forum
        $topics_moved = sizeof($topic_data);
        // Approved topics added to target forum
        $topics_authed_moved = 0;
        // Posts (topic replies + topic post if approved) added to target forum
        $topic_posts_added = 0;
        // Posts (topic replies + topic post if approved and not global announcement) removed from source forum
        $topic_posts_removed = 0;
        // Real topics removed from source forum (all topics without global announcements)
        $topics_removed = 0;
        // Approved topics removed from source forum (except global announcements)
        $topics_authed_removed = 0;
        foreach ($topic_data as $topic_id => $topic_info) {
            if ($topic_info['topic_approved']) {
                $topics_authed_moved++;
                $topic_posts_added++;
            }
            $topic_posts_added += $topic_info['topic_replies'];
            if ($topic_info['topic_type'] != POST_GLOBAL) {
                $topics_removed++;
                $topic_posts_removed += $topic_info['topic_replies'];
                if ($topic_info['topic_approved']) {
                    $topics_authed_removed++;
                    $topic_posts_removed++;
                }
            }
        }
        $db->sql_transaction('begin');
        $sync_sql = array();
        if ($topic_posts_added) {
            $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $topic_posts_added;
        }
        if ($topics_authed_moved) {
            $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved;
        }
        $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved;
        // Move topics, but do not resync yet
        move_topics($topic_ids, $to_forum_id, false);
        $forum_ids = array($to_forum_id);
        foreach ($topic_data as $topic_id => $row) {
            // Get the list of forums to resync, add a log entry
            $forum_ids[] = $row['forum_id'];
            add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']);
            // If we have moved a global announcement, we need to correct the topic type
            if ($row['topic_type'] == POST_GLOBAL) {
                $sql = 'UPDATE ' . TOPICS_TABLE . '
					SET topic_type = ' . POST_ANNOUNCE . '
					WHERE topic_id = ' . (int) $row['topic_id'];
                $db->sql_query($sql);
            }
            // Leave a redirection if required and only if the topic is visible to users
//.........这里部分代码省略.........
开发者ID:danielheyman,项目名称:EazySubs,代码行数:101,代码来源:mcp_main.php


示例8: move

 function move($forum_id)
 {
     move_topics($this->topic_id, $forum_id);
     $this->forum_id = $forum_id;
     foreach ($this->posts as $post) {
         $post->forum_id = $forum_id;
     }
 }
开发者ID:gn36,项目名称:phpbb-oo-posting-api,代码行数:8,代码来源:functions_post_oo.php


示例9: mcp_move_topic

/**
* Move Topic
*/
function mcp_move_topic($topic_ids)
{
    global $auth, $user, $db, $template;
    global $phpEx, $phpbb_root_path;
    if (!($forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', 'm_move'))) {
        return;
    }
    $to_forum_id = request_var('to_forum_id', 0);
    $redirect = request_var('redirect', $user->data['session_page']);
    $additional_msg = $success_msg = '';
    $s_hidden_fields = build_hidden_fields(array('topic_id_list' => $topic_ids, 'f' => $forum_id, 'action' => 'move', 'redirect' => $redirect));
    if ($to_forum_id) {
        $forum_data = get_forum_data($to_forum_id);
        if (!sizeof($forum_data)) {
            $additional_msg = $user->lang['FORUM_NOT_EXIST'];
        } else {
            $forum_data = $forum_data[$to_forum_id];
            if ($forum_data['forum_type'] != FORUM_POST) {
                $additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
            } else {
                if (!$auth->acl_get('f_post', $to_forum_id)) {
                    $additional_msg = $user->lang['USER_CANNOT_POST'];
                } else {
                    if ($forum_id == $to_forum_id) {
                        $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM'];
                    }
                }
            }
        }
    }
    if (!$to_forum_id || $additional_msg) {
        unset($_POST['confirm']);
    }
    if (confirm_box(true)) {
        $topic_data = get_topic_data($topic_ids);
        $leave_shadow = isset($_POST['move_leave_shadow']) ? true : false;
        // Move topics, but do not resync yet
        move_topics($topic_ids, $to_forum_id, false);
        $forum_ids = array($to_forum_id);
        foreach ($topic_data as $topic_id => $row) {
            // Get the list of forums to resync, add a log entry
            $forum_ids[] = $row['forum_id'];
            add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name']);
            // Leave a redirection if required and only if the topic is visible to users
            if ($leave_shadow && $row['topic_approved']) {
                $shadow = array('forum_id' => (int) $row['forum_id'], 'icon_id' => (int) $row['icon_id'], 'topic_attachment' => (int) $row['topic_attachment'], 'topic_approved' => 1, 'topic_reported' => (int) $row['topic_reported'], 'topic_title' => (string) $row['topic_title'], 'topic_poster' => (int) $row['topic_poster'], 'topic_time' => (int) $row['topic_time'], 'topic_time_limit' => (int) $row['topic_time_limit'], 'topic_views' => (int) $row['topic_views'], 'topic_replies' => (int) $row['topic_replies'], 'topic_replies_real' => (int) $row['topic_replies_real'], 'topic_status' => ITEM_MOVED, 'topic_type' => (int) $row['topic_type'], 'topic_first_post_id' => (int) $row['topic_first_post_id'], 'topic_first_poster_name' => (string) $row['topic_first_poster_name'], 'topic_last_post_id' => (int) $row['topic_last_post_id'], 'topic_last_poster_id' => (int) $row['topic_last_poster_id'], 'topic_last_poster_name' => (string) $row['topic_last_poster_name'], 'topic_last_post_time' => (int) $row['topic_last_post_time'], 'topic_last_view_time' => (int) $row['topic_last_view_time'], 'topic_moved_id' => (int) $row['topic_id'], 'topic_bumped' => (int) $row['topic_bumped'], 'topic_bumper' => (int) $row['topic_bumper'], 'poll_title' => (string) $row['poll_title'], 'poll_start' => (int) $row['poll_start'], 'poll_length' => (int) $row['poll_length'], 'poll_max_options' => (int) $row['poll_max_options'], 'poll_last_vote' => (int) $row['poll_last_vote']);
                $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
            }
        }
        unset($topic_data);
        // Now sync forums
        sync('forum', 'forum_id', $forum_ids);
        $success_msg = sizeof($topic_ids) == 1 ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
    } else {
        $template->assign_vars(array('S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true), 'S_CAN_LEAVE_SHADOW' => true, 'ADDITIONAL_MSG' => $additional_msg));
        confirm_box(false, 'MOVE_TOPIC' . (sizeof($topic_ids) == 1 ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
    }
    $redirect = request_var('redirect', "index.{$phpEx}");
    $redirect = reapply_sid($redirect);
    if (!$success_msg) {
        redirect($redirect);
    } else {
        meta_refresh(3, $redirect);
        $message = $user->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}") . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$to_forum_id}") . '">', '</a>');
        trigger_error($message);
    }
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:73,代码来源:mcp_main.php


示例10: mcp_trash_topic

function mcp_trash_topic($trash_forum, $forum_id, $topic_id)
{
    global $auth, $user, $db, $template, $config;
    global $phpEx, $phpbb_root_path;
    move_topics($topic_id, $trash_forum[0], true);
    add_log('mod', $trash_forum, $topic_id, 'LOG_TRASH');
    $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
    $additional_msg = $success_msg = '';
    $success_msg = sizeof($topic_id) == 1 ? 'TOPIC_TRASHED_SUCCESS' : 'TOPIC_TRASHED_SUCCESS';
    meta_refresh(3, $redirect);
    $message = $user->lang[$success_msg];
    trigger_error($message);
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:13,代码来源:mcp_main.php


示例11: mcp_move_topic

function mcp_move_topic($topic_ids)
{
    global $_CLASS;
    $old_forums = check_ids($topic_ids, FORUMS_TOPICS_TABLE, 'topic_id', 'm_move');
    if (!$old_forums) {
        return;
    }
    $redirect = get_variable('redirect', 'POST', $_CLASS['core_user']->data['session_url']);
    $to_forum_id = get_variable('to_forum_id', 'POST', 0, 'int');
    $additional_msg = $success_msg = '';
    if ($to_forum_id) {
        $forum_data = get_forum_data($to_forum_id, 'm_');
        if (empty($forum_data[$to_forum_id])) {
            $additional_msg = $_CLASS['core_user']->lang['FORUM_NOT_EXIST'];
            $to_forum_id = 0;
        } else {
            $forum_data = $forum_data[$to_forum_id];
            if ($forum_data['forum_type'] != FORUM_POST) {
                $additional_msg = $_CLASS['core_user']->lang['FORUM_NOT_POSTABLE'];
            } elseif (!$_CLASS['auth']->acl_get('f_post', $to_forum_id)) {
                $additional_msg = $_CLASS['core_user']->lang['USER_CANNOT_POST'];
            } elseif (in_array($to_forum_id, $old_forums)) {
                $additional_msg = $_CLASS['core_user']->lang['CANNOT_MOVE_SAME_FORUM'];
            }
        }
    }
    if (!$to_forum_id || $additional_msg) {
        unset($_POST['confirm']);
    }
    $hidden_fields = generate_hidden_fields(array('topic_id_list' => $topic_ids, 'mode' => 'move', 'redirect' => $redirect));
    $_CLASS['core_template']->assign_array(array('S_FORUM_SELECT' => make_forum_select($to_forum_id, $old_forums, false, true, true), 'S_CAN_LEAVE_SHADOW' => true, 'ADDITIONAL_MSG' => $additional_msg));
    $message = $_CLASS['core_user']->get_lang('MOVE_TOPIC' . (count($topic_ids) === 1 ? '' : 'S'));
    page_header();
    if (display_confirmation($message, $hidden_fields, 'modules/Forums/mcp_move.html')) {
        $topic_data = get_topic_data($topic_ids);
        $leave_shadow = isset($_POST['move_leave_shadow']);
        // Move topics, but do not resync yet
        move_topics($topic_ids, $to_forum_id, false);
        $_CLASS['core_db']->transaction();
        $forum_ids = array($to_forum_id);
        $shadow = array();
        foreach ($topic_data as $topic_id => $row) {
            // Get the list of forums to resync, add a log entry
            $forum_ids[] = $row['forum_id'];
            add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name']);
            // Leave a redirection if required and only if the topic is visible to users
            if ($leave_shadow && $row['topic_approved']) {
                $shadow[] = array('forum_id' => (int) $row['forum_id'], 'icon_id' => (int) $row['icon_id'], 'topic_attachment' => (int) $row['topic_attachment'], 'topic_approved' => 1, 'topic_reported' => (int) $row['topic_reported'], 'topic_title' => (string) $row['topic_title'], 'topic_poster' => (int) $row['topic_poster'], 'topic_time' => (int) $row['topic_time'], 'topic_time_limit' => (int) $row['topic_time_limit'], 'topic_views' => (int) $row['topic_views'], 'topic_replies' => (int) $row['topic_replies'], 'topic_replies_real' => (int) $row['topic_replies_real'], 'topic_status' => ITEM_MOVED, 'topic_type' => (int) $row['topic_type'], 'topic_first_post_id' => (int) $row['topic_first_post_id'], 'topic_first_poster_name' => (string) $row['topic_first_poster_name'], 'topic_last_post_id' => (int) $row['topic_last_post_id'], 'topic_last_poster_id' => (int) $row['topic_last_poster_id'], 'topic_last_poster_name' => (string) $row['topic_last_poster_name'], 'topic_last_post_time' => (int) $row['topic_last_post_time'], 'topic_last_view_time' => (int) $row['topic_last_view_time'], 'topic_moved_id' => (int) $row['topic_id'], 'topic_bumped' => (int) $row['topic_bumped'], 'topic_bumper' => (int) $row['topic_bumper'], 'poll_title' => (string) $row['poll_title'], 'poll_start' => (int) $row['poll_start'], 'poll_length' => (int) $row['poll_length'], 'poll_max_options' => (int) $row['poll_max_options'], 'poll_last_vote' => (int) $row['poll_last_vote']);
            }
        }
        $_CLASS['core_db']->sql_query_build('MULTI_INSERT', $shadow, FORUMS_TOPICS_TABLE);
        $_CLASS['core_db']->transaction('commit');
        unset($topic_data, $shadow);
        // Now sync forums
        sync('forum', 'forum_id', $forum_ids);
        $success_msg = count($topic_ids) === 1 ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
    }
    $redirect = generate_link($redirect);
    if (!$success_msg) {
        redirect($redirect);
    } else {
        $_CLASS['core_display']->meta_refresh(3, $redirect);
        $message = $_CLASS['core_user']->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_FORUM'], '<a href="' . generate_link('Forums&amp;file=viewforum&amp;f=' . $to_forum_id) . '">', '</a>');
        $message .= '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_NEW_FORUM'], '<a href=' . generate_link('Forums&amp;file=viewforum&amp;f=' . $to_forum_id) . '">', '</a>');
        trigger_error($message);
    }
}
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:69,代码来源:mcp_main.php


示例12: mcp_lock_unlock_after

    /**
     * Event: core.mcp_lock_unlock_after
     */
    public function mcp_lock_unlock_after($event)
    {
        if ($event['action'] == 'lock') {
            $topic_ids = $event['ids'];
            $topic_id = (int) current($topic_ids);
            $topic_data = $event['data'];
            $forum_id = (int) $topic_data[$topic_id]['forum_id'];
            $to_forum_id = (int) $topic_data[$topic_id]['move_topics_to'];
            $forum_data = phpbb_get_forum_data($to_forum_id);
            $to_forum_name = $forum_data[$to_forum_id]['forum_name'];
            $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0;
            foreach ($topic_data as $topic_id => $topic_info) {
                if ($topic_info['topic_visibility'] == ITEM_APPROVED) {
                    $topics_moved++;
                } else {
                    if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) {
                        $topics_moved_unapproved++;
                    } else {
                        if ($topic_info['topic_visibility'] == ITEM_DELETED) {
                            $topics_moved_softdeleted++;
                        }
                    }
                }
            }
            $this->db->sql_transaction('begin');
            // Move topics, but do not resync yet
            if (!function_exists('move_topics')) {
                include $this->root_path . 'includes/functions_admin.' . $this->php_ext;
            }
            move_topics($topic_ids, $to_forum_id, false);
            foreach ($topic_data as $topic_id => $row) {
                // We add the $to_forum_id twice, because 'forum_id' is updated
                // when the topic is moved again later.
                $this->log->add('mod', $this->user->data['user_id'], $this->user->ip, 'LOG_MOVED_LOCKED_TOPIC', false, array('forum_id' => $to_forum_id, 'topic_id' => $topic_id, $row['topic_title'], $row['forum_name'], $to_forum_name));
            }
            unset($topic_data);
            $sync_sql = array();
            if ($topics_moved) {
                $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved;
                if ($topics_moved > 0) {
                    $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) $topics_moved;
                }
            }
            if ($topics_moved_unapproved) {
                $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved;
                $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved;
            }
            if ($topics_moved_softdeleted) {
                $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted;
                $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted;
            }
            foreach ($sync_sql as $forum_id_key => $array) {
                $sql = 'UPDATE ' . FORUMS_TABLE . '
					SET ' . implode(', ', $array) . '
					WHERE forum_id = ' . $forum_id_key;
                $this->db->sql_query($sql);
            }
            $this->db->sql_transaction('commit');
            sync('forum', 'forum_id', array($forum_id, $to_forum_id));
        }
    }
开发者ID:phpbb-es,项目名称:phpbb-ext-movetopicswhenlocked,代码行数:64,代码来源:listener.php


示例13: delete_topics

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP move_upload_file函数代码示例发布时间:2022-05-15
下一篇:
PHP move_section_to函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap