Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

topics_active.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 3.92 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   * Active Topics feed
018   *
019   * This will give you the last {$this->num_items} topics
020   * with replies made within the last {$this->sort_days} days
021   * including the last post.
022   */
023  class topics_active extends topic_base
024  {
025      protected $sort_days = 7;
026   
027      /**
028       * {@inheritdoc}
029       */
030      public function set_keys()
031      {
032          parent::set_keys();
033   
034          $this->set('author_id',    'topic_last_poster_id');
035          $this->set('creator',    'topic_last_poster_name');
036      }
037   
038      /**
039       * {@inheritdoc}
040       */
041      protected function get_sql()
042      {
043          $forum_ids_read = $this->get_readable_forums();
044          if (empty($forum_ids_read))
045          {
046              return false;
047          }
048   
049          $in_fid_ary = array_intersect($forum_ids_read, $this->get_forum_ids());
050          $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
051          if (empty($in_fid_ary))
052          {
053              return false;
054          }
055   
056          // Search for topics in last X days
057          $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : '';
058   
059          // We really have to get the post ids first!
060          $sql = 'SELECT topic_last_post_id, topic_last_post_time
061              FROM ' . TOPICS_TABLE . '
062              WHERE topic_moved_id = 0
063                  AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . '
064                  ' . $last_post_time_sql . '
065              ORDER BY topic_last_post_time DESC, topic_last_post_id DESC';
066          $result = $this->db->sql_query_limit($sql, $this->num_items);
067   
068          $post_ids = array();
069          while ($row = $this->db->sql_fetchrow($result))
070          {
071              $post_ids[] = (int) $row['topic_last_post_id'];
072          }
073          $this->db->sql_freeresult($result);
074   
075          if (empty($post_ids))
076          {
077              return false;
078          }
079   
080          parent::fetch_attachments($post_ids);
081   
082          $this->sql = array(
083              'SELECT'    => 'f.forum_id, f.forum_name,
084                              t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views,
085                              t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time,
086                              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',
087              'FROM'        => array(
088                  TOPICS_TABLE    => 't',
089                  POSTS_TABLE        => 'p',
090              ),
091              'LEFT_JOIN'    => array(
092                  array(
093                      'FROM'    => array(FORUMS_TABLE => 'f'),
094                      'ON'    => 'p.forum_id = f.forum_id',
095                  ),
096              ),
097              'WHERE'        => 'p.topic_id = t.topic_id
098                              AND ' . $this->db->sql_in_set('p.post_id', $post_ids),
099              'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
100          );
101   
102          return true;
103      }
104   
105      /**
106       * Returns the ids of the forums not excluded from the active list
107       *
108       * @return int[]
109       */
110      private function get_forum_ids()
111      {
112          static $forum_ids;
113   
114          $cache_name    = 'feed_topic_active_forum_ids';
115   
116          if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
117          {
118              $sql = 'SELECT forum_id
119                  FROM ' . FORUMS_TABLE . '
120                  WHERE forum_type = ' . FORUM_POST . '
121                      AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . '
122                      AND ' . $this->db->sql_bit_and('forum_flags', round(log(FORUM_FLAG_ACTIVE_TOPICS, 2)), '<> 0');
123              $result = $this->db->sql_query($sql);
124   
125              $forum_ids = array();
126              while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
127              {
128                  $forum_ids[$forum_id] = $forum_id;
129              }
130              $this->db->sql_freeresult($result);
131   
132              $this->cache->put('_' . $cache_name, $forum_ids, 180);
133          }
134   
135          return $forum_ids;
136      }
137   
138      /**
139       * {@inheritdoc}
140       */
141      public function adjust_item(&$item_row, &$row)
142      {
143          parent::adjust_item($item_row, $row);
144   
145          $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title'];
146      }
147  }
148