* @copyright 2007-2023 ETS-Soft * @license Valid for 1 website (or project) for each purchase of license * International Registered Trademark & Property of ETS-Soft */ if (!defined('_PS_VERSION_')) exit; class EtsRVUnsubscribe extends ObjectModel { public $email; public $active; public $date_add; public static $definition = array( 'table' => 'ets_rv_unsubscribe', 'primary' => 'id_ets_rv_unsubscribe', 'fields' => array( 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 255), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ) ); public static function isUnsubscribe($email) { return (bool)Db::getInstance()->getValue('SELECT `email` FROM `' . _DB_PREFIX_ . 'ets_rv_unsubscribe` WHERE `active`=1 AND `email`=\'' . pSQL(trim($email)) . '\''); } public static function setCustomerUnsubscribe($email, $active = 1) { return Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'ets_rv_unsubscribe` VALUES (' . (int)$email . ', ' . (int)$active . ', \'' . pSQL(date('Y-m-d H:i:s')) . '\') ON DUPLICATE KEY UPDATE `date_add`=\'' . pSQL(date('Y-m-d H:i:s')) . '\', `active`=' . (int)$active); } public static function isSubscribeByEmail($email) { if (trim($email) == '' || !Validate::isEmail($email)) return false; return Db::getInstance()->getValue('SELECT `email` FROM `' . _DB_PREFIX_ . (version_compare(_PS_VERSION_, '1.7', '>=') ? 'emailsubscription' : 'newsletter') . '` WHERE `email`=\'' . pSQL(trim($email)) . '\''); } }