Source for file newsfeed.php
Documentation is available at newsfeed.php
* @subpackage com_newsfeeds
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Newsfeeds Component Newsfeed Model
* @subpackage com_newsfeeds
protected $_context =
'com_newsfeeds.newsfeed';
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
// Load state from the request.
$pk =
$app->input->getInt('id');
$offset =
$app->input->get('limitstart', 0, 'uint');
$this->setState('list.offset', $offset);
$params =
$app->getParams();
if ((!$user->authorise('core.edit.state', 'com_newsfeeds')) &&
(!$user->authorise('core.edit', 'com_newsfeeds'))){
* Method to get newsfeed data.
* @param integer The id of the newsfeed.
* @return mixed Menu item data object on success, false on failure.
public function &getItem($pk =
null)
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('newsfeed.id');
if ($this->_item ===
null)
if (!isset
($this->_item[$pk]))
$query =
$db->getQuery(true)
->select($this->getState('item.select', 'a.*'))
->from('#__newsfeeds AS a');
// Join on category table.
$query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
->join('LEFT', '#__categories AS c on c.id = a.catid');
$query->select('u.name AS author')
->join('LEFT', '#__users AS u on u.id = a.created_by');
// Join over the categories to get parent category titles
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id')
->where('a.id = ' . (int)
$pk);
// Filter by start and end dates.
$nullDate =
$db->quote($db->getNullDate());
// Filter by published state.
$published =
$this->getState('filter.published');
$archived =
$this->getState('filter.archived');
$query->where('(a.published = ' . (int)
$published .
' OR a.published =' . (int)
$archived .
')')
->where('(a.publish_up = ' .
$nullDate .
' OR a.publish_up <= ' .
$nowDate .
')')
->where('(a.publish_down = ' .
$nullDate .
' OR a.publish_down >= ' .
$nowDate .
')')
->where('(c.published = ' . (int)
$published .
' OR c.published =' . (int)
$archived .
')');
$data =
$db->loadObject();
// Check for published state if filter set.
if (((is_numeric($published)) ||
(is_numeric($archived))) &&
(($data->published !=
$published) &&
($data->published !=
$archived)))
// Convert parameter fields to objects.
$registry->loadString($data->params);
$data->params =
clone $this->getState('params');
$data->params->merge($registry);
$registry->loadString($data->metadata);
$data->metadata =
$registry;
// Compute access permissions.
if ($access =
$this->getState('filter.access'))
// If the access filter has been set, we already know this user can view.
$data->params->set('access-view', true);
// If no access filter is set, the layout takes some responsibility for display of limited information.
$groups =
$user->getAuthorisedViewLevels();
$data->params->set('access-view', in_array($data->access, $groups) &&
in_array($data->category_access, $groups));
$this->_item[$pk] =
$data;
$this->_item[$pk] =
false;
return $this->_item[$pk];
* Increment the hit counter for the newsfeed.
* @param int $pk Optional primary key of the item to increment.
* @return boolean True if successful; false otherwise and internal error set.
public function hit($pk =
0)
$hitcount =
$input->getInt('hitcount', 1);
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('newsfeed.id');
Documentation generated on Tue, 19 Nov 2013 15:09:29 +0100 by phpDocumentor 1.4.3