* * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } fn_define('KEEP_UPLOADED_FILES', true); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $suffix = ''; if (!fn_allowed_for('ULTIMATE:FREE')) { if ($mode == 'add_exceptions') { foreach ($_REQUEST['add_options_combination'] as $k => $v) { $exist = fn_check_combination($v, $_REQUEST['product_id']); $_data = array('product_id' => $_REQUEST['product_id'], 'combination' => serialize($v)); if (!$exist) { db_query("INSERT INTO ?:product_options_exceptions ?e", $_data); } else { fn_set_notification('W', __('warning'), __('exception_exist')); } } fn_update_exceptions($_REQUEST['product_id']); $suffix = ".exceptions?product_id={$_REQUEST['product_id']}"; } if ($mode == 'm_delete_exceptions') { db_query("DELETE FROM ?:product_options_exceptions WHERE exception_id IN (?n)", $_REQUEST['exception_ids']); $suffix = ".exceptions?product_id={$_REQUEST['product_id']}"; } }
/** * Updates exception data * * @param array $exception_data Exception data * @param int $exception_id Exception ID * @return bool true if updated */ function fn_update_exception($exception_data, $exception_id = 0) { /** * Changes params before updating exception * * @param array $exception_data Exception data * @param int $exception_id Exception ID */ fn_set_hook('update_exception_pre', $exception_data, $exception_id); if (empty($exception_id)) { $exception_id = fn_check_combination($exception_data['combination'], $exception_data['product_id']); if (empty($exception_id)) { $exception_id = db_query('INSERT INTO ?:product_options_exceptions ?e', array('product_id' => $exception_data['product_id'], 'combination' => serialize($exception_data['combination']))); } else { fn_set_notification('W', __('warning'), __('exception_exist'), 'K', 'exception_exist'); } } else { $exception_data['combination'] = serialize($exception_data['combination']); db_query("UPDATE ?:product_options_exceptions SET ?u WHERE exception_id = ?i", $exception_data, $exception_id); } /** * Adds additional actions afrer updating exception * * @param array $exception_data Exception data * @param int $exception_id Exception ID */ fn_set_hook('update_exception_post', $exception_data, $exception_id); return $exception_id; }