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

topic.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.97 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_topic_exception;
 018  use phpbb\feed\exception\unauthorized_forum_exception;
 019  use phpbb\feed\exception\unauthorized_topic_exception;
 020   
 021  /**
 022   * Topic feed for a specific topic
 023   *
 024   * This will give you the last {$this->num_items} posts made within this topic.
 025   */
 026  class topic extends post_base
 027  {
 028      protected $topic_id        = 0;
 029      protected $forum_id        = 0;
 030      protected $topic_data    = array();
 031   
 032      /**
 033       * Set the Topic ID
 034       *
 035       * @param int    $topic_id            Topic ID
 036       * @return    \phpbb\feed\topic
 037       */
 038      public function set_topic_id($topic_id)
 039      {
 040          $this->topic_id = (int) $topic_id;
 041   
 042          return $this;
 043      }
 044   
 045      /**
 046       * {@inheritdoc}
 047       */
 048      public function open()
 049      {
 050          $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
 051              FROM ' . TOPICS_TABLE . ' t
 052              LEFT JOIN ' . FORUMS_TABLE . ' f
 053                  ON (f.forum_id = t.forum_id)
 054              WHERE t.topic_id = ' . $this->topic_id;
 055          $result = $this->db->sql_query($sql);
 056          $this->topic_data = $this->db->sql_fetchrow($result);
 057          $this->db->sql_freeresult($result);
 058   
 059          if (empty($this->topic_data))
 060          {
 061              throw new no_topic_exception($this->topic_id);
 062          }
 063   
 064          $this->forum_id = (int) $this->topic_data['forum_id'];
 065   
 066          // Make sure topic is either approved or user authed
 067          if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id))
 068          {
 069              if ($this->user->data['user_id'] != ANONYMOUS)
 070              {
 071                  send_status_line(403, 'Forbidden');
 072              }
 073              else
 074              {
 075                  send_status_line(401, 'Unauthorized');
 076              }
 077              throw new unauthorized_topic_exception($this->topic_id);
 078          }
 079   
 080          // Make sure forum is not excluded from feed
 081          if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options']))
 082          {
 083              throw new no_feed_exception();
 084          }
 085   
 086          // Make sure we can read this forum
 087          if (!$this->auth->acl_get('f_read', $this->forum_id))
 088          {
 089              if ($this->user->data['user_id'] != ANONYMOUS)
 090              {
 091                  send_status_line(403, 'Forbidden');
 092              }
 093              else
 094              {
 095                  send_status_line(401, 'Unauthorized');
 096              }
 097              throw new unauthorized_forum_exception($this->forum_id);
 098          }
 099   
 100          // Make sure forum is not passworded or user is authed
 101          if ($this->topic_data['forum_password'])
 102          {
 103              $forum_ids_passworded = $this->get_passworded_forums();
 104   
 105              if (isset($forum_ids_passworded[$this->forum_id]))
 106              {
 107                  if ($this->user->data['user_id'] != ANONYMOUS)
 108                  {
 109                      send_status_line(403, 'Forbidden');
 110                  }
 111                  else
 112                  {
 113                      send_status_line(401, 'Unauthorized');
 114                  }
 115                  throw new unauthorized_forum_exception($this->forum_id);
 116              }
 117   
 118              unset($forum_ids_passworded);
 119          }
 120   
 121          parent::open();
 122      }
 123   
 124      /**
 125       * {@inheritdoc}
 126       */
 127      protected function get_sql()
 128      {
 129          parent::fetch_attachments();
 130   
 131          $this->sql = array(
 132              'SELECT'    =>    'p.post_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, ' .
 133                  'u.username, u.user_id',
 134              'FROM'        => array(
 135                  POSTS_TABLE        => 'p',
 136                  USERS_TABLE        => 'u',
 137              ),
 138              'WHERE'        => 'p.topic_id = ' . $this->topic_id . '
 139                                  AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . '
 140                                  AND p.poster_id = u.user_id',
 141              'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
 142          );
 143   
 144          return true;
 145      }
 146   
 147      /**
 148       * {@inheritdoc}
 149       */
 150      public function adjust_item(&$item_row, &$row)
 151      {
 152          parent::adjust_item($item_row, $row);
 153   
 154          $item_row['forum_id'] = $this->forum_id;
 155      }
 156   
 157      /**
 158       * {@inheritdoc}
 159       */
 160      public function get_item()
 161      {
 162          return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row;
 163      }
 164  }
 165