english/administrator/components/com_banners/tables/banner.php
/**
	 * Method to set the sticky state for a row or list of rows in the database
	 * table.  The method respects checked out rows by other users and will attempt
	 * to checkin rows that it can after adjustments are made.
	 *
	 * @param	mixed	An optional array of primary key values to update.  If not
	 *					set the instance property value is used.
	 * @param	integer The sticky state. eg. [0 = unsticked, 1 = sticked]
	 * @param	integer The user id of the user performing the operation.
	 * @return	boolean	True on success.
	 * @since	1.6
	 */
Method to set the sticky state for a row or list of rows in the database
table.  The method respects checked out rows by other users and will attempt
to checkin rows that it can after adjustments are made.

@param       mixed   An optional array of primary key values to update.  If not
set the instance property value is used.
@param       integer The sticky state. eg. [0 = unsticked, 1 = sticked]
@param       integer The user id of the user performing the operation.
@return      boolean True on success.
Method to set the sticky state for a row or list of rows in the database table . The method respects checked out rows by other users and will attempt to checkin rows that it can after adjustments are made . @param mixed An optional array of primary key values to update . If not set the instance property value is used . @param integer The sticky state . eg . [ 0 = unsticked 1 = sticked ] @param integer The user id of the user performing the operation . @return boolean True on success .
public function stick($pks = null, $state = 1, $userId = 0)
	{
		$k = $this->_tbl_key;
		JArrayHelper::toInteger($pks);
		$userId = (int) $userId;
		$state  = (int) $state;
		if (empty($pks))
		{
			if ($this->$k) {
				$pks = array($this->$k);
			}
			else {
				$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
				return false;
			}
		}
		$table = JTable::getInstance('Banner','BannersTable');
		foreach ($pks as $pk)
		{
			if(!$table->load($pk))
			{
				$this->setError($table->getError());
			}
			if($table->checked_out==0 || $table->checked_out==$userId)
			{
				$table->sticky = $state;
				$table->checked_out=0;
				$table->checked_out_time=0;
				$table->check();
				if (!$table->store())
				{
					$this->setError($table->getError());
				}
			}
		}
		return count($this->getErrors())==0;
	}
public function stick ( $ pks = null , $ state = 1 , $ userId = 0 ) { $ k = $ this -> _tbl_key ; JArrayHelper :: toInteger ( $ pks ) ; $ userId = ( int ) $ userId ; $ state = ( int ) $ state ; if ( empty ( $ pks ) ) { if ( $ this -> $ k ) { $ pks = array ( $ this -> $ k ) ; } else { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_NO_ROWS_SELECTED' ) ) ; return false ; } } $ table = JTable :: getInstance ( 'Banner' , 'BannersTable' ) ; foreach ( $ pks as $ pk ) { if ( ! $ table -> load ( $ pk ) ) { $ this -> setError ( $ table -> getError ( ) ) ; } if ( $ table -> checked_out == 0 || $ table -> checked_out == $ userId ) { $ table -> sticky = $ state ; $ table -> checked_out = 0 ; $ table -> checked_out_time = 0 ; $ table -> check ( ) ; if ( ! $ table -> store ( ) ) { $ this -> setError ( $ table -> getError ( ) ) ; } } } return count ( $ this -> getErrors ( ) ) == 0 ; }
Method to set the sticky state for a row or list of rows in the database
 table.
Method to set the sticky state for a row or list of rows in the database table .
// Initialise variables. // Sanitize input. // If there are no primary keys set check to see if the instance key is set. // Nothing to set publishing state on, return false. // Get an instance of the table // For all keys // Load the banner // Verify checkout // Change the state // Check the row // Store the row