| 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/plugins/solidres/experience/ |
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;
class plgSolidresExperienceInstallerScript
{
public function install($adapter)
{
$plugins = JFolder::folders($adapter->getParent()->getPath('source') . '/experiencepayment', '[^\.]', false, true);
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update($db->qn('#__extensions'))
->set('enabled = 1')
->where($db->qn('type') . ' = ' . $db->q('plugin'))
->where($db->qn('folder') . ' = ' . $db->q('solidres'))
->where($db->qn('element') . ' = ' . $db->q('experience'));
$db->setQuery($query)
->execute();
foreach ($plugins as $plugin)
{
$installer = new JInstaller;
$installer->setPath('source', $plugin);
$newAdapter = $installer->setupInstall('install', true);
if (is_object($newAdapter) && $newAdapter->install())
{
$pluginName = trim(basename($plugin));
$query->clear()
->update($db->qn('#__extensions'))
->set('enabled = 1')
->where($db->qn('type') . ' = ' . $db->q('plugin'))
->where($db->qn('folder') . ' = ' . $db->q('experiencepayment'))
->where($db->qn('element') . ' = ' . $db->q($pluginName));
$db->setQuery($query)
->execute();
}
}
$query->clear();
$query->select('COUNT(*)')
->from($db->quoteName('#__sr_customfields'))
->where($db->quoteName('context') . ' = ' . $db->quote('com_solidres.experience.customer'));
$count = $db->setQuery($query)->loadResult();
if ($count < 1)
{
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Title', 'customer_title', '1', 'select', '1', '2015-12-03 07:28:48', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{\"multiple\":\"0\",\"options\":[{\"text\":\"Mr.\",\"value\":\"Mr.\"},{\"text\":\"Mrs.\",\"value\":\"Mrs.\"},{\"text\":\"Ms.\",\"value\":\"Ms.\"}],\"format\":\"dd-mm-yy\"}', '17', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'First name', 'customer_firstname', '1', 'text', '0', '2015-12-03 09:06:03', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '18', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Middlename', 'customer_middlename', '1', 'text', '1', '2015-12-03 09:06:35', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '19', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Last name', 'customer_lastname', '1', 'text', '0', '2015-12-03 09:07:18', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '20', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Email', 'customer_email', '1', 'email', '0', '2015-12-03 09:07:37', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '21', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Confirm Email', 'customer_email2', '1', 'email', '0', '2015-12-03 09:07:37', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '22', '0', 'Confirm your email address.', 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Landline number', 'customer_phonenumber', '1', 'text', '0', '2015-12-03 09:08:03', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '23', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Mobile phone', 'customer_mobilephone', '1', 'text', '1', '2015-12-03 09:08:13', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '24', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Company', 'customer_company', '1', 'text', '1', '2015-12-03 09:08:26', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '25', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Address 1', 'customer_address1', '1', 'text', '0', '2015-12-03 09:08:46', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '26', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Address 2', 'customer_address2', '1', 'text', '1', '2015-12-03 09:09:14', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '27', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'VAT number', 'customer_vat_number', '1', 'text', '1', '2015-12-03 09:09:38', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '28', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'City', 'customer_city', '1', 'text', '0', '2015-12-03 09:09:54', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '29', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Zip/Postal code', 'customer_zipcode', '1', 'text', '1', '2015-12-03 09:10:07', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '30', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Country', 'customer_country_id', '1', 'country', '0', '2015-12-03 09:10:49', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '31', '0', NULL, 0) ")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'State/Province', 'customer_geo_state_id', '1', 'zone_state', '1', '2015-12-03 09:11:23', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '32', '0', NULL, 0)")->execute();
$db->setQuery("INSERT INTO " . $db->quoteName('#__sr_customfields') . " VALUES ('0', 'Note', 'customer_note', '1', 'textarea', '1', '2015-12-03 09:11:49', '0', '0', '0000-00-00 00:00:00', '1', 'com_solidres.experience.customer', '{}', '33', '0', NULL, 0)")->execute();
}
$contentElementPath = JPATH_ADMINISTRATOR . '/components/com_falang/contentelements';
if (JFolder::exists($contentElementPath))
{
$path = $adapter->getParent()->getPath('source') . '/administrator/components/com_solidres/falang';
$translateFiles = JFolder::files($path, '\.xml', false, true);
foreach ($translateFiles as $file)
{
JFile::copy($file, $contentElementPath . '/' . basename($file));
}
}
}
public function update($adapter)
{
$this->install($adapter);
$db = JFactory::getDbo();
if ((string) $adapter->getManifest()->version == '0.3.0')
{
$query = $db->getQuery(true)
->select($db->qn('id'))
->from($db->qn('#__sr_experience_reservations'));
$db->setQuery($query);
if (($pks = $db->loadColumn()) && SRPlugin::isEnabled('experience'))
{
foreach ($pks as $pk)
{
SRExperienceHelper::updateCustomerName($pk);
}
}
}
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->qn('#__sr_experience_date_xref'));
$db->setQuery($query);
if (!$db->loadResult())
{
$query->clear()
->select('a.id, a.available_dates', 'a')
->from($db->qn('#__sr_experiences', 'a'));
$db->setQuery($query);
if ($rows = $db->loadObjectList())
{
$nowDate = JFactory::getDate();
$values = array();
foreach ($rows as $row)
{
$pk = (int) $row->id;
$dates = json_decode($row->available_dates, true);
if (!empty($dates))
{
foreach ($dates as $date)
{
try
{
$date = JFactory::getDate($date);
if ((int) $nowDate->diff($date)->format('%R%a') >= 0)
{
$values[] = $pk . ',' . $db->q($date->toSql());
}
}
catch (Exception $e)
{
}
}
}
}
if ($values)
{
$query->clear()
->insert($db->qn('#__sr_experience_date_xref'))
->columns($db->qn(array('experience_id', 'date')))
->values(\Joomla\Utilities\ArrayHelper::arrayUnique($values));
$db->setQuery($query)
->execute();
}
}
}
// Update add new confirm email field if not exists
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__sr_customfields'))
->where($db->quoteName('context') . ' = ' . $db->quote('com_solidres.experience.customer'))
->order($db->quoteName('ordering') . ' ASC');
$db->setQuery($query);
$willUpdateFields = [];
$ordering = 0;
foreach ($db->loadObjectList() as $field)
{
if ($field->field_name === 'customer_email2')
{
$willUpdateFields = false;
break;
}
// Update ordering
$field->ordering = ++$ordering;
$willUpdateFields[] = $field;
if ($field->field_name === 'customer_email')
{
$confirmEmailField = clone $field;
$confirmEmailField->id = 0;
$confirmEmailField->title = 'Confirm Email';
$confirmEmailField->description = 'Confirm your email address.';
$confirmEmailField->field_name = 'customer_email2';
$confirmEmailField->ordering = ++$ordering;
$willUpdateFields[] = $confirmEmailField;
}
}
if (false !== $willUpdateFields)
{
foreach ($willUpdateFields as $willUpdateField)
{
if ($willUpdateField->id)
{
$db->updateObject('#__sr_customfields', $willUpdateField, 'id');
}
else
{
$db->insertObject('#__sr_customfields', $willUpdateField, 'id');
}
}
}
}
public function uninstall($adapter)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update($db->qn('#__extensions'))
->set('enabled = 0')
->where($db->qn('type') . ' = ' . $db->q('plugin'))
->where($db->qn('folder') . ' = ' . $db->q('experiencepayment'));
$db->setQuery($query)
->execute();
$query->clear('where')
->where($db->qn('type') . ' = ' . $db->q('module'))
->where($db->qn('element') . ' LIKE ' . $db->q('mod_sr_experience%'));
$db->setQuery($query)
->execute();
$query->clear()
->update($db->qn('#__modules'))
->set('published = 0')
->where($db->qn('module') . ' LIKE ' . $db->q('mod_sr_experience%'));
$db->setQuery($query)
->execute();
$query->clear()
->delete($db->quoteName('#__sr_customfield_values'))
->where($db->quoteName('context') . ' LIKE ' . $db->quote('com_solidres.experience.customer%'));
$db->setQuery($query)
->execute();
$query->clear()
->delete($db->quoteName('#__sr_customfields'))
->where($db->quoteName('context') . ' = ' . $db->quote('com_solidres.experience.customer'));
$db->setQuery($query)
->execute();
}
public function preflight($type, $parent)
{
if (!JComponentHelper::isEnabled('com_solidres'))
{
$msg = "<p>Experience installed failed. Please make sure that Solidres Component is installed then try again.</p>";
JLog::add($msg, JLog::WARNING, 'jerror');
}
$isCustomFieldInstalled = JPluginHelper::isEnabled('solidres', 'customfield');
if (!$isCustomFieldInstalled)
{
$msg = "<p>Experience installed failed. Please make sure that Solidres Custom Field plugin is installed and enabled then try again.</p>";
JLog::add($msg, JLog::WARNING, 'jerror');
return false;
}
/** @var JTableMenu $table */
$table = JTable::getInstance('menu');
$componentId = (int) JComponentHelper::getComponent('com_solidres')->id;
$db = $table->getDbo();
$query = $db->getQuery(true);
if ($table->load(array(
'client_id' => 1,
'parent_id' => 1,
'type' => 'component',
'menutype' => 'main',
'link' => 'index.php?option=com_solidres&view=experiences',
'component_id' => $componentId,
)))
{
$menuId = (int) $table->id;
$db = $table->getDbo();
$query->delete($db->qn('#__menu'))
->where('(' . $db->qn('id') . ' = ' . $menuId . ' OR ' . $db->qn('parent_id') . ' = ' . $menuId . ')');
$db->setQuery($query)
->execute();
}
if ($type === 'uninstall')
{
$query->clear()
->select('a.extension_id')
->from($db->qn('#__extensions', 'a'))
->where('a.type = ' . $db->q('plugin'))
->where('a.folder = ' . $db->q('solidres'))
->where('a.element = ' . $db->q('experienceinvoice'));
$db->setQuery($query);
if ($eid = $db->loadResult())
{
$jInstaller = new JInstaller;
$jInstaller->uninstall('plugin', $eid);
}
return;
}
$data = array();
$data['menutype'] = 'main';
$data['title'] = 'SR_SUBMENU_EXPERIENCES';
$data['alias'] = 'solidres-experiences';
$data['link'] = 'index.php?option=com_solidres&view=experiences';
$data['type'] = 'component';
$data['img'] = 'class:component';
$data['component_id'] = $componentId;
$data['client_id'] = 1;
$data['published'] = 1;
$data['parent_id'] = 1;
$data['home'] = 0;
$data['path'] = '';
$data['params'] = '';
if ($parentId = $this->createAdminMenuItem($data, 1))
{
$data['parent_id'] = $parentId;
$subMenus = array(
array('SR_EXPERIENCES_LABEL', 'sr-experiences', 'index.php?option=com_solidres&view=experiences'),
array('SR_CATEGORIES_LABEL', 'sr-expcategories', 'index.php?option=com_solidres&view=expcategories'),
array('SR_TRANSPORTATIONS_LABEL', 'sr-transportations', 'index.php?option=com_solidres&view=transportations'),
array('SR_EXP_EXTRAS', 'sr-expextras', 'index.php?option=com_solidres&view=expextras'),
array('SR_SUBMENU_COUPONS_LIST', 'sr-expcoupons', 'index.php?option=com_solidres&view=expcoupons'),
array('SR_EXP_GUIDES_LABEL', 'sr-expguides', 'index.php?option=com_solidres&view=expguides'),
array('SR_CUSTOM_FIELDS_LABEL', 'sr-experience-fields', 'index.php?option=com_solidres&view=customfields&context=com_solidres.experience.customer'),
array('SR_RESERVATIONS_LABEL', 'sr-expreservations', 'index.php?option=com_solidres&view=expreservations'),
array('SR_EXPERIENCE_INVOICES', 'sr-expinvoices', 'index.php?option=com_solidres&view=expinvoices'),
array('SR_STATUSES', 'sr-statuses', 'index.php?option=com_solidres&view=statuses&scope=1'),
array('SR_ORIGINS', 'sr-origins', 'index.php?option=com_solidres&view=origins&scope=1'),
array('SR_EXP_CALENDARS', 'sr-expcalendars', 'index.php?option=com_solidres&view=expcalendars'),
array('SR_EXP_REPORT_N_STATISTICS', 'sr-expdashboard', 'index.php?option=com_solidres&view=expdashboard'),
);
foreach ($subMenus as $subMenu)
{
$data['title'] = $subMenu[0];
$data['alias'] = $subMenu[1];
$data['link'] = $subMenu[2];
$this->createAdminMenuItem($data, $parentId);
}
}
$files = array(
JPATH_ROOT . '/media/plg_solidres_experience/assets/css/datepicker.css',
JPATH_ROOT . '/media/plg_solidres_experience/assets/css/datepicker.min.css',
JPATH_ROOT . '/media/plg_solidres_experience/assets/js/datepicker.js',
JPATH_ROOT . '/media/plg_solidres_experience/assets/js/datepicker.min.js',
JPATH_PLUGINS . '/solidres/experience/administrator/components/com_solidres/models/fields/date.php',
);
foreach ($files as $file)
{
if (JFile::exists($file))
{
@JFile::delete($file);
}
}
if (JFolder::exists(JPATH_ROOT . '/media/plg_solidres_experience/assets/js/i18n'))
{
@JFolder::delete(JPATH_ROOT . '/media/plg_solidres_experience/assets/js/i18n');
}
}
protected function createAdminMenuItem($data, $parentId)
{
/** @var JTableMenu $table */
$table = JTable::getInstance('menu');
$db = $table->getDbo();
try
{
$table->setLocation($parentId, 'last-child');
}
catch (InvalidArgumentException $e)
{
JLog::add($e->getMessage(), JLog::WARNING, 'jerror');
return false;
}
if (!$table->bind($data) || !$table->check() || !$table->store())
{
$query = $db->getQuery(true)
->select('id')
->from('#__menu')
->where('menutype = ' . $db->q($data['menutype']))
->where('client_id = 1')
->where('link = ' . $db->q($data['link']))
->where('type = ' . $db->q($data['type']))
->where('parent_id = ' . $db->q($data['parent_id']))
->where('home = ' . $db->q($data['home']));
$db->setQuery($query);
$menuId = $db->loadResult();
if (!$menuId)
{
throw new RuntimeException($table->getError());
}
else
{
/** @var JTableMenu $temporaryTable */
$temporaryTable = JTable::getInstance('menu');
$temporaryTable->delete($menuId, true);
$temporaryTable->rebuild($data['parent_id']);
// Retry creating the menu item
$table->setLocation($parentId, 'last-child');
if (!$table->bind($data) || !$table->check() || !$table->store())
{
// Install failed, warn user and rollback changes
throw new RuntimeException($table->getError());
}
}
}
return $table->id;
}
}