aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/feed.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/feed.php')
-rw-r--r--phpBB/feed.php583
1 files changed, 331 insertions, 252 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php
index a6206d9203..a7c6f831a3 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -35,14 +35,12 @@ $forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$mode = request_var('mode', '');
-// Feed date format for PHP > 5 and PHP4
-$feed_date_format = (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:sO";
-$params = false;
-
// We do not use a template, therefore we simply define the global template variables here
$global_vars = $item_vars = array();
+$feed_updated_time = 0;
// Generate params array for use in append_sid() to correctly link back to this page
+$params = false;
if ($forum_id || $topic_id || $mode)
{
$params = array(
@@ -67,19 +65,6 @@ if ($feed === false)
// Open Feed
$feed->open();
-// Some default assignments
-// FEED_IMAGE is not used (atom)
-$global_vars = array(
- 'FEED_IMAGE' => ($user->img('site_logo', '', false, '', 'src')) ? $board_url . '/' . substr($user->img('site_logo', '', false, '', 'src'), strlen($phpbb_root_path)) : '',
- 'SELF_LINK' => feed_append_sid('/feed.' . $phpEx, $params),
- 'FEED_LINK' => $board_url . '/index.' . $phpEx,
- 'FEED_TITLE' => $config['sitename'],
- 'FEED_SUBTITLE' => $config['site_desc'],
- 'FEED_UPDATED' => $user->format_date(time(), $feed_date_format, true),
- 'FEED_LANG' => $user->lang['USER_LANG'],
- 'FEED_AUTHOR' => $config['sitename'],
-);
-
// Iterate through items
while ($row = $feed->get_item())
{
@@ -99,16 +84,17 @@ while ($row = $feed->get_item())
$options = $row[$feed->get('options')];
}
- $title = ($row[$feed->get('title')]) ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : '');
- $title = censor_text($title);
+ $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : '');
+
+ $item_time = (int) $row[$feed->get('date')];
$item_row = array(
'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '',
- 'pubdate' => $user->format_date($row[$feed->get('date')], $feed_date_format, true),
+ 'pubdate' => feed_format_date($item_time),
'link' => '',
'title' => censor_text($title),
'category' => ($config['feed_item_statistics']) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
- 'category_name' => ($config['feed_item_statistics']) ? utf8_htmlspecialchars($row['forum_name']) : '',
+ 'category_name' => ($config['feed_item_statistics']) ? $row['forum_name'] : '',
'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)),
'statistics' => '',
);
@@ -117,8 +103,29 @@ while ($row = $feed->get_item())
$feed->adjust_item($item_row, $row);
$item_vars[] = $item_row;
+
+ $feed_updated_time = max($feed_updated_time, $item_time);
}
+// If we do not have any items at all, sending the current time is better than sending no time.
+if (!$feed_updated_time)
+{
+ $feed_updated_time = time();
+}
+
+// Some default assignments
+// FEED_IMAGE is not used (atom)
+$global_vars = array_merge($global_vars, array(
+ 'FEED_IMAGE' => ($user->img('site_logo', '', false, '', 'src')) ? $board_url . '/' . substr($user->img('site_logo', '', false, '', 'src'), strlen($phpbb_root_path)) : '',
+ 'SELF_LINK' => feed_append_sid('/feed.' . $phpEx, $params),
+ 'FEED_LINK' => $board_url . '/index.' . $phpEx,
+ 'FEED_TITLE' => $config['sitename'],
+ 'FEED_SUBTITLE' => $config['site_desc'],
+ 'FEED_UPDATED' => feed_format_date($feed_updated_time),
+ 'FEED_LANG' => $user->lang['USER_LANG'],
+ 'FEED_AUTHOR' => $config['sitename'],
+));
+
$feed->close();
// Output page
@@ -133,12 +140,7 @@ if ($config['gzip_compress'])
}
// IF debug extra is enabled and admin want to "explain" the page we need to set other headers...
-if (!defined('DEBUG_EXTRA') || !request_var('explain', 0) || !$auth->acl_get('a_'))
-{
- header("Content-Type: application/atom+xml; charset=UTF-8");
- header("Last-Modified: " . gmdate('D, d M Y H:i:s', time()) . ' GMT');
-}
-else
+if (defined('DEBUG_EXTRA') && request_var('explain', 0) && $auth->acl_get('a_'))
{
header('Content-type: text/html; charset=UTF-8');
header('Cache-Control: private, no-cache="set-cookie"');
@@ -157,6 +159,9 @@ else
exit_handler();
}
+header("Content-Type: application/atom+xml; charset=UTF-8");
+header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT');
+
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $global_vars['FEED_LANG'] . '">' . "\n";
echo '<link rel="self" type="application/atom+xml" href="' . $global_vars['SELF_LINK'] . '" />' . "\n\n";
@@ -196,7 +201,7 @@ foreach ($item_vars as $row)
echo '<p>' . $user->lang['STATISTICS'] . ': ' . $row['statistics'] . '</p>';
}
- echo '<hr /></div>' . "\n" . ']]></content>' . "\n";
+ echo '<hr />' . "\n" . ']]></content>' . "\n";
echo '</entry>' . "\n";
}
@@ -212,17 +217,34 @@ function feed_append_sid($url, $params)
{
global $board_url;
- $link = append_sid($board_url . $url, $params);
+ return append_sid($board_url . $url, $params, true, '');
+}
- // Remove added sid - not as easy as it sounds. ;)
- $link = (strpos($link, 'sid=') !== false) ? trim(preg_replace('/(&amp;|&|\?)sid=[a-z0-9]+(&amp;|&)?/', '\1', $link), '?& ') : $link;
+/**
+* Generate ISO 8601 date string (RFC 3339)
+**/
+function feed_format_date($time)
+{
+ static $zone_offset;
+ static $offset_string;
+
+ if (empty($offset_string))
+ {
+ global $user;
+
+ $zone_offset = (int) $user->timezone + (int) $user->dst;
- // Now the only thing remaining could be an empty &amp;
- $link = (substr($link, -5) === '&amp;') ? substr($link, 0, -5) : $link;
- // And &amp;#xxx
- $link = str_replace('&amp;#', '#', $link);
+ $sign = ($zone_offset < 0) ? '-' : '+';
+ $time_offset = abs($zone_offset);
- return $link;
+ $offset_seconds = $time_offset % 3600;
+ $offset_minutes = $offset_seconds / 60;
+ $offset_hours = ($time_offset - $offset_seconds) / 3600;
+
+ $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes);
+ }
+
+ return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string;
}
/**
@@ -376,26 +398,16 @@ class phpbb_feed_factory
}
/**
-* Base/default Feed class if no mode is specified.
-* This can be the overall site feed or a forum/topic feed.
+* Base class with some generic functions and settings.
+*
* @package phpBB3
*/
-class phpbb_feed
+class phpbb_feed_base
{
/**
- * Forum id specified for forum feed.
- */
- var $forum_id = 0;
-
- /**
- * Topic id specified for topic feed.
- */
- var $topic_id = 0;
-
- /**
* SQL Query to be executed to get feed items
*/
- var $sql;
+ var $sql = array();
/**
* Keys specified for retrieval of title, content, etc.
@@ -408,9 +420,9 @@ class phpbb_feed
var $excluded_forums_ary = NULL;
/**
- * Number of items to fetch
+ * Number of items to fetch. Usually overwritten by $config['feed_something']
*/
- var $num_items;
+ var $num_items = 15;
/**
* boolean to determine if items array is filled or not
@@ -430,7 +442,7 @@ class phpbb_feed
/**
* Default cache time of entries in seconds
*/
- var $cache_time = 300;
+ var $cache_time = 90;
/**
* Separator for title elements to separate items (for example forum / topic)
@@ -438,79 +450,49 @@ class phpbb_feed
var $separator = "\xE2\x80\xA2"; // &bull;
/**
- * Constructor. Set standard keys.
+ * Separator for the statistics row (Posted by, post date, replies, etc.)
*/
- function phpbb_feed($forum_id = 0, $topic_id = 0)
- {
- global $config;
+ var $separator_stats = "\xE2\x80\x94"; // &mdash;
- $this->forum_id = $forum_id;
- $this->topic_id = $topic_id;
+ /**
+ * Constructor
+ */
+ function phpbb_feed_base()
+ {
+ global $user;
- $this->sql = array();
+ // Disable cache if it is not a guest or a bot but a registered user
+ if ($this->cache_time && !empty($user) && $user->data['is_registered'])
+ {
+ $this->cache_time = 0;
+ }
- // Set some values for pagination
- $this->num_items = (int) $config['feed_limit'];
$this->set_keys();
}
+ /**
+ * Set keys.
+ */
function set_keys()
{
- // Set keys for items...
- $this->set('title', 'post_subject');
- $this->set('title2', 'topic_title');
- $this->set('author_id', 'user_id');
- $this->set('creator', 'username');
- $this->set('text', 'post_text');
- $this->set('bitfield', 'bbcode_bitfield');
- $this->set('bbcode_uid','bbcode_uid');
- $this->set('date', 'post_time');
-
- $this->set('enable_bbcode', 'enable_bbcode');
- $this->set('enable_smilies', 'enable_smilies');
- $this->set('enable_magic_url', 'enable_magic_url');
}
+ /**
+ * Open feed
+ */
function open()
{
- if (!$this->forum_id && !$this->topic_id)
- {
- return;
- }
- else if ($this->forum_id && !$this->topic_id)
- {
- global $db, $user, $global_vars;
-
- $sql = 'SELECT forum_name
- FROM ' . FORUMS_TABLE . '
- WHERE forum_id = ' . $this->forum_id;
- $result = $db->sql_query($sql);
-
- $global_vars['FEED_MODE'] = $user->lang['FORUM'] . ': ' . $db->sql_fetchfield('forum_name');
-
- $db->sql_freeresult($result);
- }
- else if ($this->topic_id)
- {
- global $db, $user, $global_vars;
-
- $sql = 'SELECT topic_title
- FROM ' . TOPICS_TABLE . '
- WHERE topic_id = ' . $this->topic_id;
- $result = $db->sql_query($sql);
-
- $global_vars['FEED_MODE'] = $user->lang['TOPIC'] . ': ' . $db->sql_fetchfield('topic_title');
-
- $db->sql_freeresult($result);
- }
}
+ /**
+ * Close feed
+ */
function close()
{
+ global $db;
+
if (!empty($this->result))
{
- global $db;
-
$db->sql_freeresult($this->result);
}
}
@@ -544,55 +526,224 @@ class phpbb_feed
global $auth, $db, $config, $phpbb_root_path, $phpEx, $user;
// Which forums should not be searched ?
- $exclude_forums = array();
+ $this->excluded_forums_ary = array();
+
+ // Exclude excluded forums and forums we cannot read
+ $forum_ids_read = array_keys($auth->acl_getf('f_read', true));
+ $sql_or = (!empty($forum_ids_read)) ? 'OR ' . $db->sql_in_set('forum_id', $forum_ids_read, true) : '';
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
- WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0');
+ WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0') . "
+ $sql_or";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- $exclude_forums[] = (int) $row['forum_id'];
+ $this->excluded_forums_ary[(int) $row['forum_id']] = (int) $row['forum_id'];
}
$db->sql_freeresult($result);
- // Exclude forums the user is not able to read
- $this->excluded_forums_ary = array_keys($auth->acl_getf('!f_read', true));
- $this->excluded_forums_ary = (sizeof($exclude_forums)) ? array_merge($exclude_forums, $this->excluded_forums_ary) : $this->excluded_forums_ary;
+ // Include passworded forums
+ $this->excluded_forums_ary = array_unique(array_merge($this->excluded_forums_ary, $this->get_passworded_forums()));
- $not_in_fid = (sizeof($this->excluded_forums_ary)) ? 'WHERE (' . $db->sql_in_set('f.forum_id', $this->excluded_forums_ary, true) . ' AND ' . $db->sql_in_set('f.parent_id', $this->excluded_forums_ary, true) . ") OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : '';
+ return $this->excluded_forums_ary;
+ }
- $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id
+ function get_passworded_forums()
+ {
+ global $db, $user;
+
+ // Exclude passworded forums
+ $sql = 'SELECT f.forum_id, fa.user_id
FROM ' . FORUMS_TABLE . ' f
- LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
- AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
- $not_in_fid
- ORDER BY f.left_id";
+ LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa
+ ON (fa.forum_id = f.forum_id
+ AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
+ WHERE f.forum_password <> ''";
$result = $db->sql_query($sql);
- $right_id = 0;
+ $forum_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- // Exclude passworded forum completely
- if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
+ $forum_id = (int) $row['forum_id'];
+
+ if ($row['user_id'] != $user->data['user_id'])
{
- $this->excluded_forums_ary[] = (int) $row['forum_id'];
- continue;
+ $forum_ids[$forum_id] = $forum_id;
}
+ }
+ $db->sql_freeresult($result);
- if ($row['right_id'] > $right_id)
+ return $forum_ids;
+ }
+
+ function get_item()
+ {
+ global $db, $cache;
+
+ if (!$this->cache_time)
+ {
+ if (empty($this->result))
{
- $right_id = (int) $row['right_id'];
+ if (!$this->get_sql())
+ {
+ return false;
+ }
+
+ // Query database
+ $sql = $db->sql_build_query('SELECT', $this->sql);
+ $this->result = $db->sql_query_limit($sql, $this->num_items);
}
- else if ($row['right_id'] < $right_id)
+
+ return $db->sql_fetchrow($this->result);
+ }
+ else
+ {
+ if (empty($this->items_filled))
{
- continue;
+ // Try to load result set...
+ $cache_filename = substr(get_class($this), strlen('phpbb_'));
+
+ if (($this->items = $cache->get('_' . $cache_filename)) === false)
+ {
+ $this->items = array();
+
+ if ($this->get_sql())
+ {
+ // Query database
+ $sql = $db->sql_build_query('SELECT', $this->sql);
+ $result = $db->sql_query_limit($sql, $this->num_items);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $this->items[] = $row;
+ }
+ $db->sql_freeresult($result);
+ }
+
+ $cache->put('_' . $cache_filename, $this->items, $this->cache_time);
+ }
+
+ $this->items_filled = true;
}
+
+ $row = array_shift($this->items);
+ return (!$row) ? false : $row;
}
- $db->sql_freeresult($result);
+ }
+}
- return $this->excluded_forums_ary;
+/**
+* Default feed class if no mode is specified.
+* This can be the overall site feed or a forum/topic feed.
+*
+* @package phpBB3
+*/
+class phpbb_feed extends phpbb_feed_base
+{
+ /**
+ * Forum id specified for forum feed.
+ */
+ var $forum_id = 0;
+
+ /**
+ * Topic id specified for topic feed.
+ */
+ var $topic_id = 0;
+
+ /**
+ * Constructor.
+ */
+ function phpbb_feed($forum_id = 0, $topic_id = 0)
+ {
+ global $config;
+
+ // Call parent constructor.
+ parent::phpbb_feed_base();
+
+ $this->forum_id = $forum_id;
+ $this->topic_id = $topic_id;
+
+ $this->sql = array();
+ }
+
+ function set_keys()
+ {
+ global $config;
+
+ $this->set('title', 'post_subject');
+ $this->set('title2', 'topic_title');
+ $this->set('author_id', 'user_id');
+ $this->set('creator', 'username');
+ $this->set('text', 'post_text');
+ $this->set('bitfield', 'bbcode_bitfield');
+ $this->set('bbcode_uid','bbcode_uid');
+ $this->set('date', 'post_time');
+
+ $this->set('enable_bbcode', 'enable_bbcode');
+ $this->set('enable_smilies', 'enable_smilies');
+ $this->set('enable_magic_url', 'enable_magic_url');
+
+ $this->num_items = (int) $config['feed_limit'];
+ }
+
+ function open()
+ {
+ global $auth, $db, $user;
+
+ // Topic/Forum feed
+ if ($this->topic_id || $this->forum_id)
+ {
+ if ($this->topic_id)
+ {
+ // Topic feed
+ $sql = 'SELECT t.forum_id, f.forum_options
+ FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
+ WHERE t.topic_id = ' . $this->topic_id . '
+ AND t.forum_id = f.forum_id';
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (empty($row))
+ {
+ trigger_error('NO_TOPIC');
+ }
+
+ $this->forum_id = (int) $row['forum_id'];
+ }
+ else
+ {
+ // Forum feed
+ $sql = 'SELECT forum_options
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . $this->forum_id;
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (empty($row))
+ {
+ trigger_error('NO_FORUM');
+ }
+ }
+
+ // Make sure forum is not excluded from feed
+ if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']))
+ {
+ trigger_error('NO_FEED');
+ }
+
+ // Make sure we can read this forum
+ if (!$auth->acl_get('f_read', $this->forum_id))
+ {
+ trigger_error('SORRY_AUTH_READ');
+ }
+
+ // Disable caching
+ $this->cache_time = 0;
+ }
}
/**
@@ -638,7 +789,7 @@ class phpbb_feed
}
// Determine which forums to fetch
- $not_in_fid = (sizeof($this->excluded_forums())) ? ' AND ' . $db->sql_in_set('f1.forum_id', $this->excluded_forums(), true) : '';
+ $not_in_fid = (sizeof($this->excluded_forums())) ? ' AND ' . $db->sql_in_set('f2.forum_id', $this->excluded_forums(), true) : '';
// Determine forum childs...
$sql = 'SELECT f2.forum_id
@@ -673,14 +824,6 @@ class phpbb_feed
// Fetch last posts from specified topic...
else if ($this->topic_id)
{
- // First of all, determine the forum...
- $sql = 'SELECT forum_id
- FROM ' . TOPICS_TABLE . '
- WHERE topic_id = ' . $this->topic_id;
- $result = $db->sql_query_limit($sql, 1);
- $this->forum_id = (int) $db->sql_fetchfield('forum_id');
- $db->sql_freeresult($result);
-
// non-global announcement
if ($this->forum_id && in_array($this->forum_id, $this->excluded_forums()))
{
@@ -711,7 +854,7 @@ class phpbb_feed
'SELECT' => 'f.forum_id, f.forum_name, f.forum_desc_options, ' .
't.topic_last_post_time, t.topic_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_views, ' .
'p.post_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
- 'u.username, u.user_id, u.user_email, u.user_colour',
+ 'u.username, u.user_id',
'FROM' => array(
POSTS_TABLE => 'p',
TOPICS_TABLE => 't',
@@ -728,73 +871,6 @@ class phpbb_feed
return true;
}
- function get_item()
- {
- global $db, $cache;
-
- // Disable cache if it is not a guest or a bot but a registered user
- if ($this->cache_time)
- {
- global $user;
-
- // We check this here because we call get_item() quite often
- if (!empty($user) && $user->data['is_registered'])
- {
- $this->cache_time = 0;
- }
- }
-
- if (!$this->cache_time)
- {
- if (empty($this->result))
- {
- if (!$this->get_sql())
- {
- return false;
- }
-
- // Query database
- $sql = $db->sql_build_query('SELECT', $this->sql);
- $this->result = $db->sql_query_limit($sql, $this->num_items);
- }
-
- return $db->sql_fetchrow($this->result);
- }
- else
- {
- if (empty($this->items_filled))
- {
- // Try to load result set...
- $cache_filename = substr(get_class($this), strlen('phpbb_'));
-
- if (($this->items = $cache->get('_' . $cache_filename)) === false)
- {
- $this->items = array();
-
- if ($this->get_sql())
- {
- // Query database
- $sql = $db->sql_build_query('SELECT', $this->sql);
- $result = $db->sql_query_limit($sql, $this->num_items);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $this->items[] = $row;
- }
- $db->sql_freeresult($result);
- }
-
- $cache->put('_' . $cache_filename, $this->items, $this->cache_time);
- }
-
- $this->items_filled = true;
- }
-
- $row = array_shift($this->items);
- return (!$row) ? false : $row;
- }
- }
-
function adjust_item(&$item_row, &$row)
{
global $phpEx, $config;
@@ -806,16 +882,17 @@ class phpbb_feed
{
global $user;
- $user_link = '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row['user_id']) . '">' . $row['username'] . '</a>';
-
- $time = ($this->topic_id) ? $row['post_time'] : $row['topic_time'];
+ $user_link = ($row['user_id'] != ANONYMOUS) ? '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row['user_id']) . '">' . $row['username'] . '</a>' : $row['username'];
- $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link . ' - ' . $user->format_date($time). ' - ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies'] . ' - ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
+ $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link
+ . ' ' . $this->separator_stats . ' ' . $user->format_date($row['post_time'])
+ . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies']
+ . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
}
}
}
-class phpbb_feed_forums extends phpbb_feed
+class phpbb_feed_forums extends phpbb_feed_base
{
function set_keys()
{
@@ -831,13 +908,6 @@ class phpbb_feed_forums extends phpbb_feed
$this->num_items = (int) $config['feed_overall_forums_limit'];
}
- function open()
- {
- global $user, $global_vars;
-
- $global_vars['FEED_MODE'] = $user->lang['FORUMS'];
- }
-
function get_sql()
{
global $db;
@@ -866,13 +936,19 @@ class phpbb_feed_forums extends phpbb_feed
{
global $user;
- $item_row['statistics'] = sprintf($user->lang['TOTAL_TOPICS_OTHER'], $row['forum_topics']) . ' - ' . sprintf($user->lang['TOTAL_POSTS_OTHER'], $row['forum_posts']);
+ $item_row['statistics'] = sprintf($user->lang['TOTAL_TOPICS_OTHER'], $row['forum_topics'])
+ . ' ' . $this->separator_stats . ' ' . sprintf($user->lang['TOTAL_POSTS_OTHER'], $row['forum_posts']);
}
}
}
-class phpbb_feed_news extends phpbb_feed
+class phpbb_feed_news extends phpbb_feed_base
{
+ /**
+ * Longer cache time for the news feed
+ */
+ var $cache_time = 180;
+
function set_keys()
{
global $config;
@@ -893,16 +969,12 @@ class phpbb_feed_news extends phpbb_feed
$this->num_items = (int) $config['feed_overall_forums_limit'];
}
- function open()
- {
- global $user, $global_vars;
-
- $global_vars['FEED_MODE'] = $user->lang['FEED_NEWS'];
- }
-
function get_sql()
{
- global $db, $config;
+ global $auth, $config, $db;
+
+ // Get passworded forums
+ $forum_ids_passworded = $this->get_passworded_forums();
// Get news forums...
$sql = 'SELECT forum_id
@@ -913,6 +985,20 @@ class phpbb_feed_news extends phpbb_feed
$in_fid_ary = array();
while ($row = $db->sql_fetchrow($result))
{
+ $forum_id = (int) $row['forum_id'];
+
+ // Passworded forum
+ if (isset($forum_ids_passworded[$forum_id]))
+ {
+ continue;
+ }
+
+ // Make sure we can read this forum
+ if (!$auth->acl_get('f_read', $forum_id))
+ {
+ continue;
+ }
+
$in_fid_ary[] = (int) $row['forum_id'];
}
$db->sql_freeresult($result);
@@ -924,20 +1010,17 @@ class phpbb_feed_news extends phpbb_feed
// Build SQL Query
$this->sql = array(
- 'SELECT' => 'f.forum_id, f.forum_password, f.forum_name, f.forum_topics, f.forum_posts, f.parent_id, f.left_id, f.right_id,
+ 'SELECT' => 'f.forum_id, f.forum_name, f.forum_topics, f.forum_posts,
t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_views, t.topic_time,
- p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url,
- u.username, u.user_id, u.user_email, u.user_colour',
+ p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url',
'FROM' => array(
TOPICS_TABLE => 't',
FORUMS_TABLE => 'f',
POSTS_TABLE => 'p',
- USERS_TABLE => 'u',
),
'WHERE' => $db->sql_in_set('t.forum_id', $in_fid_ary) . '
AND f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
- AND t.topic_poster = u.user_id
AND t.topic_moved_id = 0',
'ORDER_BY' => 't.topic_time DESC',
);
@@ -955,14 +1038,17 @@ class phpbb_feed_news extends phpbb_feed
{
global $user;
- $user_link = '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row[$this->get('author_id')]) . '">' . $row[$this->get('creator')] . '</a>';
+ $user_link = ($row[$this->get('author_id')] != ANONYMOUS) ? '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row[$this->get('author_id')]) . '">' . $row[$this->get('creator')] . '</a>' : $row[$this->get('creator')];
- $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link . ' - ' . $user->format_date($row['topic_time']). ' - ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies'] . ' - ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
+ $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link
+ . ' ' . $this->separator_stats . ' ' . $user->format_date($row['topic_time'])
+ . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies']
+ . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
}
}
}
-class phpbb_feed_topics extends phpbb_feed
+class phpbb_feed_topics extends phpbb_feed_base
{
function set_keys()
{
@@ -984,13 +1070,6 @@ class phpbb_feed_topics extends phpbb_feed
$this->num_items = (int) $config['feed_overall_topics_limit'];
}
- function open()
- {
- global $user, $global_vars;
-
- $global_vars['FEED_MODE'] = $user->lang['TOPICS'];
- }
-
function get_sql()
{
global $db, $config;
@@ -1023,20 +1102,17 @@ class phpbb_feed_topics extends phpbb_feed
}
$this->sql = array(
- 'SELECT' => 'f.forum_id, f.forum_password, f.forum_name, f.forum_topics, f.forum_posts, f.parent_id, f.left_id, f.right_id,
+ 'SELECT' => 'f.forum_id, f.forum_name, f.forum_topics, f.forum_posts,
t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_views, t.topic_time,
- p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url,
- u.username, u.user_id, u.user_email, u.user_colour',
+ p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url',
'FROM' => array(
TOPICS_TABLE => 't',
FORUMS_TABLE => 'f',
POSTS_TABLE => 'p',
- USERS_TABLE => 'u',
),
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
AND f.forum_id = p.forum_id
- AND t.topic_id = p.topic_id
- AND u.user_id = p.poster_id',
+ AND t.topic_id = p.topic_id',
'ORDER_BY' => 't.topic_last_post_time DESC',
);
@@ -1053,9 +1129,12 @@ class phpbb_feed_topics extends phpbb_feed
{
global $user;
- $user_link = '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row[$this->get('author_id')]) . '">' . $row[$this->get('creator')] . '</a>';
+ $user_link = ($row[$this->get('author_id')] != ANONYMOUS) ? '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $row[$this->get('author_id')]) . '">' . $row[$this->get('creator')] . '</a>' : $row[$this->get('creator')];
- $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link . ' - ' . $user->format_date($row['topic_time']). ' - ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies'] . ' - ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
+ $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $user_link
+ . ' ' . $this->separator_stats . ' ' . $user->format_date($row['topic_time'])
+ . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies']
+ . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
}
}
}