[*] 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

View File

@@ -52,11 +52,6 @@ class BlockCms extends Module
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
!Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
@@ -69,15 +64,12 @@ class BlockCms extends Module
PRIMARY KEY (`id_cms_block`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
!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`(
`id_cms_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default \'\',
PRIMARY KEY (`id_cms_block`, `id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
!Db::getInstance()->execute(rtrim($queryLang, ',')) OR
!Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`(
`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_POWEREDBY', 1))
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()

View File

@@ -80,7 +80,7 @@ class Editorial extends Module
$id_editorial = Db::getInstance()->Insert_ID();
$result = true;
foreach (Language::getLanguages() as $lang)
foreach (Language::getLanguages(false) as $lang)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
'id_editorial' => $id_editorial,
'id_lang' => $lang['id_lang'],

View File

@@ -2,7 +2,7 @@
<module>
<name>mondialrelay</name>
<displayName><![CDATA[Mondial Relay]]></displayName>
<version><![CDATA[1.7.6]]></version>
<version><![CDATA[1.7.8]]></version>
<description><![CDATA[Deliver in Relay points]]></description>
<author><![CDATA[]]></author>
<tab><![CDATA[shipping_logistics]]></tab>

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -29,7 +29,7 @@ if (!defined('_PS_VERSION_'))
exit;
class MoneyBookers extends PaymentModule
{
{
const LEFT_COLUMN = 0;
const RIGHT_COLUMN = 1;
const DISABLE = -1;
@@ -123,8 +123,8 @@ class MoneyBookers extends PaymentModule
public function install()
{
if (!parent::install() OR
!$this->registerHook('payment') OR
if (!parent::install() OR
!$this->registerHook('payment') OR
!$this->registerHook('paymentReturn'))
return false;
Configuration::updateValue('MB_HIDE_LOGIN', 1);
@@ -134,6 +134,8 @@ class MoneyBookers extends PaymentModule
Configuration::updateValue('MB_ID_LOGO_WALLET', 1);
Configuration::updateValue('MB_PARAMETERS', 0);
Configuration::updateValue('MB_DISPLAY_MODE', 1);
Configuration::updateValue('MB_LOCAL_METHODS', 2);
Configuration::updateValue('MB_INTER_METHODS', 5);
return true;
}
@@ -169,28 +171,28 @@ class MoneyBookers extends PaymentModule
'max_redirects' => 10,
'timeout' => $timeout,
'header' => array(
'Accept-language: en',
'Accept-language: en',
'Cookie: foo=bar')));
if (is_callable('curl_init') && ($ch = curl_init()))
{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);
curl_close($ch);
}
else
{
// Check availability of the context options
// Check availability of the context options
if (!is_array($contextOptions) || !count($contextOptions))
$contextOptions = $defaultContextOptions;
// Create a stream context
$stream_context = @stream_context_create($contextOptions);
if (($fp = @fopen($url, $mode, false, $stream_context)))
{
$content = fgets($fp, 4096);
@@ -199,7 +201,7 @@ class MoneyBookers extends PaymentModule
else if (!($content = @file_get_contents($url, false, $stream_context)))
if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout)))
{
preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
$host = $matches[1];
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: ".$host."\r\n";
@@ -231,7 +233,7 @@ class MoneyBookers extends PaymentModule
if (isset($_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__;
$content = $this->_fetchWebContent($url);
@@ -250,13 +252,13 @@ class MoneyBookers extends PaymentModule
}
}
catch(Exception $e)
{
{
$errors[] = $this->l('Unable to contact activation server, please try again later.');
}
}
else
else
$errors[] = $this->l('E-mail field is required');
/* Validate secret word */
if (isset($_POST['SubmitSecret']))
{
@@ -325,7 +327,7 @@ class MoneyBookers extends PaymentModule
Configuration::updateValue('MB_INTER_METHODS', $inter);
Configuration::updateValue('MB_DISPLAY_MODE', (int)($_POST['mb_display_mode']));
}
if (Tools::getValue('submitSettings'))
{
foreach(array('leftColumn', 'rightColumn') as $hookName)
@@ -336,7 +338,7 @@ class MoneyBookers extends PaymentModule
else if (Tools::getValue('logo_position') == self::RIGHT_COLUMN)
$this->registerHook('rightColumn');
}
/* Display errors */
if (sizeof($errors))
{
@@ -364,9 +366,9 @@ class MoneyBookers extends PaymentModule
self::DISABLE => $this->l('Disable'),
self::LEFT_COLUMN => $this->l('Left Column'),
self::RIGHT_COLUMN => $this->l('Right Column'));
$currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN :
(($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1);
$currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN :
(($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1);
/* Display settings form */
$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('Moneybookers changes its name and becomes Skrill!').'<br /><br />
<div style="clear: both;"></div>
<form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" id="form-settings">
<fieldset class="width2" style="margin: 20px 0; width: 800px;">
<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">
<b>'.$this->l('Select the logo position').'</b> :
<b>'.$this->l('Select the logo position').'</b> :
<select name="logo_position">';
foreach($blockPositionList as $position => $translation)
{
@@ -394,8 +396,8 @@ class MoneyBookers extends PaymentModule
$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' :
'http://www.moneybookers.com/ads/partners/'.$iso_code.'/index.html?p=Prestashop';
$output .= '
</select>
<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>
</table>
<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">
** '.$this->l('Moneybookers eWallet').'<br />
@@ -572,7 +574,7 @@ class MoneyBookers extends PaymentModule
return $output;
}
private function _displayLogoBlock($position)
{
$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';
return '<div style="text-align:center;"><img src="'.$imgPath.'" width=150 /></div>';
}
public function hookRightColumn($params)
{
return $this->_displayLogoBlock(self::RIGHT_COLUMN);
@@ -595,7 +597,7 @@ class MoneyBookers extends PaymentModule
public function hookPayment($params)
{
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') == ''))
return;
@@ -617,7 +619,7 @@ class MoneyBookers extends PaymentModule
{
$localMethods = Configuration::get('MB_LOCAL_METHODS');
$interMethods = Configuration::get('MB_INTER_METHODS');
$smarty->assign(array(
'display_mode' => (int)(Configuration::get('MB_DISPLAY_MODE')),
'local' => $localMethods ? explode('|', $localMethods) : array(),
@@ -684,11 +686,11 @@ class MoneyBookers extends PaymentModule
case _PS_OS_OUTOFSTOCK_:
$smarty->assign('status', 'ok');
break;
case _PS_OS_BANKWIRE_:
$smarty->assign('status', 'pending');
break;
case _PS_OS_ERROR_:
default:
$smarty->assign('status', 'failed');
@@ -697,7 +699,7 @@ class MoneyBookers extends PaymentModule
return $this->display(__FILE__, 'confirmation.tpl');
}
/**
* Set the detail of a payment - Call before the validate order init
* correctly the pcc object
@@ -717,7 +719,7 @@ class MoneyBookers extends PaymentModule
$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'] : '');
}
}