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 table
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_banners
  17.  * @since       1.6
  18.  */
  19. class BannersTableClient extends JTable
  20. {
  21.     public function __construct(&$_db)
  22.     {
  23.         $this->checked_out_time $_db->getNullDate();
  24.         parent::__construct('#__banner_clients''id'$_db);
  25.     }
  26.  
  27.     /**
  28.      * Method to set the publishing state for a row or list of rows in the database
  29.      * table.  The method respects checked out rows by other users and will attempt
  30.      * to checkin rows that it can after adjustments are made.
  31.      *
  32.      * @param   mixed    An optional array of primary key values to update.  If not
  33.      *                     set the instance property value is used.
  34.      * @param   integer The publishing state. eg. [0 = unpublished, 1 = published]
  35.      * @param   integer The user id of the user performing the operation.
  36.      * @return  boolean  True on success.
  37.      * @since   1.0.4
  38.      */
  39.     public function publish($pks null$state 1$userId 0)
  40.     {
  41.         $k $this->_tbl_key;
  42.  
  43.         // Sanitize input.
  44.         JArrayHelper::toInteger($pks);
  45.         $userId = (int) $userId;
  46.         $state  = (int) $state;
  47.  
  48.         // If there are no primary keys set check to see if the instance key is set.
  49.         if (empty($pks))
  50.         {
  51.             if ($this->$k)
  52.             {
  53.                 $pks array($this->$k);
  54.             }
  55.             // Nothing to set publishing state on, return false.
  56.             else {
  57.                 $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
  58.                 return false;
  59.             }
  60.         }
  61.  
  62.         // Build the WHERE clause for the primary keys.
  63.         $where $k.'='.implode(' OR '.$k.'='$pks);
  64.  
  65.         // Determine if there is checkin support for the table.
  66.         if (!property_exists($this'checked_out'|| !property_exists($this'checked_out_time'))
  67.         {
  68.             $checkin '';
  69.         }
  70.         else
  71.         {
  72.             $checkin ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')';
  73.         }
  74.  
  75.         // Update the publishing state for rows with the given primary keys.
  76.         $this->_db->setQuery(
  77.             'UPDATE '.$this->_db->quoteName($this->_tbl).
  78.             ' SET '.$this->_db->quoteName('state').' = '.(int) $state .
  79.             ' WHERE ('.$where.')' .
  80.             $checkin
  81.         );
  82.  
  83.         try
  84.         {
  85.             $this->_db->execute();
  86.         }
  87.         catch (RuntimeException $e)
  88.         {
  89.             $this->setError($e->getMessage());
  90.             return false;
  91.         }
  92.  
  93.         // If checkin is supported and all rows were adjusted, check them in.
  94.         if ($checkin && (count($pks== $this->_db->getAffectedRows()))
  95.         {
  96.             // Checkin the rows.
  97.             foreach ($pks as $pk)
  98.             {
  99.                 $this->checkin($pk);
  100.             }
  101.         }
  102.  
  103.         // If the JTable instance value is in the list of primary keys that were set, set the instance.
  104.         if (in_array($this->$k$pks))
  105.         {
  106.             $this->state $state;
  107.         }
  108.  
  109.         $this->setError('');
  110.         return true;
  111.     }
  112. }

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