[*] MO: Set default config for blockcms, editorial and moneybookers in their install method

This commit is contained in:
rMalie
2011-11-10 14:25:15 +00:00
parent ccf8d86f8a
commit 88feeb34b2
4 changed files with 63 additions and 44 deletions
+26 -9
View File
@@ -52,11 +52,6 @@ class BlockCms extends Module
public function install() public function install()
{ {
$languages = Language::getLanguages(false);
$queryLang = 'INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`) VALUES';
foreach ($languages AS $language)
$queryLang .= '(1, '.(int)($language['id_lang']).'),';
if (!parent::install() OR !$this->registerHook('leftColumn') OR !$this->registerHook('rightColumn') OR !$this->registerHook('footer') OR !$this->registerHook('header') OR if (!parent::install() OR !$this->registerHook('leftColumn') OR !$this->registerHook('rightColumn') OR !$this->registerHook('footer') OR !$this->registerHook('header') OR
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
@@ -69,15 +64,12 @@ class BlockCms extends Module
PRIMARY KEY (`id_cms_block`) PRIMARY KEY (`id_cms_block`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
!Db::getInstance()->execute(' !Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)') OR
!Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`(
`id_cms_block` int(10) unsigned NOT NULL, `id_cms_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default \'\', `name` varchar(40) NOT NULL default \'\',
PRIMARY KEY (`id_cms_block`, `id_lang`) PRIMARY KEY (`id_cms_block`, `id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
!Db::getInstance()->execute(rtrim($queryLang, ',')) OR
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`(
`id_cms_block_page` int(10) unsigned NOT NULL auto_increment, `id_cms_block_page` int(10) unsigned NOT NULL auto_increment,
@@ -90,7 +82,32 @@ class BlockCms extends Module
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR
!Configuration::updateValue('FOOTER_POWEREDBY', 1)) !Configuration::updateValue('FOOTER_POWEREDBY', 1))
return false; return false;
return true;
// Install fixtures for blockcms
if (!Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block', array(
'id_cms_category' => 1,
'location' => 0,
'position' => 0,
), 'INSERT'))
return false;
$id_cms_block = Db::getInstance()->Insert_ID();
$result = true;
foreach (Language::getLanguages(false) as $lang)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_lang', array(
'id_cms_block' => $id_cms_block,
'id_lang' => $lang['id_lang'],
'name' => $this->l('Information'),
), 'INSERT');
foreach (CMS::getCMSPages(null, 1) as $cms)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_page', array(
'id_cms_block' => $id_cms_block,
'id_cms' => $cms['id_cms'],
'is_category' => 0,
), 'INSERT');
return $result;
} }
public function uninstall() public function uninstall()
+1 -1
View File
@@ -80,7 +80,7 @@ class Editorial extends Module
$id_editorial = Db::getInstance()->Insert_ID(); $id_editorial = Db::getInstance()->Insert_ID();
$result = true; $result = true;
foreach (Language::getLanguages() as $lang) foreach (Language::getLanguages(false) as $lang)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array( $result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
'id_editorial' => $id_editorial, 'id_editorial' => $id_editorial,
'id_lang' => $lang['id_lang'], 'id_lang' => $lang['id_lang'],
+1 -1
View File
@@ -2,7 +2,7 @@
<module> <module>
<name>mondialrelay</name> <name>mondialrelay</name>
<displayName><![CDATA[Mondial Relay]]></displayName> <displayName><![CDATA[Mondial Relay]]></displayName>
<version><![CDATA[1.7.6]]></version> <version><![CDATA[1.7.8]]></version>
<description><![CDATA[Deliver in Relay points]]></description> <description><![CDATA[Deliver in Relay points]]></description>
<author><![CDATA[]]></author> <author><![CDATA[]]></author>
<tab><![CDATA[shipping_logistics]]></tab> <tab><![CDATA[shipping_logistics]]></tab>
+35 -33
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -29,7 +29,7 @@ if (!defined('_PS_VERSION_'))
exit; exit;
class MoneyBookers extends PaymentModule class MoneyBookers extends PaymentModule
{ {
const LEFT_COLUMN = 0; const LEFT_COLUMN = 0;
const RIGHT_COLUMN = 1; const RIGHT_COLUMN = 1;
const DISABLE = -1; const DISABLE = -1;
@@ -123,8 +123,8 @@ class MoneyBookers extends PaymentModule
public function install() public function install()
{ {
if (!parent::install() OR if (!parent::install() OR
!$this->registerHook('payment') OR !$this->registerHook('payment') OR
!$this->registerHook('paymentReturn')) !$this->registerHook('paymentReturn'))
return false; return false;
Configuration::updateValue('MB_HIDE_LOGIN', 1); Configuration::updateValue('MB_HIDE_LOGIN', 1);
@@ -134,6 +134,8 @@ class MoneyBookers extends PaymentModule
Configuration::updateValue('MB_ID_LOGO_WALLET', 1); Configuration::updateValue('MB_ID_LOGO_WALLET', 1);
Configuration::updateValue('MB_PARAMETERS', 0); Configuration::updateValue('MB_PARAMETERS', 0);
Configuration::updateValue('MB_DISPLAY_MODE', 1); Configuration::updateValue('MB_DISPLAY_MODE', 1);
Configuration::updateValue('MB_LOCAL_METHODS', 2);
Configuration::updateValue('MB_INTER_METHODS', 5);
return true; return true;
} }
@@ -169,28 +171,28 @@ class MoneyBookers extends PaymentModule
'max_redirects' => 10, 'max_redirects' => 10,
'timeout' => $timeout, 'timeout' => $timeout,
'header' => array( 'header' => array(
'Accept-language: en', 'Accept-language: en',
'Cookie: foo=bar'))); 'Cookie: foo=bar')));
if (is_callable('curl_init') && ($ch = curl_init())) if (is_callable('curl_init') && ($ch = curl_init()))
{ {
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch); $content = curl_exec($ch);
curl_close($ch); curl_close($ch);
} }
else else
{ {
// Check availability of the context options // Check availability of the context options
if (!is_array($contextOptions) || !count($contextOptions)) if (!is_array($contextOptions) || !count($contextOptions))
$contextOptions = $defaultContextOptions; $contextOptions = $defaultContextOptions;
// Create a stream context // Create a stream context
$stream_context = @stream_context_create($contextOptions); $stream_context = @stream_context_create($contextOptions);
if (($fp = @fopen($url, $mode, false, $stream_context))) if (($fp = @fopen($url, $mode, false, $stream_context)))
{ {
$content = fgets($fp, 4096); $content = fgets($fp, 4096);
@@ -199,7 +201,7 @@ class MoneyBookers extends PaymentModule
else if (!($content = @file_get_contents($url, false, $stream_context))) else if (!($content = @file_get_contents($url, false, $stream_context)))
if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout))) if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout)))
{ {
preg_match('@^(?:http://)?([^/]+)@i', $url, $matches); preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
$host = $matches[1]; $host = $matches[1];
$out = "GET / HTTP/1.1\r\n"; $out = "GET / HTTP/1.1\r\n";
$out .= "Host: ".$host."\r\n"; $out .= "Host: ".$host."\r\n";
@@ -231,7 +233,7 @@ class MoneyBookers extends PaymentModule
if (isset($_POST['mb_email_to_validate']) && if (isset($_POST['mb_email_to_validate']) &&
!empty($_POST['mb_email_to_validate'])) !empty($_POST['mb_email_to_validate']))
{ {
try try
{ {
$url = 'http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_email_to_validate'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__; $url = 'http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_email_to_validate'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
$content = $this->_fetchWebContent($url); $content = $this->_fetchWebContent($url);
@@ -250,13 +252,13 @@ class MoneyBookers extends PaymentModule
} }
} }
catch(Exception $e) catch(Exception $e)
{ {
$errors[] = $this->l('Unable to contact activation server, please try again later.'); $errors[] = $this->l('Unable to contact activation server, please try again later.');
} }
} }
else else
$errors[] = $this->l('E-mail field is required'); $errors[] = $this->l('E-mail field is required');
/* Validate secret word */ /* Validate secret word */
if (isset($_POST['SubmitSecret'])) if (isset($_POST['SubmitSecret']))
{ {
@@ -325,7 +327,7 @@ class MoneyBookers extends PaymentModule
Configuration::updateValue('MB_INTER_METHODS', $inter); Configuration::updateValue('MB_INTER_METHODS', $inter);
Configuration::updateValue('MB_DISPLAY_MODE', (int)($_POST['mb_display_mode'])); Configuration::updateValue('MB_DISPLAY_MODE', (int)($_POST['mb_display_mode']));
} }
if (Tools::getValue('submitSettings')) if (Tools::getValue('submitSettings'))
{ {
foreach(array('leftColumn', 'rightColumn') as $hookName) foreach(array('leftColumn', 'rightColumn') as $hookName)
@@ -336,7 +338,7 @@ class MoneyBookers extends PaymentModule
else if (Tools::getValue('logo_position') == self::RIGHT_COLUMN) else if (Tools::getValue('logo_position') == self::RIGHT_COLUMN)
$this->registerHook('rightColumn'); $this->registerHook('rightColumn');
} }
/* Display errors */ /* Display errors */
if (sizeof($errors)) if (sizeof($errors))
{ {
@@ -364,9 +366,9 @@ class MoneyBookers extends PaymentModule
self::DISABLE => $this->l('Disable'), self::DISABLE => $this->l('Disable'),
self::LEFT_COLUMN => $this->l('Left Column'), self::LEFT_COLUMN => $this->l('Left Column'),
self::RIGHT_COLUMN => $this->l('Right Column')); self::RIGHT_COLUMN => $this->l('Right Column'));
$currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN : $currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN :
(($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1); (($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1);
/* Display settings form */ /* Display settings form */
$output .= ' $output .= '
@@ -376,13 +378,13 @@ class MoneyBookers extends PaymentModule
$this->l('With more than 17 million users and more than 15,000 new accounts created per day, Moneybookers also offers one of the biggest electronic wallet in the world. Your customers can also pay by using their e-mail and password thanks to the e-Wallet solution.').'<br /><br />'. $this->l('With more than 17 million users and more than 15,000 new accounts created per day, Moneybookers also offers one of the biggest electronic wallet in the world. Your customers can also pay by using their e-mail and password thanks to the e-Wallet solution.').'<br /><br />'.
$this->l('Moneybookers changes its name and becomes Skrill!').'<br /><br /> $this->l('Moneybookers changes its name and becomes Skrill!').'<br /><br />
<div style="clear: both;"></div> <div style="clear: both;"></div>
<form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" id="form-settings"> <form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" id="form-settings">
<fieldset class="width2" style="margin: 20px 0; width: 800px;"> <fieldset class="width2" style="margin: 20px 0; width: 800px;">
<legend><img src="'.__PS_BASE_URI__.'modules/moneybookers/logo.gif" alt="" />'.$this->l('Settings').'</legend> <legend><img src="'.__PS_BASE_URI__.'modules/moneybookers/logo.gif" alt="" />'.$this->l('Settings').'</legend>
<div class="margin-form" style="margin:0; padding:0 0 1em 20px">'.$this->l('You can display the Skrill/Moneybookers logo on your shop, this may reassure your customers about the fact that you are a serious merchant.').'</div> <div class="margin-form" style="margin:0; padding:0 0 1em 20px">'.$this->l('You can display the Skrill/Moneybookers logo on your shop, this may reassure your customers about the fact that you are a serious merchant.').'</div>
<div class="margin-form" style="margin:0; padding:0 0 1em 20px"> <div class="margin-form" style="margin:0; padding:0 0 1em 20px">
<b>'.$this->l('Select the logo position').'</b> : <b>'.$this->l('Select the logo position').'</b> :
<select name="logo_position">'; <select name="logo_position">';
foreach($blockPositionList as $position => $translation) foreach($blockPositionList as $position => $translation)
{ {
@@ -394,8 +396,8 @@ class MoneyBookers extends PaymentModule
$iso_code = strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))); $iso_code = strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
$landingPage = ($iso_code == 'en' || $iso_code == 'us') ? 'http://www.moneybookers.com/ads/partners/index.html?p=Prestashop' : $landingPage = ($iso_code == 'en' || $iso_code == 'us') ? 'http://www.moneybookers.com/ads/partners/index.html?p=Prestashop' :
'http://www.moneybookers.com/ads/partners/'.$iso_code.'/index.html?p=Prestashop'; 'http://www.moneybookers.com/ads/partners/'.$iso_code.'/index.html?p=Prestashop';
$output .= ' $output .= '
</select> </select>
<p>'.$this->l('Change your logo position in the Front Office. Works with').' <p>'.$this->l('Change your logo position in the Front Office. Works with').'
@@ -438,7 +440,7 @@ class MoneyBookers extends PaymentModule
<tr><td colspan="3" style="border-top: 1px solid black;"><small>'.$this->l('For merchants over €100,000 fees can be negotiated.').' Contact: ecommerce@moneybookers.com</small></td></tr> <tr><td colspan="3" style="border-top: 1px solid black;"><small>'.$this->l('For merchants over €100,000 fees can be negotiated.').' Contact: ecommerce@moneybookers.com</small></td></tr>
</table> </table>
<br /> <br />
'.$this->l('To view the last update of the detailed fees').'<a href="'.$landingPage.'"> <b>'.$this->l('Click here').'</b></a> '.$this->l('To view the last update of the detailed fees').'<a href="'.$landingPage.'"> <b>'.$this->l('Click here').'</b></a>
<p align="left"> <p align="left">
** '.$this->l('Moneybookers eWallet').'<br /> ** '.$this->l('Moneybookers eWallet').'<br />
@@ -572,7 +574,7 @@ class MoneyBookers extends PaymentModule
return $output; return $output;
} }
private function _displayLogoBlock($position) private function _displayLogoBlock($position)
{ {
$imgPath = 'http://www.prestashop.com/images/logo_partners/logo-skrill.png'; $imgPath = 'http://www.prestashop.com/images/logo_partners/logo-skrill.png';
@@ -580,7 +582,7 @@ class MoneyBookers extends PaymentModule
$imgPath = __PS_BASE_URI__.'modules/moneybookers/logo-skrill.png'; $imgPath = __PS_BASE_URI__.'modules/moneybookers/logo-skrill.png';
return '<div style="text-align:center;"><img src="'.$imgPath.'" width=150 /></div>'; return '<div style="text-align:center;"><img src="'.$imgPath.'" width=150 /></div>';
} }
public function hookRightColumn($params) public function hookRightColumn($params)
{ {
return $this->_displayLogoBlock(self::RIGHT_COLUMN); return $this->_displayLogoBlock(self::RIGHT_COLUMN);
@@ -595,7 +597,7 @@ class MoneyBookers extends PaymentModule
public function hookPayment($params) public function hookPayment($params)
{ {
global $smarty, $cookie; global $smarty, $cookie;
if (!Configuration::get('MB_PARAMETERS') OR !Configuration::get('MB_PARAMETERS_2') OR (Configuration::get('MB_LOCAL_METHODS') == '' AND Configuration::get('MB_INTER_METHODS') == '')) if (!Configuration::get('MB_PARAMETERS') OR !Configuration::get('MB_PARAMETERS_2') OR (Configuration::get('MB_LOCAL_METHODS') == '' AND Configuration::get('MB_INTER_METHODS') == ''))
return; return;
@@ -617,7 +619,7 @@ class MoneyBookers extends PaymentModule
{ {
$localMethods = Configuration::get('MB_LOCAL_METHODS'); $localMethods = Configuration::get('MB_LOCAL_METHODS');
$interMethods = Configuration::get('MB_INTER_METHODS'); $interMethods = Configuration::get('MB_INTER_METHODS');
$smarty->assign(array( $smarty->assign(array(
'display_mode' => (int)(Configuration::get('MB_DISPLAY_MODE')), 'display_mode' => (int)(Configuration::get('MB_DISPLAY_MODE')),
'local' => $localMethods ? explode('|', $localMethods) : array(), 'local' => $localMethods ? explode('|', $localMethods) : array(),
@@ -684,11 +686,11 @@ class MoneyBookers extends PaymentModule
case _PS_OS_OUTOFSTOCK_: case _PS_OS_OUTOFSTOCK_:
$smarty->assign('status', 'ok'); $smarty->assign('status', 'ok');
break; break;
case _PS_OS_BANKWIRE_: case _PS_OS_BANKWIRE_:
$smarty->assign('status', 'pending'); $smarty->assign('status', 'pending');
break; break;
case _PS_OS_ERROR_: case _PS_OS_ERROR_:
default: default:
$smarty->assign('status', 'failed'); $smarty->assign('status', 'failed');
@@ -697,7 +699,7 @@ class MoneyBookers extends PaymentModule
return $this->display(__FILE__, 'confirmation.tpl'); return $this->display(__FILE__, 'confirmation.tpl');
} }
/** /**
* Set the detail of a payment - Call before the validate order init * Set the detail of a payment - Call before the validate order init
* correctly the pcc object * correctly the pcc object
@@ -717,7 +719,7 @@ class MoneyBookers extends PaymentModule
$this->pcc->card_expiration = ''; $this->pcc->card_expiration = '';
$this->pcc->card_holder = (string)(isset($response['pay_to_email']) ? $this->pcc->card_holder = (string)(isset($response['pay_to_email']) ?
$response['pay_to_email'] : ''); $response['pay_to_email'] : '');
} }
} }