primo commit
This commit is contained in:
276
administrator/components/com_jem/tables/category.php
Normal file
276
administrator/components/com_jem/tables/category.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Nested;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
jimport('joomla.database.tablenested');
|
||||
|
||||
/**
|
||||
* Category Table
|
||||
*/
|
||||
class JemTableCategory extends Nested
|
||||
{
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__jem_categories', 'id', $db);
|
||||
|
||||
if (self::addRoot() !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a node and, optionally, its child nodes from the table.
|
||||
*
|
||||
* @param integer $pk The primary key of the node to delete.
|
||||
* @param boolean $children True to delete child nodes, false to move them up a level.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @link https://docs.joomla.org/JTableNested/delete
|
||||
*/
|
||||
public function delete($pk = null, $children = false)
|
||||
{
|
||||
return parent::delete($pk, $children);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the root node to an empty table.
|
||||
*
|
||||
* @return integer The id of the new root node.
|
||||
*/
|
||||
public function addRoot()
|
||||
{
|
||||
if (self::getRootId() !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Insert columns.
|
||||
$columns = array('parent_id', 'lft','rgt', 'level', 'catname', 'alias', 'access','title','published');
|
||||
|
||||
// Insert values.
|
||||
$values = array(0, 0, 1, 0, $db->quote('root'), $db->quote('root'),1, $db->quote('root'),1);
|
||||
|
||||
// Prepare the insert query.
|
||||
$query
|
||||
->insert($db->quoteName('#__jem_categories'))
|
||||
->columns($db->quoteName($columns))
|
||||
->values(implode(',', $values));
|
||||
$db->setQuery($query);
|
||||
|
||||
$db->execute();
|
||||
|
||||
return $db->insertid();
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
if ($ret < 0) {
|
||||
$this->setError(get_class($this).'::store failed - '.$this->_db->getError());
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
$results = $this->_db->execute();
|
||||
if ($results === false){
|
||||
return -1;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @see Table::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Check for a title.
|
||||
if (trim($this->catname) == '') {
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_CATEGORY'));
|
||||
return false;
|
||||
}
|
||||
$this->alias = trim($this->alias);
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = $this->catname;
|
||||
}
|
||||
|
||||
$this->alias = JemHelper::stringURLSafe($this->alias);
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function.
|
||||
*
|
||||
* @param array $array named array
|
||||
* @param string $ignore An optional array or space separated list of properties
|
||||
* to ignore while binding.
|
||||
*
|
||||
* @return mixed Null if operation was satisfactory, otherwise returns an error
|
||||
*
|
||||
* @see Table::bind
|
||||
* @since 11.1
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
if (isset($array['params']) && is_array($array['params'])) {
|
||||
$registry = new Registry;
|
||||
$registry->loadArray($array['params']);
|
||||
$array['params'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['metadata']) && is_array($array['metadata'])) {
|
||||
$registry = new Registry;
|
||||
$registry->loadArray($array['metadata']);
|
||||
$array['metadata'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['rules']) && is_array($array['rules'])) {
|
||||
$rules = new JAccessRules($array['rules']);
|
||||
$this->setRules($rules);
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded Table::store to set created/modified and user id.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = JemFactory::getUser();
|
||||
if ($this->id) {
|
||||
// Existing category
|
||||
$this->modified_time = $date->toSql();
|
||||
$this->modified_user_id = $user->get('id');
|
||||
} else {
|
||||
// New category
|
||||
$this->created_time = $date->toSql();
|
||||
$this->created_user_id = $user->get('id');
|
||||
}
|
||||
// Verify that the alias is unique
|
||||
$table = Table::getInstance('Category', 'JEMTable', array('dbo' => Factory::getContainer()->get('DatabaseDriver')));
|
||||
|
||||
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id))
|
||||
&& ($table->id != $this->id || $this->id == 0)) {
|
||||
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Csv Import
|
||||
* @Todo add validation
|
||||
*/
|
||||
public function checkCsvImport()
|
||||
{
|
||||
foreach (get_object_vars($this) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
//Change datetime to null when its value is '000-00-00' (support J4 & J5)
|
||||
if(strpos($v, "0000-00-00")!== FALSE){
|
||||
$this->$k = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Csv Import
|
||||
*/
|
||||
public function storeCsvImport($updateNulls = false)
|
||||
{
|
||||
// Initialise variables.
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// If a primary key exists update the object, otherwise insert it.
|
||||
if ($this->$k) {
|
||||
$stored = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
|
||||
} else {
|
||||
$stored = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
|
||||
}
|
||||
|
||||
// If the store failed return false.
|
||||
if (!$stored) {
|
||||
$e = Text::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $stored->getError());
|
||||
$this->setError($e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_locked) {
|
||||
$this->_unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
468
administrator/components/com_jem/tables/event.php
Normal file
468
administrator/components/com_jem/tables/event.php
Normal file
@ -0,0 +1,468 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
|
||||
/**
|
||||
* JEM Event Table
|
||||
*/
|
||||
class JemTableEvent extends Table
|
||||
{
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__jem_events', 'id', $db);
|
||||
}
|
||||
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Overloaded bind method for the Event table.
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
// in here we are checking for the empty value of the checkbox
|
||||
|
||||
if (!isset($array['registra'])) {
|
||||
$array['registra'] = 0 ;
|
||||
}
|
||||
if(isset($array['contactid'])){
|
||||
$array['contactid'] = (int) $array['contactid'];
|
||||
}
|
||||
if (!isset($array['unregistra'])) {
|
||||
$array['unregistra'] = 0 ;
|
||||
}
|
||||
|
||||
if (!isset($array['waitinglist'])) {
|
||||
$array['waitinglist'] = 0 ;
|
||||
}
|
||||
|
||||
if (!isset($array['requestanswer'])) {
|
||||
$array['requestanswer'] = 0 ;
|
||||
}
|
||||
|
||||
// Search for the {readmore} tag and split the text up accordingly.
|
||||
if (isset($array['articletext'])) {
|
||||
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
|
||||
$tagPos = preg_match($pattern, $array['articletext']);
|
||||
|
||||
if ($tagPos == 0) {
|
||||
$this->introtext = $array['articletext'];
|
||||
$this->fulltext = '';
|
||||
} else {
|
||||
list ($this->introtext, $this->fulltext) = preg_split($pattern, $array['articletext'], 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($array['attribs']) && is_array($array['attribs'])) {
|
||||
$registry = new Registry;
|
||||
$registry->loadArray($array['attribs']);
|
||||
$array['attribs'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['metadata']) && is_array($array['metadata'])) {
|
||||
$registry = new Registry;
|
||||
$registry->loadArray($array['metadata']);
|
||||
$array['metadata'] = (string) $registry;
|
||||
}
|
||||
|
||||
// Bind the rules.
|
||||
/*
|
||||
if (isset($array['rules']) && is_array($array['rules'])) {
|
||||
$rules = new JAccessRules($array['rules']);
|
||||
$this->setRules($rules);
|
||||
}
|
||||
*/
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* overloaded check function
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$jinput = Factory::getApplication()->input;
|
||||
|
||||
if (trim($this->title) == '') {
|
||||
$this->setError(Text::_('COM_JEM_EVENT_ERROR_NAME'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trim($this->alias) == '') {
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
$this->alias = JemHelper::stringURLSafe($this->alias);
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = JemHelper::stringURLSafe($this->title);
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($this->times)) {
|
||||
$this->times = null;
|
||||
}
|
||||
|
||||
if (empty($this->endtimes)) {
|
||||
$this->endtimes = null;
|
||||
}
|
||||
|
||||
|
||||
// Dates
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$nullDate = $db->getNullDate();
|
||||
|
||||
if (empty($this->enddates) || ($this->enddates == $nullDate)) {
|
||||
$this->enddates = null;
|
||||
}
|
||||
|
||||
if (empty($this->dates) || ($this->dates == $nullDate)) {
|
||||
$this->dates = null;
|
||||
}
|
||||
|
||||
// check startDate - don't delete other fields; it's ok to know a time but not the day
|
||||
//if ($this->dates == NULL) {
|
||||
// $this->times = NULL;
|
||||
// $this->enddates = NULL;
|
||||
// $this->endtimes = NULL;
|
||||
//}
|
||||
|
||||
// Check begin date is before end date
|
||||
|
||||
// Check if end date is set
|
||||
if ($this->enddates == null) {
|
||||
// Check if end time is set
|
||||
if ($this->endtimes == null) {
|
||||
$date1 = new DateTime('00:00');
|
||||
$date2 = new DateTime('00:00');
|
||||
} else {
|
||||
$date1 = new DateTime($this->times);
|
||||
$date2 = new DateTime($this->endtimes);
|
||||
}
|
||||
} else {
|
||||
// Check if end time is set
|
||||
if ($this->endtimes == null) {
|
||||
$date1 = new DateTime($this->dates);
|
||||
$date2 = new DateTime($this->enddates);
|
||||
} else {
|
||||
$date1 = new DateTime($this->dates.' '.$this->times);
|
||||
$date2 = new DateTime($this->enddates.' '.$this->endtimes);
|
||||
}
|
||||
}
|
||||
|
||||
if ($date1 > $date2) {
|
||||
$this->setError(Text::_('COM_JEM_EVENT_ERROR_END_BEFORE_START_DATES'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* store method for the Event table.
|
||||
*/
|
||||
public function store($updateNulls = true)
|
||||
{
|
||||
|
||||
$date = Factory::getDate();
|
||||
$user = JemFactory::getUser();
|
||||
$userid = $user->get('id');
|
||||
$app = Factory::getApplication();
|
||||
$jinput = $app->input;
|
||||
$jemsettings = JemHelper::config();
|
||||
|
||||
// Check if we're in the front or back
|
||||
if ($app->isClient('administrator')) {
|
||||
$backend = true;
|
||||
} else {
|
||||
$backend = false;
|
||||
}
|
||||
if ($this->id) {
|
||||
// Existing event
|
||||
$this->modified = $date->toSql();
|
||||
$this->modified_by = $userid;
|
||||
} else {
|
||||
$this->modified = null;
|
||||
if(empty($this->created_by_alias))
|
||||
$this->created_by_alias='';
|
||||
if(empty($this->language))
|
||||
$this->language='';
|
||||
|
||||
// New event
|
||||
if (!intval($this->created)) {
|
||||
$this->created = $date->toSql();
|
||||
}
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = $userid;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if image was selected
|
||||
jimport('joomla.filesystem.file');
|
||||
$image_dir = JPATH_SITE.'/images/jem/events/';
|
||||
$filetypes = $jemsettings->image_filetypes ?: 'jpg,gif,png,webp';
|
||||
$allowable = explode(',', strtolower($filetypes));
|
||||
array_walk($allowable, function(&$v){$v = trim($v);});
|
||||
$image_to_delete = false;
|
||||
|
||||
// get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
|
||||
if (!$backend) {
|
||||
if (($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1)) {
|
||||
$file = $jinput->files->get('userfile', array(), 'array');
|
||||
$removeimage = $jinput->getInt('removeimage', 0);
|
||||
$datimage = $jinput->getCmd('datimage', '');
|
||||
|
||||
if (empty($file)) {
|
||||
$file2 = $jinput->files->get('jform', array(), 'array');
|
||||
if (!empty($file2['userfile'])) {
|
||||
$file = $file2['userfile'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($file['name'])) {
|
||||
// only on first event, skip on recurrence events
|
||||
|
||||
if (empty($this->recurrence_first_id)) {
|
||||
//check the image
|
||||
$check = JemImage::check($file, $jemsettings);
|
||||
|
||||
if ($check !== false) {
|
||||
//sanitize the image filename
|
||||
$filename = JemImage::sanitize($image_dir, $file['name']);
|
||||
$filepath = $image_dir . $filename;
|
||||
|
||||
if (File::upload($file['tmp_name'], $filepath)) {
|
||||
$image_to_delete = $this->datimage; // delete previous image
|
||||
$this->datimage = $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (!empty($removeimage)) {
|
||||
// if removeimage is non-zero remove image from event
|
||||
// (file will be deleted later (e.g. housekeeping) if unused)
|
||||
$image_to_delete = $this->datimage;
|
||||
$this->datimage = '';
|
||||
} elseif (!$this->id && is_null($this->datimage) && !empty($datimage)) {
|
||||
// event is a copy so copy datimage too
|
||||
if (File::exists($image_dir . $datimage)) {
|
||||
// if it's already within image folder it's safe
|
||||
$this->datimage = $datimage;
|
||||
}
|
||||
}
|
||||
} // end image if
|
||||
} // if (!backend)
|
||||
|
||||
$format = File::getExt($image_dir . $this->datimage);
|
||||
if (!in_array($format, $allowable))
|
||||
{
|
||||
$this->datimage = '';
|
||||
}
|
||||
|
||||
// user check on frontend but not if caused by cleanup function (recurrence)
|
||||
if (!$backend && !(isset($this->_autocreate) && ($this->_autocreate === true))) {
|
||||
// check if the user has the required rank to publish this event
|
||||
if (!$this->id && !$user->can('publish', 'event', $this->id, $this->created_by)) {
|
||||
$this->published = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// item must be stored BEFORE image deletion
|
||||
$ret = parent::store($updateNulls);
|
||||
if ($ret && $image_to_delete) {
|
||||
JemHelper::delete_unused_image_files('event', $image_to_delete);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the publishing 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 array of primary key values to update. If not set
|
||||
* the instance property value is used. [optional]
|
||||
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] [optional]
|
||||
* @param integer $userId The user id of the user performing the operation. [optional]
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
public function publish($pks = null, $state = 1, $userId = 0)
|
||||
{
|
||||
// Initialise variables.
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// Sanitize input.
|
||||
\Joomla\Utilities\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((int)$this->$k);
|
||||
} else {
|
||||
// Nothing to set publishing state on, return false.
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the WHERE clause for the primary keys.
|
||||
$where = $this->_db->quoteName($k) . ' IN (' . implode(',', $pks) . ')';
|
||||
|
||||
// Determine if there is checkin support for the table.
|
||||
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
|
||||
$checkin = '';
|
||||
} else {
|
||||
$checkin = ' AND (checked_out IS null OR checked_out = 0 OR checked_out = ' . (int) $userId . ')';
|
||||
}
|
||||
|
||||
// Update the publishing state for rows with the given primary keys.
|
||||
$query = $this->_db->getQuery(true);
|
||||
$query->update($this->_db->quoteName($this->_tbl));
|
||||
$query->set($this->_db->quoteName('published') . ' = ' . (int) $state);
|
||||
$query->where($where);
|
||||
|
||||
|
||||
// Check for a database error.
|
||||
// TODO: use exception handling
|
||||
// if ($this->_db->getErrorNum()) {
|
||||
// $this->setError($this->_db->getErrorMsg());
|
||||
// return false;
|
||||
// }
|
||||
try
|
||||
{
|
||||
$this->_db->setQuery($query . $checkin);
|
||||
$this->_db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
|
||||
}
|
||||
|
||||
// If checkin is supported and all rows were adjusted, check them in.
|
||||
if ($checkin && (count($pks) == $this->_db->getAffectedRows())) {
|
||||
// Checkin the rows.
|
||||
foreach ($pks as $pk) {
|
||||
$this->checkin($pk);
|
||||
}
|
||||
}
|
||||
|
||||
// If the Table instance value is in the list of primary keys that were set, set the instance.
|
||||
if (in_array($this->$k, $pks)) {
|
||||
$this->published = $state;
|
||||
}
|
||||
|
||||
$this->setError('');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a row from the database table by primary key value.
|
||||
* After deletion all category relations are deleted from jem_cats_event_relations table.
|
||||
*
|
||||
* @param mixed $pk An optional primary key value to delete. If not set the instance property value is used.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @note With Joomla 3.1+ we should use an observer instead but J! 2.5 doesn't provide this.
|
||||
* Also on J! 2.5 $pk is a single key while on J! 3.x it's a list of keys.
|
||||
* We know the key is 'id', so keep it simple.
|
||||
*/
|
||||
public function delete($pk = null)
|
||||
{
|
||||
$id = $this->id;
|
||||
|
||||
if (parent::delete($pk)) {
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
$query->delete($db->quoteName('#__jem_cats_event_relations'));
|
||||
$query->where('itemid = '.$db->quote($id));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->delete($db->quoteName('#__jem_register'));
|
||||
$query->where('event = '.$db->quote($id));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
149
administrator/components/com_jem/tables/group.php
Normal file
149
administrator/components/com_jem/tables/group.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* JEM Group Table
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class JemTableGroup extends Table
|
||||
{
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__jem_groups', 'id', $db);
|
||||
}
|
||||
|
||||
/** overloaded check function
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Not typed in a category name?
|
||||
if (trim($this->name ) == '') {
|
||||
$this->setError(Text::_('COM_JEM_ADD_GROUP_NAME'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set alias
|
||||
//$this->alias = JemHelper::stringURLSafe($this->alias);
|
||||
//if (empty($this->alias)) {
|
||||
// $this->alias = JemHelper::stringURLSafe($this->title);
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload the store method for the Venue table.
|
||||
*
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
// in here we are checking for the empty value of the checkbox
|
||||
|
||||
//don't override without calling base class
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the publishing 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 array of primary key values to update. If not
|
||||
* set the instance property value is used. [optional]
|
||||
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] [optional]
|
||||
* @param integer $userId The user id of the user performing the operation. [optional]
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
function publish($pks = null, $state = 1, $userId = 0)
|
||||
{
|
||||
// Initialise variables.
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// Sanitize input.
|
||||
\Joomla\Utilities\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((int)$this->$k);
|
||||
} else {
|
||||
// Nothing to set publishing state on, return false.
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the WHERE clause for the primary keys.
|
||||
$where = $this->_db->quoteName($k) . ' IN (' . implode(',', $pks) . ')';
|
||||
|
||||
// Determine if there is checkin support for the table.
|
||||
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
|
||||
$checkin = '';
|
||||
} else {
|
||||
$checkin = ' AND (checked_out IS null OR checked_out = 0 OR checked_out = ' . (int) $userId . ')';
|
||||
}
|
||||
|
||||
// Update the publishing state for rows with the given primary keys.
|
||||
$query = $this->_db->getQuery(true);
|
||||
$query->update($this->_db->quoteName($this->_tbl));
|
||||
$query->set($this->_db->quoteName('published') . ' = ' . (int) $state);
|
||||
$query->where($where);
|
||||
|
||||
|
||||
// Check for a database error.
|
||||
// TODO: use exception handling
|
||||
// if ($this->_db->getErrorNum()) {
|
||||
// $this->setError($this->_db->getErrorMsg());
|
||||
// return false;
|
||||
// }
|
||||
try
|
||||
{
|
||||
$this->_db->setQuery($query . $checkin);
|
||||
$this->_db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
|
||||
}
|
||||
|
||||
// If checkin is supported and all rows were adjusted, check them in.
|
||||
if ($checkin && (count($pks) == $this->_db->getAffectedRows())) {
|
||||
// Checkin the rows.
|
||||
foreach ($pks as $pk) {
|
||||
$this->checkin($pk);
|
||||
}
|
||||
}
|
||||
|
||||
// If the Table instance value is in the list of primary keys that were set, set the instance.
|
||||
if (in_array($this->$k, $pks)) {
|
||||
$this->published = $state;
|
||||
}
|
||||
|
||||
$this->setError('');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
1
administrator/components/com_jem/tables/index.html
Normal file
1
administrator/components/com_jem/tables/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
||||
59
administrator/components/com_jem/tables/jem_attachments.php
Normal file
59
administrator/components/com_jem/tables/jem_attachments.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/**
|
||||
* JEM attachments table class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_attachments extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var int */
|
||||
public $file = '';
|
||||
/** @var int */
|
||||
public $object = '';
|
||||
/** @var string */
|
||||
public $name = null;
|
||||
/** @var string */
|
||||
public $description = null;
|
||||
/** @var string */
|
||||
public $icon = null;
|
||||
/** @var int */
|
||||
public $frontend = 1;
|
||||
/** @var int */
|
||||
public $access = 0;
|
||||
/** @var int */
|
||||
public $ordering = 0;
|
||||
/** @var string */
|
||||
public $added = '';
|
||||
/** @var int */
|
||||
public $added_by = 0;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_attachments', 'id', $db);
|
||||
}
|
||||
|
||||
// overloaded check function
|
||||
public function check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
161
administrator/components/com_jem/tables/jem_categories.php
Normal file
161
administrator/components/com_jem/tables/jem_categories.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Nested;
|
||||
|
||||
jimport('joomla.database.tablenested');
|
||||
|
||||
/**
|
||||
* JEM categories Model class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_categories extends Nested
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var int */
|
||||
public $parent_id = 0;
|
||||
/** @var string */
|
||||
public $catname = '';
|
||||
/** @var string */
|
||||
public $alias = '';
|
||||
/** @var string */
|
||||
public $description = null;
|
||||
/** @var string */
|
||||
public $meta_description = '';
|
||||
/** @var string */
|
||||
public $meta_keywords = '';
|
||||
/** @var string */
|
||||
public $image = '';
|
||||
/** @var string */
|
||||
public $color = '';
|
||||
/** @var int */
|
||||
public $published = null;
|
||||
/** @var int */
|
||||
public $checked_out = null;
|
||||
/** @var date */
|
||||
public $checked_out_time = null;
|
||||
/** @var int */
|
||||
public $access = 0;
|
||||
/** @var int */
|
||||
public $groupid = 0;
|
||||
/** @var string */
|
||||
public $maintainers = null;
|
||||
/** @var int */
|
||||
public $ordering = null;
|
||||
|
||||
|
||||
/**
|
||||
* @param database A database connector object
|
||||
*/
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_categories', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Not typed in a category name?
|
||||
if (trim($this->catname) == '') {
|
||||
$this->_error = Text::_('COM_JEM_ADD_NAME_CATEGORY');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$alias = JFilterOutput::stringURLSafe($this->catname);
|
||||
|
||||
if (empty($this->alias) || $this->alias === $alias) {
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
/** check for existing name */
|
||||
/* in fact, it can happen for subcategories
|
||||
$query = 'SELECT id FROM #__jem_categories WHERE catname = '.$this->_db->Quote($this->catname);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
$xid = intval($this->_db->loadResult());
|
||||
if ($xid && $xid != intval($this->id)) {
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_JEM_CATEGORY_NAME_ALREADY_EXIST', $this->catname), 'warning');
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
function insertIgnore($updateNulls = false)
|
||||
{
|
||||
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/**
|
||||
* JEM table class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_cats_event_relations extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/**
|
||||
* Category ID
|
||||
* @var int
|
||||
*/
|
||||
public $catid = null;
|
||||
/**
|
||||
* Event ID
|
||||
* @var int
|
||||
*/
|
||||
public $itemid = null;
|
||||
/**
|
||||
* Ordering
|
||||
* @var int
|
||||
* @todo implement
|
||||
*/
|
||||
public $ordering = null;
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_cats_event_relations', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* overloaded check function
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
274
administrator/components/com_jem/tables/jem_events.php
Normal file
274
administrator/components/com_jem/tables/jem_events.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* JEM events Model class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_events extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var int */
|
||||
public $locid = null;
|
||||
/** @var date */
|
||||
public $dates = null;
|
||||
/** @var date */
|
||||
public $enddates = null;
|
||||
/** @var date */
|
||||
public $times = null;
|
||||
/** @var date */
|
||||
public $endtimes = null;
|
||||
/** @var string */
|
||||
public $title = '';
|
||||
/** @var string */
|
||||
public $alias = '';
|
||||
/** @var date */
|
||||
public $created = null;
|
||||
/** @var int */
|
||||
public $created_by = null;
|
||||
/** @var int */
|
||||
public $modified = 0;
|
||||
/** @var int */
|
||||
public $modified_by = null;
|
||||
/** @var int */
|
||||
public $version = 0;
|
||||
/** @var string */
|
||||
public $meta_description = '';
|
||||
/** @var string */
|
||||
public $meta_keywords = '';
|
||||
/**
|
||||
* repetition intervall
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $recurrence_number = 0;
|
||||
/**
|
||||
* type of recurrence (daily, weekly, monthly)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $recurrence_type = 0;
|
||||
/**
|
||||
* occurence counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $recurrence_counter = 0;
|
||||
/**
|
||||
* limit counter for repetition
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $recurrence_limit = 0;
|
||||
/**
|
||||
* limit date for repetition
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $recurrence_limit_date = null;
|
||||
/**
|
||||
* list of day the event occurs on (2 letters, separated by comma)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $recurrence_byday = '';
|
||||
/** @var int id of first event for recurrence events*/
|
||||
public $recurrence_first_id = 0;
|
||||
/** @var string */
|
||||
public $datimage = '';
|
||||
/** @var string */
|
||||
public $author_ip = null;
|
||||
/** @var int */
|
||||
public $published = null;
|
||||
/** @var int */
|
||||
public $registra = null;
|
||||
/** @var int */
|
||||
public $unregistra = null;
|
||||
/** @var int */
|
||||
public $maxplaces = 0;
|
||||
/** @var int */
|
||||
public $waitinglist = 0;
|
||||
/** @var int */
|
||||
public $hits = 0;
|
||||
/** @var int */
|
||||
public $checked_out = null;
|
||||
/** @var date */
|
||||
public $checked_out_time = null;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_events', 'id', $db);
|
||||
}
|
||||
|
||||
/** overloaded check function
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function check($jemsettings = null)
|
||||
{
|
||||
// Check fields
|
||||
if (empty($this->enddates)) {
|
||||
$this->enddates = NULL;
|
||||
}
|
||||
|
||||
if (preg_match("/^:[0-5][0-9](:[0-5][0-9])?$/", $this->times)) {
|
||||
$this->_error = Text::_('WRONGSTARTTIMEFORMAT'.': '.$this->times);
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
if (empty($this->times) || preg_match("/^:[0-5][0-9](:[0-5][0-9])?$/", $this->times)) {
|
||||
$this->times = NULL;
|
||||
}
|
||||
if (preg_match("/^:[0-5][0-9](:[0-5][0-9])?$/", $this->endtimes)) {
|
||||
$this->_error = Text::_('WRONGENDTIMEFORMAT'.': '.$this->endtimes);
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
if (empty($this->endtimes) || empty($this->times) || preg_match("/^:[0-5][0-9](:[0-5][0-9])?$/", $this->endtimes)
|
||||
|| preg_match("/^:[0-5][0-9](:[0-5][0-9])?$/", $this->times))
|
||||
{
|
||||
$this->endtimes = NULL;
|
||||
}
|
||||
|
||||
$this->title = strip_tags(trim($this->title));
|
||||
$titlelength = \Joomla\String\StringHelper::strlen($this->title);
|
||||
|
||||
if ($this->title == '') {
|
||||
$this->_error = Text::_('COM_JEM_ADD_TITLE');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($titlelength > 100) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_TITLE_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$alias = JFilterOutput::stringURLSafe($this->title);
|
||||
|
||||
if (empty($this->alias) || $this->alias === $alias) {
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
if ($this->dates && !preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->dates)) {
|
||||
$this->_error = Text::_('COM_JEM_DATE_WRONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($this->enddates)) {
|
||||
if (!preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->enddates)) {
|
||||
$this->_error = Text::_('COM_JEM_ENDDATE_WRONG_FORMAT');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* if (isset($this->recurrence_limit_date)) {
|
||||
if (!preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->recurrence_limit_date)) {
|
||||
$this->_error = Text::_('COM_JEM_WRONGRECURRENCEDATEFORMAT');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (isset($this->times) && $this->times) {
|
||||
if (!preg_match("/^[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?$/", $this->times)) {
|
||||
$this->_error = Text::_('WRONGSTARTTIMEFORMAT'.': '.$this->times);
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->endtimes) && $this->endtimes) {
|
||||
if (!preg_match("/^[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?$/", $this->endtimes)) {
|
||||
$this->_error = Text::_('COM_JEM_WRONGENDTIMEFORMAT');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//No venue or category choosen?
|
||||
//if ($this->locid == '') {
|
||||
// $this->_error = Text::_('COM_JEM_VENUE_EMPTY');
|
||||
// Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
37
administrator/components/com_jem/tables/jem_groupmembers.php
Normal file
37
administrator/components/com_jem/tables/jem_groupmembers.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/**
|
||||
* JEM groupmembers Model class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_groupmembers extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var int */
|
||||
public $group_id = null;
|
||||
/** @var int */
|
||||
public $member = null;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_groupmembers', 'id', $db);
|
||||
}
|
||||
}
|
||||
?>
|
||||
119
administrator/components/com_jem/tables/jem_groups.php
Normal file
119
administrator/components/com_jem/tables/jem_groups.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* JEM groups Model class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_groups extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var string */
|
||||
public $name = '';
|
||||
/** @var string */
|
||||
public $description = '';
|
||||
/** @var int */
|
||||
public $checked_out = null;
|
||||
/** @var date */
|
||||
public $checked_out_time = null;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_groups', 'id', $db);
|
||||
}
|
||||
|
||||
// overloaded check function
|
||||
public function check()
|
||||
{
|
||||
// Not typed in a category name?
|
||||
if (trim($this->name) == '') {
|
||||
$this->_error = Text::_('COM_JEM_ADD_GROUP_NAME');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for existing name
|
||||
$query = 'SELECT id FROM #__jem_groups WHERE name = '.$this->_db->Quote($this->name);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
$xid = intval($this->_db->loadResult());
|
||||
if ($xid && $xid != intval($this->id)) {
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_JEM_GROUP_NAME_ALREADY_EXIST', $this->name), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
123
administrator/components/com_jem/tables/jem_register.php
Normal file
123
administrator/components/com_jem/tables/jem_register.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/**
|
||||
* Table: Register
|
||||
*/
|
||||
class jem_register extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var int */
|
||||
public $event = null;
|
||||
/** @var int */
|
||||
public $uid = null;
|
||||
/** @var date */
|
||||
public $uregdate = null;
|
||||
/** @var string */
|
||||
public $uip = null;
|
||||
/** @var int */
|
||||
public $waiting = 0;
|
||||
/** @var int */
|
||||
public $status = 0;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_register', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to store a row in the database from the Table instance properties.
|
||||
* If a primary key value is set the row with that primary key value will be
|
||||
* updated with the instance property values. If no primary key value is set
|
||||
* a new row will be inserted into the database with the properties from the
|
||||
* Table instance.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @link https://docs.joomla.org/Table/store
|
||||
* @since 11.1
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
if (isset($this->status)) {
|
||||
if ($this->status == 2) {
|
||||
$this->waiting = 1;
|
||||
$this->status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
176
administrator/components/com_jem/tables/jem_settings.php
Normal file
176
administrator/components/com_jem/tables/jem_settings.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/**
|
||||
* JEM settings table class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
class jem_settings extends Table
|
||||
{
|
||||
/**
|
||||
* Unique Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = '1';
|
||||
/** @var int */
|
||||
public $oldevent = '2';
|
||||
/** @var int */
|
||||
public $minus = '1';
|
||||
/** @var int */
|
||||
public $showtime = '0';
|
||||
/** @var int */
|
||||
public $showtitle = '1';
|
||||
/** @var int */
|
||||
public $showlocate = '1';
|
||||
/** @var int */
|
||||
public $showcity = '1';
|
||||
/** @var int */
|
||||
public $showmapserv = '0';
|
||||
/** @var string */
|
||||
public $tablewidth = null;
|
||||
/** @var string */
|
||||
public $datewidth = null;
|
||||
/** @var int */
|
||||
public $datemode = '1';
|
||||
/** @var string */
|
||||
public $titlewidth = null;
|
||||
/** @var string */
|
||||
public $infobuttonwidth = null;
|
||||
/** @var string */
|
||||
public $locationwidth = null;
|
||||
/** @var string */
|
||||
public $citywidth = null;
|
||||
/** @var string */
|
||||
public $formatdate = null;
|
||||
/** @var string */
|
||||
public $formatShortDate = null;
|
||||
/** @var string */
|
||||
public $formattime = null;
|
||||
/** @var string */
|
||||
public $timename = null;
|
||||
/** @var int */
|
||||
public $showdetails = '1';
|
||||
/** @var int */
|
||||
public $showtimedetails = '1';
|
||||
/** @var int */
|
||||
public $showevdescription = '1';
|
||||
/** @var int */
|
||||
public $showdetailstitle = '1';
|
||||
/** @var int */
|
||||
public $showdetailsadress = '1';
|
||||
/** @var int */
|
||||
public $showlocdescription = '1';
|
||||
/** @var int */
|
||||
public $showlinkvenue = '1';
|
||||
/** @var int */
|
||||
public $showdetlinkvenue = '1';
|
||||
/** @var int */
|
||||
public $delivereventsyes = '-2';
|
||||
/** @var int */
|
||||
public $datdesclimit = '1000';
|
||||
/** @var int */
|
||||
public $autopubl = '-2';
|
||||
/** @var int */
|
||||
public $deliverlocsyes = '-2';
|
||||
/** @var int */
|
||||
public $autopublocate = '-2';
|
||||
/** @var int */
|
||||
public $showcat = '0';
|
||||
/** @var int */
|
||||
public $catfrowidth = '';
|
||||
/** @var int */
|
||||
public $evdelrec = '1';
|
||||
/** @var int */
|
||||
public $evpubrec = '1';
|
||||
/** @var int */
|
||||
public $locdelrec = '1';
|
||||
/** @var int */
|
||||
public $locpubrec = '1';
|
||||
/** @var int */
|
||||
public $sizelimit = '100';
|
||||
/** @var int */
|
||||
public $imagehight = '100';
|
||||
/** @var int */
|
||||
public $imagewidth = '100';
|
||||
/** @var int */
|
||||
public $gddisabled = '0';
|
||||
/** @var int */
|
||||
public $imageenabled = '1';
|
||||
/** @var int */
|
||||
public $comunsolution = '0';
|
||||
/** @var int */
|
||||
public $comunoption = '0';
|
||||
/** @var int */
|
||||
public $catlinklist = '0';
|
||||
/** @var int */
|
||||
public $showfroregistra = '0';
|
||||
/** @var int */
|
||||
public $showfrounregistra = '0';
|
||||
/** @var int */
|
||||
public $eventedit = '-2';
|
||||
/** @var int */
|
||||
public $eventeditrec = '1';
|
||||
/** @var int */
|
||||
public $eventowner = '0';
|
||||
/** @var int */
|
||||
public $venueedit = '-2';
|
||||
/** @var int */
|
||||
public $venueeditrec = '1';
|
||||
/** @var int */
|
||||
public $venueowner = '0';
|
||||
/** @var int */
|
||||
public $lightbox = '0';
|
||||
/** @var string */
|
||||
public $meta_keywords = null;
|
||||
/** @var string */
|
||||
public $meta_description = null;
|
||||
/** @var int */
|
||||
public $showstate = '0';
|
||||
/** @var string */
|
||||
public $statewidth = null;
|
||||
/** @var int */
|
||||
public $regname = null;
|
||||
/** @var int */
|
||||
public $storeip = null;
|
||||
/** @var string */
|
||||
public $lastupdate = null;
|
||||
/** @var int */
|
||||
public $checked_out = null;
|
||||
/** @var date */
|
||||
public $checked_out_time = null;
|
||||
/** @var string */
|
||||
public $tld = 0;
|
||||
/** @var int */
|
||||
public $display_num = 0;
|
||||
public $cat_num = 0;
|
||||
public $filter = 0;
|
||||
public $display = 0;
|
||||
public $icons = 0;
|
||||
public $show_print_icon = 0;
|
||||
public $show_email_icon = 0;
|
||||
public $events_ical = 0;
|
||||
/** @var string */
|
||||
public $defaultCountry = null;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_settings', 'id', $db);
|
||||
}
|
||||
}
|
||||
?>
|
||||
240
administrator/components/com_jem/tables/jem_venues.php
Normal file
240
administrator/components/com_jem/tables/jem_venues.php
Normal file
@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* JEM venues Model class
|
||||
*
|
||||
* @package JEM
|
||||
*
|
||||
*/
|
||||
class jem_venues extends Table
|
||||
{
|
||||
/**
|
||||
* Primary Key
|
||||
* @var int
|
||||
*/
|
||||
public $id = null;
|
||||
/** @var string */
|
||||
public $venue = '';
|
||||
/** @var string */
|
||||
public $alias = '';
|
||||
/** @var string */
|
||||
public $url = '';
|
||||
/** @var string */
|
||||
public $street = '';
|
||||
/** @var string */
|
||||
public $postalCode = '';
|
||||
/** @var string */
|
||||
public $city = '';
|
||||
/** @var string */
|
||||
public $state = '';
|
||||
/** @var string */
|
||||
public $country = '';
|
||||
/** @var float */
|
||||
public $latitude = null;
|
||||
/** @var float */
|
||||
public $longitude = null;
|
||||
/** @var string */
|
||||
public $locdescription = null;
|
||||
/** @var string */
|
||||
public $meta_description = '';
|
||||
/** @var string */
|
||||
public $meta_keywords = '';
|
||||
/** @var string */
|
||||
public $locimage = '';
|
||||
/** @var int */
|
||||
public $map = null;
|
||||
/** @var int */
|
||||
public $created_by = null;
|
||||
/** @var string */
|
||||
public $author_ip = null;
|
||||
/** @var date */
|
||||
public $created = null;
|
||||
/** @var date */
|
||||
public $modified = 0;
|
||||
/** @var int */
|
||||
public $modified_by = null;
|
||||
/** @var int */
|
||||
public $version = null;
|
||||
/** @var int */
|
||||
public $published = null;
|
||||
/** @var int */
|
||||
public $checked_out = null;
|
||||
/** @var date */
|
||||
public $checked_out_time = null;
|
||||
/** @var int */
|
||||
public $ordering = null;
|
||||
|
||||
|
||||
public function __construct(& $db)
|
||||
{
|
||||
parent::__construct('#__jem_venues', 'id', $db);
|
||||
}
|
||||
|
||||
/** overloaded check function
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// not typed in a venue name
|
||||
if (!trim($this->venue)) {
|
||||
$this->_error = Text::_('COM_JEM_ADD_VENUE');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$alias = JFilterOutput::stringURLSafe($this->venue);
|
||||
|
||||
if (empty($this->alias) || $this->alias === $alias) {
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
if ($this->map) {
|
||||
if (!trim($this->street) || !trim($this->city) || !trim($this->country) || !trim($this->postalCode)) {
|
||||
if ((!trim($this->latitude) && !trim($this->longitude))) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_ADDRESS');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (JFilterInput::checkAttribute(array ('href', $this->url))) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_URL_WRONG_FORMAT');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trim($this->url)) {
|
||||
$this->url = strip_tags($this->url);
|
||||
|
||||
if (strlen($this->url) > 199) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_URL_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}'
|
||||
.'((:[0-9]{1,5})?\/.*)?$/i' , $this->url)) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_URL_WRONG_FORMAT');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->street = strip_tags($this->street);
|
||||
if (\Joomla\String\StringHelper::strlen($this->street) > 50) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_STREET_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->postalCode = strip_tags($this->postalCode);
|
||||
if (\Joomla\String\StringHelper::strlen($this->postalCode) > 10) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_ZIP_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->city = strip_tags($this->city);
|
||||
if (\Joomla\String\StringHelper::strlen($this->city) > 50) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_CITY_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->state = strip_tags($this->state);
|
||||
if (\Joomla\String\StringHelper::strlen($this->state) > 50) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_STATE_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->country = strip_tags($this->country);
|
||||
if (\Joomla\String\StringHelper::strlen($this->country) > 2) {
|
||||
$this->_error = Text::_('COM_JEM_ERROR_COUNTRY_LONG');
|
||||
Factory::getApplication()->enqueueMessage($this->_error, 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
/** check for existing name */
|
||||
/*
|
||||
$query = 'SELECT id FROM #__jem_venues WHERE venue = '.$this->_db->Quote($this->venue);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
$xid = intval($this->_db->loadResult());
|
||||
if ($xid && $xid != intval($this->id)) {
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_JEM_VENUE_NAME_ALREADY_EXIST', $this->venue), 'warning');
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
}
|
||||
?>
|
||||
67
administrator/components/com_jem/tables/settings.php
Normal file
67
administrator/components/com_jem/tables/settings.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
/**
|
||||
* JEM Settings Table
|
||||
*
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
class JemTableSettings extends Table
|
||||
{
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__jem_settings', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validators
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded the store method
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.1.6
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
if (isset($array['globalattribs']) && is_array($array['globalattribs']))
|
||||
{
|
||||
$registry = new Registry;
|
||||
$registry->loadArray($array['globalattribs']);
|
||||
$array['globalattribs'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['css']) && is_array($array['css']))
|
||||
{
|
||||
$registrycss = new Registry;
|
||||
$registrycss->loadArray($array['css']);
|
||||
$array['css'] = (string) $registrycss;
|
||||
}
|
||||
|
||||
//don't override without calling base class
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
}
|
||||
?>
|
||||
369
administrator/components/com_jem/tables/venue.php
Normal file
369
administrator/components/com_jem/tables/venue.php
Normal file
@ -0,0 +1,369 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
|
||||
/**
|
||||
* JEM Venue Table
|
||||
*/
|
||||
class JemTableVenue extends Table
|
||||
{
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__jem_venues', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind method for the Venue table.
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
// in here we are checking for the empty value of the checkbox
|
||||
|
||||
if (!isset($array['map'])) {
|
||||
$array['map'] = 0 ;
|
||||
}
|
||||
|
||||
//don't override without calling base class
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* overloaded check function
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$jinput = Factory::getApplication()->input;
|
||||
|
||||
if (trim($this->venue) == '') {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_NAME'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set alias
|
||||
$this->alias = JemHelper::stringURLSafe($this->alias);
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = JemHelper::stringURLSafe($this->venue);
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->map) {
|
||||
if (!trim($this->street) || !trim($this->city) || !trim($this->country) || !trim($this->postalCode)) {
|
||||
if ((!trim($this->latitude) && !trim($this->longitude))) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_MAP_ADDRESS'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trim($this->url)) {
|
||||
$this->url = strip_tags($this->url);
|
||||
|
||||
if (strlen($this->url) > 199) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_URL_LENGTH'));
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9äöüáéíóúñ]+)*\.[a-z]{2,24}'
|
||||
.'((:[0-9]{1,5})?\/.*)?$/i' , $this->url))
|
||||
{
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_URL_FORMAT'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->street = strip_tags($this->street);
|
||||
$streetlength = \Joomla\String\StringHelper::strlen($this->street);
|
||||
if ($streetlength > 50) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_STREET'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->postalCode = strip_tags($this->postalCode);
|
||||
if (\Joomla\String\StringHelper::strlen($this->postalCode) > 10) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_POSTALCODE'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->city = strip_tags($this->city);
|
||||
if (\Joomla\String\StringHelper::strlen($this->city) > 50) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_CITY'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->state = strip_tags($this->state);
|
||||
if (\Joomla\String\StringHelper::strlen($this->state) > 50) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_STATE'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->country = strip_tags($this->country);
|
||||
if (\Joomla\String\StringHelper::strlen($this->country) > 2) {
|
||||
$this->setError(Text::_('COM_JEM_VENUE_ERROR_COUNTRY'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded store method for the Venue table.
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = JemFactory::getUser();
|
||||
$userid = $user->get('id');
|
||||
$app = Factory::getApplication();
|
||||
$jinput = $app->input;
|
||||
$jemsettings = JemHelper::config();
|
||||
|
||||
// Check if we're in the front or back
|
||||
if ($app->isClient('administrator')) {
|
||||
$backend = true;
|
||||
} else {
|
||||
$backend = false;
|
||||
}
|
||||
|
||||
if ($this->id) {
|
||||
// Existing venue
|
||||
$this->modified = $date->toSql();
|
||||
$this->modified_by = $userid;
|
||||
} else {
|
||||
// New venue
|
||||
if (!intval($this->created)) {
|
||||
$this->created = $date->toSql();
|
||||
}
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = $userid;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if image was selected
|
||||
jimport('joomla.filesystem.file');
|
||||
$image_dir = JPATH_SITE.'/images/jem/venues/';
|
||||
$filetypes = $jemsettings->image_filetypes ?: 'jpg,gif,png,webp';
|
||||
$allowable = explode(',', strtolower($filetypes));
|
||||
array_walk($allowable, function(&$v){$v = trim($v);});
|
||||
$image_to_delete = false;
|
||||
|
||||
// get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
|
||||
if (!$backend) {
|
||||
if (($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1)) {
|
||||
$file = $jinput->files->get('userfile', array(), 'array');
|
||||
$removeimage = $jinput->getInt('removeimage', 0);
|
||||
$locimage = $jinput->getCmd('locimage', '');
|
||||
|
||||
if (empty($file)) {
|
||||
$file2 = $jinput->files->get('jform', array(), 'array');
|
||||
if (!empty($file2['userfile'])) {
|
||||
$file = $file2['userfile'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($file['name'])) {
|
||||
//check the image
|
||||
$check = JemImage::check($file, $jemsettings);
|
||||
|
||||
if ($check !== false) {
|
||||
//sanitize the image filename
|
||||
$filename = JemImage::sanitize($image_dir, $file['name']);
|
||||
$filepath = $image_dir . $filename;
|
||||
|
||||
if (File::upload($file['tmp_name'], $filepath)) {
|
||||
$image_to_delete = $this->locimage; // delete previous image
|
||||
$this->locimage = $filename;
|
||||
}
|
||||
}
|
||||
} elseif (!empty($removeimage)) {
|
||||
// if removeimage is non-zero remove image from venue
|
||||
// (file will be deleted later (e.g. housekeeping) if unused)
|
||||
$image_to_delete = $this->locimage;
|
||||
$this->locimage = '';
|
||||
} elseif (!$this->id && is_null($this->locimage) && !empty($locimage)) {
|
||||
// venue is a copy so copy locimage too
|
||||
if (File::exists($image_dir . $locimage)) {
|
||||
// if it's already within image folder it's safe
|
||||
$this->locimage = $locimage;
|
||||
}
|
||||
}
|
||||
} // end image if
|
||||
} // if (!backend)
|
||||
|
||||
$format = File::getExt($image_dir . $this->locimage);
|
||||
if (!in_array($format, $allowable))
|
||||
{
|
||||
$this->locimage = '';
|
||||
}
|
||||
|
||||
if (!$backend) {
|
||||
// check if the user has the required rank to publish this venue
|
||||
if (!$this->id && !$user->can('publish', 'venue', $this->id, $this->created_by)) {
|
||||
$this->published = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// item must be stored BEFORE image deletion
|
||||
$ret = parent::store($updateNulls);
|
||||
if ($ret && $image_to_delete) {
|
||||
JemHelper::delete_unused_image_files('venue', $image_to_delete);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to insert first, update if fails
|
||||
*
|
||||
* Can be overloaded/supplemented by the child class
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If false, null object variables are not updated
|
||||
* @return null|string null if successful otherwise returns and error message
|
||||
*/
|
||||
public function insertIgnore($updateNulls = false)
|
||||
{
|
||||
|
||||
try {
|
||||
$ret = $this->_insertIgnoreObject($this->_tbl, $this, $this->_tbl_key);
|
||||
} catch (RuntimeException $e){
|
||||
$this->setError(get_class($this).'::store failed - '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row into a table based on an objects properties, ignore if already exists
|
||||
*
|
||||
* @access protected
|
||||
* @param string The name of the table
|
||||
* @param object An object whose properties match table fields
|
||||
* @param string The name of the primary key. If provided the object property is updated.
|
||||
* @return int number of affected row
|
||||
*/
|
||||
protected function _insertIgnoreObject($table, &$object, $keyName = NULL)
|
||||
{
|
||||
$fmtsql = 'INSERT IGNORE INTO '.$this->_db->quoteName($table).' (%s) VALUES (%s) ';
|
||||
$fields = array();
|
||||
|
||||
foreach (get_object_vars($object) as $k => $v) {
|
||||
if (is_array($v) or is_object($v) or $v === NULL) {
|
||||
continue;
|
||||
}
|
||||
if ($k[0] == '_') { // internal field
|
||||
continue;
|
||||
}
|
||||
$fields[] = $this->_db->quoteName($k);
|
||||
$values[] = $this->_db->quote($v);
|
||||
}
|
||||
|
||||
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
|
||||
if ($this->_db->execute() === false) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->_db->insertid();
|
||||
if ($keyName && $id) {
|
||||
$object->$keyName = $id;
|
||||
}
|
||||
|
||||
return $this->_db->getAffectedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the publishing 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 array of primary key values to update. If not set
|
||||
* the instance property value is used. [optional]
|
||||
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] [optional]
|
||||
* @param integer $userId The user id of the user performing the operation. [optional]
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
public function publish($pks = null, $state = 1, $userId = 0)
|
||||
{
|
||||
// Initialise variables.
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// Sanitize input.
|
||||
\Joomla\Utilities\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((int)$this->$k);
|
||||
} else {
|
||||
// Nothing to set publishing state on, return false.
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the WHERE clause for the primary keys.
|
||||
$where = $this->_db->quoteName($k) . ' IN (' . implode(',', $pks) . ')';
|
||||
|
||||
// Determine if there is checkin support for the table.
|
||||
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
|
||||
$checkin = '';
|
||||
} else {
|
||||
$checkin = ' AND (checked_out IS null OR checked_out = 0 OR checked_out = ' . (int) $userId . ')';
|
||||
}
|
||||
|
||||
// Update the publishing state for rows with the given primary keys.
|
||||
$query = $this->_db->getQuery(true);
|
||||
$query->update($this->_db->quoteName($this->_tbl));
|
||||
$query->set($this->_db->quoteName('published') . ' = ' . (int) $state);
|
||||
$query->where($where);
|
||||
|
||||
|
||||
// Check for a database error.
|
||||
// TODO: use exception handling
|
||||
// if ($this->_db->getErrorNum()) {
|
||||
// $this->setError($this->_db->getErrorMsg());
|
||||
// return false;
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
$this->_db->setQuery($query . $checkin);
|
||||
$this->_db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
|
||||
}
|
||||
|
||||
// If checkin is supported and all rows were adjusted, check them in.
|
||||
if ($checkin && (count($pks) == $this->_db->getAffectedRows())) {
|
||||
// Checkin the rows.
|
||||
foreach ($pks as $pk) {
|
||||
$this->checkin($pk);
|
||||
}
|
||||
}
|
||||
|
||||
// If the Table instance value is in the list of primary keys that were set, set the instance.
|
||||
if (in_array($this->$k, $pks)) {
|
||||
$this->published = $state;
|
||||
}
|
||||
|
||||
$this->setError('');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user