Example #1
0
    function open()
    {
        // Check if forum exists
        $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options
			FROM ' . FORUMS_TABLE . '
			WHERE forum_id = ' . $this->forum_id;
        $result = $this->db->sql_query($sql);
        $this->forum_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($this->forum_data)) {
            trigger_error('NO_FORUM');
        }
        // Forum needs to be postable
        if ($this->forum_data['forum_type'] != FORUM_POST) {
            trigger_error('NO_FEED');
        }
        // Make sure forum is not excluded from feed
        if (src_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options'])) {
            trigger_error('NO_FEED');
        }
        // Make sure we can read this forum
        if (!$this->auth->acl_get('f_read', $this->forum_id)) {
            trigger_error('SORRY_AUTH_READ');
        }
        // Make sure forum is not passworded or user is authed
        if ($this->forum_data['forum_password']) {
            $forum_ids_passworded = $this->get_passworded_forums();
            if (isset($forum_ids_passworded[$this->forum_id])) {
                trigger_error('SORRY_AUTH_READ');
            }
            unset($forum_ids_passworded);
        }
        parent::open();
    }
Example #2
0
    function open()
    {
        $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . FORUMS_TABLE . ' f
				ON (f.forum_id = t.forum_id)
			WHERE t.topic_id = ' . $this->topic_id;
        $result = $this->db->sql_query($sql);
        $this->topic_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($this->topic_data)) {
            trigger_error('NO_TOPIC');
        }
        $this->forum_id = (int) $this->topic_data['forum_id'];
        // Make sure topic is either approved or user authed
        if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id)) {
            trigger_error('SORRY_AUTH_READ');
        }
        // Make sure forum is not excluded from feed
        if (src_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) {
            trigger_error('NO_FEED');
        }
        // Make sure we can read this forum
        if (!$this->auth->acl_get('f_read', $this->forum_id)) {
            trigger_error('SORRY_AUTH_READ');
        }
        // Make sure forum is not passworded or user is authed
        if ($this->topic_data['forum_password']) {
            $forum_ids_passworded = $this->get_passworded_forums();
            if (isset($forum_ids_passworded[$this->forum_id])) {
                trigger_error('SORRY_AUTH_READ');
            }
            unset($forum_ids_passworded);
        }
        parent::open();
    }