phpBB

Code Changes

File: phpbb/feed/base.php

  Unmodified   Added   Modified   Removed
Line 16Line 16
/**
* Base class with some generic functions and settings.
*/

/**
* Base class with some generic functions and settings.
*/

abstract class base

abstract class base implements feed_interface

{
/**
* Feed helper object

{
/**
* Feed helper object

Line 38Line 38

/** @var \phpbb\auth\auth */
protected $auth;


/** @var \phpbb\auth\auth */
protected $auth;

 

/** @var \phpbb\content_visibility */
protected $content_visibility;

/** @var \phpbb\event\dispatcher_interface */
protected $phpbb_dispatcher;


/** @var string */
protected $phpEx;


/** @var string */
protected $phpEx;

Line 45Line 51
	/**
* SQL Query to be executed to get feed items
*/

	/**
* SQL Query to be executed to get feed items
*/

	var $sql = array();

	protected $sql = array();


/**
* Keys specified for retrieval of title, content, etc.
*/


/**
* Keys specified for retrieval of title, content, etc.
*/

	var $keys = array();

	protected $keys = array();


/**
* Number of items to fetch. Usually overwritten by $config['feed_something']
*/


/**
* Number of items to fetch. Usually overwritten by $config['feed_something']
*/

	var $num_items = 15;

	protected $num_items = 15;


/**
* Separator for title elements to separate items (for example forum / topic)
*/


/**
* Separator for title elements to separate items (for example forum / topic)
*/

	var $separator = "\xE2\x80\xA2"; // •

	protected $separator = "\xE2\x80\xA2"; // •


/**
* Separator for the statistics row (Posted by, post date, replies, etc.)
*/


/**
* Separator for the statistics row (Posted by, post date, replies, etc.)
*/

	var $separator_stats = "\xE2\x80\x94"; // —




	protected $separator_stats = "\xE2\x80\x94"; // —

/** @var mixed Query result handle */
protected $result;


/**
* Constructor


/**
* Constructor

Line 77Line 86
	* @param \phpbb\user						$user		User object
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\content_visibility $content_visibility Auth object

	* @param \phpbb\user						$user		User object
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\content_visibility $content_visibility Auth object

 
	 * @param \phpbb\event\dispatcher_interface	$phpbb_dispatcher		Event dispatcher object

	* @param string								$phpEx		php file extension
*/

	* @param string								$phpEx		php file extension
*/

	function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)











	public function __construct(
\phpbb\feed\helper $helper,
\phpbb\config\config $config,
\phpbb\db\driver\driver_interface $db,
\phpbb\cache\driver\driver_interface $cache,
\phpbb\user $user,
\phpbb\auth\auth $auth,
\phpbb\content_visibility $content_visibility,
\phpbb\event\dispatcher_interface $phpbb_dispatcher,
$phpEx
)

	{
$this->config = $config;
$this->helper = $helper;

	{
$this->config = $config;
$this->helper = $helper;

Line 88Line 108
		$this->user = $user;
$this->auth = $auth;
$this->content_visibility = $content_visibility;

		$this->user = $user;
$this->auth = $auth;
$this->content_visibility = $content_visibility;

 
		$this->phpbb_dispatcher = $phpbb_dispatcher;

		$this->phpEx = $phpEx;

$this->set_keys();

		$this->phpEx = $phpEx;

$this->set_keys();

Line 106Line 127
	}

/**

	}

/**

	* Set keys.

	 * {@inheritdoc}

	*/

	*/

	function set_keys()

	public function set_keys()

	{
}

/**

	{
}

/**

	* Open feed

	 * {@inheritdoc}

	*/

	*/

	function open()

	public function open()

	{
}

/**

	{
}

/**

	* Close feed

	 * {@inheritdoc}

	*/

	*/

	function close()

	public function close()

	{
if (!empty($this->result))
{

	{
if (!empty($this->result))
{

Line 131Line 152
	}

/**

	}

/**

	* Set key
*
* @param string $key Key
* @param mixed $value Value

	 * {@inheritdoc}




	*/

	*/

	function set($key, $value)

	public function set($key, $value)

	{
$this->keys[$key] = $value;
}

/**

	{
$this->keys[$key] = $value;
}

/**

	* Get key
*
* @param string $key Key
* @return mixed

	 * {@inheritdoc}




	*/

	*/

	function get($key)

	public function get($key)

	{
return (isset($this->keys[$key])) ? $this->keys[$key] : null;
}


	{
return (isset($this->keys[$key])) ? $this->keys[$key] : null;
}


	function get_readable_forums()









































	/**
* {@inheritdoc}
*/
public function get_item()
{
if (!isset($this->result))
{
if (!$this->get_sql())
{
return false;
}

$sql_ary = $this->sql;

/**
* Event to modify the feed item sql
*
* @event core.feed_base_modify_item_sql
* @var array sql_ary The SQL array to get the feed item data
*
* @since 3.1.10-RC1
*/
$vars = array('sql_ary');
extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars)));
$this->sql = $sql_ary;
unset($sql_ary);

// Query database
$sql = $this->db->sql_build_query('SELECT', $this->sql);
$this->result = $this->db->sql_query_limit($sql, $this->num_items);
}

return $this->db->sql_fetchrow($this->result);
}

/**
* Returns the ids of the forums readable by the current user.
*
* @return int[]
*/
protected function get_readable_forums()

	{
static $forum_ids;


	{
static $forum_ids;


Line 164Line 219
		return $forum_ids;
}


		return $forum_ids;
}


	function get_moderator_approve_forums()






	/**
* Returns the ids of the forum for which the current user can approve the post in the moderation queue.
*
* @return int[]
*/
protected function get_moderator_approve_forums()

	{
static $forum_ids;


	{
static $forum_ids;


Line 176Line 236
		return $forum_ids;
}


		return $forum_ids;
}


	function is_moderator_approve_forum($forum_id)







	/**
* Returns true if the current user can approve the post of the given forum
*
* @param int $forum_id Forum id to check
* @return bool
*/
protected function is_moderator_approve_forum($forum_id)

	{
static $forum_ids;


	{
static $forum_ids;


Line 188Line 254
		return (isset($forum_ids[$forum_id])) ? true : false;
}


		return (isset($forum_ids[$forum_id])) ? true : false;
}


	function get_excluded_forums()






	/**
* Returns the ids of the forum excluded from the feeds
*
* @return int[]
*/
protected function get_excluded_forums()

	{
static $forum_ids;


	{
static $forum_ids;


Line 215Line 286
		return $forum_ids;
}


		return $forum_ids;
}


	function is_excluded_forum($forum_id)







	/**
* Returns true if the given id is in the excluded forums list.
*
* @param int $forum_id Id to check
* @return bool
*/
protected function is_excluded_forum($forum_id)

	{
$forum_ids = $this->get_excluded_forums();

return isset($forum_ids[$forum_id]) ? true : false;
}


	{
$forum_ids = $this->get_excluded_forums();

return isset($forum_ids[$forum_id]) ? true : false;
}


	function get_passworded_forums()






	/**
* Returns all password protected forum ids the current user is currently NOT authenticated for.
*
* @return array Array of forum ids
*/
protected function get_passworded_forums()

	{
return $this->user->get_passworded_forums();
}


	{
return $this->user->get_passworded_forums();
}


	function get_item()
{
static $result;

if (!isset($result))
{
if (!$this->get_sql())
{
return false;
}

// Query database
$sql = $this->db->sql_build_query('SELECT', $this->sql);
$result = $this->db->sql_query_limit($sql, $this->num_items);
}

return $this->db->sql_fetchrow($result);
}

function user_viewprofile($row)

	/**
* Returns the link to the user profile.
*
* @return string
*/
protected function user_viewprofile($row)















	{
$author_id = (int) $row[$this->get('author_id')];


	{
$author_id = (int) $row[$this->get('author_id')];


Line 259Line 327

return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&amp;u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
}


return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&amp;u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
}

 

/**
* Returns the SQL query used to retrieve the posts of the feed.
*
* @return string SQL SELECT query
*/
protected abstract function get_sql();

}


}