Merge 'origin/develop' into gli-838
This commit is contained in:
@@ -178,6 +178,12 @@ class AddressCore extends ObjectModel
|
||||
*/
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
// for customer address we need to check of customer address already exists.
|
||||
if ($this->id_customer) {
|
||||
if ($id_address = Customer::getCustomerIdAddress($this->id_customer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!parent::add($autodate, $null_values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -243,6 +249,15 @@ class AddressCore extends ObjectModel
|
||||
public function validateController($htmlentities = true)
|
||||
{
|
||||
$errors = parent::validateController($htmlentities);
|
||||
|
||||
// for customer address we need to check of customer address already exists.
|
||||
if ($idCustomer = Tools::getValue('id_customer')) {
|
||||
if ($id_address = Customer::getCustomerIdAddress($idCustomer)) {
|
||||
|
||||
$errors[] = sprintf(Tools::displayError('Customer address already exists. Id address: #%d'), $id_address);
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -465,6 +465,21 @@ class CustomerCore extends ObjectModel
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
public static function getCustomerIdAddress($id_customer)
|
||||
{
|
||||
$cache_id = 'Customer::getCustomerIdAddress'.(int)$id_customer;
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$sql = 'SELECT id_address
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
WHERE `id_customer` = '.(int)$id_customer.' AND a.`deleted` = 0';
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
return $result;
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of addresses for a customer
|
||||
*
|
||||
|
||||
@@ -491,10 +491,7 @@ class EmployeeCore extends ObjectModel
|
||||
|
||||
public function getImage()
|
||||
{
|
||||
if (!Validate::isLoadedObject($this)) {
|
||||
return Tools::getAdminImageUrl('prestashop-avatar.png');
|
||||
}
|
||||
return Tools::getShopProtocol().'profile.prestashop.com/'.urlencode($this->email).'.jpg';
|
||||
return Context::getContext()->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO'));
|
||||
}
|
||||
|
||||
public function getLastElementsForNotify($element)
|
||||
|
||||
@@ -43,6 +43,9 @@ class ImageTypeCore extends ObjectModel
|
||||
/** @var int Apply to categories */
|
||||
public $categories;
|
||||
|
||||
/** @var int Apply to hotels */
|
||||
public $hotels;
|
||||
|
||||
/** @var int Apply to manufacturers */
|
||||
public $manufacturers;
|
||||
|
||||
@@ -67,6 +70,7 @@ class ImageTypeCore extends ObjectModel
|
||||
'height' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true),
|
||||
'categories' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'products' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'hotels' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'manufacturers' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'suppliers' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'scenes' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
@@ -110,6 +114,19 @@ class ImageTypeCore extends ObjectModel
|
||||
return self::$images_types_cache[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image type properties from type name
|
||||
*
|
||||
* @param string $type_name Name
|
||||
* @return array Image type definition
|
||||
*/
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT `id_image_type`, `width`, `height` FROM `'._DB_PREFIX_.'image_type` WHERE `name` like "'.pSQL($name).'"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if type already is already registered in database
|
||||
*
|
||||
|
||||
@@ -800,10 +800,9 @@ class LanguageCore extends ObjectModel
|
||||
$lang->iso_code = Tools::strtolower($iso_code);
|
||||
$lang->language_code = $iso_code; // Rewritten afterwards if the language code is available
|
||||
$lang->active = true;
|
||||
|
||||
// If the language pack has not been provided, retrieve it from prestashop.com
|
||||
if (!$lang_pack) {
|
||||
$lang_pack = json_decode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
||||
$lang_pack = json_decode(Tools::file_get_contents(_QLO_API_URL_.'/lang_pack/get_lang_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
||||
}
|
||||
|
||||
// If a language pack has been found or provided, prefill the language object with the value
|
||||
@@ -836,7 +835,7 @@ class LanguageCore extends ObjectModel
|
||||
Configuration::updateGlobalValue('PS_ALLOW_ACCENTED_CHARS_URL', 1);
|
||||
}
|
||||
|
||||
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
$flag = Tools::file_get_contents(_QLO_API_URL_.'/download/lang_pack/flags/'.$iso_code.'.jpg');
|
||||
if ($flag != null && !preg_match('/<body>/', $flag)) {
|
||||
$file = fopen(_PS_ROOT_DIR_.'/img/l/'.(int)$lang->id.'.jpg', 'w');
|
||||
if ($file) {
|
||||
@@ -917,11 +916,11 @@ class LanguageCore extends ObjectModel
|
||||
$errors = array();
|
||||
$file = _PS_TRANSLATIONS_DIR_.(string)$iso.'.gzip';
|
||||
|
||||
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.Tools::strtolower((string)$iso))) {
|
||||
if (!$lang_pack_link = Tools::file_get_contents(_QLO_API_URL_.'/lang_pack/get_lang_pack.php?version='.$version.'&iso_lang='.Tools::strtolower((string)$iso))) {
|
||||
$errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
||||
} elseif (!$lang_pack = json_decode($lang_pack_link)) {
|
||||
$errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
||||
} elseif (empty($lang_pack->error) && ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.Tools::strtolower($lang_pack->iso_code.'.gzip')))) {
|
||||
} elseif (empty($lang_pack->error) && ($content = Tools::file_get_contents($lang_pack->download_link))) {
|
||||
if (!@file_put_contents($file, $content)) {
|
||||
if (is_writable(dirname($file))) {
|
||||
@unlink($file);
|
||||
@@ -939,7 +938,6 @@ class LanguageCore extends ObjectModel
|
||||
$gz = new Archive_Tar($file, true);
|
||||
$files_list = AdminTranslationsController::filterTranslationFiles(Language::getLanguagePackListContent((string)$iso, $gz));
|
||||
$files_paths = AdminTranslationsController::filesListToPaths($files_list);
|
||||
|
||||
$i = 0;
|
||||
$tmp_array = array();
|
||||
|
||||
@@ -982,8 +980,6 @@ class LanguageCore extends ObjectModel
|
||||
AdminTranslationsController::checkAndAddMailsFiles((string)$iso, $files_list);
|
||||
AdminTranslationsController::addNewTabs((string)$iso, $files_list);
|
||||
}
|
||||
//By webkul....Replace our customized mail files in the mail folder.....
|
||||
Language::replaceCustomizedMailFiles($iso);
|
||||
}
|
||||
|
||||
return count($errors) ? $errors : true;
|
||||
|
||||
96
classes/MaintenanceAccess.php
Normal file
96
classes/MaintenanceAccess.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 2010-2022 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2022 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class MaintenanceAccessCore extends ObjectModel
|
||||
{
|
||||
|
||||
public $id_maintenance_access;
|
||||
public $ip_address;
|
||||
public $email;
|
||||
public $date_add;
|
||||
const USERNAME_ATTEMPTS_PER_QUARTER_HOUR = 3;
|
||||
const IP_ATTEMPTS_QUARTER_HOUR = 12;
|
||||
const USERNAME_ATTEMPTS_PER_HOUR = 6;
|
||||
const IP_ATTEMPTS_PER_HOUR = 24;
|
||||
const QUARTER_HOUR = 60*15;
|
||||
const HOUR = 60*60;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'maintenance_access',
|
||||
'primary' => 'id_maintenance_access',
|
||||
'fields' => array(
|
||||
'ip_address' => array('type' => self::TYPE_STRING, 'size' => 50),
|
||||
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
),
|
||||
);
|
||||
|
||||
public function cleanData()
|
||||
{
|
||||
$time = (time() - (self::HOUR*2));
|
||||
Db::getInstance()->execute(
|
||||
'DELETE FROM `' . _DB_PREFIX_ .'maintenance_access`
|
||||
WHERE `date_add` < "' . pSQL(date("Y-m-d H:i:s", $time)) . '"'
|
||||
);
|
||||
}
|
||||
|
||||
public function getUserFailedCount($time, $email=false, $ip_address=false, $attempts)
|
||||
{
|
||||
$sql = "SELECT COUNT(`id_maintenance_access`) FROM `". _DB_PREFIX_ ."maintenance_access` WHERE `date_add` > '"
|
||||
. pSQL(date('Y-m-d H:i:s', $time)) ."'";
|
||||
|
||||
if ($email) {
|
||||
$sql .= " AND `email` = '".pSQL($email)."'";
|
||||
}
|
||||
|
||||
if ($ip_address) {
|
||||
$sql .= " AND `ip_address` = '".pSQL($ip_address)."'";
|
||||
}
|
||||
|
||||
return Db::getInstance()->getValue($sql) >= $attempts;
|
||||
}
|
||||
|
||||
public function checkLimit($email)
|
||||
{
|
||||
$has_error = false;
|
||||
$minutes_ago = time() - self::QUARTER_HOUR;
|
||||
$hours_ago = time() - self::HOUR;
|
||||
$ip_address = Tools::getRemoteAddr();
|
||||
|
||||
$has_error |= $this->getUserFailedCount(
|
||||
$minutes_ago, $email, false, self::USERNAME_ATTEMPTS_PER_QUARTER_HOUR
|
||||
)? true : $has_error;
|
||||
$has_error |= $this->getUserFailedCount(
|
||||
$minutes_ago, false, $ip_address, self::IP_ATTEMPTS_QUARTER_HOUR
|
||||
)? true : $has_error;
|
||||
$has_error |= $this->getUserFailedCount(
|
||||
$hours_ago, $email, false, self::USERNAME_ATTEMPTS_PER_HOUR
|
||||
)? true : $has_error;
|
||||
$has_error |= $this->getUserFailedCount(
|
||||
$hours_ago, false, $ip_address, self::IP_ATTEMPTS_PER_HOUR
|
||||
)? true : $has_error;
|
||||
|
||||
return $has_error;
|
||||
}
|
||||
}
|
||||
@@ -1692,8 +1692,8 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
|
||||
$types = ImageType::getImagesTypes();
|
||||
foreach ($types as $image_type) {
|
||||
if ($this->image_name) { // by webkul
|
||||
if (file_exists($this->image_dir.$this->id.'-'.stripslashes($image_type['name']).'.'.$this->image_format)
|
||||
&& !unlink($this->image_dir.$this->id.'-'.stripslashes($image_type['name']).'.'.$this->image_format)) {
|
||||
if (file_exists($this->image_dir.$this->image_name.'-'.stripslashes($image_type['name']).'.'.$this->image_format)
|
||||
&& !unlink($this->image_dir.$this->image_name.'-'.stripslashes($image_type['name']).'.'.$this->image_format)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -85,7 +85,7 @@ class PrestaShopLoggerCore extends ObjectModel
|
||||
Mail::Send(
|
||||
(int)Configuration::get('PS_LANG_DEFAULT'),
|
||||
'log_alert',
|
||||
Mail::l('Log: You have a new alert from your shop', (int)Configuration::get('PS_LANG_DEFAULT')),
|
||||
Mail::l('Log: You have a new alert from your website', (int)Configuration::get('PS_LANG_DEFAULT')),
|
||||
array(),
|
||||
Configuration::get('PS_SHOP_EMAIL')
|
||||
);
|
||||
|
||||
@@ -46,8 +46,6 @@ class TabCore extends ObjectModel
|
||||
/** @var int hide_host_mode */
|
||||
public $hide_host_mode = false;
|
||||
|
||||
const TAB_MODULE_LIST_URL = _QLO_TAB_MODULE_LIST_URL_;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
@@ -597,4 +595,9 @@ class TabCore extends ObjectModel
|
||||
|
||||
return $modules_list;
|
||||
}
|
||||
|
||||
public static function isTabModuleListAvailable()
|
||||
{
|
||||
return file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3324,11 +3324,13 @@ exit;
|
||||
'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code),
|
||||
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(),
|
||||
'shop_url_ssl' => isset($params['shop_url_ssl']) ? $params['shop_url_ssl'] : Tools::getShopDomainSsl(),
|
||||
'physical_uri' => Context::getContext()->shop->physical_uri,
|
||||
'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')
|
||||
));
|
||||
|
||||
$protocols = array('https');
|
||||
$end_point = 'api.qloapps.com';
|
||||
$end_point = _QLO_API_DOMAIN_;
|
||||
|
||||
switch ($request) {
|
||||
case 'native':
|
||||
@@ -3347,6 +3349,10 @@ exit;
|
||||
$protocols[] = 'http';
|
||||
$post_data .= '&method=listing&action=must-have-themes';
|
||||
break;
|
||||
case 'addons-modules':
|
||||
$protocols[] = 'http';
|
||||
$post_data .= '&method=listing&action=addons-modules';
|
||||
break;
|
||||
case 'customer':
|
||||
$post_data .= '&method=listing&action=customer&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
|
||||
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
|
||||
@@ -3359,10 +3365,10 @@ exit;
|
||||
$post_data .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
break;
|
||||
case 'check_module':
|
||||
$post_data .= '&method=check&module_name='.urlencode($params['module_name']).'&module_key='.urlencode($params['module_key']);
|
||||
break;
|
||||
$post_data .= '&method=check&module='.urlencode($params['module_name']);
|
||||
break;
|
||||
case 'module':
|
||||
$post_data .= '&method=module&module_name='.urlencode($params['module_name']);
|
||||
$post_data .= '&method=module&module='.urlencode($params['module_name']);
|
||||
if (isset($params['username_addons']) && isset($params['password_addons'])) {
|
||||
$post_data .= '&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
} else {
|
||||
@@ -3374,13 +3380,24 @@ exit;
|
||||
.'&password='.urlencode($params['password_addons'])
|
||||
.'&shop_url='.urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain())
|
||||
.'&mail='.urlencode(isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'));
|
||||
$protocols[] = 'https';
|
||||
break;
|
||||
case 'install-modules':
|
||||
$protocols[] = 'http';
|
||||
$post_data .= '&method=listing&action=install-modules';
|
||||
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
|
||||
break;
|
||||
case 'catalog-recommendation':
|
||||
$protocols[] = 'http';
|
||||
$post_data .= '&method=content&action=catalogRecommendation';
|
||||
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
|
||||
break;
|
||||
case 'dashboard-recommendation':
|
||||
$protocols[] = 'http';
|
||||
$post_data .= '&method=content&action=dashboardRecommendation';
|
||||
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
|
||||
break;
|
||||
case 'check-version':
|
||||
$post_data .= '&method=check-version&autoupgrade='.(int)(Module::isInstalled('qloautoupgrade') && Module::isEnabled('qloautoupgrade'));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
*/
|
||||
class TranslateCore
|
||||
{
|
||||
public static $ignore_folder = array('.', '..', '.svn', '.git', '.htaccess', 'index.php');
|
||||
|
||||
/**
|
||||
* Get a translation for an admin controller
|
||||
*
|
||||
@@ -315,4 +317,338 @@ class TranslateCore
|
||||
{
|
||||
return Translate::postProcessTranslation($string, array('tags' => $tags));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method parse a file by type of translation and type file
|
||||
*
|
||||
* @param $content
|
||||
* @param $type_translation : front, back, errors, modules...
|
||||
* @param string|bool $type_file : (tpl|php)
|
||||
* @param string $module_name : name of the module
|
||||
* @return array
|
||||
*/
|
||||
public static function userParseFile($content, $type_translation, $type_file = false, $module_name = '')
|
||||
{
|
||||
switch ($type_translation) {
|
||||
case 'front':
|
||||
// Parsing file in Front office
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?\s*\}/U';
|
||||
break;
|
||||
|
||||
case 'back':
|
||||
// Parsing file in Back office
|
||||
if ($type_file == 'php') {
|
||||
$regex = '/this->l\((\')'._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
|
||||
} elseif ($type_file == 'specific') {
|
||||
$regex = '/Translate::getAdminTranslation\((\')'._PS_TRANS_PATTERN_.'\'(?:,.*)*\)/U';
|
||||
} else {
|
||||
$regex = '/\{l\s*s\s*=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?.*\}/U';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'errors':
|
||||
// Parsing file for all errors syntax
|
||||
$regex = '/Tools::displayError\((\')'._PS_TRANS_PATTERN_.'\'(,\s*(.+))?\)/U';
|
||||
break;
|
||||
|
||||
case 'modules':
|
||||
// Parsing modules file
|
||||
if ($type_file == 'php') {
|
||||
$regex = '/->l\((\')'._PS_TRANS_PATTERN_.'\'(, ?\'(.+)\')?(, ?(.+))?\)/U';
|
||||
} else {
|
||||
// In tpl file look for something that should contain mod='module_name' according to the documentation
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1.*\s+mod=\''.$module_name.'\'.*\}/U';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pdf':
|
||||
// Parsing PDF file
|
||||
if ($type_file == 'php') {
|
||||
$regex = array(
|
||||
'/HTMLTemplate.*::l\((\')'._PS_TRANS_PATTERN_.'\'[\)|\,]/U',
|
||||
'/->l\((\')'._PS_TRANS_PATTERN_.'\'(, ?\'(.+)\')?(, ?(.+))?\)/U'
|
||||
);
|
||||
} else {
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?(\s*pdf=\'true\')?\s*\}/U';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_array($regex)) {
|
||||
$regex = array($regex);
|
||||
}
|
||||
|
||||
$strings = array();
|
||||
foreach ($regex as $regex_row) {
|
||||
$matches = array();
|
||||
$n = preg_match_all($regex_row, $content, $matches);
|
||||
for ($i = 0; $i < $n; $i += 1) {
|
||||
$quote = $matches[1][$i];
|
||||
$string = $matches[2][$i];
|
||||
|
||||
if ($quote === '"') {
|
||||
// Escape single quotes because the core will do it when looking for the translation of this string
|
||||
$string = str_replace('\'', '\\\'', $string);
|
||||
// Unescape double quotes
|
||||
$string = preg_replace('/\\\\+"/', '"', $string);
|
||||
}
|
||||
|
||||
$strings[] = $string;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively list files in directory $dir
|
||||
*
|
||||
* @param string $dir
|
||||
* @param array $list
|
||||
* @param string $file_ext
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function listFiles($dir, $list = array(), $file_ext = 'tpl')
|
||||
{
|
||||
$dir = rtrim($dir, '/').DIRECTORY_SEPARATOR;
|
||||
|
||||
$to_parse = scandir($dir);
|
||||
// copied (and kind of) adapted from AdminImages.php
|
||||
foreach ($to_parse as $file) {
|
||||
if (!in_array($file, self::$ignore_folder)) {
|
||||
if (preg_match('#'.preg_quote($file_ext, '#').'$#i', $file)) {
|
||||
$list[$dir][] = $file;
|
||||
} elseif (is_dir($dir.$file)) {
|
||||
$list = self::listFiles($dir.$file, $list, $file_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find sentence which use %d, %s, %%, %1$d, %1$s...
|
||||
*
|
||||
* @param $key : english sentence
|
||||
* @return array|bool return list of matches
|
||||
*/
|
||||
public static function checkIfKeyUseSprintf($key)
|
||||
{
|
||||
if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $key, $matches)) {
|
||||
return implode(', ', $matches[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getTranslationsCountFrontOffice($theme, $isoCode)
|
||||
{
|
||||
$themeDir = _PS_ROOT_DIR_.'/themes/'.$theme.'/';
|
||||
$langFile = $themeDir.'lang/'.$isoCode.'.php';
|
||||
|
||||
// include global translation file
|
||||
if (Tools::file_exists_cache($langFile)) {
|
||||
include $langFile;
|
||||
} else {
|
||||
$_LANG = array();
|
||||
}
|
||||
|
||||
// count translatable strings in theme tpl files
|
||||
$directories = array();
|
||||
$directories['tpl'] = array(_PS_ALL_THEMES_DIR_ => scandir(_PS_ALL_THEMES_DIR_));
|
||||
self::$ignore_folder[] = 'modules';
|
||||
$directories['tpl'] = array_merge($directories['tpl'], self::listFiles($themeDir));
|
||||
if (isset($directories['tpl'][$themeDir.'pdf/'])) {
|
||||
unset($directories['tpl'][$themeDir.'pdf/']);
|
||||
}
|
||||
|
||||
if (Tools::file_exists_cache(_PS_THEME_OVERRIDE_DIR_)) {
|
||||
$directories['tpl'] = array_merge($directories['tpl'], self::listFiles(_PS_THEME_OVERRIDE_DIR_));
|
||||
}
|
||||
|
||||
// process tpl files
|
||||
$countTotal = 0;
|
||||
$countTranslated = 0;
|
||||
foreach ($directories['tpl'] as $dir => $files) {
|
||||
$prefix = $dir == _PS_THEME_OVERRIDE_DIR_ ? 'override_' : '';
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/^(.*).tpl$/', $file) && (Tools::file_exists_cache($filePath = $dir.$file))) {
|
||||
$prefixKey = $prefix.substr(basename($file), 0, -4);
|
||||
$fileContent = Tools::file_get_contents($filePath);
|
||||
$matches = self::userParseFile($fileContent, 'front');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
$countTotal++;
|
||||
|
||||
if (!empty($key)) {
|
||||
if (isset($_LANG[$prefixKey.'_'.md5($key)])) {
|
||||
$countTranslated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('total' => $countTotal, 'translated' => $countTranslated);
|
||||
}
|
||||
|
||||
public static function getTranslationsCountBackOffice($isoCode)
|
||||
{
|
||||
$translationsFile = _PS_TRANSLATIONS_DIR_.$isoCode.'/admin.php';
|
||||
|
||||
// include global translation file
|
||||
if (Tools::file_exists_cache($translationsFile)) {
|
||||
include $translationsFile;
|
||||
} else {
|
||||
$_LANGADM = array();
|
||||
}
|
||||
|
||||
// list directories with translatable files
|
||||
$directories = array(
|
||||
'php' => array(
|
||||
_PS_ADMIN_CONTROLLER_DIR_ => scandir(_PS_ADMIN_CONTROLLER_DIR_),
|
||||
_PS_OVERRIDE_DIR_.'controllers/admin/' => scandir(_PS_OVERRIDE_DIR_.'controllers/admin/'),
|
||||
_PS_CLASS_DIR_.'helper/' => scandir(_PS_CLASS_DIR_.'helper/'),
|
||||
_PS_CLASS_DIR_.'controller/' => array('AdminController.php'),
|
||||
_PS_CLASS_DIR_ => array('PaymentModule.php'),
|
||||
),
|
||||
'tpl' => self::listFiles(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'themes/'),
|
||||
'specific' => array(
|
||||
_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR => array(
|
||||
'header.inc.php',
|
||||
'footer.inc.php',
|
||||
'index.php',
|
||||
'functions.php',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// list directories from override folders
|
||||
if (Tools::file_exists_cache(_PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates')) {
|
||||
$directories['tpl'] = array_merge($directories['tpl'], self::listFiles(_PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates'));
|
||||
}
|
||||
|
||||
// process files
|
||||
$countTotal = 0;
|
||||
$countTranslated = 0;
|
||||
foreach ($directories['php'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
// check if $file is a PHP file and corresponding override file exists
|
||||
if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($filePath = $dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
$prefixKey = basename($file);
|
||||
// -4 becomes -14 to remove the ending "Controller.php" from the filename
|
||||
if (strpos($file, 'Controller.php') !== false) {
|
||||
$prefixKey = basename(substr($file, 0, -14));
|
||||
} elseif (strpos($file, 'Helper') !== false) {
|
||||
$prefixKey = 'Helper';
|
||||
}
|
||||
|
||||
if ($prefixKey == 'Admin') {
|
||||
$prefixKey = 'AdminController';
|
||||
}
|
||||
|
||||
if ($prefixKey == 'PaymentModule.php') {
|
||||
$prefixKey = 'PaymentModule';
|
||||
}
|
||||
|
||||
$fileContent = Tools::file_get_contents($filePath);
|
||||
$matches = self::userParseFile($fileContent, 'back', 'php');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
$countTotal++;
|
||||
|
||||
if (!empty($key)) {
|
||||
if (isset($_LANGADM[$prefixKey.md5($key)])) {
|
||||
$countTranslated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($directories['specific'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (Tools::file_exists_cache($filePath = $dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
$prefixKey = 'index';
|
||||
|
||||
$fileContent = Tools::file_get_contents($filePath);
|
||||
$matches = self::userParseFile($fileContent, 'back', 'specific');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
$countTotal++;
|
||||
|
||||
if (!empty($key)) {
|
||||
if (isset($_LANGADM[$prefixKey.md5($key)])) {
|
||||
$countTranslated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($directories['tpl'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/^(.*).tpl$/', $file) && Tools::file_exists_cache($filePath = $dir.$file)) {
|
||||
// get controller name instead of file name
|
||||
$prefixKey = Tools::toCamelCase(str_replace(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'themes', '', $filePath), true);
|
||||
$pos = strrpos($prefixKey, DIRECTORY_SEPARATOR);
|
||||
$tmp = substr($prefixKey, 0, $pos);
|
||||
|
||||
if (preg_match('#controllers#', $tmp)) {
|
||||
$parentClass = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $tmp));
|
||||
$override = array_search('override', $parentClass);
|
||||
if ($override !== false) {
|
||||
// case override/controllers/admin/templates/controller_name
|
||||
$prefixKey = 'Admin'.ucfirst($parentClass[$override + 4]);
|
||||
} else {
|
||||
// case admin_name/themes/theme_name/template/controllers/controller_name
|
||||
$key = array_search('controllers', $parentClass);
|
||||
$prefixKey = 'Admin'.ucfirst($parentClass[$key + 1]);
|
||||
}
|
||||
} else {
|
||||
$prefixKey = 'Admin'.ucfirst(substr($tmp, strrpos($tmp, DIRECTORY_SEPARATOR) + 1, $pos));
|
||||
}
|
||||
|
||||
// Adding list, form, option in Helper Translations
|
||||
$listPrefixKey = array('AdminHelpers', 'AdminList', 'AdminView', 'AdminOptions', 'AdminForm',
|
||||
'AdminCalendar', 'AdminTree', 'AdminUploader', 'AdminDataviz', 'AdminKpi', 'AdminModule_list', 'AdminModulesList');
|
||||
if (in_array($prefixKey, $listPrefixKey)) {
|
||||
$prefixKey = 'Helper';
|
||||
}
|
||||
|
||||
// Adding the folder backup/download/ in AdminBackup Translations
|
||||
if ($prefixKey == 'AdminDownload') {
|
||||
$prefixKey = 'AdminBackup';
|
||||
}
|
||||
|
||||
// use the prefix 'AdminController' (like old php files 'header', 'footer.inc', 'index', 'login', 'password', 'functions'
|
||||
if ($prefixKey == 'Admin' || $prefixKey == 'AdminTemplate') {
|
||||
$prefixKey = 'AdminController';
|
||||
}
|
||||
|
||||
$fileContent = Tools::file_get_contents($filePath);
|
||||
$matches = self::userParseFile($fileContent, 'back', 'tpl');
|
||||
|
||||
// get string translation for each tpl file
|
||||
foreach ($matches as $key) {
|
||||
$countTotal++;
|
||||
|
||||
if (!empty($key)) {
|
||||
if (isset($_LANGADM[$prefixKey.md5($key)])) {
|
||||
$countTranslated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('total' => $countTotal, 'translated' => $countTranslated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
class UpgraderCore
|
||||
{
|
||||
const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24;
|
||||
|
||||
// @todo find correct class to declare upgrade_info for header
|
||||
const CACHE_FILE_UPGRADE_AVAILABE = '/config/xml/upgrade_available.xml';
|
||||
|
||||
public $rss_version_link;
|
||||
public $rss_md5file_link_dir;
|
||||
/**
|
||||
|
||||
@@ -1575,6 +1575,7 @@ class AdminControllerCore extends Controller
|
||||
$this->page_header_toolbar_title = $this->toolbar_title[count($this->toolbar_title) - 1];
|
||||
}
|
||||
|
||||
$this->initTabModuleList();
|
||||
$this->addPageHeaderToolBarModulesListButton();
|
||||
|
||||
$this->context->smarty->assign('help_link', 'http://help.prestashop.com/'.Language::getIsoById($this->context->employee->id_lang).'/doc/'
|
||||
@@ -1652,7 +1653,6 @@ class AdminControllerCore extends Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->addToolBarModulesListButton();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2086,7 +2086,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
$this->getLanguages();
|
||||
$this->initToolbar();
|
||||
$this->initTabModuleList();
|
||||
// $this->initTabModuleList();
|
||||
$this->initPageHeaderToolbar();
|
||||
|
||||
if ($this->display == 'edit' || $this->display == 'add') {
|
||||
@@ -2128,22 +2128,10 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
protected function initTabModuleList()
|
||||
{
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
|
||||
}
|
||||
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800)) {
|
||||
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _QLO_TAB_MODULE_LIST_URL_);
|
||||
}
|
||||
|
||||
$this->tab_modules_list = Tab::getTabModulesList($this->id);
|
||||
|
||||
if (is_array($this->tab_modules_list['default_list']) && count($this->tab_modules_list['default_list'])) {
|
||||
$this->filter_modules_list = $this->tab_modules_list['default_list'];
|
||||
} elseif (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) {
|
||||
$this->addToolBarModulesListButton();
|
||||
$this->addPageHeaderToolBarModulesListButton();
|
||||
$this->context->smarty->assign(array(
|
||||
'tab_modules_list' => implode(',', $this->tab_modules_list['slider_list']),
|
||||
'admin_module_ajax_url' => $this->context->link->getAdminLink('AdminModules'),
|
||||
'back_tab_modules_list' => $this->context->link->getAdminLink(Tools::getValue('controller')),
|
||||
'tab_modules_open' => (int)Tools::getValue('tab_modules_open')
|
||||
@@ -2151,11 +2139,17 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function addPageHeaderToolBarModulesListButton()
|
||||
{
|
||||
$this->filterTabModuleList();
|
||||
$tab_modules_list = Tab::getTabModulesList($this->id);
|
||||
|
||||
if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) {
|
||||
$tab_modules_list = $this->filterTabModuleList($tab_modules_list);
|
||||
|
||||
if ((is_array($tab_modules_list['slider_list']) && count($tab_modules_list['slider_list']))
|
||||
|| !Tab::isTabModuleListAvailable()
|
||||
) {
|
||||
$this->page_header_toolbar_btn['modules-list'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Recommended Modules and Services')
|
||||
@@ -2163,19 +2157,8 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
protected function addToolBarModulesListButton()
|
||||
{
|
||||
$this->filterTabModuleList();
|
||||
|
||||
if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) {
|
||||
$this->toolbar_btn['modules-list'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Recommended Modules and Services')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function filterTabModuleList()
|
||||
protected function filterTabModuleList($tab_modules_list)
|
||||
{
|
||||
static $list_is_filtered = null;
|
||||
|
||||
@@ -2183,59 +2166,84 @@ class AdminControllerCore extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400)) {
|
||||
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, 86400)) {
|
||||
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, Tools::addonsRequest('native_all'));
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
|
||||
}
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
$country_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
|
||||
$must_have_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST);
|
||||
$all_module_list = array();
|
||||
|
||||
if (!empty($country_module_list) && $country_module_list_xml = @simplexml_load_string($country_module_list)) {
|
||||
$country_module_list_array = array();
|
||||
if (is_object($country_module_list_xml->module)) {
|
||||
foreach ($country_module_list_xml->module as $k => $m) {
|
||||
$all_module_list[] = (string)$m->name;
|
||||
libxml_use_internal_errors(true);
|
||||
if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
|
||||
$country_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
|
||||
if (!empty($country_module_list) && $country_module_list_xml = @simplexml_load_string($country_module_list)) {
|
||||
$country_module_list_array = array();
|
||||
if (is_object($country_module_list_xml->module)) {
|
||||
foreach ($country_module_list_xml->module as $k => $m) {
|
||||
$all_module_list[] = (string)$m->name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
$this->errors[] = Tools::displayError(sprintf('Error found : %1$s in country_module_list.xml file.', $error->message));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
$this->errors[] = Tools::displayError(sprintf('Error found : %1$s in country_module_list.xml file.', $error->message));
|
||||
}
|
||||
}
|
||||
|
||||
libxml_clear_errors();
|
||||
|
||||
|
||||
|
||||
if (!empty($must_have_module_list) && $must_have_module_list_xml = @simplexml_load_string($must_have_module_list)) {
|
||||
$must_have_module_list_array = array();
|
||||
if (is_object($country_module_list_xml->module)) {
|
||||
foreach ($must_have_module_list_xml->module as $l => $mo) {
|
||||
$all_module_list[] = (string)$mo->name;
|
||||
if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST)) {
|
||||
$must_have_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST);
|
||||
if (!empty($must_have_module_list) && $must_have_module_list_xml = @simplexml_load_string($must_have_module_list)) {
|
||||
$must_have_module_list_array = array();
|
||||
if (is_object($country_module_list_xml->module)) {
|
||||
foreach ($must_have_module_list_xml->module as $l => $mo) {
|
||||
$all_module_list[] = (string)$mo->name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
$this->errors[] = Tools::displayError(sprintf('Error found : %1$s in must_have_module_list.xml file.', $error->message));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
$this->errors[] = Tools::displayError(sprintf('Error found : %1$s in must_have_module_list.xml file.', $error->message));
|
||||
}
|
||||
}
|
||||
|
||||
libxml_clear_errors();
|
||||
|
||||
$this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $all_module_list);
|
||||
$tab_modules_list['slider_list'] = array_intersect($tab_modules_list['slider_list'], $all_module_list);
|
||||
|
||||
$list_is_filtered = true;
|
||||
|
||||
return $tab_modules_list;
|
||||
}
|
||||
|
||||
public function ajaxProcessRefreshModuleList($force_reload_cache = false)
|
||||
{
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'))) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
$this->status = 'error';
|
||||
}
|
||||
} else {
|
||||
$this->status = 'cache';
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'))) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
$this->status = 'error';
|
||||
}
|
||||
} else {
|
||||
$this->status = 'cache';
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, _TIME_1_WEEK_)) {
|
||||
if ($this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _QLO_TAB_MODULE_LIST_URL_)) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
$this->status = 'error';
|
||||
}
|
||||
} else {
|
||||
$this->status = 'cache';
|
||||
}
|
||||
Module::generateTrustedXml();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2369,7 +2377,9 @@ class AdminControllerCore extends Controller
|
||||
foreach ($xml_module->children() as $module) {
|
||||
/** @var SimpleXMLElement $module */
|
||||
foreach ($module->attributes() as $key => $value) {
|
||||
if ($xml_module->attributes() == 'native' && $key == 'name') {
|
||||
if (($xml_module->attributes() == 'native' || $xml_module->attributes() == 'disk')
|
||||
&& $key == 'name'
|
||||
) {
|
||||
$this->list_natives_modules[] = (string)$value;
|
||||
}
|
||||
if ($xml_module->attributes() == 'partner' && $key == 'name') {
|
||||
@@ -2441,6 +2451,8 @@ class AdminControllerCore extends Controller
|
||||
|
||||
$helper = new HelperList();
|
||||
|
||||
unset($this->toolbar_btn);
|
||||
$this->initToolbar();
|
||||
// Empty list is ok
|
||||
if (!is_array($this->_list)) {
|
||||
$this->displayWarning($this->l('Bad SQL query', 'Helper').'<br />'.htmlspecialchars($this->_list_error));
|
||||
@@ -2824,6 +2836,19 @@ class AdminControllerCore extends Controller
|
||||
'submit_form_ajax' => (int)Tools::getValue('submitFormAjax')
|
||||
));
|
||||
|
||||
// get upgrade available info
|
||||
if (!$this->isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_)) {
|
||||
file_put_contents(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE, Tools::addonsRequest('check-version'));
|
||||
}
|
||||
if (file_exists(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE)) {
|
||||
$content = Tools::file_get_contents( _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE);
|
||||
$upgradeInfo = simplexml_load_string($content);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'upgrade_info' => $upgradeInfo
|
||||
));
|
||||
}
|
||||
|
||||
Employee::setLastConnectionDate($this->context->employee->id);
|
||||
|
||||
$this->initProcess();
|
||||
@@ -4053,7 +4078,7 @@ class AdminControllerCore extends Controller
|
||||
* @param int $timeout
|
||||
* @return bool
|
||||
*/
|
||||
public function isFresh($file, $timeout = 604800)
|
||||
public function isFresh($file, $timeout = _TIME_1_WEEK_)
|
||||
{
|
||||
if (($time = @filemtime(_PS_ROOT_DIR_.$file)) && filesize(_PS_ROOT_DIR_.$file) > 0) {
|
||||
return ((time() - $time) < $timeout);
|
||||
@@ -4103,8 +4128,17 @@ class AdminControllerCore extends Controller
|
||||
$link_admin_modules = $this->context->link->getAdminLink('AdminModules', true);
|
||||
|
||||
$module->options['install_url'] = $link_admin_modules.'&install='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
$module->options['update_url'] = $link_admin_modules.'&update='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
if ($module->is_native) {
|
||||
$module->options['update_url'] = $link_admin_modules.'&update='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
} else {
|
||||
if ($module->url) {
|
||||
$module->options['update_url'] = $module->url;
|
||||
} else {
|
||||
$module->options['update_url'] = '';
|
||||
}
|
||||
}
|
||||
$module->options['uninstall_url'] = $link_admin_modules.'&uninstall='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
$module->options['delete_url'] = $link_admin_modules.'&delete='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
|
||||
$module->optionsHtml = $this->displayModuleOptions($module, $output_type, $back);
|
||||
|
||||
|
||||
@@ -214,7 +214,43 @@ class FrontControllerCore extends Controller
|
||||
self::$initialized = true;
|
||||
|
||||
parent::init();
|
||||
$this->context->smarty->assign([
|
||||
'css_dir' => _THEME_CSS_DIR_,
|
||||
'img_ps_dir' => _PS_IMG_,
|
||||
'tpl_dir' => _PS_THEME_DIR_,
|
||||
'js_dir' => _THEME_JS_DIR_,
|
||||
'base_dir' => __PS_BASE_URI__,
|
||||
'language_code' => $this->context->language->language_code ? $this->context->language->language_code : $this->context->language->iso_code,
|
||||
]);
|
||||
|
||||
/* get page name to display it in body id */
|
||||
|
||||
// Are we in a payment module
|
||||
$module_name = '';
|
||||
if (Validate::isModuleName(Tools::getValue('module'))) {
|
||||
$module_name = Tools::getValue('module');
|
||||
}
|
||||
|
||||
if (!empty($this->page_name)) {
|
||||
$page_name = $this->page_name;
|
||||
} elseif (!empty($this->php_self)) {
|
||||
$page_name = $this->php_self;
|
||||
} elseif (Tools::getValue('fc') == 'module' && $module_name != '' && (Module::getInstanceByName($module_name) instanceof PaymentModule)) {
|
||||
$page_name = 'module-payment-submit';
|
||||
}
|
||||
// @retrocompatibility Are we in a module ?
|
||||
elseif (preg_match('#^'.preg_quote($this->context->shop->physical_uri, '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
|
||||
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
||||
} else {
|
||||
$page_name = Dispatcher::getInstance()->getController();
|
||||
$page_name = (preg_match('/^[0-9]/', $page_name) ? 'page_'.$page_name : $page_name);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
|
||||
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||
|
||||
Tools::setCookieLanguage($this->context->cookie);
|
||||
$this->displayMaintenancePage();
|
||||
// If current URL use SSL, set it true (used a lot for module redirect)
|
||||
if (Tools::usingSecureMode()) {
|
||||
$useSSL = true;
|
||||
@@ -236,12 +272,10 @@ class FrontControllerCore extends Controller
|
||||
$this->context->smarty->assign('account_created', 1);
|
||||
unset($this->context->cookie->account_created);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// Init cookie language
|
||||
// @TODO This method must be moved into switchLanguage
|
||||
Tools::setCookieLanguage($this->context->cookie);
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode()) ? 'https://' : 'http://';
|
||||
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
|
||||
@@ -370,32 +404,6 @@ class FrontControllerCore extends Controller
|
||||
$this->context->cart = $cart;
|
||||
}
|
||||
|
||||
/* get page name to display it in body id */
|
||||
|
||||
// Are we in a payment module
|
||||
$module_name = '';
|
||||
if (Validate::isModuleName(Tools::getValue('module'))) {
|
||||
$module_name = Tools::getValue('module');
|
||||
}
|
||||
|
||||
if (!empty($this->page_name)) {
|
||||
$page_name = $this->page_name;
|
||||
} elseif (!empty($this->php_self)) {
|
||||
$page_name = $this->php_self;
|
||||
} elseif (Tools::getValue('fc') == 'module' && $module_name != '' && (Module::getInstanceByName($module_name) instanceof PaymentModule)) {
|
||||
$page_name = 'module-payment-submit';
|
||||
}
|
||||
// @retrocompatibility Are we in a module ?
|
||||
elseif (preg_match('#^'.preg_quote($this->context->shop->physical_uri, '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
|
||||
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
||||
} else {
|
||||
$page_name = Dispatcher::getInstance()->getController();
|
||||
$page_name = (preg_match('/^[0-9]/', $page_name) ? 'page_'.$page_name : $page_name);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
|
||||
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||
|
||||
/* Breadcrumb */
|
||||
$navigation_pipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');
|
||||
$this->context->smarty->assign('navigationPipe', $navigation_pipe);
|
||||
@@ -404,7 +412,6 @@ class FrontControllerCore extends Controller
|
||||
if (!empty($this->php_self) && !Tools::getValue('ajax')) {
|
||||
$this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
|
||||
}
|
||||
|
||||
Product::initPricesComputation();
|
||||
|
||||
$display_tax_label = $this->context->country->display_tax_label;
|
||||
@@ -444,13 +451,11 @@ class FrontControllerCore extends Controller
|
||||
'force_ssl' => Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'),
|
||||
'content_dir' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__,
|
||||
'base_uri' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__.(!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''),
|
||||
'tpl_dir' => _PS_THEME_DIR_,
|
||||
'tpl_uri' => _THEME_DIR_,
|
||||
'modules_dir' => _MODULE_DIR_,
|
||||
'mail_dir' => _MAIL_DIR_,
|
||||
'lang_iso' => $this->context->language->iso_code,
|
||||
'lang_id' => (int)$this->context->language->id,
|
||||
'language_code' => $this->context->language->language_code ? $this->context->language->language_code : $this->context->language->iso_code,
|
||||
'come_from' => Tools::getHttpHost(true, true).Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))),
|
||||
'cart_qties' => (int)$cart->nbProducts(),
|
||||
'currencies' => Currency::getCurrencies(),
|
||||
@@ -494,7 +499,6 @@ class FrontControllerCore extends Controller
|
||||
));
|
||||
|
||||
$assign_array = array(
|
||||
'img_ps_dir' => _PS_IMG_,
|
||||
'img_cat_dir' => _THEME_CAT_DIR_,
|
||||
'img_lang_dir' => _THEME_LANG_DIR_,
|
||||
'img_prod_dir' => _THEME_PROD_DIR_,
|
||||
@@ -504,8 +508,6 @@ class FrontControllerCore extends Controller
|
||||
'img_store_dir' => _THEME_STORE_DIR_,
|
||||
'img_col_dir' => _THEME_COL_DIR_,
|
||||
'img_dir' => _THEME_IMG_DIR_,
|
||||
'css_dir' => _THEME_CSS_DIR_,
|
||||
'js_dir' => _THEME_JS_DIR_,
|
||||
'pic_dir' => _THEME_PROD_PIC_DIR_
|
||||
);
|
||||
|
||||
@@ -538,14 +540,12 @@ class FrontControllerCore extends Controller
|
||||
self::$link = $link;
|
||||
$defaultCountry = $this->context->country;
|
||||
|
||||
$this->displayMaintenancePage();
|
||||
|
||||
if ($this->restrictedCountry) {
|
||||
$this->displayRestrictedCountryPage();
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('live_edit') && !$this->checkLiveEditAccess()) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
Tools::redirect('index.php');
|
||||
}
|
||||
|
||||
$this->iso = $iso;
|
||||
@@ -749,22 +749,101 @@ class FrontControllerCore extends Controller
|
||||
*/
|
||||
protected function displayMaintenancePage()
|
||||
{
|
||||
if ($this->maintenance == true || !(int)Configuration::get('PS_SHOP_ENABLE')) {
|
||||
$this->maintenance = true;
|
||||
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) {
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
|
||||
$this->context->smarty->assign($this->initLogoAndFavicon());
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
|
||||
));
|
||||
|
||||
// If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller
|
||||
$front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this;
|
||||
$this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl'));
|
||||
exit;
|
||||
if (isset(Context::getContext()->cookie->remote_addr)
|
||||
&& Context::getContext()->cookie->remote_addr != ip2long(Tools::getRemoteAddr())
|
||||
) {
|
||||
$cookie = Context::getContext()->cookie;
|
||||
if (isset($cookie->remote_addr)) {
|
||||
$cookie->enable_maintenance_view = false;
|
||||
$cookie->remote_addr = false;
|
||||
$cookie->write();
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('SubmitLogin')
|
||||
&& Configuration::get('PS_ALLOW_EMP')
|
||||
&& !Context::getContext()->cookie->enable_maintenance_view
|
||||
) {
|
||||
$email = trim(Tools::getValue('email'));
|
||||
$passwd = trim(Tools::getValue('passwd'));
|
||||
$this->processLogin($email, $passwd);
|
||||
}
|
||||
|
||||
if (!Context::getContext()->cookie->enable_maintenance_view || !Configuration::get('PS_ALLOW_EMP')) {
|
||||
Context::getContext()->cookie->__unset('enable_maintenance_view');
|
||||
Context::getContext()->cookie->write();
|
||||
if ($this->maintenance == true || !(int)Configuration::get('PS_SHOP_ENABLE')) {
|
||||
$this->maintenance = true;
|
||||
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) {
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
|
||||
$this->context->smarty->assign($this->initLogoAndFavicon());
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
|
||||
'allowEmployee' => Configuration::get('PS_ALLOW_EMP'),
|
||||
'maintenance' => $this->context->link->getAdminLink('AdminMaintenance', false),
|
||||
));
|
||||
// If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller
|
||||
$front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this;
|
||||
$this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function processLogin($email, $passwd)
|
||||
{
|
||||
$result = false;
|
||||
$objMaintenanceAccess = new MaintenanceAccess();
|
||||
|
||||
/* Check fields validity */
|
||||
if (empty($email)) {
|
||||
$this->errors[] = Tools::displayError('Email is empty.');
|
||||
} elseif (!Validate::isEmail($email)) {
|
||||
$this->errors[] = Tools::displayError('Invalid email address.');
|
||||
}
|
||||
|
||||
if (empty($passwd)) {
|
||||
$this->errors[] = Tools::displayError('The password field is blank.');
|
||||
} elseif (!Validate::isPasswd($passwd)) {
|
||||
$this->errors[] = Tools::displayError('Invalid password.');
|
||||
}
|
||||
|
||||
if ($objMaintenanceAccess->checkLimit($email)) {
|
||||
$this->errors[] =Tools::displayError('You have exceeded the limit of login attempts, please try after some time');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
// Find employee
|
||||
$this->context->employee = new Employee();
|
||||
$is_employee_loaded = $this->context->employee->getByEmail($email, $passwd);
|
||||
$employee_associated_shop = $this->context->employee->getAssociatedShops();
|
||||
if (!$is_employee_loaded) {
|
||||
$this->errors[] = Tools::displayError('The Employee does not exist, or the password provided is incorrect.');
|
||||
$this->context->employee->logout();
|
||||
} elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) {
|
||||
$this->errors[] = Tools::displayError('This employee does not manage the shop anymore (Either the shop has been deleted or permissions have been revoked).');
|
||||
$this->context->employee->logout();
|
||||
} else {
|
||||
// Update cookie
|
||||
$cookie = Context::getContext()->cookie;
|
||||
$cookie->enable_maintenance_view = $this->context->employee->id;
|
||||
$cookie->remote_addr = ip2long(Tools::getRemoteAddr());
|
||||
$cookie->write();
|
||||
}
|
||||
if (count($this->errors)) {
|
||||
$this->context->smarty->assign('errors', $this->errors);
|
||||
$objMaintenanceAccess->email = $email;
|
||||
$objMaintenanceAccess->ip_address = Tools::getRemoteAddr();
|
||||
$objMaintenanceAccess->save();
|
||||
} else {
|
||||
Tools::redirect('index.php');
|
||||
}
|
||||
} else {
|
||||
$this->context->smarty->assign('errors', $this->errors);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -171,13 +171,15 @@ abstract class ModuleCore
|
||||
|
||||
const CACHE_FILE_TAB_MODULES_LIST = '/config/xml/tab_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_ALL_COUNTRY_MODULES_LIST = '/config/xml/modules_native_addons.xml';
|
||||
// const CACHE_FILE_ALL_COUNTRY_MODULES_LIST = '/config/xml/modules_native_addons.xml';
|
||||
const CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST = '/config/xml/default_country_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_CUSTOMER_MODULES_LIST = '/config/xml/customer_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_MUST_HAVE_MODULES_LIST = '/config/xml/must_have_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_ADDONS_MODULES_LIST = '/config/xml/addons_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_TRUSTED_MODULES_LIST = '/config/xml/trusted_modules_list.xml';
|
||||
const CACHE_FILE_UNTRUSTED_MODULES_LIST = '/config/xml/untrusted_modules_list.xml';
|
||||
|
||||
@@ -1259,6 +1261,16 @@ abstract class ModuleCore
|
||||
return Translate::getModuleTranslation((string)$xml_module->name, Module::configXmlStringFormat($xml_module->displayName), (string)$xml_module->name);
|
||||
}
|
||||
|
||||
public static function getModuleInstallVersion($module)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT m.`name`, m.`version`, mp.`interest`, module_shop.`enable_device`
|
||||
FROM `'._DB_PREFIX_.'module` m
|
||||
'.Shop::addSqlAssociation('module', 'm', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'module_preference` mp ON (mp.`module` = m.`name` AND mp.`id_employee` = '.(int)$id_employee.')
|
||||
WHERE m.`name` = "'.pSQL($module).'"');
|
||||
}
|
||||
|
||||
protected static function useTooMuchMemory()
|
||||
{
|
||||
$memory_limit = Tools::getMemoryLimit();
|
||||
@@ -1297,7 +1309,7 @@ abstract class ModuleCore
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT m.name, m.version, mp.interest, module_shop.enable_device
|
||||
FROM `'._DB_PREFIX_.'module` m
|
||||
'.Shop::addSqlAssociation('module', 'm').'
|
||||
'.Shop::addSqlAssociation('module', 'm', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'module_preference` mp ON (mp.`module` = m.`name` AND mp.`id_employee` = '.(int)$id_employee.')');
|
||||
foreach ($result as $row) {
|
||||
$modules_installed[$row['name']] = $row;
|
||||
@@ -1364,7 +1376,22 @@ abstract class ModuleCore
|
||||
|
||||
$item->active = 0;
|
||||
$item->onclick_option = false;
|
||||
$item->trusted = Module::isModuleTrusted($item->name);
|
||||
$item->url = false;
|
||||
$item->trusted = Module::isModuleTrusted($item->name, false);
|
||||
$item->is_native = false;
|
||||
|
||||
if (defined('_PS_HOST_MODE_') && in_array($item->name, self::$hosted_modules_blacklist)) {
|
||||
continue;
|
||||
} elseif (isset($modules_installed[$item->name])) {
|
||||
$item->installed = true;
|
||||
$item->database_version = $modules_installed[$item->name]['version'];
|
||||
$item->interest = $modules_installed[$item->name]['interest'];
|
||||
$item->enable_device = $modules_installed[$item->name]['enable_device'];
|
||||
} else {
|
||||
$item->installed = false;
|
||||
$item->database_version = 0;
|
||||
$item->interest = 0;
|
||||
}
|
||||
|
||||
$module_list[] = $item;
|
||||
|
||||
@@ -1417,7 +1444,7 @@ abstract class ModuleCore
|
||||
$item->is_configurable = $tmp_module->is_configurable = method_exists($tmp_module, 'getContent') ? 1 : 0;
|
||||
$item->need_instance = isset($tmp_module->need_instance) ? $tmp_module->need_instance : 0;
|
||||
$item->active = $tmp_module->active;
|
||||
$item->trusted = Module::isModuleTrusted($tmp_module->name);
|
||||
$item->trusted = Module::isModuleTrusted($tmp_module->name, false);
|
||||
$item->currencies = isset($tmp_module->currencies) ? $tmp_module->currencies : null;
|
||||
$item->currencies_mode = isset($tmp_module->currencies_mode) ? $tmp_module->currencies_mode : null;
|
||||
$item->confirmUninstall = isset($tmp_module->confirmUninstall) ? html_entity_decode($tmp_module->confirmUninstall) : null;
|
||||
@@ -1429,6 +1456,7 @@ abstract class ModuleCore
|
||||
$item->badges = isset($tmp_module->badges) ? (array)$tmp_module->badges : null;
|
||||
$item->url = isset($tmp_module->url) ? $tmp_module->url : null;
|
||||
$item->onclick_option = method_exists($module, 'onclickOption') ? true : false;
|
||||
$item->is_native = false;
|
||||
|
||||
if ($item->onclick_option) {
|
||||
$href = Context::getContext()->link->getAdminLink('Module', true).'&module_name='.$tmp_module->name.'&tab_module='.$tmp_module->tab;
|
||||
@@ -1440,6 +1468,19 @@ abstract class ModuleCore
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('_PS_HOST_MODE_') && in_array($item->name, self::$hosted_modules_blacklist)) {
|
||||
continue;
|
||||
} elseif (isset($modules_installed[$item->name])) {
|
||||
$item->installed = true;
|
||||
$item->database_version = $modules_installed[$item->name]['version'];
|
||||
$item->interest = $modules_installed[$item->name]['interest'];
|
||||
$item->enable_device = $modules_installed[$item->name]['enable_device'];
|
||||
} else {
|
||||
$item->installed = false;
|
||||
$item->database_version = 0;
|
||||
$item->interest = 0;
|
||||
}
|
||||
|
||||
$module_list[] = $item;
|
||||
|
||||
if (!$xml_exist || $need_new_config_file) {
|
||||
@@ -1475,9 +1516,8 @@ abstract class ModuleCore
|
||||
}
|
||||
|
||||
$files_list = array(
|
||||
array('type' => 'addonsModules', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_ADDONS_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
array('type' => 'addonsMustHave', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
|
||||
);
|
||||
foreach ($files_list as $f) {
|
||||
if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $logged_on_addons)) {
|
||||
@@ -1497,90 +1537,20 @@ abstract class ModuleCore
|
||||
if (Tools::strtolower($m->name) == Tools::strtolower($modaddons->name) && !isset($m->available_on_addons)) {
|
||||
$flag_found = 1;
|
||||
if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1) {
|
||||
$module_list[$k]->version_addons = $modaddons->version;
|
||||
$module_list[$k]->version_addons = strip_tags((string)$modaddons->version);
|
||||
}
|
||||
$module_list[$k]->url = isset($modaddons->url) ? strip_tags((string)$modaddons->url) : null;
|
||||
|
||||
if ($f['type'] == 'addonsNative') {
|
||||
$module_list[$k]->is_native = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($flag_found == 0) {
|
||||
$item = new stdClass();
|
||||
$item->id = 0;
|
||||
$item->warning = '';
|
||||
$item->type = strip_tags((string)$f['type']);
|
||||
$item->name = strip_tags((string)$modaddons->name);
|
||||
$item->version = strip_tags((string)$modaddons->version);
|
||||
$item->tab = strip_tags((string)$modaddons->tab);
|
||||
$item->displayName = strip_tags((string)$modaddons->displayName);
|
||||
$item->description = stripslashes(strip_tags((string)$modaddons->description));
|
||||
$item->description_full = stripslashes(strip_tags((string)$modaddons->description_full));
|
||||
$item->author = strip_tags((string)$modaddons->author);
|
||||
$item->limited_countries = array();
|
||||
$item->parent_class = '';
|
||||
$item->onclick_option = false;
|
||||
$item->is_configurable = 0;
|
||||
$item->need_instance = 0;
|
||||
$item->not_on_disk = 1;
|
||||
$item->available_on_addons = 1;
|
||||
$item->trusted = Module::isModuleTrusted($item->name);
|
||||
$item->active = 0;
|
||||
$item->description_full = stripslashes($modaddons->description_full);
|
||||
$item->additional_description = isset($modaddons->additional_description) ? stripslashes($modaddons->additional_description) : null;
|
||||
$item->compatibility = isset($modaddons->compatibility) ? (array)$modaddons->compatibility : null;
|
||||
$item->nb_rates = isset($modaddons->nb_rates) ? (array)$modaddons->nb_rates : null;
|
||||
$item->avg_rate = isset($modaddons->avg_rate) ? (array)$modaddons->avg_rate : null;
|
||||
$item->badges = isset($modaddons->badges) ? (array)$modaddons->badges : null;
|
||||
$item->url = isset($modaddons->url) ? $modaddons->url : null;
|
||||
|
||||
if (isset($modaddons->img)) {
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) {
|
||||
if (!file_put_contents(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg', Tools::file_get_contents($modaddons->img))) {
|
||||
copy(_PS_IMG_DIR_.'404.gif', _PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) {
|
||||
$item->image = '../img/tmp/'.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->type == 'addonsMustHave') {
|
||||
$item->addons_buy_url = strip_tags((string)$modaddons->url);
|
||||
$prices = (array)$modaddons->price;
|
||||
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
foreach ($prices as $currency => $price) {
|
||||
if ($id_currency = Currency::getIdByIsoCode($currency)) {
|
||||
$item->price = (float)$price;
|
||||
$item->id_currency = (int)$id_currency;
|
||||
|
||||
if ($id_default_currency == $id_currency) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$module_list[$modaddons->id.'-'.$item->name] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($module_list as $key => &$module) {
|
||||
if (defined('_PS_HOST_MODE_') && in_array($module->name, self::$hosted_modules_blacklist)) {
|
||||
unset($module_list[$key]);
|
||||
} elseif (isset($modules_installed[$module->name])) {
|
||||
$module->installed = true;
|
||||
$module->database_version = $modules_installed[$module->name]['version'];
|
||||
$module->interest = $modules_installed[$module->name]['interest'];
|
||||
$module->enable_device = $modules_installed[$module->name]['enable_device'];
|
||||
} else {
|
||||
$module->installed = false;
|
||||
$module->database_version = 0;
|
||||
$module->interest = 0;
|
||||
}
|
||||
}
|
||||
usort($module_list, function ($a, $b) { return strnatcasecmp($a->displayName, $b->displayName); });
|
||||
if ($errors) {
|
||||
if (!isset(Context::getContext()->controller) && !Context::getContext()->controller->controller_name) {
|
||||
@@ -1622,6 +1592,92 @@ abstract class ModuleCore
|
||||
return $module_list;
|
||||
}
|
||||
|
||||
public static function getInstalledModulesOnDisk($use_config = false, $logged_on_addons = false, $id_employee = false)
|
||||
{
|
||||
$modules = self::getModulesOnDisk($use_config, $logged_on_addons, $id_employee);
|
||||
return array_filter($modules, function($m) {
|
||||
return $m->installed;
|
||||
});
|
||||
}
|
||||
|
||||
public static function getSuggestedModules()
|
||||
{
|
||||
$files_list = array(
|
||||
array('type' => 'addonsMustHave', 'file' => _PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
);
|
||||
$module_list = array();
|
||||
foreach ($files_list as $f) {
|
||||
$file = $f['file'];
|
||||
$content = Tools::file_get_contents($file);
|
||||
$xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
|
||||
if ($xml && isset($xml->module)) {
|
||||
foreach ($xml->module as $modaddons) {
|
||||
$item = new stdClass();
|
||||
$item->id = 0;
|
||||
$item->warning = '';
|
||||
$item->type = strip_tags((string)$f['type']);
|
||||
$item->name = strip_tags((string)$modaddons->name);
|
||||
$item->version = strip_tags((string)$modaddons->version);
|
||||
$item->tab = strip_tags((string)$modaddons->tab);
|
||||
$item->displayName = strip_tags((string)$modaddons->displayName);
|
||||
$item->description = stripslashes(strip_tags((string)$modaddons->description));
|
||||
$item->description_full = stripslashes(strip_tags((string)$modaddons->description_full));
|
||||
$item->author = strip_tags((string)$modaddons->author);
|
||||
$item->limited_countries = array();
|
||||
$item->parent_class = '';
|
||||
$item->onclick_option = false;
|
||||
$item->is_configurable = 0;
|
||||
$item->need_instance = 0;
|
||||
$item->not_on_disk = 1;
|
||||
$item->available_on_addons = 1;
|
||||
$item->trusted = Module::isModuleTrusted($item->name, false);
|
||||
$item->active = 0;
|
||||
$item->description_full = stripslashes($modaddons->description_full);
|
||||
$item->additional_description = isset($modaddons->additional_description) ? stripslashes($modaddons->additional_description) : null;
|
||||
$item->compatibility = isset($modaddons->compatibility) ? (array)$modaddons->compatibility : null;
|
||||
$item->nb_rates = isset($modaddons->nb_rates) ? (array)$modaddons->nb_rates : null;
|
||||
$item->avg_rate = isset($modaddons->avg_rate) ? (array)$modaddons->avg_rate : null;
|
||||
$item->badges = isset($modaddons->badges) ? (array)$modaddons->badges : null;
|
||||
$item->url = isset($modaddons->url) ? $modaddons->url : null;
|
||||
$item->is_native = false;
|
||||
|
||||
if (isset($modaddons->img)) {
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) {
|
||||
if (!file_put_contents(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg', Tools::file_get_contents($modaddons->img))) {
|
||||
copy(_PS_IMG_DIR_.'404.gif', _PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) {
|
||||
$item->image = '../img/tmp/'.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->type == 'addonsMustHave') {
|
||||
$item->addons_buy_url = strip_tags((string)$modaddons->url);
|
||||
$prices = (array)$modaddons->price;
|
||||
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
foreach ($prices as $currency => $price) {
|
||||
if ($id_currency = Currency::getIdByIsoCode($currency)) {
|
||||
$item->price = (float)$price;
|
||||
$item->id_currency = (int)$id_currency;
|
||||
|
||||
if ($id_default_currency == $id_currency) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$module_list[$modaddons->id.'-'.$item->name] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
$module_list = array_values($module_list);
|
||||
return $module_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return non native module
|
||||
@@ -1641,7 +1697,7 @@ abstract class ModuleCore
|
||||
$arr_native_modules = array();
|
||||
if (is_array($native_modules)) {
|
||||
foreach ($native_modules as $native_modules_type) {
|
||||
if (in_array($native_modules_type['type'], array('native', 'partner'))) {
|
||||
if (in_array($native_modules_type['type'], array('native', 'disk', 'partner'))) {
|
||||
$arr_native_modules[] = '""';
|
||||
foreach ($native_modules_type->module as $module) {
|
||||
$arr_native_modules[] = '"'.pSQL($module['name']).'"';
|
||||
@@ -1710,7 +1766,7 @@ abstract class ModuleCore
|
||||
* @param string $key The key provided by addons
|
||||
* @return int
|
||||
*/
|
||||
final public static function isModuleTrusted($module_name)
|
||||
final public static function isModuleTrusted($module_name, $check_api = true)
|
||||
{
|
||||
static $trusted_modules_list_content = null;
|
||||
static $modules_list_content = null;
|
||||
@@ -1724,7 +1780,7 @@ abstract class ModuleCore
|
||||
// we use the file, otherwise we regenerate it
|
||||
if (!(file_exists(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST)
|
||||
&& filesize(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST) > 0
|
||||
&& ((time() - filemtime(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST)) < 86400)
|
||||
&& ((time() - filemtime(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST)) < _TIME_1_DAY_)
|
||||
)) {
|
||||
self::generateTrustedXml();
|
||||
}
|
||||
@@ -1748,8 +1804,6 @@ abstract class ModuleCore
|
||||
$untrusted_modules_list_content = Tools::file_get_contents(_PS_ROOT_DIR_.self::CACHE_FILE_UNTRUSTED_MODULES_LIST);
|
||||
}
|
||||
|
||||
$objModule = Module::getInstanceByName($module_name);
|
||||
|
||||
// If the module is trusted, which includes both partner modules and modules bought on Addons
|
||||
|
||||
if (stripos($trusted_modules_list_content, $module_name) !== false) {
|
||||
@@ -1769,10 +1823,11 @@ abstract class ModuleCore
|
||||
// If the module isn't in one of the xml files
|
||||
// It might have been uploaded recenlty so we check
|
||||
// Addons API and clear XML files to be regenerated next time
|
||||
Tools::deleteFile(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST);
|
||||
Tools::deleteFile(_PS_ROOT_DIR_.self::CACHE_FILE_UNTRUSTED_MODULES_LIST);
|
||||
|
||||
return (int)Module::checkModuleFromAddonsApi($module_name);
|
||||
if ($check_api) {
|
||||
Tools::deleteFile(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST);
|
||||
Tools::deleteFile(_PS_ROOT_DIR_.self::CACHE_FILE_UNTRUSTED_MODULES_LIST);
|
||||
return (int)Module::checkModuleFromAddonsApi($module_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1787,9 +1842,11 @@ abstract class ModuleCore
|
||||
$untrusted = array();
|
||||
|
||||
$trusted_modules_xml = array(
|
||||
_PS_ROOT_DIR_.self::CACHE_FILE_ALL_COUNTRY_MODULES_LIST,
|
||||
_PS_ROOT_DIR_.self::CACHE_FILE_MUST_HAVE_MODULES_LIST,
|
||||
);
|
||||
// _PS_ROOT_DIR_.self::CACHE_FILE_ALL_COUNTRY_MODULES_LIST,
|
||||
_PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST,
|
||||
_PS_ROOT_DIR_.self::CACHE_FILE_MUST_HAVE_MODULES_LIST,
|
||||
_PS_ROOT_DIR_.self::CACHE_FILE_ADDONS_MODULES_LIST,
|
||||
);
|
||||
|
||||
if (file_exists(_PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST)) {
|
||||
$trusted_modules_xml[] = _PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST;
|
||||
@@ -1874,12 +1931,12 @@ abstract class ModuleCore
|
||||
|
||||
if (!is_object($obj)) {
|
||||
return false;
|
||||
} elseif ($obj->module_key === '') {
|
||||
return false;
|
||||
// } elseif ($obj->module_key === '') {
|
||||
// return false;
|
||||
} else {
|
||||
$params = array(
|
||||
'module_name' => $obj->name,
|
||||
'module_key' => $obj->module_key,
|
||||
// 'module_key' => $obj->module_key,
|
||||
);
|
||||
$xml = Tools::addonsRequest('check_module', $params);
|
||||
return (bool)(strpos($xml, 'success') !== false);
|
||||
|
||||
@@ -1747,6 +1747,10 @@ class OrderCore extends ObjectModel
|
||||
$this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2);
|
||||
}
|
||||
|
||||
if (!validate::isPrice($this->total_paid_real)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We put autodate parameter of add method to true if date_add field is null
|
||||
$res = $order_payment->add(is_null($order_payment->date_add)) && $this->update();
|
||||
|
||||
|
||||
@@ -410,7 +410,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += $data_v['total_price_tax_excl'];
|
||||
|
||||
// For order refund
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
|
||||
} else {
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
@@ -455,7 +454,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $data_v['total_price_tax_excl'];
|
||||
|
||||
// For order refund
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
|
||||
$totalDemandsPriceTE += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'];
|
||||
$totalDemandsPriceTI += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
|
||||
|
||||
@@ -183,7 +183,7 @@ class WebserviceRequestCore
|
||||
public static $ws_current_classname;
|
||||
|
||||
|
||||
public static $shopIDs;
|
||||
public static $shopIDs = array();
|
||||
|
||||
|
||||
public function getOutputEnabled()
|
||||
|
||||
@@ -48,12 +48,13 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
'invoice' => array(),
|
||||
'store_icon' => array(),
|
||||
),
|
||||
'products' => array(),
|
||||
'room_types' => array(),
|
||||
'hotels' => array(),
|
||||
'categories' => array(),
|
||||
'manufacturers' => array(),
|
||||
'suppliers' => array(),
|
||||
'stores' => array(),
|
||||
'customizations' => array(),
|
||||
// 'manufacturers' => array(),
|
||||
// 'suppliers' => array(),
|
||||
// 'stores' => array(),
|
||||
// 'customizations' => array(),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -300,6 +301,8 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
case 'suppliers':
|
||||
case 'stores':
|
||||
case 'features':
|
||||
case 'hotels':
|
||||
case 'room_types':
|
||||
switch ($this->wsObject->urlSegment[1]) {
|
||||
case 'categories':
|
||||
$directory = _PS_CAT_IMG_DIR_;
|
||||
@@ -316,14 +319,16 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
case 'features':
|
||||
$directory = _PS_IMG_DIR_.'rf/';
|
||||
break;
|
||||
case 'room_types':
|
||||
$directory = _PS_PROD_IMG_DIR_;
|
||||
break;
|
||||
case 'hotels':
|
||||
$directory = _PS_HOTEL_IMG_DIR_;
|
||||
break;
|
||||
}
|
||||
return $this->manageDeclinatedImages($directory);
|
||||
break;
|
||||
|
||||
// product image management : many image for one entity (product)
|
||||
case 'room_types':
|
||||
return $this->manageProductImages();
|
||||
break;
|
||||
case 'customizations':
|
||||
return $this->manageCustomizationImages();
|
||||
break;
|
||||
@@ -508,6 +513,17 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
foreach ($ids as $id) {
|
||||
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('image', array(), array('id' => $id, 'xlink_resource'=>$this->wsObject->wsUrl.'images/'.'room_types'.'/'.$id), false);
|
||||
}
|
||||
} else if ($this->imageType == 'hotels') {
|
||||
$ids = array();
|
||||
$objHotelImage = new HotelImage();
|
||||
$images = $objHotelImage->getAllImages();
|
||||
foreach ($images as $image) {
|
||||
$ids[] = $image['id_hotel'];
|
||||
}
|
||||
$ids = array_unique($ids, SORT_NUMERIC);
|
||||
foreach ($ids as $id) {
|
||||
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('image', array(), array('id' => $id, 'xlink_resource'=>$this->wsObject->wsUrl.'images/'.'hotels'.'/'.$id), false);
|
||||
}
|
||||
} else {
|
||||
$nodes = scandir($directory);
|
||||
foreach ($nodes as $node) {
|
||||
@@ -591,6 +607,47 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
$this->wsObject->setOutputEnabled(false);
|
||||
}
|
||||
}
|
||||
} elseif ($this->imageType == 'hotels') {
|
||||
// Get available image ids
|
||||
$available_image_ids = array();
|
||||
$objHotelImage = new HotelImage();
|
||||
|
||||
foreach (Language::getIDs() as $id_lang) {
|
||||
foreach ($objHotelImage->getImagesByHotelId($object_id) as $image) {
|
||||
$available_image_ids[] = $image['id'];
|
||||
}
|
||||
}
|
||||
$available_image_ids = array_unique($available_image_ids, SORT_NUMERIC);
|
||||
|
||||
if ($this->wsObject->urlSegment[3] != '') {
|
||||
if ($this->wsObject->urlSegment[3] == 'bin') {
|
||||
$hotelCoverImage = HotelImage::getCover($object_id);
|
||||
$this->wsObject->urlSegment[3] = $hotelCoverImage['id'];
|
||||
}
|
||||
if (!Validate::isUnsignedId($object_id) || !in_array($this->wsObject->urlSegment[3], $available_image_ids)) {
|
||||
throw new WebserviceException('This image id does not exist', array(57, 400));
|
||||
} else {
|
||||
$image_id = $this->wsObject->urlSegment[3];
|
||||
$path = $object_id;
|
||||
$image_size = $this->wsObject->urlSegment[4];
|
||||
if (file_exists($directory.$path.'/'.$image_id.(strlen($this->wsObject->urlSegment[4]) > 0 ? '-'.$this->wsObject->urlSegment[4] : '').'.jpg')) {
|
||||
$filename = $directory.$path.'/'.$image_id.(strlen($this->wsObject->urlSegment[4]) > 0 ? '-'.$this->wsObject->urlSegment[4] : '').'.jpg';
|
||||
|
||||
$orig_filename = $directory.$path.'/'.$image_id.'.jpg';
|
||||
}
|
||||
}
|
||||
} elseif ($this->wsObject->method == 'GET' || $this->wsObject->method == 'HEAD') {
|
||||
if ($available_image_ids) {
|
||||
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('image', array(), array('id'=>$object_id));
|
||||
foreach ($available_image_ids as $available_image_id) {
|
||||
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('declination', array(), array('id'=>$available_image_id, 'xlink_resource'=>$this->wsObject->wsUrl.'images/'.'hotels'.'/'.$object_id.'/'.$available_image_id), false);
|
||||
}
|
||||
$this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('image', array());
|
||||
} else {
|
||||
$this->objOutput->setStatus(404);
|
||||
$this->wsObject->setOutputEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for all other cases
|
||||
@@ -664,11 +721,6 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
}
|
||||
}
|
||||
|
||||
protected function manageProductImages()
|
||||
{
|
||||
$this->manageDeclinatedImages(_PS_PROD_IMG_DIR_);
|
||||
}
|
||||
|
||||
protected function getCustomizations()
|
||||
{
|
||||
$customizations = array();
|
||||
|
||||
Reference in New Issue
Block a user