Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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