* @copyright 2007-2012 PrestaShop SA
* @version Release: $Revision: 14006 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class PoradnaControllerCore extends FrontController
{
public $php_self = 'poradna.php';
public function canonicalRedirection()
{
if (Validate::isLoadedObject($this->manufacturer) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET')
{
$canonicalURL = self::$link->getManufacturerLink($this->manufacturer);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
header('Cache-Control: no-cache');
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
die('[Debug] This page has moved
Please use the following URL instead: '.$canonicalURL.'');
Tools::redirectLink($canonicalURL);
}
}
}
public function preProcess()
{
parent::preProcess();
if (self::$cookie->isLogged())
{
self::$smarty->assign('isLogged', 1);
$customer = new Customer((int)(self::$cookie->id_customer));
if (!Validate::isLoadedObject($customer))
die(Tools::displayError('Customer not found'));
self::$smarty->assign('email_from', $customer->email);
}
}
public function process()
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT dotaz.id_customer_message as dotaz_id,
odpoved.id_customer_message as odpoved_id,
employee.firstname as jmeno,
employee.lastname as prijmeni,
dotaz.message as dotaz,
odpoved.message as odpoved
FROM `ps_customer_message` as dotaz
left join `ps_customer_message` as odpoved
on (
dotaz.id_customer_thread=odpoved.id_customer_thread
and
odpoved.id_customer_message>dotaz.id_customer_message)
left join `ps_employee` as employee on (odpoved.id_employee=employee.id_employee)
where dotaz.id_employee=0 and odpoved.id_customer_message is not null
group by dotaz.id_customer_message
order by odpoved_id desc
');
self::$smarty->assign(array(
'otazky' => $result
));
}
public function displayContent()
{
self::$smarty->display(_PS_THEME_DIR_.'poradna.tpl');
}
}