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