小组发帖要用的 forum_id
160738
def forum_id(self):
        """"""
        html = self.request(self.team_url).text
        soup = BeautifulSoup(html)
        return soup.find(id='forum_id').attrs['value']
653030
def get_unread_forums(self, user):
        
        return self.get_unread_forums_from_list(
            user, self.perm_handler.get_readable_forums(Forum.objects.all(), user))
599434
public function communityIdToSteamId($community_id, $is_short = FALSE)
    {
        $temp = intval($community_id) - 76561197960265728;
        $odd_id = $temp % 2;
        $temp = floor($temp / 2);
        if ($is_short) {
            return $odd_id . ':' . $temp;
        } else {
            return 'STEAM_0:' . $odd_id . ':' . $temp;
        }
    }
1358567
public function getForumActions($forum_id, $subscriptions, $is_subscribed)
    {
        $forum_actions = [];

        $forum_actions = Container::get('hooks')
            ->fire('model.forum.get_page_head_start', $forum_actions, $forum_id, $subscriptions, $is_subscribed);

        if (!User::get()->is_guest) {
            if ($subscriptions == 1) {
                if ($is_subscribed) {
                    $forum_actions[] = '<span>'.__('Is subscribed').
                        ' - </span><a class="btn btn-primary btn-sm" href="'.
                        Router::pathFor('unsubscribeForum', ['id' => $forum_id]).'">'.__('Unsubscribe').'</a>';
                } else {
                    $forum_actions[] = '<a class="btn btn-primary btn-sm" href="'.
                        Router::pathFor('subscribeForum', ['id' => $forum_id]).'">'.__('Subscribe').'</a>';
                }
            }

            $forum_actions[] = '<a class="btn btn-primary btn-sm" href="'.
                Router::pathFor('markForumRead', ['id' => $forum_id]).'">'.__('Mark forum read').'</a>';
        }

        $forum_actions = Container::get('hooks')->fire('model.forum.get_page_head', $forum_actions);

        return $forum_actions;
    }
1262
def get_forum_url(self):
        
        return reverse('forum:forum', kwargs={'slug': self.forum.slug, 'pk': self.forum.pk})
1034175
public static function get_forum_access_information($forumid) {
        global $DB;

        $params = self::validate_parameters(self::get_forum_access_information_parameters(), array('forumid' => $forumid));

        // Request and permission validation.
        $forum = $DB->get_record('forum', array('id' => $params['forumid']), '*', MUST_EXIST);
        $cm = get_coursemodule_from_instance('forum', $forum->id);

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        $result = array();
        // Return all the available capabilities.
        $capabilities = load_capability_def('mod_forum');
        foreach ($capabilities as $capname => $capdata) {
            // Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.
            $field = 'can' . str_replace('mod/forum:', '', $capname);
            $result[$field] = has_capability($capname, $context);
        }

        $result['warnings'] = array();
        return $result;
    }
451928
def from_forums(cls, forums):
        
        root_level = None
        current_path = []
        nodes = []

        # Ensures forums last posts and related poster relations are "followed" for better
        # performance (only if we're considering a queryset).
        forums = (
            forums.select_related('last_post', 'last_post__poster')
            if isinstance(forums, QuerySet) else forums
        )

        for forum in forums:
            level = forum.level

            # Set the root level to the top node level at the first iteration.
            if root_level is None:
                root_level = level

            # Initializes a visibility forum node associated with current forum instance.
            vcontent_node = ForumVisibilityContentNode(forum)

            # Computes a relative level associated to the node.
            relative_level = level - root_level
            vcontent_node.relative_level = relative_level

            # All children nodes will be stored in an array attached to the current node.
            vcontent_node.children = []

            # Removes the forum that are not in the current branch.
            while len(current_path) > relative_level:
                current_path.pop(-1)

            if level != root_level:
                # Update the parent of the current forum.
                parent_node = current_path[-1]
                vcontent_node.parent = parent_node
                parent_node.children.append(vcontent_node)

            # Sets visible flag if applicable. The visible flag is used to determine whether a forum
            # can be seen in a forum list or not. A forum can be seen if one of the following
            # statements is true:
            #
            # * the forum is a direct child of the starting forum for the considered level
            # * the forum have a parent which is a category and this category is a direct child of
            #   the starting forum
            # * the forum have its 'display_sub_forum_list' option set to True and have a parent
            #   which is another forum. The latter is a direct child of the starting forum
            # * the forum have its 'display_sub_forum_list' option set to True and have a parent
            #   which is another forum. The later have a parent which is a category and this
            #   category is a direct child of the starting forum
            #
            # If forums at the root level don't have parents, the visible forums are those that can
            # be seen from the root of the forums tree.
            vcontent_node.visible = (
                (relative_level == 0) or
                (forum.display_sub_forum_list and relative_level == 1) or
                (forum.is_category and relative_level == 1) or
                (
                    relative_level == 2 and
                    vcontent_node.parent.parent.obj.is_category and
                    vcontent_node.parent.obj.is_forum
                )
            )

            # Add the current forum to the end of the current branch and inserts the node inside the
            # final node dictionary.
            current_path.append(vcontent_node)
            nodes.append(vcontent_node)

        tree = cls(nodes=nodes)
        for node in tree.nodes:
            node.tree = tree

        return tree
789157
public function actionDeletepoll($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $poll = Poll::find()->joinWith('thread')->where([
            Poll::tableName() . '.id' => $pid,
            Poll::tableName() . '.thread_id' => $tid,
            Thread::tableName() . '.category_id' => $cid,
            Thread::tableName() . '.forum_id' => $fid,
        ])->limit(1)->one();
        if (empty($poll)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the poll you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($poll->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $poll->thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $poll->thread->category_id,
                'fid' => $poll->thread->forum_id,
                'id' => $poll->thread->id,
                'slug' => $poll->thread->slug
            ]);
        }

        if ($poll->author_id != User::loggedId() && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $poll->thread])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $postData = Yii::$app->request->post('poll');
        if ($postData) {
            if ($postData != $poll->id) {
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the poll.'));
            } else {
                if ($poll->podiumDelete()) {
                    $this->success(Yii::t('podium/flash', 'Poll has been deleted.'));
                    return $this->redirect([
                        'forum/thread',
                        'cid' => $poll->thread->category_id,
                        'fid' => $poll->thread->forum_id,
                        'id' => $poll->thread->id,
                        'slug' => $poll->thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the poll.'));
            }
        }

        return $this->render('deletepoll', ['model' => $poll]);
    }
417430
def get_success_url(self):
        
        return '{0}?post={1}#{1}'.format(
            reverse(
                'forum_conversation:topic',
                kwargs={
                    'forum_slug': self.forum_post.topic.forum.slug,
                    'forum_pk': self.forum_post.topic.forum.pk,
                    'slug': self.forum_post.topic.slug,
                    'pk': self.forum_post.topic.pk,
                },
            ),
            self.forum_post.pk,
        )
770189
public function actionDeleteposts($cid = null, $fid = null, $id = null, $slug = null)
    {
        $thread = (new ThreadVerifier([
            'categoryId' => $cid,
            'forumId' => $fid,
            'threadId' => $id,
            'threadSlug' => $slug
        ]))->verify();
        if (empty($thread)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the thread you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if (!User::can(Rbac::PERM_DELETE_POST, ['item' => $thread])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $posts = Yii::$app->request->post('post');
        if ($posts) {
            if (!is_array($posts)) {
                $this->error(Yii::t('podium/flash', 'You have to select at least one post.'));
            } else {
                if ($thread->podiumDeletePosts($posts)) {
                    $this->success(Yii::t('podium/flash', 'Posts have been deleted.'));
                    if (Thread::find()->where(['id' => $thread->id])->exists()) {
                        return $this->redirect([
                            'forum/thread',
                            'cid' => $thread->forum->category->id,
                            'fid' => $thread->forum->id,
                            'id' => $thread->id,
                            'slug' => $thread->slug
                        ]);
                    }
                    return $this->redirect([
                        'forum',
                        'cid' => $thread->forum->category->id,
                        'id' => $thread->forum->id,
                        'slug' => $thread->forum->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the posts.'));
            }
        }
        return $this->render('deleteposts', [
            'model' => $thread,
            'dataProvider' => (new Post())->search($thread->forum->id, $thread->id)
        ]);
    }
934703
def permlink(self, identifier):
        ''' 
        '''
        temp = identifier.split("@")
        temp2 = temp[1].split("/")
        return [temp2[0], temp2[1]]
1323808
public static function get_forum_discussions_parameters() {
        return new external_function_parameters (
            array(
                'forumid' => new external_value(PARAM_INT, 'forum instance id', VALUE_REQUIRED),
                'sortorder' => new external_value(PARAM_INT,
                    'sort by this element: numreplies, , created or timemodified', VALUE_DEFAULT, -1),
                'page' => new external_value(PARAM_INT, 'current page', VALUE_DEFAULT, -1),
                'perpage' => new external_value(PARAM_INT, 'items per page', VALUE_DEFAULT, 0),
                'groupid' => new external_value(PARAM_INT, 'group id', VALUE_DEFAULT, 0),
            )
        );
    }
1056473
public static function verify($categoryId = null, $forumId = null, $threadId = null, $id = null)
    {
        if (!is_numeric($categoryId) || $categoryId < 1
                || !is_numeric($forumId) || $forumId < 1
                || !is_numeric($threadId) || $threadId < 1
                || !is_numeric($id) || $id < 1) {
            return null;
        }
        return static::find()->joinWith(['thread', 'forum' => function ($query) use ($categoryId) {
                $query->joinWith(['category'])->andWhere([Category::tableName() . '.id' => $categoryId]);
            }])->where([
                static::tableName() . '.id' => $id,
                static::tableName() . '.thread_id' => $threadId,
                static::tableName() . '.forum_id' => $forumId,
            ])->limit(1)->one();
    }
118743
def get_object(self, request, *args, **kwargs):
        
        forum_pk = kwargs.get('forum_pk', None)
        descendants = kwargs.get('descendants', None)
        self.user = request.user

        if forum_pk:
            forum = get_object_or_404(Forum, pk=forum_pk)
            forums_qs = (
                forum.get_descendants(include_self=True)
                if descendants else Forum.objects.filter(pk=forum_pk)
            )
            self.forums = request.forum_permission_handler.get_readable_forums(
                forums_qs, request.user,
            )
        else:
            self.forums = request.forum_permission_handler.get_readable_forums(
                Forum.objects.all(), request.user,
            )
1293551
def moveforum_view(self, request, forum_id, direction):
        
        forum = get_object_or_404(Forum, pk=forum_id)

        # Fetch the target
        target, position = None, None
        if direction == 'up':
            target, position = forum.get_previous_sibling(), 'left'
        elif direction == 'down':
            target, position = forum.get_next_sibling(), 'right'

        # Do the move
        try:
            assert target is not None
            forum.move_to(target, position)
        except (InvalidMove, AssertionError):
            pass
        self.message_user(request, _("'{}' forum successfully moved").format(forum.name))
        return HttpResponseRedirect(reverse('admin:forum_forum_changelist'))
683951
public static function lastActive()
    {
        $last = Podium::getInstance()->podiumCache->get('forum.lastactive');
        if ($last === false) {
            $time = time() - 15 * 60;
            $last = [
                'count' => static::find()->where(['>', 'updated_at', $time])->count(),
                'members' => static::find()->where(['and',
                        ['>', 'updated_at', $time],
                        ['is not', 'user_id', null],
                        ['anonymous' => 0]
                    ])->count(),
                'anonymous' => static::find()->where(['and',
                        ['>', 'updated_at', $time],
                        ['is not', 'user_id', null],
                        ['anonymous' => 1]
                    ])->count(),
                'guests' => static::find()->where(['and',
                        ['>', 'updated_at', $time],
                        ['user_id' => null]
                    ])->count(),
                'names' => [],
            ];
            $members = static::find()->where(['and',
                    ['>', 'updated_at', $time],
                    ['is not', 'user_id', null],
                    ['anonymous' => 0]
                ]);
            foreach ($members->each() as $member) {
                $last['names'][$member->user_id] = [
                    'name' => $member->username,
                    'role' => $member->user_role,
                    'slug' => $member->user_slug,
                ];
            }
            Podium::getInstance()->podiumCache->set('forum.lastactive', $last, 60);
        }
        return $last;
    }
25911
private Long getUserIdArg(Object[] arguments) {
        if (arguments.length <= USER_ID_INDEX) {
            log.error("Illegal number of args: " + arguments.length);
        }
        return (Long) arguments[USER_ID_INDEX];
    }