Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/ptitsanes/administrator/components/com_solidres/models/ |
Upload File : |
<?php
/**
------------------------------------------------------------------------
SOLIDRES - Accommodation booking extension for Joomla
------------------------------------------------------------------------
* @author Solidres Team <contact@solidres.com>
* @website https://www.solidres.com
* @copyright Copyright (C) 2013 - 2019 Solidres. All Rights Reserved.
* @license GNU General Public License version 3, or later
------------------------------------------------------------------------
*/
defined('_JEXEC') or die;
/**
* State model.
*
* @package Solidres
* @subpackage State
* @since 0.1.0
*/
class SolidresModelState extends JModelAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = null;
/**
* @var string The event to trigger after deleting the data.
* @since 1.6
*/
protected $event_after_delete = null;
/**
* @var string The event to trigger after saving the data.
* @since 1.6
*/
protected $event_after_save = null;
/**
* @var string The event to trigger after deleting the data.
* @since 1.6
*/
protected $event_before_delete = null;
/**
* @var string The event to trigger after saving the data.
* @since 1.6
*/
protected $event_before_save = null;
/**
* @var string The event to trigger after changing the published state of the data.
* @since 1.6
*/
protected $event_change_state = null;
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->event_after_delete = 'onStateAfterDelete';
$this->event_after_save = 'onStateAfterSave';
$this->event_before_delete = 'onStateBeforeDelete';
$this->event_before_save = 'onStateBeforeSave';
$this->event_change_state = 'onStateChangeState';
$this->text_prefix = strtoupper($this->option);
}
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
$user = JFactory::getUser();
return $user->authorise('core.delete', 'com_solidres.state.' . (int) $record->id);
}
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
return $user->authorise('core.edit.state', 'com_solidres.state.' . (int) $record->id);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
*
* @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'State', $prefix = 'SolidresTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to interogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return JForm A JForm object on success, false on failure
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_solidres.state', 'state', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Determine correct permissions to check.
if ($this->getState('state.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_solidres.edit.state.data', array());
if (empty($data))
{
$data = $this->getItem();
}
return $data;
}
/**
* Prepare and sanitise the table prior to saving.
*
* @since 1.6
*/
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
/**
* A protected method to get a set of ordering conditions.
*
* @param object A record object.
*
* @return array An array of conditions to add to add to ordering queries.
* @since 1.6
*/
protected function getReorderConditions($table = null)
{
$condition = array();
$condition[] = 'catid = ' . (int) $table->catid;
return $condition;
}
}