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

news.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 2.95 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  /**
017   * News feed
018   *
019   * This will give you {$this->num_items} first posts
020   * of all topics in the selected news forums.
021   */
022  class news extends topic_base
023  {
024      /**
025       * Returns the ids of the 'news forums'
026       * @return int[]
027       */
028      private function get_news_forums()
029      {
030          static $forum_ids;
031   
032          // Matches acp/acp_board.php
033          $cache_name    = 'feed_news_forum_ids';
034   
035          if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
036          {
037              $sql = 'SELECT forum_id
038                  FROM ' . FORUMS_TABLE . '
039                  WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
040              $result = $this->db->sql_query($sql);
041   
042              $forum_ids = array();
043              while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
044              {
045                  $forum_ids[$forum_id] = $forum_id;
046              }
047              $this->db->sql_freeresult($result);
048   
049              $this->cache->put('_' . $cache_name, $forum_ids);
050          }
051   
052          return $forum_ids;
053      }
054   
055      /**
056       * {@inheritdoc}
057       */
058      protected function get_sql()
059      {
060          // Determine forum ids
061          $in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums());
062          if (empty($in_fid_ary))
063          {
064              return false;
065          }
066   
067          $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
068          if (empty($in_fid_ary))
069          {
070              return false;
071          }
072   
073          // We really have to get the post ids first!
074          $sql = 'SELECT topic_first_post_id, topic_time
075              FROM ' . TOPICS_TABLE . '
076              WHERE topic_moved_id = 0
077                  AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . '
078              ORDER BY topic_time DESC';
079          $result = $this->db->sql_query_limit($sql, $this->num_items);
080   
081          $post_ids = array();
082          while ($row = $this->db->sql_fetchrow($result))
083          {
084              $post_ids[] = (int) $row['topic_first_post_id'];
085          }
086          $this->db->sql_freeresult($result);
087   
088          if (empty($post_ids))
089          {
090              return false;
091          }
092   
093          parent::fetch_attachments($post_ids);
094   
095          $this->sql = array(
096              'SELECT'    => 'f.forum_id, f.forum_name,
097                              t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time,
098                              p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility',
099              'FROM'        => array(
100                  TOPICS_TABLE    => 't',
101                  POSTS_TABLE        => 'p',
102              ),
103              'LEFT_JOIN'    => array(
104                  array(
105                      'FROM'    => array(FORUMS_TABLE => 'f'),
106                      'ON'    => 'p.forum_id = f.forum_id',
107                  ),
108              ),
109              'WHERE'        => 'p.topic_id = t.topic_id
110                              AND ' . $this->db->sql_in_set('p.post_id', $post_ids),
111              'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
112          );
113   
114          return true;
115      }
116  }
117