| Current Path : /home/juvelize/www/administrator/components/com_icagenda/tables/ |
| Current File : /home/juvelize/www/administrator/components/com_icagenda/tables/registration.php |
<?php
/**
*----------------------------------------------------------------------------
* iCagenda Events Management Extension for Joomla!
*----------------------------------------------------------------------------
* @version 3.9.0 2023-10-25
*
* @package iCagenda.Admin
* @link https://www.icagenda.com
*
* @author Cyril Rezé
* @copyright (c) 2012-2024 Cyril Rezé / iCagenda. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*
* @since 3.3.3
*----------------------------------------------------------------------------
*/
defined('_JEXEC') or die;
/**
* category Table class
*/
class iCagendaTableregistration extends JTable
{
/**
* Constructor
*
* @param JDatabaseDriver $db Database connector object
*
* @since 3.3.3
*/
public function __construct(&$db)
{
parent::__construct('#__icagenda_registration', 'id', $db);
// Set the alias for 'published' since the column is called 'state'
$this->setColumnAlias('published', 'state');
}
/**
* Overloaded bind function.
*
* @param array Named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 3.3.3
*/
public function bind($array, $ignore = '')
{
if ($array['date'] == 'period')
{
$array['date'] = '';
}
return parent::bind($array, $ignore);
}
/**
* Overloaded check function
*/
public function check()
{
// If there is an ordering column and this is a new row then get the next ordering value
if (property_exists($this, 'ordering') && $this->id == 0)
{
$this->ordering = self::getNextOrder();
}
return parent::check();
}
/**
* 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 $pks An optional array of primary key values to update. If not set the instance property value is used.
* @param integer $state The sticky state. eg. [0 = unsticked, 1 = sticked]
* @param integer $userId The user id of the user performing the operation.
*
* @return boolean True on success.
*
* @since 3.8
*/
public function stick($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
$pks = ArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Get an instance of the table
/** @var iCagendaTableRegistration $table */
$table = JTable::getInstance('Registration', 'iCagendaTable');
// For all keys
foreach ($pks as $pk)
{
// Load the banner
if (!$table->load($pk))
{
$this->setError($table->getError());
}
// Verify checkout
if (is_null($table->checked_out) || $table->checked_out == $userId)
{
// Change the state
$table->sticky = $state;
$table->checked_out = null;
$table->checked_out_time = null;
// Check the row
$table->check();
// Store the row
if (!$table->store())
{
$this->setError($table->getError());
}
}
}
return count($this->getErrors()) == 0;
}
}