Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

forum.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 4.35 KiB


001  <?php
002  /**
003   *
004   * This file is part of the phpBB Forum Software package.
005   *
006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
007   * @license GNU General Public License, version 2 (GPL-2.0)
008   *
009   * For full copyright and license information, please see
010   * the docs/CREDITS.txt file.
011   *
012   */
013   
014  namespace phpbb\feed;
015   
016  use phpbb\feed\exception\no_feed_exception;
017  use phpbb\feed\exception\no_forum_exception;
018  use phpbb\feed\exception\unauthorized_forum_exception;
019   
020  /**
021   * Forum feed
022   *
023   * This will give you the last {$this->num_items} posts made
024   * within a specific forum.
025   */
026  class forum extends post_base
027  {
028      protected $forum_id        = 0;
029      protected $forum_data    = array();
030   
031      /**
032       * Set the Forum ID
033       *
034       * @param int    $forum_id            Forum ID
035       * @return    \phpbb\feed\forum
036       */
037      public function set_forum_id($forum_id)
038      {
039          $this->forum_id = (int) $forum_id;
040   
041          return $this;
042      }
043   
044      /**
045       * {@inheritdoc}
046       */
047      public function open()
048      {
049          // Check if forum exists
050          $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options
051              FROM ' . FORUMS_TABLE . '
052              WHERE forum_id = ' . $this->forum_id;
053          $result = $this->db->sql_query($sql);
054          $this->forum_data = $this->db->sql_fetchrow($result);
055          $this->db->sql_freeresult($result);
056   
057          if (empty($this->forum_data))
058          {
059              throw new no_forum_exception($this->forum_id);
060          }
061   
062          // Forum needs to be postable
063          if ($this->forum_data['forum_type'] != FORUM_POST)
064          {
065              throw new no_feed_exception();
066          }
067   
068          // Make sure forum is not excluded from feed
069          if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options']))
070          {
071              throw new no_feed_exception();
072          }
073   
074          // Make sure we can read this forum
075          if (!$this->auth->acl_get('f_read', $this->forum_id))
076          {
077              if ($this->user->data['user_id'] != ANONYMOUS)
078              {
079                  send_status_line(403, 'Forbidden');
080              }
081              else
082              {
083                  send_status_line(401, 'Unauthorized');
084              }
085              throw new unauthorized_forum_exception($this->forum_id);
086          }
087   
088          // Make sure forum is not passworded or user is authed
089          if ($this->forum_data['forum_password'])
090          {
091              $forum_ids_passworded = $this->get_passworded_forums();
092   
093              if (isset($forum_ids_passworded[$this->forum_id]))
094              {
095                  if ($this->user->data['user_id'] != ANONYMOUS)
096                  {
097                      send_status_line(403, 'Forbidden');
098                  }
099                  else
100                  {
101                      send_status_line(401, 'Unauthorized');
102                  }
103                  throw new unauthorized_forum_exception($this->forum_id);
104              }
105   
106              unset($forum_ids_passworded);
107          }
108   
109          parent::open();
110      }
111   
112      /**
113       * {@inheritdoc}
114       */
115      protected function get_sql()
116      {
117          // Determine topics with recent activity
118          $sql = 'SELECT topic_id, topic_last_post_time
119              FROM ' . TOPICS_TABLE . '
120              WHERE forum_id = ' . $this->forum_id . '
121                  AND topic_moved_id = 0
122                  AND ' . $this->content_visibility->get_visibility_sql('topic', $this->forum_id) . '
123              ORDER BY topic_last_post_time DESC, topic_last_post_id DESC';
124          $result = $this->db->sql_query_limit($sql, $this->num_items);
125   
126          $topic_ids = array();
127          $min_post_time = 0;
128          while ($row = $this->db->sql_fetchrow())
129          {
130              $topic_ids[] = (int) $row['topic_id'];
131   
132              $min_post_time = (int) $row['topic_last_post_time'];
133          }
134          $this->db->sql_freeresult($result);
135   
136          if (empty($topic_ids))
137          {
138              return false;
139          }
140   
141          parent::fetch_attachments(array(), $topic_ids);
142   
143          $this->sql = array(
144              'SELECT'    =>    'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
145                  'u.username, u.user_id',
146              'FROM'        => array(
147                  POSTS_TABLE        => 'p',
148                  USERS_TABLE        => 'u',
149              ),
150              'WHERE'        => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
151                              AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . '
152                              AND p.post_time >= ' . $min_post_time . '
153                              AND p.poster_id = u.user_id',
154              'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
155          );
156   
157          return true;
158      }
159   
160      /**
161       * {@inheritdoc}
162       */
163      public function adjust_item(&$item_row, &$row)
164      {
165          parent::adjust_item($item_row, $row);
166   
167          $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title'];
168          $item_row['forum_id'] = $this->forum_id;
169      }
170   
171      /**
172       * {@inheritdoc}
173       */
174      public function get_item()
175      {
176          return ($row = parent::get_item()) ? array_merge($this->forum_data, $row) : $row;
177      }
178  }
179