Source for file banner.php

Documentation is available at banner.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_banners
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Banner controller class.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_banners
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * @var    string  The prefix to use with controller messages.
  22.      * @since  1.6
  23.      */
  24.     protected $text_prefix = 'COM_BANNERS_BANNER';
  25.  
  26.     /**
  27.      * Method override to check if you can add a new record.
  28.      *
  29.      * @param   array  $data  An array of input data.
  30.      *
  31.      * @return  boolean 
  32.      *
  33.      * @since   1.6
  34.      */
  35.     protected function allowAdd($data array())
  36.     {
  37.         $user       JFactory::getUser();
  38.         $filter     $this->input->getInt('filter_category_id');
  39.         $categoryId JArrayHelper::getValue($data'catid'$filter'int');
  40.         $allow      null;
  41.  
  42.         if ($categoryId)
  43.         {
  44.             // If the category has been passed in the URL check it.
  45.             $allow    $user->authorise('core.create'$this->option . '.category.' $categoryId);
  46.         }
  47.  
  48.         if ($allow === null)
  49.         {
  50.             // In the absence of better information, revert to the component permissions.
  51.             return parent::allowAdd($data);
  52.         }
  53.         else
  54.         {
  55.             return $allow;
  56.         }
  57.     }
  58.  
  59.     /**
  60.      * Method override to check if you can edit an existing record.
  61.      *
  62.      * @param   array   $data  An array of input data.
  63.      * @param   string  $key   The name of the key for the primary key.
  64.      *
  65.      * @return  boolean 
  66.      *
  67.      * @since   1.6
  68.      */
  69.     protected function allowEdit($data array()$key 'id')
  70.     {
  71.         $user        JFactory::getUser();
  72.         $recordId    = (int) isset($data[$key]$data[$key0;
  73.         $categoryId 0;
  74.  
  75.         if ($recordId)
  76.         {
  77.             $categoryId = (int) $this->getModel()->getItem($recordId)->catid;
  78.         }
  79.  
  80.         if ($categoryId)
  81.         {
  82.             // The category has been set. Check the category permissions.
  83.             return $user->authorise('core.edit'$this->option . '.category.' $categoryId);
  84.         }
  85.         else
  86.         {
  87.             // Since there is no asset tracking, revert to the component permissions.
  88.             return parent::allowEdit($data$key);
  89.         }
  90.     }
  91.  
  92.     /**
  93.      * Method to run batch operations.
  94.      *
  95.      * @param   string  $model  The model
  96.      *
  97.      * @return  boolean  True on success.
  98.      *
  99.      * @since    2.5
  100.      */
  101.     public function batch($model null)
  102.     {
  103.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  104.  
  105.         // Set the model
  106.         $model    $this->getModel('Banner'''array());
  107.  
  108.         // Preset the redirect
  109.         $this->setRedirect(JRoute::_('index.php?option=com_banners&view=banners' $this->getRedirectToListAppend()false));
  110.  
  111.         return parent::batch($model);
  112.     }
  113.  
  114. }

Documentation generated on Tue, 19 Nov 2013 14:54:17 +0100 by phpDocumentor 1.4.3