This commit is contained in:
rGaillard
2011-07-06 10:10:43 +00:00
parent 31d94236ac
commit d1a13007b9
4695 changed files with 0 additions and 339293 deletions
@@ -1,151 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
abstract class AbsTrustedShops
{
/**
* Saved errors messages.
* @var array
*/
public $errors = array();
/**
* Saved warning messages.
* @var array
*/
public $warnings = array();
/**
* Saved confirmations messages.
* @var array
*/
public $confirmations = array();
/**
* @var string
*/
protected static $module_name;
public $limited_countries = array();
public static $smarty;
public $tab_name;
public $id_tab;
/**
* Set the object which use the translation method for the specific module.
* @var Module
*/
protected static $translation_object;
abstract public function install();
abstract public function uninstall();
abstract public function getContent();
public static function setTranslationObject(Module $object)
{
self::$translation_object = $object;
}
protected function _makeFormAction($uri, $id_tab)
{
$uri_component = parse_url($uri);
$arr_query = explode('&', $uri_component['query']);
$arr_query_new = array();
foreach($arr_query as $key=>$value)
{
$arr = explode('=', $value);
$arr_query_new[$arr[0]] = $arr[1];
}
$arr_query_new['id_tab'] = $id_tab;
return str_replace($uri_component['query'], '', $uri).http_build_query($arr_query_new);
}
/**
* Set a static name for the module.
*
* @param string $name
*/
public function setModuleName($name)
{
self::$module_name = $name;
}
public function setSmarty($smarty)
{
self::$smarty = $smarty;
}
/**
* Get translation for a given module text
*
* @param string $string String to translate
* @return string Translation
*/
public function l($string, $specific = false)
{
if ($specific === false)
{
$reflection_class = new ReflectionClass(get_class($this));
$specific = basename($reflection_class->getFileName(), '.php');
}
if (self::$translation_object instanceof Module)
{
return self::$translation_object->l($string, $specific);
}
}
public function display($file, $template, $cacheId = NULL, $compileId = NULL)
{
global $smarty;
if (Configuration::get('PS_FORCE_SMARTY_2')) /* Keep a backward compatibility for Smarty v2 */
{
$previousTemplate = $smarty->currentTemplate;
$smarty->currentTemplate = substr(basename($template), 0, -4);
}
$smarty->assign('module_dir', __PS_BASE_URI__.'modules/'.basename($file, '.php').'/');
if (($overloaded = self::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === NULL)
$result = Tools::displayError('No template found');
else
{
$smarty->assign('module_template_dir', ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/');
$result = $smarty->fetch(($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, $cacheId, $compileId);
}
if (Configuration::get('PS_FORCE_SMARTY_2')) /* Keep a backward compatibility for Smarty v2 */
$smarty->currentTemplate = $previousTemplate;
return $result;
}
/**
* Template management (display, overload, cache)
* @see Module::_isTemplateOverloadedStatic()
*/
protected static function _isTemplateOverloadedStatic($moduleName, $template)
{
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$moduleName.'/'.$template))
return true;
elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$moduleName.'/'.$template))
return false;
return NULL;
}
}
-109
View File
@@ -1,109 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class RatingAlert
{
const TABLE_NAME = 'ts_rating_alert';
const MAIL_TEMPLATE = 'rating_email';
public static function save($id_order)
{
Db::getInstance()->AutoExecute(_DB_PREFIX_.self::TABLE_NAME, array('id_order' => (int)($id_order)), 'INSERT');
}
private static function _getAlertsInformations($nb_days = 10)
{
return Db::getInstance()->ExecuteS('
SELECT a.id_alert, c.`email`, o.`id_order`, o.`id_lang`
FROM `'._DB_PREFIX_.self::TABLE_NAME.'` a
LEFT JOIN '._DB_PREFIX_.'orders o ON (a.id_order = o.id_order)
LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = o.id_customer)
WHERE DATE_ADD(o.`date_add`, INTERVAL '.(int)($nb_days).' DAY) <= NOW()');
}
public static function removeAlerts($ids)
{
$to_remove = array();
foreach ($ids AS $id)
$to_remove[] = (int)($id);
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.self::TABLE_NAME.'` WHERE `id_alert` IN (\''.implode('\',\'', $to_remove).'\')');
}
public static function executeCronTask()
{
global $cookie;
if (!Configuration::get('TS_SEND_SEPERATE_MAIL'))
return true;
$to_remove = array();
$alerts_infos = RatingAlert::_getAlertsInformations((int)(Configuration::get('TS_SEND_SEPERATE_MAIL_DELAY')));
$ts_module = new TrustedShops();
foreach ($alerts_infos AS $infos)
{
$cookie->id_lang = $infos['id_lang'];
$subject = $ts_module->getL('title_part_1').' '.Configuration::get('PS_SHOP_NAME').$ts_module->getL('title_part_2');
$template_vars = array('{ts_id}' => Configuration::get('TS_ID_'.(int)($infos['id_lang'])),
'{button_url}' => TrustedShops::getHttpHost(true, true)._MODULE_DIR_.$ts_module->name.'/img',
'{rating_url}' => $ts_module->getRatingUrlWithBuyerEmail($infos['id_lang'], $infos['id_order'], $infos['email']));
$result = Mail::Send((int)($infos['id_lang']), self::MAIL_TEMPLATE, $subject, $template_vars, $infos['email'], NULL, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), NULL, NULL, dirname(__FILE__).'/mails/');
if ($result)
$to_remove[] = (int)($infos['id_alert']);
}
if (sizeof($to_remove) > 0)
self::removeAlerts($to_remove);
return (sizeof($to_remove) == sizeof($alerts_infos));
}
public static function createTable()
{
return Db::getInstance()->Execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.self::TABLE_NAME.'` (
`id_alert` INT NOT NULL AUTO_INCREMENT,
`id_order` INT NOT NULL,
PRIMARY KEY (`id_alert`),
UNIQUE KEY `id_order` (`id_order`)
) ENGINE = '._MYSQL_ENGINE_);
}
public static function dropTable()
{
return Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.self::TABLE_NAME.'`');
}
public static function truncateTable()
{
return Db::getInstance()->Execute('TRUNCATE TABLE `'._DB_PREFIX_.self::TABLE_NAME.'`');
}
}
-106
View File
@@ -1,106 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class TSBPException extends Exception
{
const ADMINISTRATION = 1;
const FRONT_END = 2;
/**
* Set the object which use the translation method for the specific module.
* @var AbsTrustedShops
*/
private static $translation_object;
private static $translate_key;
public function __construct($code, $type = TSBPException::ADMINISTRATION)
{
if(!(self::$translation_object instanceof AbsTrustedShops) OR self::$translation_object === NULL)
{
die('In '.__METHOD__.', you must defined an object for get messages translations. An herited object from AbsTrustedShops.');
}
if (TSBPException::$translate_key === NULL)
TSBPException::$translate_key = basename(__FILE__, '.php');
if($type === TSBPException::ADMINISTRATION)
$message = $this->_getAdministrationMessage((int)$code);
else
$message = $this->_getFrontEndMessage($code);
parent::__construct($message, $code);
}
private function _getAdministrationMessage($code)
{
// @todo : don't forget to change email in translation
$mail = self::$translation_object->l('Please contact Trusted Shops at service@trustedshops.co.uk.', TSBPException::$translate_key);
$errors = array(
-10001 => self::$translation_object->l('Username or password invalid.', TSBPException::$translate_key),
-10002 => self::$translation_object->l('You have reached your credit limit.', TSBPException::$translate_key),
-10011 => self::$translation_object->l('No credit available from Trusted Shops.', TSBPException::$translate_key),
-11111 => self::$translation_object->l('The data could not be saved.', TSBPException::$translate_key),
);
$return_message = '';
if(array_key_exists($code, $errors))
$return_message = $errors[$code].$mail;
else
$return_message = self::$translation_object->l('An error occured.').$mail;
return $return_message;
}
private function _getFrontEndMessage($code)
{
$return_message = '';
switch ($code)
{
case -10001 : case 'NO_VALID_SHOP' : $return_message .= self::$translation_object->l('Web service login or TS-ID invalid', TSBPException::$translate_key);break;
case -10002 : case 'LIMIT_CANCELLED' : $return_message .= self::$translation_object->l('The shop\'s credit limit has been suspended by Trusted Shops', TSBPException::$translate_key); break;
case -10003 : case 'DUPLICATE_ORDER_NUMBER' : $return_message .= self::$translation_object->l('Order number already used', TSBPException::$translate_key); break;
case -10004 : case 'UNSUPPORTED_TS_PRODUCT' : $return_message .= self::$translation_object->l('Unsupported Buyer Protection product', TSBPException::$translate_key); break;
case -10005 : case 'INACTIVE_PAYMENT_TYPE' : $return_message .= self::$translation_object->l('Inactive payment method', TSBPException::$translate_key); break;
case -10006 : case 'UNSUPPORTED_PAYMENT_TYPE' : $return_message .= self::$translation_object->l('Unsupported payment method', TSBPException::$translate_key); break;
case -10007 : case 'CURRENCY_MISMATCH' : $return_message .= self::$translation_object->l('The currency of the Buyer Protection product does not match with the currency of the shopping basket', TSBPException::$translate_key); break;
case -10008 : case 'UNSUPPORTED_CURRENCY' : $return_message .= self::$translation_object->l('This currency is not supported in this shop', TSBPException::$translate_key); break;
case -10009 : case 'UNSUPPORTED_EXCHANGE_RATE' : $return_message .= self::$translation_object->l('This exchange rate is not supported', TSBPException::$translate_key); break;
case -10010 : case 'NOT_PERSISTENT_PAYMENT_TYPE' : $return_message .= self::$translation_object->l('This payment method is not supported', TSBPException::$translate_key); break;
case -10011 : case 'NO_LIMIT' : $return_message .= self::$translation_object->l('No credit limit available for this certificate', TSBPException::$translate_key); break;
case -10012 : case 'PAST_DELIVERY_DATE' : $return_message .= self::$translation_object->l('The delivery date is in the past', TSBPException::$translate_key); break;
case -10013 : case 'TOO_OLD_ORDER' : $return_message .= self::$translation_object->l('The guarantee is for a purchase that was made over 3 days ago', TSBPException::$translate_key); break;
case -10014 : case 'EMAIL_MALFORMED' : $return_message .= self::$translation_object->l('The email address contains an error', TSBPException::$translate_key); break;
case -10015 : case 'ORDER_ID_EMPTY' : $return_message .= self::$translation_object->l('No order number was assigned', TSBPException::$translate_key); break;
case -10016 : case 'CUSTOMER_ID_EMPTY' : $return_message .= self::$translation_object->l('No customer number was assigned', TSBPException::$translate_key); break;
case -10017 : case 'LIMIT_OVERFLOW' : $return_message .= self::$translation_object->l('The credit limit for this certificate has been exceeded', TSBPException::$translate_key); break;
case -10018 : case 'EMAIL_EMPTY' : $return_message .= self::$translation_object->l('No email address was assigned', TSBPException::$translate_key); break;
case -10019 : case 'WRONG_TS_PRODUCT' : $return_message .= self::$translation_object->l('Non-applicable Buyer Protection product', TSBPException::$translate_key); break;
case -11001 : case 'INVALID_SECURITY_TOKEN' : $return_message .= self::$translation_object->l('Invalid security token', TSBPException::$translate_key); break;
case -11111 : case 'SYSTEM_EXCEPTION' : $return_message .= self::$translation_object->l('General system error, please contact Trusted Shops', TSBPException::$translate_key); break;
default : $return_message .= self::$translation_object->l('An error occured.', TSBPException::$translate_key); break;
}
return $return_message;
}
public static function setTranslationObject(AbsTrustedShops $object)
{
self::$translation_object = $object;
}
}
File diff suppressed because it is too large Load Diff
@@ -1,492 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(_PS_MODULE_DIR_.'/trustedshops/lib/TrustedShopsSoapApi.php');
include(_PS_MODULE_DIR_.'/trustedshops/lib/WidgetCache.php');
include(_PS_MODULE_DIR_.'/trustedshops/lib/RatingAlert.php');
class TrustedShopsRating extends AbsTrustedShops
{
const APPLY_URL = 'https://www.trustedshops.com/buyerrating/signup.html';
const PARTNER_PACKAGE = 'presta';
const SHOP_SW = 'PrestaShop';
private $allowed_languages = array();
private $available_languages = array('en', 'fr', 'de');
private $rating_url_base = array('en' => 'https://www.trustedshops.com/buyerrating/rate_',
'de' => 'https://www.trustedshops.com/bewertung/bewerten_',
'fr' => 'https://www.trustedshops.com/evaluation/evaluer_');
private $apply_url_base = array('en' => 'https://www.trustedshops.com/buyerrating/signup.html',
'de' => 'https://www.trustedshops.com/bewertung/anmeldung.html',
'fr' => 'https://www.trustedshops.com/evaluation/inscription.html');
private $apply_url_tracker = array('en' => '&et_cid=53&et_lid=3361',
'de' => '',
'fr' => '&et_cid=53&et_lid=3362');
public function __construct()
{
$this->tab_name = $this->l('Customer Rating');
// @todo : That gonna be change - Be worry it's false, countries have not the same ISO code as Languages, waiting Truste Shop's answer
$this->limited_countries = $this->available_languages;
}
public function install()
{
foreach ($this->available_languages AS $language)
{
Configuration::updateValue('TS_TAB0_ID_'.(int)(Language::getIdByIso($language)), '');
Configuration::updateValue('TS_TAB0_ID_ACTIVE_'.(int)(Language::getIdByIso($language)), '');
}
Configuration::updateValue('TS_TAB0_DISPLAY_IN_SHOP', '');
Configuration::updateValue('TS_TAB0_DISPLAY_RATING_FRONT_END', '');
Configuration::updateValue('TS_TAB0_DISPLAY_RATING_OC', '');
Configuration::updateValue('TS_TAB0_SEND_RATING', '');
Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL', '');
Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL_DELAY', '');
return (RatingAlert::createTable() AND Configuration::updateValue('PS_TS_TAB0_SECURE_KEY', strtoupper(Tools::passwdGen(16))));
}
public function uninstall()
{
foreach ($this->available_languages AS $language)
{
Configuration::deleteByName('TS_TAB0_ID_'.(int)(Language::getIdByIso($language)));
Configuration::deleteByName('TS_TAB0_ID_ACTIVE_'.(int)(Language::getIdByIso($language)));
}
Configuration::deleteByName('TS_TAB0_DISPLAY_IN_SHOP');
Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_FRONT_END');
Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_OC');
Configuration::deleteByName('TS_TAB0_SEND_RATING');
Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL');
Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL_DELAY');
Configuration::deleteByName('PS_TS_TAB0_SECURE_KEY');
return (RatingAlert::dropTable());
}
private function _initAllowedLanguages()
{
$languages = Language::getLanguages();
foreach ($languages AS $key => $language)
{
if (in_array($language['iso_code'], $this->available_languages))
$this->allowed_languages[] = $languages[$key];
}
}
static public function getHttpHost($http = false, $entities = false)
{
if (method_exists('Tools', 'getHttpHost'))
return call_user_func(array('Tools', 'getHttpHost'), array($http, $entities));
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
if ($entities)
$host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8');
if ($http)
$host = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$host;
return $host;
}
private function _isTsIdActive($id_lang, $ts_id = NULL)
{
if (is_null($ts_id))
$ts_id = Configuration::get('TS_TAB0_ID_'.(int)($id_lang));
return (!empty($ts_id) AND ($ts_id == Configuration::get('TS_TAB0_ID_ACTIVE_'.$id_lang)));
}
// Return true if at least one TS_ID is active
private function _isConfigurable()
{
foreach ($this->allowed_languages AS $language)
if ($this->_isTsIdActive($language['id_lang']))
return true;
return false;
}
private function _getLastOrderId($id_customer)
{
return (int)(Db::getInstance()->getValue('
SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_customer` = '.(int)($id_customer).'
ORDER BY `date_add` DESC'));
}
private function _getAllowedIsobyId($id_lang)
{
$lang = Language::getIsoById($id_lang);
$lang = in_array($lang, $this->available_languages) ? $lang : 'en';
return $lang;
}
public function getContent()
{
$this->_initAllowedLanguages();
$out = '';
if (is_writable(_PS_MODULE_DIR_.'/trustedshops/cache') === FALSE)
$this->errors[] = $this->l('This module requires write and read permissions on the module cache directory.');
if (Tools::isSubmit('submitTrustedShops'))
{
$this->_validateForm();
if (empty($this->errors))
$this->_postProcess();
}
$out .= $this->displayInformationsPage();
$out .= $this->displayForm();
return $out;
}
private function _validateForm()
{
if (!extension_loaded('soap'))
{
$this->errors[] = $this->l('This module requires the SOAP PHP extension to function properly.');
return false;
}
$flag_return = true;
foreach ($this->allowed_languages AS $language)
{
$ts_id = Tools::getValue('trusted_shops_id_'.(int)($language['id_lang']));
if (!empty($ts_id))
{
if (!preg_match('/^[[:alnum:]]{33}$/', $ts_id))
{
$this->errors[] = $this->l('Invalid Trusted Shops ID').' ['.$language['iso_code'].']';
$flag_return = false;
}
elseif (!$this->_isTsIdActive((int)($language['id_lang']), $ts_id))
{
$error = $this->_validateTrustedShopId($ts_id, (int)($language['id_lang']));
if ($error != '') $this->errors[] = $error;
$flag_return = false;
}
}
}
if (Tools::getValue('send_seperate_mail') AND !Validate::isUnsignedInt(Tools::getValue('send_seperate_mail_delay')))
{
$this->errors[] = $this->l('Invalid delay');
$flag_return = false;
}
return $flag_return;
}
private function _validateTrustedShopId($ts_id, $iso_lang)
{
$error = '';
$result = TrustedShopsSoapApi::validate(self::PARTNER_PACKAGE, $ts_id);
if ($result != TrustedShopsSoapApi::RT_OK)
{
switch($result)
{
case TrustedShopsSoapApi::RT_INVALID_TSID:
$error = $this->l('Invalid Trusted Shops ID').' ['.Language::getIsoById($iso_lang).']. '.$this->l('Please register').' <a href="'.$this->getApplyUrl().'">' .$this->l('here').'</a> '. $this->l('or contact service@trustedshops.co.uk.');
break;
case TrustedShopsSoapApi::RT_NOT_REGISTERED:
$error = $this->l('Customer Rating has not yet been activated for this Trusted Shops ID').' ['.Language::getIsoById($iso_lang).']. '.$this->l('Please register').' <a href="'.$this->getApplyUrl().'">' .$this->l('here').'</a> '. $this->l('or contact service@trustedshops.co.uk.');
break;
default:
$error = $this->l('An error has occurred');
}
}
return empty($error) ? '' : $error;
}
private function _postProcess()
{
Configuration::updateValue('TS_TAB0_DISPLAY_IN_SHOP', (int)(Tools::getValue('display_in_shop')));
Configuration::updateValue('TS_TAB0_DISPLAY_RATING_FRONT_END', (int)(Tools::getValue('display_rating_front_end')));
Configuration::updateValue('TS_TAB0_DISPLAY_RATING_OC', (int)(Tools::getValue('display_rating_order_confirmation')));
Configuration::updateValue('TS_TAB0_SEND_RATING', (int)(Tools::getValue('send_rating')));
Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL', (int)(Tools::getValue('send_seperate_mail')));
foreach ($this->allowed_languages AS $language)
{
$ts_id = Tools::getValue('trusted_shops_id_'.(int)($language['id_lang']));
Configuration::updateValue('TS_TAB0_ID_'.(int)($language['id_lang']), $ts_id);
if (!empty($ts_id))
Configuration::updateValue('TS_TAB0_ID_ACTIVE_'.(int)($language['id_lang']), $ts_id);
}
if (Configuration::get('TS_TAB0_SEND_SEPERATE_MAIL'))
Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL_DELAY', (int)(Tools::getValue('send_seperate_mail_delay')));
else
RatingAlert::truncateTable();
$params = '';
$delim = '?';
$dataSync = '';
$key = 1;
foreach($this->allowed_languages AS $language)
{
if ($this->_isTsIdActive($language['id_lang']))
{
$params .= $delim.'lang'.$key.'='.$language['iso_code'].'&ts_id'.$key.'='.Configuration::get('TS_TAB0_ID_ACTIVE_'.$language['id_lang']);
$key++;
$delim = '&';
}
}
if (!empty($params))
$dataSync = '<img src="http://www.prestashop.com/modules/'.self::$module_name.'.png'.$params.'" style="float:right" />';
$this->confirmations[] = $this->l('Settings updated').$dataSync;
return true;
}
public function displayForm()
{
// I18N TS_ID
$i18n_ts_id_fields = '';
foreach ($this->allowed_languages AS $key => $language)
{
$i18n_ts_id_fields .= '
<div id="trusted_shops_id_'.(int)($language['id_lang']).'">
<p style="line-height: 25px;">
<img src="'._PS_IMG_.'/l/'.(int)($language['id_lang']).'.jpg" style="vertical-align: middle;" alt="" />'.strtoupper($language['iso_code']).'
<input type="text" name="trusted_shops_id_'.(int)($language['id_lang']).'" id="trusted_shops_id_'.(int)($language['id_lang']).'" style="width: 270px;" value="'.Configuration::get('TS_TAB0_ID_'.(int)($language['id_lang'])).'" /> <span style="font-size: 10px;">'.($this->_isTsIdActive($language['id_lang']) ? $this->l('Active') : $this->l('Inactive unless you haven\'t specified your Trusted Shops ID')).'</span>
</p>
</div>';
}
// JAVASCRIPT
$javascript = '<script language="javascript">';
if (!Configuration::get('TS_TAB0_SEND_SEPERATE_MAIL'))
$javascript .= '$("document").ready( function() { $("#send_seperate_mail_infos").hide(); });';
$javascript .= 'function toggleSendMailInfos()
{
$("#send_seperate_mail_infos").toggle();
if (!$("input[name=send_seperate_mail]").attr("checked"))
alert("'.$this->l('Warning, all the existing rating alerts will be deleted').'");
}
</script>';
$content = $javascript .
'<form action="'.$this->_makeFormAction($_SERVER['REQUEST_URI'], $this->id_tab).'" method="post">
<fieldset>
<legend><img src="../img/admin/cog.gif" alt="" />'.$this->l('Basic Settings').'</legend>
<p>'.$this->l('Please fill your Trusted Shops ID (one different ID per language):').'</p>
<div>
'.$i18n_ts_id_fields.'
</div>
</fieldset>';
if ($this->_isConfigurable())
$content .= '<br />
<fieldset>
<legend><img src="../img/admin/appearance.gif" alt="" />'.$this->l('Display settings').'</legend>
<label>'.$this->l('Display widget in shop').'</label>
<div class="margin-form">
<input type="checkbox" name="display_in_shop" value="1" '.(Configuration::get('TS_TAB0_DISPLAY_IN_SHOP') ? 'checked' : '').'/>
</div>
<br />
<label>'.$this->l('Display rating link in shop front-end').'</label>
<div class="margin-form">
<input type="checkbox" name="display_rating_front_end" value="1" '.(Configuration::get('TS_TAB0_DISPLAY_RATING_FRONT_END') ? 'checked' : '').'/>
</div>
<br />
<label>'.$this->l('Display rating link on order confirmation page').'</label>
<div class="margin-form">
<input type="checkbox" name="display_rating_order_confirmation" value="1" '.(Configuration::get('TS_TAB0_DISPLAY_RATING_OC') ? 'checked' : '').'/>
</div>
<br />
<label>'.$this->l('Send rating link in seperate email').'</label>
<div class="margin-form">
<input onclick="toggleSendMailInfos()" type="checkbox" name="send_seperate_mail" value="1" '.(Configuration::get('TS_TAB0_SEND_SEPERATE_MAIL') ? 'checked' : '').'/> <br />
<div id="send_seperate_mail_infos">'.
$this->l('Send the email after').'<input size="2" type="text" name="send_seperate_mail_delay" value="'.(int)(Configuration::get('TS_TAB0_SEND_SEPERATE_MAIL_DELAY')).'" />'.$this->l('days').'.<br />
<span style="color: #CC0000; font-weight: bold;">'.$this->l('IMPORTANT:').'</span> '.$this->l('Put this URL in crontab or call it manually daily:').'<br />'
.self::getHttpHost(true, true)._MODULE_DIR_.self::$module_name.'/cron.php?secure_key='.Configuration::get('PS_TAB0_TS_SECURE_KEY').
'</div>
</div>
</fieldset>';
$content .= '<br /><center><input type="submit" class="button" name="submitTrustedShops" value="'.$this->l('Save').'" /></center>
</form>';
return $content;
}
public function displayInformationsPage()
{
global $cookie;
return '<fieldset>
<legend><img src="'.__PS_BASE_URI__.'modules/'.self::$module_name.'/logo.gif" alt="" />'.$this->l('Learn More').'</legend>
<img src="'._MODULE_DIR_.self::$module_name.'/img/ts_rating_'.$this->_getAllowedIsobyId($cookie->id_lang).'.jpg" />
<h3>'.$this->l('Trusted Shops Customer Rating').'</h3>
<p>'.$this->l('For online buyers, positive and verifiable customer ratings are an important indication of an online shop\'s trustworthiness. The required software is already included in Prestashop, so you can start collecting customer ratings in your online shop too. Integration is easy with just a few clicks.').'</p>
<h4>'.$this->l('Orientation support for your customers').'</h4>
<p>'.$this->l('Satisfied customers are your best sales people. Let your customers speak for themselves as to how safe and easy it is to buy from your online shop.').'</p>
<h4>'.$this->l('Basis for shop optimisation').'</h4>
<p>'.$this->l('Your customers are happy to help you optimise your shop with their feedback. After all, the better your online shop works, the more satisfied your customers will be.').'</p>
<h4>'.$this->l('Increase reach via Facebook, Twitter and Google').'</h4>
<p>'.$this->l('Your customers spread reviews and rating on Facebook and Twitter directly to friends and followers. Ratings are automatically listed in the Google-Index and are displayed in Google Shopping.').'</p>
<br />
<a style="text-decoration: underline; font-weight: bold; color: #0000CC;" target="_blank" href="'.$this->getApplyUrl().'">'.$this->l('Register for Trusted Shops Customer Rating').'</a>
</fieldset>
<br />';
}
public function getApplyUrl()
{
global $cookie;
$lang = $this->_getAllowedIsobyId($cookie->id_lang);
return $this->apply_url_base[$lang].'?partnerPackage='.self::PARTNER_PACKAGE.'&shopsw='.self::SHOP_SW.'&website='.
urlencode(_PS_BASE_URL_.__PS_BASE_URI__).'&firstName='.urlencode($cookie->firstname).'&lastName='.
urlencode($cookie->lastname).'&email='.urlencode(Configuration::get('PS_TAB0_SHOP_EMAIL')).'&language='.strtoupper(Language::getIsoById((int)($cookie->id_lang))).
'&ratingProduct=RATING_PRO'.$this->apply_url_tracker[$lang];
}
public function getRatingUrl($id_order = '')
{
global $cookie;
$buyer_email = '';
if ($cookie->isLogged())
{
if (empty($id_order) && !empty($cookie->id_customer))
$id_order = $this->_getLastOrderId($cookie->id_customer);
$buyer_email = $cookie->email;
}
return $this->getRatingUrlWithBuyerEmail((int)($cookie->id_lang), $id_order, $buyer_email);
}
public function getRatingUrlWithBuyerEmail($id_lang, $id_order = '', $buyer_email = '')
{
$language = Language::getIsoById((int)($id_lang));
$base_url = $this->rating_url_base[$language].Configuration::get('TS_TAB0_ID_'.(int)($id_lang)).'.html';
if (!empty($buyer_email))
$base_url .= '&buyerEmail='.urlencode(base64_encode($buyer_email)).($id_order ? '&orderID='.urlencode(base64_encode((int)($id_order))) : '');
return $base_url;
}
public function hookLeftColumn($params)
{
if (!$this->_isTsIdActive((int)($params['cookie']->id_lang))) return false;
self::$smarty->assign('display_widget', Configuration::get('TS_TAB0_DISPLAY_IN_SHOP'));
if (Configuration::get('TS_TAB0_DISPLAY_IN_SHOP'))
{
$filename = $this->getWidgetFilename((int)($params['cookie']->id_lang));
$cache = new WidgetCache(_PS_MODULE_DIR_.$filename, Configuration::get('TS_TAB0_ID_'.(int)($params['cookie']->id_lang)));
if (!$cache->isFresh())
$cache->refresh();
self::$smarty->assign(array('ts_id' => Configuration::get('TS_TAB0_ID_'.(int)($params['cookie']->id_lang)), 'filename' => _MODULE_DIR_.$filename));
}
self::$smarty->assign('display_rating_link', (int)(Configuration::get('TS_TAB0_DISPLAY_RATING_FRONT_END')));
if (Configuration::get('TS_TAB0_DISPLAY_RATING_FRONT_END'))
self::$smarty->assign(array('rating_url' => $this->getRatingUrl(), 'language' => Language::getIsoById((int)($params['cookie']->id_lang))));
return $this->display(self::$module_name, 'widget.tpl');
}
public function hookRightColumn($params)
{
return $this->hookLeftColumn($params);
}
public function getWidgetFilename()
{
global $cookie;
return self::$module_name.'/cache/'.Configuration::get('TS_TAB0_ID_'.(int)($cookie->id_lang)).'.gif';
}
public function hookOrderConfirmation($params)
{
if (!Configuration::get('TS_TAB0_DISPLAY_RATING_OC'))
if (!$this->_isTsIdActive((int)($params['cookie']->id_lang)))
return false;
self::$smarty->assign(array('rating_url' => $this->getRatingUrl((int)($params['objOrder']->id)), 'language' => Language::getIsoById((int)($params['cookie']->id_lang))));
return $this->display(self::$module_name, 'order-confirmation.tpl');
}
public function hookNewOrder($params)
{
if (!Configuration::get('TS_TAB0_SEND_SEPERATE_MAIL') OR !$this->_isTsIdActive((int)($params['order']->id_lang)))
return false;
RatingAlert::save((int)($params['order']->id));
}
public function getL($key)
{
$translations = array(
'title_part_1' => $this->l('Are you satisfied with'),
'title_part_2' => $this->l('? Please write a review!')
);
return $translations[$key];
}
}
@@ -1,71 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class TrustedShopsSoapApi
{
const TS_SERVER = 'www.trustedshops.de';
const WS_USER = 'presta-shopsoftware';
const WS_PASSWORD = 'Yx1F5uXR';
const ACTIVATE = 1;
const DESACTIVATE = 0;
const RT_OK = 'OK';
const RT_SOAP_ERROR = -1;
const RT_INVALID_TSID = 'INVALID_TSID';
const RT_NOT_REGISTERED = 'NOT_REGISTERED_FOR_TRUSTEDRATING';
const RT_WRONG_LOGIN = 'WRONG_WSUSERNAME_WSPASSWORD';
public static function validate($partener_package, $trusted_shops_id, $action = self::ACTIVATE)
{
$ini = ini_set('soap.wsdl_cache_enabled', 1);
$result = self::RT_SOAP_ERROR;
try
{
$wsdlUrl = 'https://'.self::TS_SERVER.'/ts/services/TsRating?wsdl';
$client = new SoapClient($wsdlUrl);
$result = $client->updateRatingWidgetState($trusted_shops_id, $action, self::WS_USER, self::WS_PASSWORD, $partener_package);
}
catch(SoapFault $fault)
{
$errorText = 'SOAP Fault: (faultcode:{$fault->faultcode}, faultstring:{$fault->faultstring})';
/** Enable this line if you are experiencing issues with your Trusted Shops ID activation.
die($errorText);
*/
}
if ($result == self::RT_WRONG_LOGIN)
die('Wrong login/password');
return $result;
}
}
-52
View File
@@ -1,52 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class WidgetCache
{
private $_fileName;
private $__ts_id;
public function __construct($_fileName, $_ts_id)
{
$this->_fileName = $_fileName;
$this->_ts_id = $_ts_id;
}
public function isFresh($timeout = 10800)
{
if (file_exists($this->_fileName))
return ((mktime() - filemtime($this->_fileName)) < $timeout);
else
return false;
}
public function refresh()
{
return file_put_contents($this->_fileName, file_get_contents('https://www.trustedshops.com/bewertung/widget/widgets/'.$this->_ts_id.'.gif'));
}
}
-103
View File
@@ -1,103 +0,0 @@
var TSPayment = (function()
{
return {
payment_type : {},
payment_module : {},
alert_message : '',
module_box : {
html : '<b class="payment-module-label"></b>',
class : '.payment-module-label',
id :'label-module-',
css : {
display : 'none',
padding :'2px 5px 2px 5px',
margin : '0 5px 0 5px',
cursor : 'pointer',
backgroundColor : '#e2e2e2',
color : '#666666'
}
},
alertMessage : function() {
if (TSPayment.alert_message != '') {
alert(TSPayment.alert_message);
}
},
deleteModuleFromList : function(id_module) {
$('select[name=payment_module]').find('option[value='+id_module+']').remove();
},
setLabelModuleName : function(id_module) {
if ($('#'+TSPayment.module_box.id+id_module).length) {
$('#'+TSPayment.module_box.id+id_module).text(TSPayment.payment_module[id_module].name)
}
},
init : function() {
clickAddFunction();
clickRemoveFunction();
hoverEffect();
}
};
function hoverEffect()
{
$(TSPayment.module_box.class).live('mouseover', function(){
$(this).css({backgroundColor:'#CF0000', opacity:0.6});
});
$(TSPayment.module_box.class).live('mouseout', function(){
$(this).css({backgroundColor:TSPayment.module_box.css.backgroundColor, opacity:1});
});
}
function addModule (payment_type, id_module)
{
$('#input-hidden-val').append('<input class="choosen_payment_type" style="display:none;" type="hidden" value="'+id_module+'" name="choosen_payment_type['+payment_type+'][]">');
if(!$('#block-payment-'+payment_type).length)
{
$("#payment_type_list").append('<label style="clear:both;"class="payment-type-label" >'+TSPayment.payment_type[payment_type]+'</label>');
$("#payment_type_list").append('<div class="margin-form" id="block-payment-'+payment_type+'" ></div>');
}
$('#block-payment-'+payment_type).append($(TSPayment.module_box.html).attr("id", TSPayment.module_box.id+id_module).css(TSPayment.module_box.css).fadeIn());
TSPayment.setLabelModuleName(id_module);
TSPayment.deleteModuleFromList(id_module);
}
function clickAddFunction()
{
$('input[name=add_payment_module]').click(function()
{
var boolean = true;
var payment_type = $('select[name=payment_type]').val();
var payment_module = $('select[name=payment_module]').val();
$('.choosen_payment_type').each(function() {
var reg = new RegExp(payment_type, 'i');
if ($(this).val() == payment_module)
boolean = false;
});
if (boolean) {
addModule(payment_type, payment_module);
TSPayment.alert_message = '';
}
else
TSPayment.alert_message = 'A payment module can be choosen for only one payment type';
TSPayment.alertMessage();
});
}
function clickRemoveFunction()
{
$('.payment-module-label').live('click', function()
{
var id_module = $(this).attr('id').split('-')[2];
var input_to_delete = $('#input-hidden-val').find('input[value='+id_module+']');
input_to_delete.remove();
$('select[name=payment_module]').append('<option value="'+id_module+'" >'+TSPayment.payment_module[id_module].name+'</option>');
$(this).fadeOut('fast', function()
{
var bloc_parent = $(this).parent();
if (bloc_parent.find('b').length == 1)
{
bloc_parent.prev('label').remove();
bloc_parent.remove();
}
$(this).remove();
});
});
}
})();