/** * {@inheritdoc} */ public 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)) { throw new no_forum_exception($this->forum_id); } // Forum needs to be postable if ($this->forum_data['forum_type'] != FORUM_POST) { throw new no_feed_exception(); } // Make sure forum is not excluded from feed if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options'])) { throw new no_feed_exception(); } // Make sure we can read this forum if (!$this->auth->acl_get('f_read', $this->forum_id)) { throw new unauthorized_forum_exception($this->forum_id); } // 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])) { throw new unauthorized_forum_exception($this->forum_id); } unset($forum_ids_passworded); } parent::open(); }
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 (phpbb_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(); }
/** * {@inheritdoc} */ public 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)) { throw new no_topic_exception($this->topic_id); } $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)) { if ($this->user->data['user_id'] != ANONYMOUS) { send_status_line(403, 'Forbidden'); } else { send_status_line(401, 'Unauthorized'); } throw new unauthorized_topic_exception($this->topic_id); } // Make sure forum is not excluded from feed if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) { throw new no_feed_exception(); } // Make sure we can read this forum if (!$this->auth->acl_get('f_read', $this->forum_id)) { if ($this->user->data['user_id'] != ANONYMOUS) { send_status_line(403, 'Forbidden'); } else { send_status_line(401, 'Unauthorized'); } throw new unauthorized_forum_exception($this->forum_id); } // 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])) { if ($this->user->data['user_id'] != ANONYMOUS) { send_status_line(403, 'Forbidden'); } else { send_status_line(401, 'Unauthorized'); } throw new unauthorized_forum_exception($this->forum_id); } unset($forum_ids_passworded); } parent::open(); }