// ajax.php clean and bug fixes
This commit is contained in:
@@ -136,16 +136,6 @@ if (Tools::isSubmit('ajaxStates') AND Tools::isSubmit('id_country'))
|
||||
die($list);
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitCustomerNote') AND $id_customer = (int)Tools::getValue('id_customer'))
|
||||
{
|
||||
$note = html_entity_decode(Tools::getValue('note'));
|
||||
if (!empty($note) AND !Validate::isCleanHtml($note))
|
||||
die ('error:validation');
|
||||
if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `note` = "'.pSQL($note, true).'" WHERE id_customer = '.(int)$id_customer.' LIMIT 1'))
|
||||
die ('error:update');
|
||||
die('ok');
|
||||
}
|
||||
|
||||
if (Tools::getValue('form_language_id'))
|
||||
{
|
||||
if (!($context->cookie->employee_form_lang = (int)(Tools::getValue('form_language_id'))))
|
||||
@@ -153,74 +143,6 @@ if (Tools::getValue('form_language_id'))
|
||||
die ('Form language updated.');
|
||||
}
|
||||
|
||||
if (Tools::getValue('submitPublishProduct'))
|
||||
{
|
||||
if (Tools::getIsset('id_product'))
|
||||
{
|
||||
$id_product = (int)(Tools::getValue('id_product'));
|
||||
$id_tab_catalog = (int)(Tab::getIdFromClassName('AdminProducts'));
|
||||
$token = Tools::getAdminToken('AdminProducts'.(int)($id_tab_catalog).(int)$context->employee->id);
|
||||
$bo_product_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminProducts&id_product='.$id_product.'&updateproduct&token='.$token;
|
||||
|
||||
if (Tools::getValue('redirect'))
|
||||
die($bo_product_url);
|
||||
|
||||
$profileAccess = Profile::getProfileAccess($context->employee->id_profile, $id_tab_catalog);
|
||||
if($profileAccess['edit'])
|
||||
{
|
||||
$product = new Product((int)(Tools::getValue('id_product')));
|
||||
if (!Validate::isLoadedObject($product))
|
||||
die('error: invalid id');
|
||||
|
||||
$product->active = 1;
|
||||
|
||||
if ($product->save())
|
||||
die($bo_product_url);
|
||||
else
|
||||
die('error: saving');
|
||||
|
||||
} else {
|
||||
die('error: permissions');
|
||||
}
|
||||
}
|
||||
else
|
||||
die ('error: parameters');
|
||||
}
|
||||
|
||||
if (Tools::getValue('submitPublishCMS'))
|
||||
{
|
||||
if (Tools::getIsset('id_cms'))
|
||||
{
|
||||
$id_cms = (int)(Tools::getValue('id_cms'));
|
||||
$id_tab_cms = (int)(Tab::getIdFromClassName('AdminCmsContent'));
|
||||
$token = Tools::getAdminToken('AdminCmsContent'.(int)($id_tab_cms).(int)$context->employee->id);
|
||||
$bo_cms_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminCmsContent&id_cms='.(int)$id_cms.'&updatecms&token='.$token;
|
||||
|
||||
if (Tools::getValue('redirect'))
|
||||
die($bo_cms_url);
|
||||
|
||||
$profileAccess = Profile::getProfileAccess($context->employee->id_profile, $id_tab_cms);
|
||||
if($profileAccess['edit'])
|
||||
{
|
||||
$cms = new CMS((int)(Tools::getValue('id_cms')));
|
||||
if (!Validate::isLoadedObject($cms))
|
||||
die('error: invalid id');
|
||||
|
||||
$cms->active = 1;
|
||||
|
||||
if ($cms->save())
|
||||
die($bo_cms_url);
|
||||
else
|
||||
die('error: saving');
|
||||
|
||||
} else {
|
||||
die('error: permissions');
|
||||
}
|
||||
}
|
||||
else
|
||||
die ('error: parameters');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitTrackClickOnHelp'))
|
||||
{
|
||||
$label = Tools::getValue('label');
|
||||
@@ -269,117 +191,6 @@ if (Tools::isSubmit('toggleScreencast'))
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('getHookableList'))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_)
|
||||
die('{"hasError" : true, "errors" : ["Live Edit : This functionnality has been disabled"]}');
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
if (!count(Tools::getValue('hooks_list')))
|
||||
die('{"hasError" : true, "errors" : ["Live Edit : no module on this page"]}');
|
||||
|
||||
$modules_list = Tools::getValue('modules_list');
|
||||
$hooks_list = Tools::getValue('hooks_list');
|
||||
$hookableList = array();
|
||||
|
||||
foreach ($modules_list as $module)
|
||||
{
|
||||
$module = trim($module);
|
||||
if (!$module)
|
||||
continue;
|
||||
|
||||
$moduleInstance = Module::getInstanceByName($module);
|
||||
foreach ($hooks_list as $hook_name)
|
||||
{
|
||||
$hook_name = trim($hook_name);
|
||||
if (!$hook_name)
|
||||
continue;
|
||||
if (!array_key_exists($hook_name, $hookableList))
|
||||
$hookableList[$hook_name] = array();
|
||||
if ($moduleInstance->isHookableOn($hook_name))
|
||||
array_push($hookableList[$hook_name], str_replace('_', '-', $module));
|
||||
}
|
||||
|
||||
}
|
||||
$hookableList['hasError'] = false;
|
||||
die(Tools::jsonEncode($hookableList));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('getHookableModuleList'))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_)
|
||||
die('{"hasError" : true, "errors" : ["Live Edit : This functionnality has been disabled"]}');
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
include('../init.php');
|
||||
$hook_name = Tools::getValue('hook');
|
||||
$hookableModulesList = array();
|
||||
$modules = Db::getInstance()->executeS('SELECT id_module, name FROM `'._DB_PREFIX_.'module` ');
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
if (file_exists(_PS_MODULE_DIR_.$module['name'].'/'.$module['name'].'.php'))
|
||||
{
|
||||
include_once(_PS_MODULE_DIR_.$module['name'].'/'.$module['name'].'.php');
|
||||
$mod = new $module['name']();
|
||||
if ($mod->isHookableOn($hook_name))
|
||||
$hookableModulesList[] = array('id' => (int)$mod->id, 'name' => $mod->displayName, 'display' => Hook::exec($hook_name, array(), (int)$mod->id));
|
||||
}
|
||||
}
|
||||
die(Tools::jsonEncode($hookableModulesList));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('saveHook'))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_)
|
||||
die('{"hasError" : true, "errors" : ["Live Edit : This functionnality has been disabled"]}');
|
||||
|
||||
$hooks_list = explode(',', Tools::getValue('hooks_list'));
|
||||
$id_shop = (int)Tools::getValue('id_shop');
|
||||
if (!$id_shop)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$res = true;
|
||||
$hookableList = array();
|
||||
// $_POST['hook'] is an array of id_module
|
||||
$hooks_list = Tools::getValue('hook');
|
||||
foreach ($hooks_list as $id_hook => $modules)
|
||||
{
|
||||
// 1st, drop all previous hooked modules
|
||||
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
|
||||
WHERE `id_hook` = '.(int)$id_hook.'
|
||||
AND id_shop = '.$id_shop;
|
||||
$res &= Db::getInstance()->execute($sql);
|
||||
|
||||
$i = 1;
|
||||
$value = '';
|
||||
$ids = array();
|
||||
// then prepare sql query to rehook all chosen modules(id_module, id_shop, id_hook, position)
|
||||
// position is i (autoincremented)
|
||||
foreach ($modules as $id_module)
|
||||
{
|
||||
if (!in_array($id_module, $ids))
|
||||
{
|
||||
$ids[] = $id_module;
|
||||
$value .= '('.(int)$id_module.', '.$id_shop.', '.(int)$id_hook.', '.$i.'),';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$value = rtrim($value, ',');
|
||||
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'hook_module`
|
||||
(id_module, id_shop, id_hook, position)
|
||||
VALUES '.$value);
|
||||
|
||||
}
|
||||
if ($res)
|
||||
$hasError = true;
|
||||
else
|
||||
$hasError = false;
|
||||
die('{"hasError" : false, "errors" : ""}');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('getAdminHomeElement'))
|
||||
{
|
||||
$result = array();
|
||||
|
||||
Reference in New Issue
Block a user