| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 4 * @license GNU General Public License version 2 or later; see LICENSE.txt 5 */ 6 7 // no direct access 8 defined('_JEXEC') or die; 9 10 /** 11 * Client table 12 * 13 * @package Joomla.Administrator 14 * @subpackage com_banners 15 * @since 1.6 16 */ 17 class BannersTableClient extends JTable 18 { 19 function __construct(&$_db) 20 { 21 $this->checked_out_time = $_db->getNullDate(); 22 parent::__construct('#__banner_clients', 'id', $_db); 23 } 24 25 /** 26 * Method to set the publishing state for a row or list of rows in the database 27 * table. The method respects checked out rows by other users and will attempt 28 * to checkin rows that it can after adjustments are made. 29 * 30 * @param mixed An optional array of primary key values to update. If not 31 * set the instance property value is used. 32 * @param integer The publishing state. eg. [0 = unpublished, 1 = published] 33 * @param integer The user id of the user performing the operation. 34 * @return boolean True on success. 35 * @since 1.0.4 36 */ 37 public function publish($pks = null, $state = 1, $userId = 0) 38 { 39 // Initialise variables. 40 $k = $this->_tbl_key; 41 42 // Sanitize input. 43 JArrayHelper::toInteger($pks); 44 $userId = (int) $userId; 45 $state = (int) $state; 46 47 // If there are no primary keys set check to see if the instance key is set. 48 if (empty($pks)) 49 { 50 if ($this->$k) { 51 $pks = array($this->$k); 52 } 53 // Nothing to set publishing state on, return false. 54 else { 55 $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); 56 return false; 57 } 58 } 59 60 // Build the WHERE clause for the primary keys. 61 $where = $k.'='.implode(' OR '.$k.'=', $pks); 62 63 // Determine if there is checkin support for the table. 64 if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) { 65 $checkin = ''; 66 } 67 else { 68 $checkin = ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')'; 69 } 70 71 // Update the publishing state for rows with the given primary keys. 72 $this->_db->setQuery( 73 'UPDATE '.$this->_db->quoteName($this->_tbl). 74 ' SET '.$this->_db->quoteName('state').' = '.(int) $state . 75 ' WHERE ('.$where.')' . 76 $checkin 77 ); 78 $this->_db->query(); 79 80 // Check for a database error. 81 if ($this->_db->getErrorNum()) { 82 $this->setError($this->_db->getErrorMsg()); 83 return false; 84 } 85 86 // If checkin is supported and all rows were adjusted, check them in. 87 if ($checkin && (count($pks) == $this->_db->getAffectedRows())) 88 { 89 // Checkin the rows. 90 foreach($pks as $pk) 91 { 92 $this->checkin($pk); 93 } 94 } 95 96 // If the JTable instance value is in the list of primary keys that were set, set the instance. 97 if (in_array($this->$k, $pks)) { 98 $this->state = $state; 99 } 100 101 $this->setError(''); 102 return true; 103 } 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |