Source for file weblink.php

Documentation is available at weblink.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_weblinks
  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.  * Weblink controller class.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_weblinks
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Method override to check if you can add a new record.
  22.      *
  23.      * @param   array  $data  An array of input data.
  24.      *
  25.      * @return  boolean 
  26.      *
  27.      * @since   1.6
  28.      */
  29.     protected function allowAdd($data array())
  30.     {
  31.         $user JFactory::getUser();
  32.         $categoryId JArrayHelper::getValue($data'catid'$this->input->getInt('filter_category_id')'int');
  33.         $allow null;
  34.  
  35.         if ($categoryId)
  36.         {
  37.             // If the category has been passed in the URL check it.
  38.             $allow $user->authorise('core.create'$this->option . '.category.' $categoryId);
  39.         }
  40.  
  41.         if ($allow === null)
  42.         {
  43.             // In the absense of better information, revert to the component permissions.
  44.             return parent::allowAdd($data);
  45.         }
  46.         else
  47.         {
  48.             return $allow;
  49.         }
  50.     }
  51.  
  52.     /**
  53.      * Method to check if you can add a new record.
  54.      *
  55.      * @param   array   $data  An array of input data.
  56.      * @param   string  $key   The name of the key for the primary key.
  57.      *
  58.      * @return  boolean 
  59.      * @since   1.6
  60.      */
  61.     protected function allowEdit($data array()$key 'id')
  62.     {
  63.         $recordId = (int) isset($data[$key]$data[$key0;
  64.         $categoryId 0;
  65.  
  66.         if ($recordId)
  67.         {
  68.             $categoryId = (int) $this->getModel()->getItem($recordId)->catid;
  69.         }
  70.  
  71.         if ($categoryId)
  72.         {
  73.             // The category has been set. Check the category permissions.
  74.             return JFactory::getUser()->authorise('core.edit'$this->option . '.category.' $categoryId);
  75.         }
  76.         else
  77.         {
  78.             // Since there is no asset tracking, revert to the component permissions.
  79.             return parent::allowEdit($data$key);
  80.         }
  81.     }
  82.  
  83.     /**
  84.      * Method to run batch operations.
  85.      *
  86.      * @param   object  $model  The model.
  87.      *
  88.      * @return  boolean   True if successful, false otherwise and internal error is set.
  89.      *
  90.      * @since   1.7
  91.      */
  92.     public function batch($model null)
  93.     {
  94.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  95.  
  96.         // Set the model
  97.         $model $this->getModel('Weblink'''array());
  98.  
  99.         // Preset the redirect
  100.         $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks' $this->getRedirectToListAppend()false));
  101.  
  102.         return parent::batch($model);
  103.     }
  104.  
  105.     /**
  106.      * Function that allows child controller access to model data after the data has been saved.
  107.      *
  108.      * @param   JModelLegacy  $model      The data model object.
  109.      * @param   array         $validData  The validated data.
  110.      *
  111.      * @return    void 
  112.      * @since    1.6
  113.      */
  114.     protected function postSaveHook(JModelLegacy $model$validData array())
  115.     {
  116.         $task $this->getTask();
  117.  
  118.         if ($task == 'save')
  119.         {
  120.             $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks'false));
  121.         }
  122.     }
  123. }

Documentation generated on Tue, 19 Nov 2013 15:18:26 +0100 by phpDocumentor 1.4.3