[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_newsfeeds/models/ -> newsfeed.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: newsfeed.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Content
   6   * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7   * @license        GNU/GPL, see LICENSE.php
   8   * Joomla! is free software. This version may have been modified pursuant to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport('joomla.application.component.model');
  19  
  20  /**
  21   * Newsfeeds Component Newsfeed Model
  22   *
  23   * @package        Joomla
  24   * @subpackage    Newsfeeds
  25   * @since 1.5
  26   */
  27  class NewsfeedsModelNewsfeed extends JModel
  28  {
  29      /**
  30       * Newsfeed id
  31       *
  32       * @var int
  33       */
  34      var $_id = null;
  35  
  36      /**
  37       * Newsfeed data
  38       *
  39       * @var array
  40       */
  41      var $_data = null;
  42  
  43      /**
  44       * Constructor
  45       *
  46       * @since 1.5
  47       */
  48  	function __construct()
  49      {
  50          parent::__construct();
  51  
  52          $id = JRequest::getVar('id', 0, '', 'int');
  53          $this->setId((int)$id);
  54      }
  55  
  56      /**
  57       * Method to set the newsfeed identifier
  58       *
  59       * @access    public
  60       * @param    int Newsfeed identifier
  61       */
  62  	function setId($id)
  63      {
  64          // Set weblink id and wipe data
  65          $this->_id     = $id;
  66          $this->_data = null;
  67      }
  68  
  69      /**
  70       * Method to get the newsfeed data
  71       *
  72       * @since 1.5
  73       */
  74      function &getData()
  75      {
  76          // Load the weblink data
  77          if ($this->_loadData())
  78          {
  79              // Initialize some variables
  80              $user = &JFactory::getUser();
  81  
  82              // Make sure the category is published
  83              if (!$this->_data->published) {
  84                  JError::raiseError(404, JText::_("Resource Not Found"));
  85                  return false;
  86              }
  87  
  88              // Check to see if the category is published
  89              if (!$this->_data->cat_pub) {
  90                  JError::raiseError( 404, JText::_("Resource Not Found") );
  91                  return;
  92              }
  93  
  94              // Check whether category access level allows access
  95              if ($this->_data->cat_access > $user->get('aid', 0)) {
  96                  JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
  97                  return;
  98              }
  99  
 100          }
 101  
 102          return $this->_data;
 103      }
 104  
 105      /**
 106       * Method to load newsfeed data
 107       *
 108       * @access    private
 109       * @return    boolean    True on success
 110       * @since    1.5
 111       */
 112  	function _loadData()
 113      {
 114          // Lets load the content if it doesn't already exist
 115          if (empty($this->_data))
 116          {
 117              $query = 'SELECT f.*, cc.title AS category,'.
 118                      ' cc.published AS cat_pub, cc.access AS cat_access,'.
 119                      ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as catslug'.
 120                      ' FROM #__newsfeeds AS f' .
 121                      ' LEFT JOIN #__categories AS cc ON cc.id = f.catid' .
 122                      ' WHERE f.id = '.$this->_id;
 123              $this->_db->setQuery($query);
 124              $this->_data = $this->_db->loadObject();
 125              return (boolean) $this->_data;
 126          }
 127          return true;
 128      }
 129  
 130  }
 131  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1