// Remove preactivation from installer
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Step 4 : configure the shop, admin access and modules preactivations
|
||||
* Step 4 : configure the shop and admin access
|
||||
*/
|
||||
class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
{
|
||||
@@ -54,18 +54,6 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
|
||||
if (!$this->session->admin_password_confirm || trim(Tools::getValue('admin_password_confirm')))
|
||||
$this->session->admin_password_confirm = trim(Tools::getValue('admin_password_confirm'));
|
||||
|
||||
// Save partners preactivation configuration
|
||||
$this->session->partners = array();
|
||||
$partners = Tools::getValue('partner');
|
||||
if (is_array($partners))
|
||||
{
|
||||
// Check all selected partners and store their fields
|
||||
$session_partners = array();
|
||||
foreach ($partners as $partner_id => $state)
|
||||
$session_partners[$partner_id] = (isset($_POST['partner_fields'][$partner_id])) ? $_POST['partner_fields'][$partner_id] : array();
|
||||
$this->session->partners = $session_partners;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +82,7 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
if ($this->session->admin_password)
|
||||
{
|
||||
if (!Validate::isPasswdAdmin($this->session->admin_password))
|
||||
$this->errors['admin_password'] = $this->l('The password is incorrect (alphanumeric string at least 8 characters)');
|
||||
$this->errors['admin_password'] = $this->l('The password is incorrect (alphanumeric string with at least 8 characters)');
|
||||
else if ($this->session->admin_password != $this->session->admin_password_confirm)
|
||||
$this->errors['admin_password'] = $this->l('Password and its confirmation are different');
|
||||
}
|
||||
@@ -112,10 +100,6 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
$this->processUploadLogo();
|
||||
else if (Tools::getValue('timezoneByIso'))
|
||||
$this->processTimezoneByIso();
|
||||
else if (Tools::getValue('getPartners'))
|
||||
$this->processGetPartners();
|
||||
else if (Tools::getValue('getPartnersFields'))
|
||||
$this->processGetPartnersFields();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +173,7 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
{
|
||||
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
if (!is_writable(_PS_ROOT_DIR_.'/img/logo.jpg'))
|
||||
$error = $this->l('Image folder is not writable');
|
||||
$error = $this->l('Image folder %s is not writable', _PS_ROOT_DIR_.'/img/');
|
||||
else if (!imagejpeg($thumb, _PS_ROOT_DIR_.'/img/logo.jpg', 90))
|
||||
$error = $this->l('Cannot upload the file');
|
||||
}
|
||||
@@ -209,149 +193,6 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
$this->ajaxJsonAnswer(($timezone) ? true : false, $timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a translation from presintall XML file
|
||||
*
|
||||
* @param SimplexmlElement $xml
|
||||
* @param string $xpath
|
||||
* @return string
|
||||
*/
|
||||
public function getPreinstallXmlLang(SimplexmlElement $xml, $xpath)
|
||||
{
|
||||
$lang = $this->language->getLanguageIso();
|
||||
$translation = $xml->xpath($xpath.'[@iso="'.$lang.'"]');
|
||||
if (!$translation && $lang != 'en')
|
||||
$translation = $xml->xpath($xpath.'[@iso="en"]');
|
||||
if (!$translation)
|
||||
$translation = $xml->xpath($xpath);
|
||||
return ($translation) ? (string)$translation[0] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of partners from PrestaShop website
|
||||
*/
|
||||
public function processGetPartners()
|
||||
{
|
||||
$this->iso = Tools::getValue('iso');
|
||||
if (!$this->iso)
|
||||
$this->ajaxJsonAnswer(false);
|
||||
|
||||
// Load partners XML file from prestashop.com
|
||||
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 3)));
|
||||
$content = @file_get_contents('http://api.prestashop.com/partner/preactivation/partners.php?version=1.1', false, $stream_context);
|
||||
if (!$xml = @simplexml_load_string($content))
|
||||
$this->ajaxJsonAnswer(false, $this->l('Cannot load partners from PrestaShop website'));
|
||||
|
||||
// Browse all partners
|
||||
$partners = array();
|
||||
foreach ($xml->partner as $partner)
|
||||
{
|
||||
// Partner available for current language ?
|
||||
if (!$partner->xpath('countries[country="'.$this->iso.'"]'))
|
||||
continue;
|
||||
|
||||
$partner_id = (string)$partner->key;
|
||||
if (!isset($this->session->shop_name))
|
||||
$checked = ($partner->prechecked) ? true : false;
|
||||
else
|
||||
$checked = (isset($this->session->partners[$partner_id])) ? true : false;
|
||||
|
||||
$partners[$partner_id] = array(
|
||||
'name' => (string)$partner->name,
|
||||
'label' => $this->getPreinstallXmlLang($partner, 'labels/label'),
|
||||
'description' => $this->getPreinstallXmlLang($partner, 'descriptions/description'),
|
||||
'logo' => $partner->logo_medium,
|
||||
'checked' => $checked,
|
||||
);
|
||||
}
|
||||
|
||||
// If no partners, don't displayany preactivation HTML
|
||||
if (!$partners)
|
||||
$this->ajaxJsonAnswer(false);
|
||||
|
||||
// Render partners
|
||||
$this->partners = $partners;
|
||||
$html = $this->displayTemplate('partners', true);
|
||||
$this->ajaxJsonAnswer(true, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields of a partner for a country as HTML
|
||||
*/
|
||||
public function processGetPartnersFields()
|
||||
{
|
||||
$this->partner_id = Tools::getValue('partner_id');
|
||||
$this->iso = Tools::getValue('iso');
|
||||
if (!$this->partner_id || !$this->iso)
|
||||
$this->ajaxJsonAnswer(false);
|
||||
|
||||
$this->fields = $this->getPartnersFields($this->partner_id, $this->iso);
|
||||
|
||||
if (!$this->fields)
|
||||
$this->ajaxJsonAnswer(false);
|
||||
|
||||
// Render fields
|
||||
$html = $this->displayTemplate('partners_fields', true);
|
||||
$this->ajaxJsonAnswer(true, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of fields of a partner for a country
|
||||
*
|
||||
* @param string $partner_id
|
||||
* @param string $iso
|
||||
* @return array
|
||||
*/
|
||||
public function getPartnersFields($partner_id, $iso)
|
||||
{
|
||||
// Load partners fields XML file from prestashop.com
|
||||
$stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)));
|
||||
$content = @file_get_contents('http://api.prestashop.com/partner/preactivation/fields.php?version=1.1&partner='.$partner_id.'&country_iso_code='.$iso, false, $stream_context);
|
||||
if (!$xml = @simplexml_load_string($content))
|
||||
$this->ajaxJsonAnswer(false, $this->l('Cannot load partners fields from PrestaShop website'));
|
||||
|
||||
// Browse all fields
|
||||
$fields = array();
|
||||
foreach ($xml->field as $field)
|
||||
{
|
||||
$key = (string)$field->key;
|
||||
$data = array(
|
||||
'type' => (string)$field->type,
|
||||
'label' => $this->getPreinstallXmlLang($field, 'labels/label'),
|
||||
'help' => $this->getPreinstallXmlLang($field, 'helps/help'),
|
||||
'value' => (isset($this->session->partners[$partner_id][$key])) ? $this->session->partners[$partner_id][$key] : (string)$field->default,
|
||||
);
|
||||
|
||||
switch ($data['type'])
|
||||
{
|
||||
case 'text' :
|
||||
case 'password' :
|
||||
$data['size'] = (string)$field->size;
|
||||
break;
|
||||
|
||||
case 'radio' :
|
||||
case 'select' :
|
||||
$data['list'] = array();
|
||||
foreach ($field->values as $value)
|
||||
$data['list'][(string)$value->value] = $this->getPreinstallXmlLang($value, 'labels/label');
|
||||
break;
|
||||
|
||||
case 'date' :
|
||||
if (!is_array($data['value']))
|
||||
$data['value'] = array(
|
||||
'year' => 0,
|
||||
'month' => 0,
|
||||
'day' => 0,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$fields[$key] = $data;
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of timezones
|
||||
*
|
||||
|
||||
@@ -242,31 +242,6 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
$this->ajaxJsonAnswer(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* PROCESS : preactivation
|
||||
* (currently not used)
|
||||
*/
|
||||
public function processPreactivation()
|
||||
{
|
||||
foreach ($this->session->partners as $partner => $data)
|
||||
{
|
||||
/*$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 5)));
|
||||
$url = 'http://api.prestashop.com/partner/preactivation/actions.php?version=1.0&partner='.addslashes($_GET['partner']);
|
||||
|
||||
// Protect fields
|
||||
foreach ($_GET as $key => $value)
|
||||
$_GET[$key] = strip_tags(str_replace(array('\'', '"'), '', trim($value)));
|
||||
|
||||
// Encore Get, Send It and Get Answers
|
||||
@require_once('../config/settings.inc.php');
|
||||
foreach ($_GET as $key => $val)
|
||||
$url .= '&'.$key.'='.urlencode($val);
|
||||
$url .= '&security='.md5($_GET['email']._COOKIE_IV_);*/
|
||||
}
|
||||
|
||||
$this->ajaxJsonAnswer(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstallAbstractModel::display()
|
||||
*/
|
||||
|
||||
@@ -20,13 +20,7 @@ $(document).ready(function()
|
||||
$('#infosTimezone').val(json.message);
|
||||
}
|
||||
});
|
||||
|
||||
// Load associated partners
|
||||
//load_partners(iso);
|
||||
});
|
||||
|
||||
//if (default_iso)
|
||||
// load_partners(default_iso);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -66,60 +60,3 @@ function upload_logo()
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Load partners for a given country
|
||||
*
|
||||
* @param string iso
|
||||
*/
|
||||
function load_partners(iso)
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php',
|
||||
data: 'getPartners=true&iso='+iso,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(json)
|
||||
{
|
||||
if (json.success)
|
||||
{
|
||||
// Display partner HTML
|
||||
$('#benefitsBlock').html(json.message).show();
|
||||
|
||||
// Add event on partner checkbox to display fields if it's checked
|
||||
$('.preinstall_partner').click(function()
|
||||
{
|
||||
var name = $(this).attr('name');
|
||||
var partner_id = name.substr(8, name.length - 9);
|
||||
|
||||
if ($(this).attr('checked'))
|
||||
load_partner_fields(partner_id, iso);
|
||||
else
|
||||
$('#partner_fields_'+partner_id).html('').hide();
|
||||
});
|
||||
}
|
||||
else
|
||||
$('#benefitsBlock').html('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display partner fields
|
||||
*
|
||||
* @param string partner_id Key of partner
|
||||
*/
|
||||
function load_partner_fields(partner_id, iso)
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php',
|
||||
data: 'getPartnersFields=true&partner_id='+partner_id+'&iso='+iso,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(json)
|
||||
{
|
||||
if (json.success)
|
||||
$('#partner_fields_'+partner_id).html(json.message).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
.moduleTable {
|
||||
padding: 5px;
|
||||
width: 650px;
|
||||
border: 1px solid #CCC;
|
||||
border-bottom:none;
|
||||
}
|
||||
.moduleTable tr {
|
||||
border-bottom: 1px solid #CCC;
|
||||
}
|
||||
.moduleTable th {
|
||||
font-size:13;
|
||||
color:#000;
|
||||
text-shadow:0 1px 0 #fff;
|
||||
background:#cfcfcf url(img/bg_moduleTable_th.png) repeat-x 0 0;
|
||||
}
|
||||
.moduleTable .field {
|
||||
padding:10px 0;
|
||||
border-bottom:none;
|
||||
}
|
||||
.moduleTable .field label {
|
||||
display:inline-block;
|
||||
padding-left:10px;
|
||||
width:180px;/* 190 */
|
||||
}
|
||||
.moduleTable .field label.radiolabel {width:auto;}
|
||||
.moduleTable .field div.contentinput {
|
||||
display:inline-block;
|
||||
width:245px;
|
||||
font-size: 11px;
|
||||
font-style:italic;
|
||||
color:#999;
|
||||
}
|
||||
|
||||
.moduleTable select {
|
||||
border: 1px solid #D41958;
|
||||
}
|
||||
|
||||
.moduleTable select.pa_list {
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
.moduleTable select.pa_list_year {
|
||||
margin-right: 10px;
|
||||
width: 60px !important;
|
||||
}
|
||||
|
||||
.moduleTable select.pa_list_month, .moduleTable select.pa_list_day {
|
||||
margin-right: 10px;
|
||||
width: 45px !important;
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
<link rel="shortcut icon" href="theme/img/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" media="all" href="theme/view.css" />
|
||||
<link rel="stylesheet" type="text/css" media="all" href="theme/preactivation.css" />
|
||||
|
||||
<script type="text/javascript" src="theme/js/jquery-1.4.4.min.js"></script>
|
||||
<script type="text/javascript" src="theme/js/jquery.ajaxfileupload.js"></script>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<h2><?php echo $this->l('Additional Benefits') ?></h2>
|
||||
<h3><?php echo ('Exclusive offers dedicated to PrestaShop merchants') ?></h3>
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="moduleTable">
|
||||
<tr>
|
||||
<th style="width: 30px;"></th>
|
||||
<th style="width: 100px;"><?php echo $this->l('Modules') ?></th>
|
||||
<th style="padding: 12px; width: 430px;"><?php echo $this->l('Benefits') ?></th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php foreach ($this->partners as $partner_id => $partner): ?>
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="moduleTable">
|
||||
<tr style="border-bottom:0px">
|
||||
<td valign="top" style="text-align: center; padding-top:10px; width: 30px;">
|
||||
<span style="padding: 12px 4px 6px 2px;">
|
||||
<input type="checkbox" style="vertical-align: middle;" class="preinstall_partner" name="partner[<?php echo $partner_id ?>]" <?php if ($partner['checked']): ?>checked="checked"<?php endif; ?> />
|
||||
</span>
|
||||
</td>
|
||||
<td valign="top" style="width: 100px; text-align: center;">
|
||||
<img src="<?php echo $partner['logo'] ?>" alt="<?php echo $partner['name'] ?>" title="<?php echo $partner['name'] ?>">
|
||||
</td>
|
||||
<td style="padding: 15px; width: 430px;">
|
||||
<?php echo $partner['description'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<div id="partner_fields_<?php echo $partner_id ?>">
|
||||
<?php if ($partner['checked'])
|
||||
{
|
||||
$this->fields = $this->getPartnersFields($partner_id, $this->iso);
|
||||
$this->partner_id = $partner_id;
|
||||
$this->displayTemplate('partners_fields');
|
||||
} ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
@@ -1,59 +0,0 @@
|
||||
<br clear="left" /><hr /><br clear="left" />
|
||||
|
||||
<?php foreach ($this->fields as $field_id => $field): ?>
|
||||
<div>
|
||||
<label class="aligned" style="float:left;width:200px;padding-left:10px;"><?php echo $field['label'] ?> :</label>
|
||||
|
||||
<?php if ($field['type'] == 'text' || $field['type'] == 'password'): ?>
|
||||
<input
|
||||
type="<?php echo $field['type'] ?>"
|
||||
name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>]"
|
||||
class="text required"
|
||||
value="<?php echo htmlspecialchars($field['value']) ?>"
|
||||
<?php if ($field['size']): ?>size="<?php echo $field['size'] ?>"<?php endif; ?>
|
||||
/>
|
||||
<?php elseif ($field['type'] == 'radio'): ?>
|
||||
<?php foreach ($field['list'] as $value => $label): ?>
|
||||
<?php echo $label ?>
|
||||
<input
|
||||
type="radio"
|
||||
name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>]"
|
||||
value="<?php echo $value ?>"
|
||||
<?php if ($field['value'] == $value): ?>checked="checked"<?php endif; ?>
|
||||
/>
|
||||
<?php endforeach; ?>
|
||||
<?php elseif ($field['type'] == 'select'): ?>
|
||||
<select name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>]" class="pa_list">
|
||||
<?php foreach ($field['list'] as $value => $label): ?>
|
||||
<option value="<?php echo $value ?>" <?php if ($field['value'] == $value): ?>selected="selected"<?php endif; ?>>
|
||||
<?php echo $label ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php elseif ($field['type'] == 'date'): ?>
|
||||
<select name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>][year]" class="pa_list_year" style="border:1px solid #D41958">
|
||||
<?php for ($i = date('Y') - 81; $i <= date('Y'); $i++): ?>
|
||||
<option value="<?php echo $i ?>" <?php if ($field['value']['year'] == $i): ?>selected="selected"<?php endif; ?>><?php echo $i ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
|
||||
<select name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>][month]" class="pa_list_month" style="border:1px solid #D41958">
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i ?>" <?php if ($field['value']['month'] == $i): ?>selected="selected"<?php endif; ?>><?php echo str_pad($i, 2, '0', STR_PAD_LEFT) ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
|
||||
<select name="partner_fields[<?php echo $this->partner_id?>][<?php echo $field_id ?>][day]" class="pa_list_day" style="border:1px solid #D41958">
|
||||
<?php for ($i = 1; $i <= 31; $i++): ?>
|
||||
<option value="<?php echo $i ?>" <?php if ($field['value']['day'] == $i): ?>selected="selected"<?php endif; ?>><?php echo str_pad($i, 2, '0', STR_PAD_LEFT) ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($field['help']): ?>
|
||||
<?php echo $field['help'] ?>
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
</div>
|
||||
<br clear="left" />
|
||||
<?php endforeach; ?>
|
||||
Reference in New Issue
Block a user