[ Index ]

PHP Cross Reference of phpBB-3.1.12-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 \phpbb\feed\topic_base
  23  {
  24  	function get_news_forums()
  25      {
  26          static $forum_ids;
  27  
  28          // Matches acp/acp_board.php
  29          $cache_name    = 'feed_news_forum_ids';
  30  
  31          if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
  32          {
  33              $sql = 'SELECT forum_id
  34                  FROM ' . FORUMS_TABLE . '
  35                  WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
  36              $result = $this->db->sql_query($sql);
  37  
  38              $forum_ids = array();
  39              while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
  40              {
  41                  $forum_ids[$forum_id] = $forum_id;
  42              }
  43              $this->db->sql_freeresult($result);
  44  
  45              $this->cache->put('_' . $cache_name, $forum_ids);
  46          }
  47  
  48          return $forum_ids;
  49      }
  50  
  51  	function get_sql()
  52      {
  53          // Determine forum ids
  54          $in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums());
  55          if (empty($in_fid_ary))
  56          {
  57              return false;
  58          }
  59  
  60          $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
  61          if (empty($in_fid_ary))
  62          {
  63              return false;
  64          }
  65  
  66          // We really have to get the post ids first!
  67          $sql = 'SELECT topic_first_post_id, topic_time
  68              FROM ' . TOPICS_TABLE . '
  69              WHERE topic_moved_id = 0
  70                  AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . '
  71              ORDER BY topic_time DESC';
  72          $result = $this->db->sql_query_limit($sql, $this->num_items);
  73  
  74          $post_ids = array();
  75          while ($row = $this->db->sql_fetchrow($result))
  76          {
  77              $post_ids[] = (int) $row['topic_first_post_id'];
  78          }
  79          $this->db->sql_freeresult($result);
  80  
  81          if (empty($post_ids))
  82          {
  83              return false;
  84          }
  85  
  86          parent::fetch_attachments($post_ids);
  87  
  88          $this->sql = array(
  89              'SELECT'    => 'f.forum_id, f.forum_name,
  90                              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,
  91                              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',
  92              'FROM'        => array(
  93                  TOPICS_TABLE    => 't',
  94                  POSTS_TABLE        => 'p',
  95              ),
  96              'LEFT_JOIN'    => array(
  97                  array(
  98                      'FROM'    => array(FORUMS_TABLE => 'f'),
  99                      'ON'    => 'p.forum_id = f.forum_id',
 100                  ),
 101              ),
 102              'WHERE'        => 'p.topic_id = t.topic_id
 103                              AND ' . $this->db->sql_in_set('p.post_id', $post_ids),
 104              'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
 105          );
 106  
 107          return true;
 108      }
 109  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1