// Normalize
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12694 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -116,9 +116,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
if (file_exists(_PS_ROOT_DIR_.$this->cache_file_modules_list))
|
||||
$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->cache_file_modules_list);
|
||||
if ($xmlModules)
|
||||
foreach($xmlModules->children() as $xmlModule)
|
||||
foreach($xmlModule->children() as $module)
|
||||
foreach($module->attributes() as $key => $value)
|
||||
foreach ($xmlModules->children() as $xmlModule)
|
||||
foreach ($xmlModule->children() as $module)
|
||||
foreach ($module->attributes() as $key => $value)
|
||||
{
|
||||
if ($xmlModule->attributes() == 'native' && $key == 'name')
|
||||
$this->list_natives_modules[] = (string)$value;
|
||||
@@ -349,7 +349,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
if (!is_array($remove))
|
||||
$remove = array($remove);
|
||||
|
||||
$url = preg_replace('#(?<=&|\?)(' . implode('|', $remove) . ')=.*?(&|$)#i', '', $url);
|
||||
$url = preg_replace('#(?<=&|\?)('.implode('|', $remove).')=.*?(&|$)#i', '', $url);
|
||||
$len = strlen($url);
|
||||
if ($url[$len - 1] == '&')
|
||||
$url = substr($url, 0, $len - 1);
|
||||
@@ -383,17 +383,17 @@ class AdminModulesControllerCore extends AdminController
|
||||
protected function recursiveDeleteOnDisk($dir)
|
||||
{
|
||||
if (strpos(realpath($dir), realpath(_PS_MODULE_DIR_)) === false)
|
||||
return ;
|
||||
return;
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object)
|
||||
if ($object != "." && $object != "..")
|
||||
if ($object != '.' && $object != '..')
|
||||
{
|
||||
if (filetype($dir."/".$object) == "dir")
|
||||
$this->recursiveDeleteOnDisk($dir."/".$object);
|
||||
if (filetype($dir.'/'.$object) == 'dir')
|
||||
$this->recursiveDeleteOnDisk($dir.'/'.$object);
|
||||
else
|
||||
unlink($dir."/".$object);
|
||||
unlink($dir.'/'.$object);
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
@@ -510,9 +510,10 @@ class AdminModulesControllerCore extends AdminController
|
||||
// Try to upload and unarchive the module
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
if (!isset($_FILES['file']['tmp_name']) OR empty($_FILES['file']['tmp_name']))
|
||||
if (!isset($_FILES['file']['tmp_name']) || empty($_FILES['file']['tmp_name']))
|
||||
$this->errors[] = $this->l('no file selected');
|
||||
elseif (substr($_FILES['file']['name'], -4) != '.tar' AND substr($_FILES['file']['name'], -4) != '.zip' AND substr($_FILES['file']['name'], -4) != '.tgz' AND substr($_FILES['file']['name'], -7) != '.tar.gz')
|
||||
elseif (substr($_FILES['file']['name'], -4) != '.tar' && substr($_FILES['file']['name'], -4) != '.zip'
|
||||
&& substr($_FILES['file']['name'], -4) != '.tgz' && substr($_FILES['file']['name'], -7) != '.tar.gz')
|
||||
$this->errors[] = Tools::displayError('Unknown archive type');
|
||||
elseif (!@copy($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name']))
|
||||
$this->errors[] = Tools::displayError('An error occurred while copying archive to module directory.');
|
||||
@@ -555,7 +556,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
if (Tools::getValue('module_name') != '')
|
||||
{
|
||||
$module = Module::getInstanceByName(Tools::getValue('module_name'));
|
||||
if (Validate::isLoadedObject($module) AND !$module->getPermission('configure'))
|
||||
if (Validate::isLoadedObject($module) && !$module->getPermission('configure'))
|
||||
$this->errors[] = Tools::displayError('You do not have the permission to use this module');
|
||||
else
|
||||
{
|
||||
@@ -581,7 +582,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
$modules = empty($modules) ? false : array($modules);
|
||||
$module_errors = array();
|
||||
if ($modules)
|
||||
foreach ($modules AS $name)
|
||||
foreach ($modules as $name)
|
||||
{
|
||||
// If Addons module, download and unzip it before installing it
|
||||
if (!is_dir('../modules/'.$name.'/'))
|
||||
@@ -612,15 +613,15 @@ class AdminModulesControllerCore extends AdminController
|
||||
// Check potential error
|
||||
if (!($module = Module::getInstanceByName(urldecode($name))))
|
||||
$this->errors[] = $this->l('module not found');
|
||||
elseif ($key == 'install' AND $this->tabAccess['add'] !== '1')
|
||||
elseif ($key == 'install' && $this->tabAccess['add'] !== '1')
|
||||
$this->errors[] = Tools::displayError('You do not have permission to install a module.');
|
||||
elseif ($key == 'uninstall' AND ($this->tabAccess['delete'] !== '1' OR !$module->getPermission('configure')))
|
||||
elseif ($key == 'uninstall' && ($this->tabAccess['delete'] !== '1' || !$module->getPermission('configure')))
|
||||
$this->errors[] = Tools::displayError('You do not have permission to delete this module.');
|
||||
elseif ($key == 'configure' AND ($this->tabAccess['edit'] !== '1' OR !$module->getPermission('configure')))
|
||||
elseif ($key == 'configure' && ($this->tabAccess['edit'] !== '1' || !$module->getPermission('configure')))
|
||||
$this->errors[] = Tools::displayError('You do not have permission to configure this module.');
|
||||
elseif ($key == 'install' AND Module::isInstalled($module->name))
|
||||
elseif ($key == 'install' && Module::isInstalled($module->name))
|
||||
$this->errors[] = Tools::displayError('This module is already installed:').' '.$module->name;
|
||||
elseif ($key == 'uninstall' AND !Module::isInstalled($module->name))
|
||||
elseif ($key == 'uninstall' && !Module::isInstalled($module->name))
|
||||
$this->errors[] = Tools::displayError('This module is already uninstalled:').' '.$module->name;
|
||||
else
|
||||
{
|
||||
@@ -660,7 +661,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
<th><a href="'.$backlink.'" style="padding:5px 10px">'.$this->l('Back').'</a></th>
|
||||
<th><a href="'.$hooklink.'" style="padding:5px 10px">'.$this->l('Manage hooks').'</a></th>
|
||||
<th style="padding:5px 10px">'.$this->l('Manage translations:').' ';
|
||||
foreach (Language::getLanguages(false) AS $language)
|
||||
foreach (Language::getLanguages(false) as $language)
|
||||
$toolbar .= '<a href="'.$tradlink.$language['iso_code'].'#'.$module->name.'" style="margin-left:5px"><img src="'._THEME_LANG_DIR_.$language['id_lang'].'.jpg" alt="'.$language['iso_code'].'" title="'.$language['iso_code'].'" /></a>';
|
||||
$toolbar .= '</th></tr>';
|
||||
|
||||
@@ -691,7 +692,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
// Display module configuration
|
||||
$this->context->smarty->assign('module_content', $toolbar.'<div class="clear"> </div>'.$echo.'<div class="clear"> </div>'.$toolbar);
|
||||
}
|
||||
elseif($echo === true)
|
||||
elseif ($echo === true)
|
||||
$return = ($method == 'install' ? 12 : 13);
|
||||
elseif ($echo === false)
|
||||
$module_errors[] = array('name' => $name, 'message' => $module->getErrors());
|
||||
@@ -787,10 +788,10 @@ class AdminModulesControllerCore extends AdminController
|
||||
if ($module->id)
|
||||
$return .= ' <span class="desactive-module"><a class="action_module" '.($module->active && method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('desactive', $href).'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab.'" '.((Shop::isFeatureActive()) ? 'title="'.htmlspecialchars($module->active ? $this->translationsTab['Disable this module'] : $this->translationsTab['Enable this module for all shops']).'"' : '').'>'.($module->active ? $this->translationsTab['Disable'] : $this->translationsTab['Enable']).'</a></span>';
|
||||
|
||||
if ($module->id AND $module->active)
|
||||
if ($module->id && $module->active)
|
||||
$return .= (!empty($result) ? '|' : '').' <span class="reset-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('reset', $href).'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'">'.$this->translationsTab['Reset'].'</a></span>';
|
||||
|
||||
if ($module->id AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND $module->is_configurable)))
|
||||
if ($module->id && (method_exists($module, 'getContent') || (isset($module->is_configurable) && $module->is_configurable)))
|
||||
$return .= (!empty($result) ? '|' : '').' <span class="configure-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->translationsTab['Configure'].'</a></span>';
|
||||
|
||||
$hrefDelete = self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
|
||||
@@ -801,12 +802,12 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
public function initModulesList($modules)
|
||||
{
|
||||
foreach ($modules AS $module)
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
if (!in_array($module->name, $this->list_natives_modules))
|
||||
$this->serial_modules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
|
||||
$module_author = $module->author;
|
||||
if (!empty($module_author)&& ($module_author != ""))
|
||||
if (!empty($module_author) && ($module_author != ''))
|
||||
$this->modules_authors[(string)$module_author] = 'notselected';
|
||||
}
|
||||
$this->serial_modules = urlencode($this->serial_modules);
|
||||
@@ -832,7 +833,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
public function isModuleFiltered($module)
|
||||
{
|
||||
// Beware $module could be an instance of Module or stdClass, that explain the static call
|
||||
if ($module->id AND !Module::getPermissionStatic($module->id, 'view') AND !Module::getPermissionStatic($module->id, 'configure'))
|
||||
if ($module->id && !Module::getPermissionStatic($module->id, 'view') && !Module::getPermissionStatic($module->id, 'configure'))
|
||||
return true;
|
||||
|
||||
|
||||
@@ -877,7 +878,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
return true;
|
||||
else if ($show_type_modules == 'partnerModules' && !in_array($module->name, $this->list_partners_modules))
|
||||
return true;
|
||||
else if ($show_type_modules == 'otherModules' && (in_array($module->name, $this->list_partners_modules) OR in_array($module->name, $this->list_natives_modules)))
|
||||
else if ($show_type_modules == 'otherModules' && (in_array($module->name, $this->list_partners_modules) || in_array($module->name, $this->list_natives_modules)))
|
||||
return true;
|
||||
else if (strpos($show_type_modules, 'authorModules[') !== false)
|
||||
{
|
||||
@@ -907,7 +908,10 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
// Filter on country
|
||||
$show_country_modules = $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee];
|
||||
if ($show_country_modules AND (isset($module->limited_countries) AND !empty($module->limited_countries) AND ((is_array($module->limited_countries) AND sizeof($module->limited_countries) AND !in_array(strtolower($this->iso_default_country), $module->limited_countries)) OR (!is_array($module->limited_countries) AND strtolower($this->iso_default_country) != strval($module->limited_countries)))))
|
||||
if ($show_country_modules && (isset($module->limited_countries) && !empty($module->limited_countries)
|
||||
&& ((is_array($module->limited_countries) && count($module->limited_countries)
|
||||
&& !in_array(strtolower($this->iso_default_country), $module->limited_countries))
|
||||
|| (!is_array($module->limited_countries) && strtolower($this->iso_default_country) != strval($module->limited_countries)))))
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
public function postProcess()
|
||||
{
|
||||
// Getting key value for display
|
||||
if (Tools::getValue('show_modules') AND strval(Tools::getValue('show_modules')) != 'all')
|
||||
if (Tools::getValue('show_modules') && strval(Tools::getValue('show_modules')) != 'all')
|
||||
$this->displayKey = (int)(Tools::getValue('show_modules'));
|
||||
|
||||
// Change position in hook
|
||||
@@ -66,9 +66,9 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$id_hook = (int)(Tools::getValue('id_hook'));
|
||||
$hook = new Hook($id_hook);
|
||||
|
||||
if (!$id_module OR !Validate::isLoadedObject($module))
|
||||
if (!$id_module || !Validate::isLoadedObject($module))
|
||||
$this->errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
elseif (!$id_hook || !Validate::isLoadedObject($hook))
|
||||
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
|
||||
elseif (Hook::getModulesFromHook($id_hook, $id_module))
|
||||
$this->errors[] = Tools::displayError('This module is already transplanted to this hook.');
|
||||
@@ -85,7 +85,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$exceptions = (isset($exceptions[0])) ? $exceptions[0] : array();
|
||||
$exceptions = explode(',', str_replace(' ', '', $exceptions));
|
||||
|
||||
foreach ($exceptions AS $except)
|
||||
foreach ($exceptions as $except)
|
||||
if (!Validate::isFileName($except))
|
||||
$this->errors[] = Tools::displayError('No valid value for field exceptions');
|
||||
|
||||
@@ -112,9 +112,9 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$id_hook = (int)(Tools::getValue('id_hook'));
|
||||
$hook = new Hook($id_hook);
|
||||
|
||||
if (!$id_module OR !Validate::isLoadedObject($module))
|
||||
if (!$id_module || !Validate::isLoadedObject($module))
|
||||
$this->errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
elseif (!$id_hook || !Validate::isLoadedObject($hook))
|
||||
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
|
||||
else
|
||||
{
|
||||
@@ -126,7 +126,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$exception = explode(',', str_replace(' ', '', $exception));
|
||||
|
||||
// Check files name
|
||||
foreach ($exception AS $except)
|
||||
foreach ($exception as $except)
|
||||
if (!Validate::isFileName($except))
|
||||
$this->errors[] = Tools::displayError('No valid value for field exceptions');
|
||||
|
||||
@@ -145,7 +145,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$exceptions = explode(',', str_replace(' ', '', $exceptions));
|
||||
|
||||
// Check files name
|
||||
foreach ($exceptions AS $except)
|
||||
foreach ($exceptions as $except)
|
||||
if (!Validate::isFileName($except))
|
||||
$this->errors[] = Tools::displayError('No valid value for field exceptions');
|
||||
|
||||
@@ -172,11 +172,11 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$hook = new Hook($id_hook);
|
||||
if (!Validate::isLoadedObject($module))
|
||||
$this->errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
elseif (!$id_hook || !Validate::isLoadedObject($hook))
|
||||
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
|
||||
else
|
||||
{
|
||||
if (!$module->unregisterHook($id_hook, Context::getContext()->shop->getListOfID()) OR !$module->unregisterExceptions($id_hook, Context::getContext()->shop->getListOfID()))
|
||||
if (!$module->unregisterHook($id_hook, Context::getContext()->shop->getListOfID()) || !$module->unregisterExceptions($id_hook, Context::getContext()->shop->getListOfID()))
|
||||
$this->errors[] = Tools::displayError('An error occurred while deleting module from hook.');
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
@@ -187,7 +187,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
}
|
||||
elseif (Tools::isSubmit('unhookform'))
|
||||
{
|
||||
if (!($unhooks = Tools::getValue('unhooks')) OR !is_array($unhooks))
|
||||
if (!($unhooks = Tools::getValue('unhooks')) || !is_array($unhooks))
|
||||
$this->errors[] = Tools::displayError('Select a module to unhook.');
|
||||
else
|
||||
{
|
||||
@@ -200,15 +200,15 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$hook = new Hook((int)($id_hook));
|
||||
if (!Validate::isLoadedObject($module))
|
||||
$this->errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
elseif (!$id_hook || !Validate::isLoadedObject($hook))
|
||||
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
|
||||
else
|
||||
{
|
||||
if (!$module->unregisterHook((int)($id_hook)) OR !$module->unregisterExceptions((int)($id_hook)))
|
||||
if (!$module->unregisterHook((int)($id_hook)) || !$module->unregisterExceptions((int)($id_hook)))
|
||||
$this->errors[] = Tools::displayError('An error occurred while deleting module from hook.');
|
||||
}
|
||||
}
|
||||
if (!sizeof($this->errors))
|
||||
if (!count($this->errors))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if (array_key_exists('addToHook', $_GET) OR array_key_exists('editGraft', $_GET) OR (Tools::isSubmit('submitAddToHook') AND $this->errors))
|
||||
if (array_key_exists('addToHook', $_GET) || array_key_exists('editGraft', $_GET) || (Tools::isSubmit('submitAddToHook') && $this->errors))
|
||||
{
|
||||
$this->display = 'edit';
|
||||
$this->content .= $this->renderForm();
|
||||
@@ -255,12 +255,12 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$hooks[$key]['module_count'] = count($hooks[$key]['modules']);
|
||||
// If modules were found, link to the previously created Module instances
|
||||
if (is_array($hooks[$key]['modules']) && !empty($hooks[$key]['modules']))
|
||||
foreach($hooks[$key]['modules'] as $module_key => $module)
|
||||
foreach ($hooks[$key]['modules'] as $module_key => $module)
|
||||
if (isset($assoc_modules_id[$module['id_module']]))
|
||||
$hooks[$key]['modules'][$module_key]['instance'] = $module_instances[$assoc_modules_id[$module['id_module']]];
|
||||
}
|
||||
|
||||
$this->addJqueryPlugin("tablednd");
|
||||
$this->addJqueryPlugin('tablednd');
|
||||
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'href' => self::$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token,
|
||||
@@ -300,7 +300,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
{
|
||||
// Check auth for this page
|
||||
if (!$id_module || !$id_hook)
|
||||
Tools::redirectAdmin(self::$currentIndex . '&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
|
||||
$sql = 'SELECT id_module
|
||||
FROM '._DB_PREFIX_.'hook_module
|
||||
@@ -308,7 +308,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
AND id_hook = '.$id_hook.'
|
||||
AND id_shop IN('.implode(', ', Context::getContext()->shop->getListOfID()).')';
|
||||
if (!Db::getInstance()->getValue($sql))
|
||||
Tools::redirectAdmin(self::$currentIndex . '&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
|
||||
$slModule = Module::getInstanceById($id_module);
|
||||
$exceptsList = $slModule->getExceptions($id_hook, true);
|
||||
@@ -333,7 +333,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$modules = Module::getModulesInstalled(0);
|
||||
|
||||
$instances = array();
|
||||
foreach ($modules AS $module)
|
||||
foreach ($modules as $module)
|
||||
if ($tmpInstance = Module::getInstanceById($module['id_module']))
|
||||
$instances[$tmpInstance->displayName] = $tmpInstance;
|
||||
ksort($instances);
|
||||
@@ -371,7 +371,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
if (!is_array($fileList))
|
||||
$fileList = ($fileList) ? array($fileList) : array();
|
||||
|
||||
$content = '<input type="text" name="exceptions['.$shopID.']" size="40" value="' . implode(', ', $fileList) . '" id="em_text_'.$shopID.'">';
|
||||
$content = '<input type="text" name="exceptions['.$shopID.']" size="40" value="'.implode(', ', $fileList).'" id="em_text_'.$shopID.'">';
|
||||
if ($shopID)
|
||||
$content .= ' ('.Shop::getInstance($shopID)->name.')';
|
||||
$content .= '<br /><select id="em_list_'.$shopID.'">';
|
||||
@@ -380,9 +380,7 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
ksort($controllers);
|
||||
foreach ($controllers as $k => $v)
|
||||
{
|
||||
$content .= '<option value="'.$k.'">'.$k.'</option>';
|
||||
}
|
||||
$content .= '</select> <input type="button" class="button" value="'.$this->l('Add').'" onclick="position_exception_add('.$shopID.')" />
|
||||
<input type="button" class="button" value="'.$this->l('Remove').'" onclick="position_exception_remove('.$shopID.')" /><br /><br />';
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
$order = new Order($id_order);
|
||||
$order_state = OrderHistory::getLastOrderState($id_order);
|
||||
if (!Validate::isLoadedObject($order_state) OR !Validate::isLoadedObject($order))
|
||||
if (!Validate::isLoadedObject($order_state) || !Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Invalid objects'));
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
@@ -292,19 +292,19 @@ class AdminOrdersControllerCore extends AdminController
|
||||
/* Get message rules and and check fields validity */
|
||||
// TODO review
|
||||
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
|
||||
foreach ($rules['required'] AS $field)
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
if (!Tools::getValue('id_'.$this->table) OR $field != 'passwd')
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false || (string)$value != '0')
|
||||
if (!Tools::getValue('id_'.$this->table) || $field != 'passwd')
|
||||
$this->errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is required.');
|
||||
foreach ($rules['size'] AS $field => $maxLength)
|
||||
if (Tools::getValue($field) AND Tools::strlen(Tools::getValue($field)) > $maxLength)
|
||||
foreach ($rules['size'] as $field => $maxLength)
|
||||
if (Tools::getValue($field) && Tools::strlen(Tools::getValue($field)) > $maxLength)
|
||||
$this->errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is too long.').' ('.$maxLength.' '.Tools::displayError('chars max').')';
|
||||
foreach ($rules['validate'] AS $field => $function)
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (Tools::getValue($field))
|
||||
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8')))
|
||||
$this->errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is invalid.');
|
||||
|
||||
if (!sizeof($this->errors))
|
||||
if (!count($this->errors))
|
||||
{
|
||||
//check if a thread already exist
|
||||
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
|
||||
@@ -386,7 +386,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('You have to write an amount if you want to do a partial credit slip');
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->errors))
|
||||
if (!count($this->errors))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=24&token='.$this->token);
|
||||
}
|
||||
else
|
||||
@@ -413,14 +413,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
|
||||
}
|
||||
|
||||
if ($productList OR $customizationList)
|
||||
if ($productList || $customizationList)
|
||||
{
|
||||
if ($productList)
|
||||
{
|
||||
$id_cart = Cart::getCartIdByOrderId($order->id);
|
||||
$customization_quantities = Customization::countQuantityByCart($id_cart);
|
||||
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
foreach ($productList as $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
if (!$qtyCancelProduct)
|
||||
@@ -441,7 +441,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
|
||||
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
foreach ($customizationList as $id_customization => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
$customization_quantity = $customization_quantities[$id_customization];
|
||||
@@ -454,14 +454,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if (!sizeof($this->errors) AND $productList)
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
if (!count($this->errors) && $productList)
|
||||
foreach ($productList as $key => $id_order_detail)
|
||||
{
|
||||
$qty_cancel_product = abs($qtyList[$key]);
|
||||
$order_detail = new OrderDetail((int)($id_order_detail));
|
||||
|
||||
// Reinject product
|
||||
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities')))
|
||||
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Tools::isSubmit('reinjectQuantities')))
|
||||
{
|
||||
$reinjectable_quantity = (int)$order_detail->product_quantity - (int)$order_detail->product_quantity_reinjected;
|
||||
$quantity_to_reinject = $qty_cancel_product > $reinjectable_quantity ? $reinjectable_quantity : $qty_cancel_product;
|
||||
@@ -473,8 +473,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')
|
||||
&& $product->advanced_stock_management
|
||||
&& $order_detail->id_warehouse != 0
|
||||
)
|
||||
&& $order_detail->id_warehouse != 0)
|
||||
{
|
||||
$mvts = StockMvt::getNegativeStockMvts(
|
||||
$order_detail->id_order,
|
||||
@@ -516,8 +515,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$order_detail->product_name.'</span>';
|
||||
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
if (!sizeof($this->errors) AND $customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
if (!count($this->errors) && $customizationList)
|
||||
foreach ($customizationList as $id_customization => $id_order_detail)
|
||||
{
|
||||
$order_detail = new OrderDetail((int)($id_order_detail));
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
@@ -525,7 +524,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('An error occurred during deletion of product customization.').' '.$id_customization;
|
||||
}
|
||||
// E-mail params
|
||||
if ((isset($_POST['generateCreditSlip']) OR isset($_POST['generateDiscount'])) AND !sizeof($this->errors))
|
||||
if ((isset($_POST['generateCreditSlip']) || isset($_POST['generateDiscount'])) && !count($this->errors))
|
||||
{
|
||||
$customer = new Customer((int)($order->id_customer));
|
||||
$params['{lastname}'] = $customer->lastname;
|
||||
@@ -534,21 +533,32 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
// Generate credit slip
|
||||
if (isset($_POST['generateCreditSlip']) AND !sizeof($this->errors))
|
||||
if (isset($_POST['generateCreditSlip']) && !count($this->errors))
|
||||
{
|
||||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack'])))
|
||||
$this->errors[] = Tools::displayError('Cannot generate credit slip');
|
||||
else
|
||||
{
|
||||
Hook::exec('actionOrderSlipAdd', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
|
||||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||||
_PS_MAIL_DIR_, true);
|
||||
@Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'credit_slip',
|
||||
Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$params,
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
_PS_MAIL_DIR_,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate voucher
|
||||
if (isset($_POST['generateDiscount']) AND !sizeof($this->errors))
|
||||
if (isset($_POST['generateDiscount']) && !count($this->errors))
|
||||
{
|
||||
// @todo generate a voucher using cartrules
|
||||
if (true || !$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))
|
||||
@@ -559,8 +569,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
$params['{voucher_num}'] = $voucher->name;
|
||||
@Mail::Send((int)$order->id_lang, 'voucher', Mail::l('New voucher regarding your order', (int)$order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
|
||||
NULL, _PS_MAIL_DIR_, true);
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null,
|
||||
null, _PS_MAIL_DIR_, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -568,7 +578,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('No product or quantity selected.');
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->errors))
|
||||
if (!count($this->errors))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=24&token='.$this->token);
|
||||
}
|
||||
else
|
||||
@@ -829,7 +839,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
elseif ($order->hasInvoice())
|
||||
{
|
||||
$order_invoices_collection = $order->getInvoicesCollection();
|
||||
foreach($order_invoices_collection as $order_invoice)
|
||||
foreach ($order_invoices_collection as $order_invoice)
|
||||
{
|
||||
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * Tools::getValue('discount_value') / 100, 2);
|
||||
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * Tools::getValue('discount_value') / 100, 2);
|
||||
@@ -865,7 +875,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
elseif ($order->hasInvoice())
|
||||
{
|
||||
$order_invoices_collection = $order->getInvoicesCollection();
|
||||
foreach($order_invoices_collection as $order_invoice)
|
||||
foreach ($order_invoices_collection as $order_invoice)
|
||||
{
|
||||
if (Tools::getValue('discount_value') > $order_invoice->total_paid_tax_incl)
|
||||
$this->errors[] = Tools::displayError('Discount value is superior than the order invoice total (Invoice: ').$order_invoice->getInvoiceNumberFormatted(Context::getContext()->language->id).')';
|
||||
@@ -906,7 +916,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
elseif ($order->hasInvoice())
|
||||
{
|
||||
$order_invoices_collection = $order->getInvoicesCollection();
|
||||
foreach($order_invoices_collection as $order_invoice)
|
||||
foreach ($order_invoices_collection as $order_invoice)
|
||||
{
|
||||
if ($order_invoice->total_shipping_tax_incl <= 0)
|
||||
continue;
|
||||
@@ -977,10 +987,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $order->id_cart);
|
||||
}
|
||||
|
||||
// Retrieve addresses informations
|
||||
// Retrieve addresses information
|
||||
$addressInvoice = new Address($order->id_address_invoice, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state)
|
||||
$invoiceState = new State((int)($addressInvoice->id_state));
|
||||
if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state)
|
||||
$invoiceState = new State((int)$addressInvoice->id_state);
|
||||
|
||||
if ($order->id_address_invoice == $order->id_address_delivery)
|
||||
{
|
||||
@@ -991,7 +1001,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
else
|
||||
{
|
||||
$addressDelivery = new Address($order->id_address_delivery, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state)
|
||||
if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state)
|
||||
$deliveryState = new State((int)($addressDelivery->id_state));
|
||||
}
|
||||
|
||||
@@ -1006,8 +1016,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product = new Product($order_detail['product_id']);
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')
|
||||
&& $product->advanced_stock_management
|
||||
)
|
||||
&& $product->advanced_stock_management)
|
||||
{
|
||||
$warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']);
|
||||
foreach ($warehouses as $warehouse)
|
||||
@@ -1019,7 +1028,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$payment_methods = array();
|
||||
foreach(PaymentModule::getInstalledPaymentModules() as $payment)
|
||||
foreach (PaymentModule::getInstalledPaymentModules() as $payment)
|
||||
{
|
||||
$module = Module::getInstanceByName($payment['name']);
|
||||
if (Validate::isLoadedObject($module))
|
||||
@@ -1082,10 +1091,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessSearchProducts()
|
||||
{
|
||||
$currency = new Currency((int)Tools::getValue('id_currency'));
|
||||
$currency = new Currency(Tools::getValue('id_currency'));
|
||||
if ($products = Product::searchByName((int)$this->context->language->id, pSQL(Tools::getValue('product_search'))))
|
||||
{
|
||||
foreach ($products AS &$product)
|
||||
foreach ($products as &$product)
|
||||
{
|
||||
// Formatted price
|
||||
$product['formatted_price'] = Tools::displayPrice(Tools::convertPrice($product['price_tax_incl'], $currency), $currency);
|
||||
@@ -1102,7 +1111,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$product['warehouse_list'] = array();
|
||||
|
||||
foreach($attributes AS $attribute)
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['attributes']))
|
||||
$combinations[$attribute['id_product_attribute']]['attributes'] = '';
|
||||
@@ -1113,12 +1122,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
$price_tax_incl = Product::getPriceStatic((int)$product['id_product'], true, $attribute['id_product_attribute']);
|
||||
$price_tax_excl = Product::getPriceStatic((int)$product['id_product'], false, $attribute['id_product_attribute']);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($price_tax_incl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($price_tax_excl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $currency), $currency);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($price_tax_incl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($price_tax_excl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $currency), $currency);
|
||||
}
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
|
||||
$combinations[$attribute['id_product_attribute']]['qty_in_stock']= StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID());
|
||||
$combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID());
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1)
|
||||
$product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']);
|
||||
@@ -1137,7 +1146,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product['stock'][0] = Product::getRealQuantity($product['id_product'], 0, 0);
|
||||
|
||||
|
||||
foreach ($combinations AS &$combination)
|
||||
foreach ($combinations as &$combination)
|
||||
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
|
||||
$product['combinations'] = $combinations;
|
||||
}
|
||||
@@ -1156,7 +1165,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$errors = array();
|
||||
$cart = new Cart((int)Tools::getValue('id_cart'));
|
||||
if (Validate::isLoadedObject($cart))
|
||||
{
|
||||
@@ -1168,7 +1176,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname
|
||||
);
|
||||
if (Mail::Send((int)$cart->id_lang, 'backoffice_order', Mail::l('Process the payment of your order', (int)$cart->id_lang), $mailVars, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,_PS_MAIL_DIR_, true))
|
||||
if (Mail::Send((int)$cart->id_lang, 'backoffice_order', Mail::l('Process the payment of your order', (int)$cart->id_lang), $mailVars, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true))
|
||||
die(Tools::jsonEncode(array('errors' => false, 'result' => $this->l('The mail was sent to your customer.'))));
|
||||
}
|
||||
}
|
||||
@@ -1388,7 +1396,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$invoice_collection = $order->getInvoicesCollection();
|
||||
|
||||
$invoice_array = array();
|
||||
foreach($invoice_collection as $invoice)
|
||||
foreach ($invoice_collection as $invoice)
|
||||
{
|
||||
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
|
||||
$invoice_array[] = $invoice;
|
||||
@@ -1541,7 +1549,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$invoice_collection = $order->getInvoicesCollection();
|
||||
|
||||
$invoice_array = array();
|
||||
foreach($invoice_collection as $invoice)
|
||||
foreach ($invoice_collection as $invoice)
|
||||
{
|
||||
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
|
||||
$invoice_array[] = $invoice;
|
||||
@@ -1619,7 +1627,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$invoice_collection = $order->getInvoicesCollection();
|
||||
|
||||
$invoice_array = array();
|
||||
foreach($invoice_collection as $invoice)
|
||||
foreach ($invoice_collection as $invoice)
|
||||
{
|
||||
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
|
||||
$invoice_array[] = $invoice;
|
||||
|
||||
@@ -48,9 +48,7 @@ class AdminOutstandingControllerCore extends AdminController
|
||||
|
||||
$risks = array();
|
||||
foreach (Risk::getRisks() as $risk)
|
||||
{
|
||||
$risks[$risk->id] = $risk->name;
|
||||
}
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'number' => array(
|
||||
@@ -159,7 +157,7 @@ class AdminOutstandingControllerCore extends AdminController
|
||||
*/
|
||||
public function renderView()
|
||||
{
|
||||
$order_invoice = new OrderInvoice((int) Tools::getValue('id_order_invoice'));
|
||||
$order_invoice = new OrderInvoice((int)Tools::getValue('id_order_invoice'));
|
||||
if (!Validate::isLoadedObject($order_invoice))
|
||||
throw new PrestaShopException('object OrderInvoice can\'t be loaded');
|
||||
$order = new Order($order_invoice->id_order);
|
||||
|
||||
@@ -97,9 +97,9 @@ class AdminPaymentControllerCore extends AdminController
|
||||
if (Tools::isSubmit('submitModulecountry'))
|
||||
$this->action = 'country';
|
||||
else if (Tools::isSubmit('submitModulecurrency'))
|
||||
$this->action ='currency';
|
||||
$this->action = 'currency';
|
||||
else if (Tools::isSubmit('submitModulegroup'))
|
||||
$this->action ='group';
|
||||
$this->action = 'group';
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
|
||||
@@ -711,7 +711,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
|
||||
}
|
||||
}
|
||||
else if($caching_system == 'MCached' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'MCached')
|
||||
else if ($caching_system == 'MCached' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'MCached')
|
||||
Cache::getInstance()->flush();
|
||||
|
||||
if (!count($this->errors))
|
||||
|
||||
@@ -326,7 +326,7 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
),
|
||||
'PS_LIMIT_UPLOAD_FILE_VALUE' => array(
|
||||
'title' => $this->l('Limit upload file value'),
|
||||
'desc' => $this->l('Define the limit upload for a downloadable product, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).',$upload_mb),
|
||||
'desc' => $this->l('Define the limit upload for a downloadable product, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
@@ -335,7 +335,7 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
),
|
||||
'PS_LIMIT_UPLOAD_IMAGE_VALUE' => array(
|
||||
'title' => $this->l('Limit upload image value'),
|
||||
'desc' => $this->l('Define the limit upload for an image, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).',$upload_mb),
|
||||
'desc' => $this->l('Define the limit upload for an image, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
@@ -382,7 +382,7 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
|
||||
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
|
||||
|
||||
if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size)
|
||||
if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size || Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size)
|
||||
{
|
||||
$this->errors[] = Tools::displayError('The limit choosen is superior to the server\'s maximum upload file You need to improve the limit of your server.');
|
||||
return;
|
||||
@@ -445,10 +445,13 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
$value = (int)$value;
|
||||
|
||||
$tabs_class_name = array('AdminOutstanding');
|
||||
if (!empty($tabs_class_name)) {
|
||||
foreach ($tabs_class_name as $tab_class_name) {
|
||||
if (!empty($tabs_class_name))
|
||||
{
|
||||
foreach ($tabs_class_name as $tab_class_name)
|
||||
{
|
||||
$tab = Tab::getInstanceFromClassName($tab_class_name);
|
||||
if (Validate::isLoadedObject($tab)) {
|
||||
if (Validate::isLoadedObject($tab))
|
||||
{
|
||||
$tab->active = $value;
|
||||
$tab->save();
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
/** @var integer Max image size for upload
|
||||
* As of 1.5 it is recommended to not set a limit to max image size
|
||||
**/
|
||||
protected $max_file_size = NULL;
|
||||
protected $max_image_size = NULL;
|
||||
protected $max_file_size = null;
|
||||
protected $max_image_size = null;
|
||||
|
||||
private $_category;
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (isset($_FILES['attachment_file']) && is_uploaded_file($_FILES['attachment_file']['tmp_name']))
|
||||
{
|
||||
if ($_FILES['attachment_file']['size'] > (Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024))
|
||||
$this->errors[] = $this->l('File too large, maximum size allowed:').' '.(Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024).' '.$this->l('kb').'. '.$this->l('File size you\'re trying to upload is:').number_format(($_FILES['attachment_file']['size']/1024), 2, '.', '').$this->l('kb');
|
||||
$this->errors[] = $this->l('File too large, maximum size allowed:').' '.(Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024).' '.$this->l('kb').'. '.$this->l('File size you\'re trying to upload is:').number_format(($_FILES['attachment_file']['size'] / 1024), 2, '.', '').$this->l('kb');
|
||||
else
|
||||
{
|
||||
do $uniqid = sha1(microtime());
|
||||
@@ -1010,11 +1010,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
// @todo rename to processaddproductimage
|
||||
/* @todo rename to processaddproductimage */
|
||||
public function ajaxProcessAddImage()
|
||||
{
|
||||
self::$currentIndex = 'index.php?tab=AdminProducts';
|
||||
$allowedExtensions = array("jpeg", "gif", "png", "jpg");
|
||||
$allowedExtensions = array('jpeg', 'jpg', 'png', 'jpg');
|
||||
// max file size in bytes
|
||||
$uploader = new FileUploader($allowedExtensions, $this->max_image_size);
|
||||
$result = $uploader->handleUpload();
|
||||
@@ -1242,9 +1242,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
WHERE `id_product` = '.(int)$image->id_product.' LIMIT 1');
|
||||
}
|
||||
|
||||
if(file_exists(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg'))
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg'))
|
||||
$res &= @unlink(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg');
|
||||
if(file_exists(_PS_TMP_IMG_DIR_.'product_mini_'.$image->id_product.'.jpg'))
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.'product_mini_'.$image->id_product.'.jpg'))
|
||||
$res &= @unlink(_PS_TMP_IMG_DIR_.'product_mini_'.$image->id_product.'.jpg');
|
||||
|
||||
if ($res)
|
||||
@@ -1272,7 +1272,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
return false;
|
||||
}
|
||||
|
||||
// Checking customs feature
|
||||
/* Checking customs feature */
|
||||
protected function checkFeatures($languages, $feature_id)
|
||||
{
|
||||
$rules = call_user_func(array('FeatureValue', 'getValidationRules'), 'FeatureValue');
|
||||
@@ -1417,7 +1417,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!$this->object->active)
|
||||
{
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
|
||||
$token = Tools::encrypt('PreviewProduct'.$this->object->id);
|
||||
$preview_url .= '&adtoken='.$token.'&ad='.$admin_dir;
|
||||
}
|
||||
@@ -1502,7 +1502,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!$object->active)
|
||||
{
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
|
||||
$token = Tools::encrypt('PreviewProduct'.$object->id);
|
||||
if (strpos($preview_url, '?') === false)
|
||||
$preview_url .= '?';
|
||||
@@ -1632,9 +1632,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
*/
|
||||
public function updateDownloadProduct($product, $edit = 0, $id_product_attribute = null)
|
||||
{
|
||||
$is_virtual_file = (int) Tools::getValue('is_virtual_file');
|
||||
$is_virtual_file = (int)Tools::getValue('is_virtual_file');
|
||||
|
||||
/* add or update a virtual product */
|
||||
// add or update a virtual product
|
||||
if (Tools::getValue('is_virtual_good') == 'true')
|
||||
{
|
||||
if (!Tools::getValue('virtual_product_name') && !Tools::getValue('virtual_product_name_attribute') && !empty($is_virtual_file))
|
||||
@@ -1765,7 +1765,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!empty($id_product_download))
|
||||
{
|
||||
$product_download = new ProductDownload($id_product_download);
|
||||
$product_download->date_expiration = date('Y-m-d H:i:s', time()-1);
|
||||
$product_download->date_expiration = date('Y-m-d H:i:s', time() - 1);
|
||||
$product_download->active = 0;
|
||||
return $product_download->save();
|
||||
}
|
||||
@@ -1773,12 +1773,12 @@ class AdminProductsControllerCore extends AdminController
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteDownloadProduct($id_product_attribute = NULL)
|
||||
public function deleteDownloadProduct($id_product_attribute = null)
|
||||
{
|
||||
if (!empty($id_product_attribute))
|
||||
{
|
||||
$product_download = new ProductDownload($id_product_attribute);
|
||||
$product_download->date_expiration = date('Y-m-d H:i:s', time()-1);
|
||||
$product_download->date_expiration = date('Y-m-d H:i:s', time() - 1);
|
||||
$product_download->active = 0;
|
||||
return $product_download->save();
|
||||
}
|
||||
@@ -1833,7 +1833,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->addJS(_PS_JS_DIR_.'admin-products.js');
|
||||
$this->fields_form = array();
|
||||
|
||||
if(method_exists($this, 'initForm'.$this->tab_display))
|
||||
if (method_exists($this, 'initForm'.$this->tab_display))
|
||||
$this->tpl_form = strtolower($this->tab_display).'.tpl';
|
||||
|
||||
if ($this->ajax)
|
||||
@@ -1907,7 +1907,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$manufacturers = Manufacturer::getManufacturers();
|
||||
$jsonArray = array();
|
||||
if ($manufacturers)
|
||||
foreach ($manufacturers AS $manufacturer)
|
||||
foreach ($manufacturers as $manufacturer)
|
||||
$jsonArray[] = '{"optionValue": "'.$manufacturer['id_manufacturer'].'", "optionDisplay": "'.htmlspecialchars(trim($manufacturer['name'])).'"}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
@@ -1982,7 +1982,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ((bool)$product->id)
|
||||
{
|
||||
// adding button for delete this product
|
||||
if ($this->tabAccess['delete'] && $this->display != 'add')
|
||||
if ($this->tabAccess['delete'] && $this->display != 'add')
|
||||
$this->toolbar_btn['delete'] = array(
|
||||
'short' => 'Delete',
|
||||
'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id.'&deleteproduct',
|
||||
@@ -2063,7 +2063,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
*/
|
||||
public function renderForm()
|
||||
{
|
||||
if(!method_exists($this, 'initForm'.$this->tab_display))
|
||||
if (!method_exists($this, 'initForm'.$this->tab_display))
|
||||
return;
|
||||
|
||||
// Sort the tabs that need to be preloaded by their priority number
|
||||
@@ -2137,16 +2137,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
Category::getLinkRewrite($product->id_category_default, $this->context->language->id), null, null, Context::getContext()->shop->getID());
|
||||
if (!$product->active)
|
||||
{
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
|
||||
$token = Tools::encrypt('PreviewProduct'.$product->id);
|
||||
if (strpos($preview_url, '?') === false)
|
||||
$preview_url .= '?';
|
||||
$preview_url = ($this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id)));
|
||||
$preview_url = $this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id));
|
||||
if (!$product->active)
|
||||
{
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
|
||||
$token = Tools::encrypt('PreviewProduct'.$product->id);
|
||||
|
||||
$preview_url .= $product->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir;
|
||||
@@ -2169,8 +2164,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
// Build tab with associated data
|
||||
$tab = array();
|
||||
foreach($zones as $zone)
|
||||
if (($num = Tools::getValue('zone_'.$zone['id_zone'])) !== NULL)
|
||||
foreach ($zones as $zone)
|
||||
if (($num = Tools::getValue('zone_'.$zone['id_zone'])) !== null)
|
||||
$tab[] = array(
|
||||
'id_zone' => $zone['id_zone'],
|
||||
'id_product' => $product->id,
|
||||
@@ -2436,7 +2431,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$id_shop = $this->context->shop->getID();
|
||||
|
||||
// Set default zone value to the shop and sort it
|
||||
foreach($zones as $zone)
|
||||
foreach ($zones as $zone)
|
||||
{
|
||||
$detail['zones'][$zone['id_zone']]['name'] = $zone['name'];
|
||||
$detail['zones'][$zone['id_zone']]['account_number'] = '';
|
||||
@@ -2444,7 +2439,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$zoneAccountNumberList = Accounting::getProductAccountNumberZoneShop($obj->id, $id_shop);
|
||||
|
||||
// Set Account number to the id_zone for an id_shop if exist
|
||||
foreach($zoneAccountNumberList as $zone)
|
||||
foreach ($zoneAccountNumberList as $zone)
|
||||
$detail['zones'][$zone['id_zone']]['account_number'] = $zone['account_number'];
|
||||
}
|
||||
|
||||
@@ -2661,9 +2656,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!file_exists($exists_file)
|
||||
&& !empty($product->productDownload->display_filename)
|
||||
&& !empty($product->cache_default_attribute))
|
||||
{
|
||||
$msg = sprintf(Tools::displayError('This file "%s" is missing'), $product->productDownload->display_filename);
|
||||
}
|
||||
else
|
||||
$msg = '';
|
||||
|
||||
@@ -2798,7 +2791,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$content .= '
|
||||
<tr '.($i%2 ? 'class="alt_row"' : '').'>
|
||||
<tr '.($i % 2 ? 'class="alt_row"' : '').'>
|
||||
<td class="cell border">'.$rule_name.'</td>
|
||||
<td class="cell border">'.$attributes_name.'</td>
|
||||
'.(Shop::isFeatureActive() ? '<td class="cell border">'.($specific_price['id_shop'] ? $shops[$specific_price['id_shop']]['name'] : $this->l('All shops')).'</td>' : '').'
|
||||
|
||||
Reference in New Issue
Block a user