<?php

class ProductController extends ProductControllerCore
{
	/*
    * module: giftonordermodule
    * date: 2017-02-27 17:40:00
    * version: 5.0.7
    */
    public function init()
	{
		
		$id_product = (int)Tools::getValue('id_product');
		if ($id_product && Product::idIsOnCategoryId($id_product, 
				array(array('id_category'=>Configuration::get('OLEA_GIFTONORDER_GIFT_CATEGORY')))))
			Tools::redirect($this->context->link->getModuleLink('giftonordermodule', 'allgifts'));		
		
			
		parent::init ();
	}
		
    /*
    * module: pagecache
    * date: 2017-03-09 11:29:31
    * version: 3.17
    */
    public function displayAjax()
    {
        $result = array();
        $index = 0;
        do
        {
            $val = Tools::getValue('hook_' . $index);
            if ($val !== false)
            {
                list($hook_name, $id_module) = explode('|', $val);
                if (Validate::isHookName($hook_name)) {
                    $result[$hook_name . '_' . (int)$id_module] = Hook::exec($hook_name, array('product' => $this->product, 'category' => $this->category) , (int)$id_module);
                }
            }
            $index++;
        } while ($val !== false);
        if (Tools::version_compare(_PS_VERSION_,'1.6','>')) {
            Media::addJsDef(array(
                'isLogged' => (bool)$this->context->customer->isLogged(),
                'isGuest' => (bool)$this->context->customer->isGuest(),
                'comparedProductsIds' => $this->context->smarty->getTemplateVars('compared_products'),
            ));
            $this->context->smarty->assign(array(
                    'js_def' => Media::getJsDef(),
            ));
            $result['js'] = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_.'javascript.tpl');
        }
        $this->context->cookie->write();
        die(Tools::jsonEncode($result));
    }
}
