Source for file contact.php

Documentation is available at contact.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_contact
  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.  * Controller for a single contact
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_contact
  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 override to check if you can edit an existing 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.      *
  60.      * @since   1.6
  61.      */
  62.     protected function allowEdit($data array()$key 'id')
  63.     {
  64.         $recordId = (int) isset($data[$key]$data[$key0;
  65.         $categoryId 0;
  66.  
  67.         if ($recordId)
  68.         {
  69.             $categoryId = (int) $this->getModel()->getItem($recordId)->catid;
  70.         }
  71.  
  72.         if ($categoryId)
  73.         {
  74.             // The category has been set. Check the category permissions.
  75.             return JFactory::getUser()->authorise('core.edit'$this->option . '.category.' $categoryId);
  76.         }
  77.         else
  78.         {
  79.             // Since there is no asset tracking, revert to the component permissions.
  80.             return parent::allowEdit($data$key);
  81.         }
  82.     }
  83.  
  84.     /**
  85.      * Method to run batch operations.
  86.      *
  87.      * @param   object  $model  The model.
  88.      *
  89.      * @return  boolean   True if successful, false otherwise and internal error is set.
  90.      *
  91.      * @since   2.5
  92.      */
  93.     public function batch($model null)
  94.     {
  95.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  96.  
  97.         // Set the model
  98.         $model $this->getModel('Contact'''array());
  99.  
  100.         // Preset the redirect
  101.         $this->setRedirect(JRoute::_('index.php?option=com_contact&view=contacts' $this->getRedirectToListAppend()false));
  102.  
  103.         return parent::batch($model);
  104.     }
  105.  
  106.     /**
  107.      * Function that allows child controller access to model data after the data has been saved.
  108.      *
  109.      * @param   JModelLegacy  $model      The data model object.
  110.      * @param   array         $validData  The validated data.
  111.      *
  112.      * @return  void 
  113.      * @since   3.1
  114.      */
  115.     protected function postSaveHook(JModelLegacy $model$validData array())
  116.     {
  117.     }
  118. }

Documentation generated on Tue, 19 Nov 2013 14:56:34 +0100 by phpDocumentor 1.4.3