[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/phpbb/feed/ -> news.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\feed;
  15  
  16  /**
  17   * News feed
  18   *
  19   * This will give you {$this->num_items} first posts
  20   * of all topics in the selected news forums.
  21   */
  22  class news extends topic_base
  23  {
  24      /**
  25       * Returns the ids of the 'news forums'
  26       * @return int[]
  27       */
  28  	private function get_news_forums()
  29      {
  30          static $forum_ids;
  31  
  32          // Matches acp/acp_board.php
  33          $cache_name    = 'feed_news_forum_ids';
  34  
  35          if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
  36          {
  37              $sql = 'SELECT forum_id
  38                  FROM ' . FORUMS_TABLE . '
  39                  WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
  40              $result = $this->db->sql_query($sql);
  41  
  42              $forum_ids = array();
  43              while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
  44              {
  45                  $forum_ids[$forum_id] = $forum_id;
  46              }
  47              $this->db->sql_freeresult($result);
  48  
  49              $this->cache->put('_' . $cache_name, $forum_ids);
  50          }
  51  
  52          return $forum_ids;
  53      }
  54  
  55      /**
  56       * {@inheritdoc}
  57       */
  58  	protected function get_sql()
  59      {
  60          // Determine forum ids
  61          $in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums());
  62          if (empty($in_fid_ary))
  63          {
  64              return false;
  65          }
  66  
  67          $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
  68          if (empty($in_fid_ary))
  69          {
  70              return false;
  71          }
  72  
  73          // We really have to get the post ids first!
  74          $sql = 'SELECT topic_first_post_id, topic_time
  75              FROM ' . TOPICS_TABLE . '
  76              WHERE topic_moved_id = 0
  77                  AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . '
  78              ORDER BY topic_time DESC';
  79          $result = $this->db->sql_query_limit($sql, $this->num_items);
  80  
  81          $post_ids = array();
  82          while ($row = $this->db->sql_fetchrow($result))
  83          {
  84              $post_ids[] = (int) $row['topic_first_post_id'];
  85          }
  86          $this->db->sql_freeresult($result);
  87  
  88          if (empty($post_ids))
  89          {
  90              return false;
  91          }
  92  
  93          parent::fetch_attachments($post_ids);
  94  
  95          $this->sql = array(
  96              'SELECT'    => 'f.forum_id, f.forum_name,
  97                              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,
  98                              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',
  99              '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  }


Generated: Sat Oct 26 11:28:42 2019 Cross-referenced by PHPXref 0.7.1