Source for file client.php

Documentation is available at client.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.  * Client model.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_banners
  17.  * @since       1.6
  18.  */
  19. {
  20.  
  21.     /**
  22.      * The type alias for this content type.
  23.      *
  24.      * @var      string 
  25.      * @since    3.2
  26.      */
  27.     public $typeAlias = 'com_banners.client';
  28.  
  29.     /**
  30.      * Method to test whether a record can be deleted.
  31.      *
  32.      * @param   object    record object.
  33.      * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
  34.      * @since   1.6
  35.      */
  36.     protected function canDelete($record)
  37.     {
  38.         if (!empty($record->id))
  39.             {
  40.                 if ($record->state != -2)
  41.                 {
  42.                     return;
  43.                 }
  44.             $user JFactory::getUser();
  45.  
  46.             if (!empty($record->catid))
  47.             {
  48.                 return $user->authorise('core.delete''com_banners.category.'.(int) $record->catid);
  49.             }
  50.             else {
  51.                 return $user->authorise('core.delete''com_banners');
  52.             }
  53.         }
  54.     }
  55.  
  56.     /**
  57.      * Method to test whether a record can be deleted.
  58.      *
  59.      * @param   object   record object.
  60.      * @return  boolean  True if allowed to change the state of the record.
  61.      *                    Defaults to the permission set in the component.
  62.      *
  63.      * @since   1.6
  64.      */
  65.     protected function canEditState($record)
  66.     {
  67.         $user JFactory::getUser();
  68.  
  69.         if (!empty($record->catid))
  70.         {
  71.             return $user->authorise('core.edit.state''com_banners.category.'.(int) $record->catid);
  72.         }
  73.         else
  74.         {
  75.             return $user->authorise('core.edit.state''com_banners');
  76.         }
  77.     }
  78.  
  79.     /**
  80.      * Returns a reference to the a Table object, always creating it.
  81.      *
  82.      * @param   type    The table type to instantiate
  83.      * @param   string    A prefix for the table class name. Optional.
  84.      * @param   array  Configuration array for model. Optional.
  85.      * @return  JTable    A database object
  86.      * @since   1.6
  87.      */
  88.     public function getTable($type 'Client'$prefix 'BannersTable'$config array())
  89.     {
  90.         return JTable::getInstance($type$prefix$config);
  91.     }
  92.  
  93.     /**
  94.      * Method to get the record form.
  95.      *
  96.      * @param   array    $data      Data for the form.
  97.      * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  98.      *
  99.      * @return  mixed    A JForm object on success, false on failure
  100.      * @since   1.6
  101.      */
  102.     public function getForm($data array()$loadData true)
  103.     {
  104.         // Get the form.
  105.         $form $this->loadForm('com_banners.client''client'array('control' => 'jform''load_data' => $loadData));
  106.         if (empty($form))
  107.         {
  108.             return false;
  109.         }
  110.  
  111.         return $form;
  112.     }
  113.  
  114.     /**
  115.      * Method to get the data that should be injected in the form.
  116.      *
  117.      * @return  mixed  The data for the form.
  118.      * @since   1.6
  119.      */
  120.     protected function loadFormData()
  121.     {
  122.         // Check the session for previously entered form data.
  123.         $data JFactory::getApplication()->getUserState('com_banners.edit.client.data'array());
  124.  
  125.         if (empty($data))
  126.         {
  127.             $data $this->getItem();
  128.         }
  129.  
  130.         $this->preprocessData('com_banners.client'$data);
  131.  
  132.         return $data;
  133.     }
  134.  
  135.     /**
  136.      * Prepare and sanitise the table data prior to saving.
  137.      *
  138.      * @param   JTable    A JTable object.
  139.      * @since   1.6
  140.      */
  141.     protected function prepareTable($table)
  142.     {
  143.         $table->name htmlspecialchars_decode($table->nameENT_QUOTES);
  144.     }
  145. }

Documentation generated on Tue, 19 Nov 2013 14:55:47 +0100 by phpDocumentor 1.4.3