* @copyright 2007-2010 Prestashop SA * @version Release: $Revision: 1.4 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class blockcustomerprivacy extends Module { public function __construct() { $this->name = 'blockcustomerprivacy'; if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0) $this->tab = 'front_office_features'; else $this->tab = 'Blocks'; $this->version = '1.0'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Block customer data privacy'); $this->description = $this->l('Adds a block to display a message about customer data privacy.'); } public function install() { return (parent::install() AND $this->registerHook('createAccountForm') AND Configuration::updateValue('CUSTPRIV_MESSAGE', array())); } public function getContent() { global $cookie; $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); $iso = Language::getIsoById((int)$cookie->id_lang); if (Tools::isSubmit('submitCustPrivMess')) { $message_trads = array(); foreach($_POST as $key => $value) if (preg_match("/custpriv_message_/i", $key)) { $id_lang = preg_split("/custpriv_message_/i", $key); $message_trads[(int)$id_lang[1]] = $value; } Configuration::updateValue('CUSTPRIV_MESSAGE', $message_trads, true); echo '
'.$this->l('Configuration updated').'
'; } $content = ''; if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0) $content .= ' '; else { $content .= ' '; } $values = Configuration::getInt('CUSTPRIV_MESSAGE'); $content .= '
'.$this->displayName.'
'; foreach ($languages as $language) $content .= '
'; $content .= $this->displayFlags($languages, $defaultLanguage, 'ccont', 'ccont', true).'

'.$this->l('Message that will be displayed in the account creation form.').'
'.$this->l('Tips: Remember that if the text is too long to be written directly in the form, you can add a link to one of your pages created via the CMS tab.').'

 
'; return $content; } public function hookCreateAccountForm($params) { if (!$this->active) return ; global $smarty, $cookie; /* Languages preliminaries */ $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); $iso = Language::getIsoById((int)($cookie->id_lang)); $smarty->assign(array( 'privacy_message' => Configuration::get('CUSTPRIV_MESSAGE', (int)($cookie->id_lang)), 'error_message' => $this->l('Please agree with the customer data privacy by ticking the checkbox below.') )); return $this->display(__FILE__, 'blockcustomerprivacy.tpl'); } }