[*] BO : Modules can now be authorized or not by client group

This commit is contained in:
vChabot
2011-10-06 15:22:25 +00:00
parent e6ea6e7877
commit ddb93a1f7d
8 changed files with 975 additions and 261 deletions
+160 -3
View File
@@ -65,7 +65,7 @@ class AdminGroups extends AdminTab
$categories = Category::getSimpleCategories($this->context->language->id);
echo '
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
<form id="group" action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/tab-groups.gif" />'.$this->l('Group').'</legend>
<label>'.$this->l('Name:').' </label>
@@ -130,11 +130,14 @@ class AdminGroups extends AdminTab
$this->displayAssoShop('group_shop');
echo '</div>';
}
echo '<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</fieldset>';
$this->displayFormRestrictions($obj->id);
echo '
</form><br />';
if ($obj->id)
@@ -163,9 +166,142 @@ class AdminGroups extends AdminTab
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</form>';
}
}
/**
* display form client groups restrictions
*/
protected function displayFormRestrictions($id = false)
{
$modules = Module::getModulesInstalled();
$authorized_modules = '';
$auth_modules = array();
$unauth_modules = array();
if ($id)
$authorized_modules = Module::getAuthorizedModules($id);
else
$id = '';
if (is_array($authorized_modules))
{
foreach ($modules as $module)
{
$authorized = false;
foreach ($authorized_modules as $auth_module)
if ($module['name'] == $auth_module['name'])
$authorized = true;
if ($authorized)
$auth_modules[] = $module;
else
$unauth_modules[] = $module;
}
}
else
$auth_modules = $modules;
echo '
<br />
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(\'#addRestrictions\').click(function() {
return !$(\'#selectRestrictions1 option:selected\').remove().appendTo(\'#selectRestrictions2\');
});
$(\'#removeRestrictions\').click(function() {
return !$(\'#selectRestrictions2 option:selected\').remove().appendTo(\'#selectRestrictions1\');
});
$(\'#group\').submit(function() {
$(\'#selectRestrictions1 option\').each(function(i) {
$(this).attr("selected", "selected");
});
$(\'#selectRestrictions2 option\').each(function(i) {
$(this).attr("selected", "selected");
});
});
$(\'#restriction\').submit(function() {
$(\'#selectRestrictions1 option\').each(function(i) {
$(this).attr("selected", "selected");
});
$(\'#selectRestrictions2 option\').each(function(i) {
$(this).attr("selected", "selected");
});
});
$(\'#selectAll1\').click(function() {
if ($(\'#selectRestrictions1 option:selected\').size() != $(\'#selectRestrictions1 option\').size())
{
$(\'#selectRestrictions1 option\').attr(\'selected\', \'selected\');
$(this).text(\''.$this->l('Unselect All', get_class($this), false, false).'\');
}
else
{
$(\'#selectRestrictions1 option\').removeAttr(\'selected\');
$(this).text(\''.$this->l('Select All', get_class($this), false, false).'\');
}
return false;
});
$(\'#selectAll2\').click(function() {
if ($(\'#selectRestrictions2 option:selected\').size() != $(\'#selectRestrictions2 option\').size())
{
$(\'#selectRestrictions2 option\').attr(\'selected\', \'selected\');
$(this).text(\''.$this->l('Unselect All', get_class($this), false, false).'\');
}
else
{
$(\'#selectRestrictions2 option\').removeAttr(\'selected\');
$(this).text(\''.$this->l('Select All', get_class($this), false, false).'\');
}
return false;
});
});
</script>
<fieldset><legend><img src="../img/admin/access.png" />'.$this->l('Modules restrictions').'</legend>
<table class="margin-form">
<tr>
<td>
<p>'.$this->l('Unauthorized modules:').'</p>
<select multiple id="selectRestrictions1" name="unauthorized_modules[]" style="width:300px;height:160px;">';
foreach ($unauth_modules as $module)
{
$module = Module::getInstanceById($module['id_module']);
echo ' <option value="'.$module->name.'">'.Tools::htmlentitiesUTF8($module->displayName).'</option>';
}
echo ' </select><br /><br />
<a href="#" id="selectAll1" style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
'.$this->l('Select All').'
</a>
<a href="#" id="addRestrictions" style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
'.$this->l('Authorize').' &gt;&gt;
</a>
</td>
<td style="padding-left:20px;">
<p>'.$this->l('Authorized modules:').'</p>
<select multiple id="selectRestrictions2" name="authorized_modules[]" style="width:300px;height:160px;">';
foreach ($auth_modules as $module)
{
$module = Module::getInstanceById($module['id_module']);
echo ' <option value="'.$module->name.'">'.Tools::htmlentitiesUTF8($module->displayName).'</option>';
}
echo ' </select><br /><br />
<a href="#" id="selectAll2" style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
'.$this->l('Select All').'
</a>
<a href="#" id="removeRestrictions" style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
&lt;&lt; '.$this->l('Unauthorize').'
</a>
</div>
</td>
</tr>
</table>
<div class="clear">&nbsp;</div>
<div class="margin-form">
<input type="submit" name="submitRestrictions" id="submitRestrictions" value="'.$this->l('Update restrictions').'" class="button" />
</div>
</fieldset>';
}
public function viewgroup()
{
$this->context = Context::getContext();
@@ -334,6 +470,12 @@ class AdminGroups extends AdminTab
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
if (Tools::isSubmit('submitRestrictions'))
{
$this->updateRestrictions();
}
if (Tools::isSubmit('submitAddgroup'))
{
if ($this->tabAccess['add'] === '1')
@@ -359,7 +501,7 @@ class AdminGroups extends AdminTab
$this->_errors[] = Tools::displayError('Cannot update group reductions');
}
}
if (!sizeof($this->_errors))
if (!count($this->_errors))
parent::postProcess();
}
}
@@ -390,4 +532,19 @@ class AdminGroups extends AdminTab
else
parent::postProcess();
}
/**
* Update (or create) restrictions for modules by group
*/
protected function updateRestrictions()
{
$id_group = Tools::getValue('id_group');
$unauth_modules = Tools::getValue('unauthorized_modules');
$auth_modules = Tools::getValue('authorized_modules');
Group::truncateModulesRestrictions($id_group);
if (is_array($auth_modules))
Group::addModulesRestrictions($id_group, $auth_modules, 1);
if (is_array($unauth_modules))
Group::addModulesRestrictions($id_group, $unauth_modules, 0);
}
}
+512
View File
@@ -0,0 +1,512 @@
{*
* 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: 7471 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{*
** Compatibility code for Prestashop older than 1.4.2 using a recent theme
** Ignore list isn't require here
** $address exist in every PrestaShop version
*}
{* Will be deleted for 1.5 version and more *}
{* Smarty code compatibility v2 *}
{* If ordered_adr_fields doesn't exist, it's a PrestaShop older than 1.4.2 *}
{if !isset($dlv_all_fields)}
{$dlv_all_fields.0 = 'company'}
{$dlv_all_fields.1 = 'firstname'}
{$dlv_all_fields.2 = 'lastname'}
{$dlv_all_fields.3 = 'address1'}
{$dlv_all_fields.4 = 'address2'}
{$dlv_all_fields.5 = 'postcode'}
{$dlv_all_fields.6 = 'city'}
{$dlv_all_fields.7 = 'country'}
{$dlv_all_fields.8 = 'state'}
{/if}
{capture name=path}{l s='Login'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<script type="text/javascript">
// <![CDATA[
idSelectedCountry = {if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}false{/if};
countries = new Array();
countriesNeedIDNumber = new Array();
countriesNeedZipCode = new Array();
{if isset($countries)}
{foreach from=$countries item='country'}
{if isset($country.states) && $country.contains_states}
countries[{$country.id_country|intval}] = new Array();
{foreach from=$country.states item='state' name='states'}
countries[{$country.id_country|intval}].push({ldelim}'id' : '{$state.id_state}', 'name' : '{$state.name|escape:'htmlall':'UTF-8'}'{rdelim});
{/foreach}
{/if}
{if $country.need_identification_number}
countriesNeedIDNumber.push({$country.id_country|intval});
{/if}
{if isset($country.need_zip_code)}
countriesNeedZipCode[{$country.id_country|intval}] = {$country.need_zip_code};
{/if}
{/foreach}
{/if}
$(function(){ldelim}
$('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', 'selected');
{rdelim});
//]]>
{if $vat_management}
{literal}
$(document).ready(function() {
$('#company').blur(function(){
vat_number();
});
vat_number();
function vat_number()
{
if ($('#company').val() != '')
$('#vat_number').show();
else
$('#vat_number').hide();
}
});
{/literal}
{/if}
</script>
<h1>{if !isset($email_create)}{l s='Log in'}{else}{l s='Create your account'}{/if}</h1>
{assign var='current_step' value='login'}
{include file="$tpl_dir./order-steps.tpl"}
{include file="$tpl_dir./errors.tpl"}
{assign var='stateExist' value=false}
{if !isset($email_create)}
<form action="{$link->getPageLink('authentication', true)}" method="post" id="create-account_form" class="std">
<fieldset>
<h3>{l s='Create your account'}</h3>
<h4>{l s='Enter your e-mail address to create an account'}.</h4>
<p class="text">
<label for="email_create">{l s='E-mail address'}</label>
<span><input type="text" id="email_create" name="email_create" value="{if isset($smarty.post.email_create)}{$smarty.post.email_create|escape:'htmlall':'UTF-8'|stripslashes}{/if}" class="account_input" /></span>
</p>
<p class="submit">
{if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
<input type="submit" id="SubmitCreate" name="SubmitCreate" class="button_large" value="{l s='Create your account'}" />
<input type="hidden" class="hidden" name="SubmitCreate" value="{l s='Create your account'}" />
</p>
</fieldset>
</form>
<form action="{$link->getPageLink('authentication', true)}" method="post" id="login_form" class="std">
<fieldset>
<h3>{l s='Already registered ?'}</h3>
<p class="text">
<label for="email">{l s='E-mail address'}</label>
<span><input type="text" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email|escape:'htmlall':'UTF-8'|stripslashes}{/if}" class="account_input" /></span>
</p>
<p class="text">
<label for="passwd">{l s='Password'}</label>
<span><input type="password" id="passwd" name="passwd" value="{if isset($smarty.post.passwd)}{$smarty.post.passwd|escape:'htmlall':'UTF-8'|stripslashes}{/if}" class="account_input" /></span>
</p>
<p class="submit">
{if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
<input type="submit" id="SubmitLogin" name="SubmitLogin" class="button" value="{l s='Log in'}" />
</p>
<p class="lost_password"><a href="{$link->getPageLink('password')}">{l s='Forgot your password?'}</a></p>
</fieldset>
</form>
{if isset($inOrderProcess) && $inOrderProcess && $PS_GUEST_CHECKOUT_ENABLED}
<form action="{$link->getPageLink('authentication', true, NULL, "back=$back")}" method="post" id="new_account_form" class="std">
<fieldset>
<h3>{l s='Instant Checkout'}</h3>
<div id="opc_account_form" style="display: block; ">
<!-- Account -->
<p class="required text">
<label for="email">{l s='E-mail address'}</label>
<input type="text" class="text" id="guest_email" name="guest_email" value="{if isset($smarty.post.guest_email)}{$smarty.post.guest_email}{/if}">
<sup>*</sup>
</p>
<p class="radio required">
<span>{l s='Title'}</span>
{foreach from=$genders key=k item=gender}
<input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} />
<label for="id_gender{$gender->id}" class="top">{$gender->name}</label>
{/foreach}
</p>
<p class="required text">
<label for="firstname">{l s='First name'}</label>
<input type="text" class="text" id="firstname" name="firstname" onblur="$('#customer_firstname').val($(this).val());" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{/if}">
<input type="hidden" class="text" id="customer_firstname" name="customer_firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{/if}">
<sup>*</sup>
</p>
<p class="required text">
<label for="lastname">{l s='Last name'}</label>
<input type="text" class="text" id="lastname" name="lastname" onblur="$('#customer_lastname').val($(this).val());" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{/if}">
<input type="hidden" class="text" id="customer_lastname" name="customer_lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{/if}">
<sup>*</sup>
</p>
<p class="select">
<span>{l s='Date of Birth'}</span>
<select id="days" name="days">
<option value="">-</option>
{foreach from=$days item=day}
<option value="{$day|escape:'htmlall':'UTF-8'}" {if ($sl_day == $day)} selected="selected"{/if}>{$day|escape:'htmlall':'UTF-8'}&nbsp;&nbsp;</option>
{/foreach}
</select>
{*
{l s='January'}
{l s='February'}
{l s='March'}
{l s='April'}
{l s='May'}
{l s='June'}
{l s='July'}
{l s='August'}
{l s='September'}
{l s='October'}
{l s='November'}
{l s='December'}
*}
<select id="months" name="months">
<option value="">-</option>
{foreach from=$months key=k item=month}
<option value="{$k|escape:'htmlall':'UTF-8'}" {if ($sl_month == $k)} selected="selected"{/if}>{l s="$month"}&nbsp;</option>
{/foreach}
</select>
<select id="years" name="years">
<option value="">-</option>
{foreach from=$years item=year}
<option value="{$year|escape:'htmlall':'UTF-8'}" {if ($sl_year == $year)} selected="selected"{/if}>{$year|escape:'htmlall':'UTF-8'}&nbsp;&nbsp;</option>
{/foreach}
</select>
</p>
{if isset($newsletter) && $newsletter}
<p class="checkbox">
<input type="checkbox" name="newsletter" id="newsletter" value="1" {if isset($smarty.post.newsletter) && $smarty.post.newsletter == '1'}checked="checked"{/if}>
<label for="newsletter">{l s='Sign up for our newsletter'}</label>
</p>
<p class="checkbox">
<input type="checkbox" name="optin" id="optin" value="1" {if isset($smarty.post.optin) && $smarty.post.optin == '1'}checked="checked"{/if}>
<label for="optin">{l s='Receive special offers from our partners'}</label>
</p>
{/if}
<h3>{l s='Delivery address'}</h3>
{foreach from=$dlv_all_fields item=field_name}
{if $field_name eq "company"}
<p class="text">
<label for="company">{l s='Company'}</label>
<input type="text" class="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" />
</p>
{elseif $field_name eq "vat_number"}
<div id="vat_number" style="display:none;">
<p class="text">
<label for="vat_number">{l s='VAT number'}</label>
<input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{/if}" />
</p>
</div>
{elseif $field_name eq "address1"}
<p class="required text">
<label for="address1">{l s='Address'}</label>
<input type="text" class="text" name="address1" id="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{/if}">
<sup>*</sup>
</p>
{elseif $field_name eq "postcode"}
<p class="required postcode text">
<label for="postcode">{l s='Zip / Postal Code'}</label>
<input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onblur="$('#postcode').val($('#postcode').val().toUpperCase());">
<sup>*</sup>
</p>
{elseif $field_name eq "city"}
<p class="required text">
<label for="city">{l s='City'}</label>
<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}">
<sup>*</sup>
</p>
<!--
if customer hasn't update his layout address, country has to be verified
but it's deprecated
-->
{elseif $field_name eq "Country:name" || $field_name eq "country"}
<p class="required select">
<label for="id_country">{l s='Country'}</label>
<select name="id_country" id="id_country">
<option value="">-</option>
{foreach from=$countries item=v}
<option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
<sup>*</sup>
</p>
{elseif $field_name eq "State:name" || $field_name eq 'state'}
{assign var='stateExist' value=true}
<p class="required id_state select">
<label for="id_state">{l s='State'}</label>
<select name="id_state" id="id_state">
<option value="">-</option>
</select>
<sup>*</sup>
</p>
{elseif $field_name eq "phone"}
<p class="text">
<label for="phone">{l s='Phone'}</label>
<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}"> <sup style="color:red;">*</sup>
</p>
{/if}
{/foreach}
{if $stateExist eq false}
<p class="required id_state select">
<label for="id_state">{l s='State'}</label>
<select name="id_state" id="id_state">
<option value="">-</option>
</select>
<sup>*</sup>
</p>
{/if}
<input type="hidden" name="alias" id="alias" value="{l s='My address'}">
<input type="hidden" name="is_new_customer" id="is_new_customer" value="0">
<!-- END Account -->
</div>
</fieldset>
<fieldset class="account_creation dni">
<h3>{l s='Tax identification'}</h3>
<p class="required text">
<label for="dni">{l s='Identification number'}</label>
<input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{/if}" />
<span class="form_info">{l s='DNI / NIF / NIE'}</span>
<sup>*</sup>
</p>
</fieldset>
<p class="cart_navigation required submit">
<span><sup>*</sup>{l s='Required field'}</span>
<input type="submit" class="button" name="submitGuestAccount" id="submitGuestAccount" style="float:right" value="{l s='Continue'}">
</p>
</form>
{/if}
{else}
<form action="{$link->getPageLink('authentication', true)}" method="post" id="account-creation_form" class="std">
{$HOOK_CREATE_ACCOUNT_TOP}
<fieldset class="account_creation">
<h3>{l s='Your personal information'}</h3>
<p class="radio required">
<span>{l s='Title'}</span>
{foreach from=$genders key=k item=gender}
<input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} />
<label for="id_gender{$gender->id}" class="top">{$gender->name}</label>
{/foreach}
</p>
<p class="required text">
<label for="customer_firstname">{l s='First name'}</label>
<input onkeyup="$('#firstname').val(this.value);" type="text" class="text" id="customer_firstname" name="customer_firstname" value="{if isset($smarty.post.customer_firstname)}{$smarty.post.customer_firstname}{/if}" />
<sup>*</sup>
</p>
<p class="required text">
<label for="customer_lastname">{l s='Last name'}</label>
<input onkeyup="$('#lastname').val(this.value);" type="text" class="text" id="customer_lastname" name="customer_lastname" value="{if isset($smarty.post.customer_lastname)}{$smarty.post.customer_lastname}{/if}" />
<sup>*</sup>
</p>
<p class="required text">
<label for="email">{l s='E-mail'}</label>
<input type="text" class="text" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email}{/if}" />
<sup>*</sup>
</p>
<p class="required password">
<label for="passwd">{l s='Password'}</label>
<input type="password" class="text" name="passwd" id="passwd" />
<sup>*</sup>
<span class="form_info">{l s='(5 characters min.)'}</span>
</p>
<p class="select">
<span>{l s='Date of Birth'}</span>
<select id="days" name="days">
<option value="">-</option>
{foreach from=$days item=day}
<option value="{$day|escape:'htmlall':'UTF-8'}" {if ($sl_day == $day)} selected="selected"{/if}>{$day|escape:'htmlall':'UTF-8'}&nbsp;&nbsp;</option>
{/foreach}
</select>
{*
{l s='January'}
{l s='February'}
{l s='March'}
{l s='April'}
{l s='May'}
{l s='June'}
{l s='July'}
{l s='August'}
{l s='September'}
{l s='October'}
{l s='November'}
{l s='December'}
*}
<select id="months" name="months">
<option value="">-</option>
{foreach from=$months key=k item=month}
<option value="{$k|escape:'htmlall':'UTF-8'}" {if ($sl_month == $k)} selected="selected"{/if}>{l s="$month"}&nbsp;</option>
{/foreach}
</select>
<select id="years" name="years">
<option value="">-</option>
{foreach from=$years item=year}
<option value="{$year|escape:'htmlall':'UTF-8'}" {if ($sl_year == $year)} selected="selected"{/if}>{$year|escape:'htmlall':'UTF-8'}&nbsp;&nbsp;</option>
{/foreach}
</select>
</p>
{if isset($newsletter) && $newsletter}
<p class="checkbox" >
<input type="checkbox" name="newsletter" id="newsletter" value="1" {if isset($smarty.post.newsletter) AND $smarty.post.newsletter == 1} checked="checked"{/if} />
<label for="newsletter">{l s='Sign up for our newsletter'}</label>
</p>
<p class="checkbox" >
<input type="checkbox"name="optin" id="optin" value="1" {if isset($smarty.post.optin) AND $smarty.post.optin == 1} checked="checked"{/if} />
<label for="optin">{l s='Receive special offers from our partners'}</label>
</p>
{/if}
</fieldset>
{if isset($PS_REGISTRATION_PROCESS_TYPE) && $PS_REGISTRATION_PROCESS_TYPE}
<fieldset class="account_creation">
<h3>{l s='Your address'}</h3>
{foreach from=$dlv_all_fields item=field_name}
{if $field_name eq "company"}
<p class="text">
<label for="company">{l s='Company'}</label>
<input type="text" class="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" />
</p>
{elseif $field_name eq "vat_number"}
<div id="vat_number" style="display:none;">
<p class="text">
<label for="vat_number">{l s='VAT number'}</label>
<input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{/if}" />
</p>
</div>
{elseif $field_name eq "firstname"}
<p class="required text">
<label for="firstname">{l s='First name'}</label>
<input type="text" class="text" id="firstname" name="firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{/if}" />
<sup>*</sup>
</p>
{elseif $field_name eq "lastname"}
<p class="required text">
<label for="lastname">{l s='Last name'}</label>
<input type="text" class="text" id="lastname" name="lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{/if}" />
<sup>*</sup>
</p>
{elseif $field_name eq "address1"}
<p class="required text">
<label for="address1">{l s='Address'}</label>
<input type="text" class="text" name="address1" id="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{/if}" />
<sup>*</sup>
<span class="inline-infos">{l s='Street address, P.O. box, company name, c/o'}</span>
</p>
{elseif $field_name eq "address2"}
<p class="text">
<label for="address2">{l s='Address (Line 2)'}</label>
<input type="text" class="text" name="address2" id="address2" value="{if isset($smarty.post.address2)}{$smarty.post.address2}{/if}" />
<span class="inline-infos">{l s='Apartment, suite, unit, building, floor, etc.'}</span>
</p>
{elseif $field_name eq "postcode"}
<p class="required postcode text">
<label for="postcode">{l s='Zip / Postal Code'}</label>
<input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
<sup>*</sup>
</p>
{elseif $field_name eq "city"}
<p class="required text">
<label for="city">{l s='City'}</label>
<input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}" />
<sup>*</sup>
</p>
<!--
if customer hasn't update his layout address, country has to be verified
but it's deprecated
-->
{elseif $field_name eq "Country:name" || $field_name eq "country"}
<p class="required select">
<label for="id_country">{l s='Country'}</label>
<select name="id_country" id="id_country">
<option value="">-</option>
{foreach from=$countries item=v}
<option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
<sup>*</sup>
</p>
{elseif $field_name eq "State:name" || $field_name eq 'state'}
{assign var='stateExist' value=true}
<p class="required id_state select">
<label for="id_state">{l s='State'}</label>
<select name="id_state" id="id_state">
<option value="">-</option>
</select>
<sup>*</sup>
</p>
{/if}
{/foreach}
{if $stateExist eq false}
<p class="required id_state select">
<label for="id_state">{l s='State'}</label>
<select name="id_state" id="id_state">
<option value="">-</option>
</select>
<sup>*</sup>
</p>
{/if}
<p class="textarea">
<label for="other">{l s='Additional information'}</label>
<textarea name="other" id="other" cols="26" rows="3">{if isset($smarty.post.other)}{$smarty.post.other}{/if}</textarea>
</p>
<p style="margin-left:50px;">{l s='You must register at least one phone number'} <sup style="color:red;">*</sup></p>
<p class="text">
<label for="phone">{l s='Home phone'}</label>
<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
</p>
<p class="text">
<label for="phone_mobile">{l s='Mobile phone'}</label>
<input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{/if}" />
</p>
<p class="required text" id="address_alias">
<label for="alias">{l s='Assign an address title for future reference'} </label>
<input type="text" class="text" name="alias" id="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{else}{l s='My address'}{/if}" />
<sup>*</sup>
</p>
</fieldset>
<fieldset class="account_creation dni">
<h3>{l s='Tax identification'}</h3>
<p class="required text">
<label for="dni">{l s='Identification number'}</label>
<input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{/if}" />
<span class="form_info">{l s='DNI / NIF / NIE'}</span>
<sup>*</sup>
</p>
</fieldset>
{/if}
{$HOOK_CREATE_ACCOUNT_FORM}
<p class="cart_navigation required submit">
<input type="hidden" name="email_create" value="1" />
<input type="hidden" name="is_new_customer" value="1" />
{if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
<input type="submit" name="submitAccount" id="submitAccount" value="{l s='Register'}" class="exclusive" />
<span><sup>*</sup>{l s='Required field'}</span>
</p>
</form>
{/if}
+2
View File
@@ -304,6 +304,8 @@
'AdminHomeController' => 'override/controllers/admin/AdminHomeController.php',
'AdminRequestSqlControllerCore' => 'controllers/admin/AdminRequestSqlController.php',
'AdminRequestSqlController' => '',
'AdminSearchEnginesControllerCore' => 'controllers/admin/AdminSearchEnginesController.php',
'AdminSearchEnginesController' => '',
'AdminShopUrlControllerCore' => 'controllers/admin/AdminShopUrlController.php',
'AdminShopUrlController' => '',
'AdminStatesControllerCore' => 'controllers/admin/AdminStatesController.php',
+158 -155
View File
@@ -277,7 +277,7 @@ abstract class AdminTabCore
if ($this->includeSubTab('display', array('submitAdd2', 'add', 'update', 'view'))){}
// Include current tab
elseif ((Tools::getValue('submitAdd'.$this->table) AND sizeof($this->_errors)) OR isset($_GET['add'.$this->table]))
elseif ((Tools::getValue('submitAdd'.$this->table) && count($this->_errors)) || isset($_GET['add'.$this->table]))
{
if ($this->tabAccess['add'] === '1')
{
@@ -290,7 +290,7 @@ abstract class AdminTabCore
}
elseif (isset($_GET['update'.$this->table]))
{
if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee')))
if ($this->tabAccess['edit'] === '1' || ($this->table == 'employee' && $this->context->employee->id == Tools::getValue('id_employee')))
{
$this->displayForm();
if ($this->tabAccess['view'])
@@ -315,11 +315,11 @@ abstract class AdminTabCore
public function displayRequiredFields()
{
if (!$this->tabAccess['add'] OR !$this->tabAccess['delete'] === '1' OR !$this->requiredDatabase)
if (!$this->tabAccess['add'] || !$this->tabAccess['delete'] === '1' || !$this->requiredDatabase)
return;
$rules = call_user_func_array(array($this->className, 'getValidationRules'), array($this->className));
$required_class_fields = array($this->identifier);
foreach ($rules['required'] AS $required)
foreach ($rules['required'] as $required)
$required_class_fields[] = $required;
echo '<br />
@@ -338,13 +338,13 @@ abstract class AdminTabCore
$res = $object->getFieldsRequiredDatabase();
$required_fields = array();
foreach ($res AS $row)
foreach ($res as $row)
$required_fields[(int)$row['id_required_field']] = $row['field_name'];
$table_fields = Db::getInstance()->ExecuteS('SHOW COLUMNS FROM '.pSQL(_DB_PREFIX_.$this->table));
$irow = 0;
foreach ($table_fields AS $field)
foreach ($table_fields as $field)
{
if (in_array($field['Field'], $required_class_fields))
continue;
@@ -360,7 +360,7 @@ abstract class AdminTabCore
public function includeSubTab($methodname, $actions = array())
{
if (!isset($this->_includeTab) OR !is_array($this->_includeTab))
if (!isset($this->_includeTab) || !is_array($this->_includeTab))
return false;
$key = 0;
$inc = false;
@@ -368,7 +368,7 @@ abstract class AdminTabCore
{
/* New tab loading */
$classname = 'Admin'.$subtab;
if ($module = Db::getInstance()->getValue('SELECT `module` FROM `'._DB_PREFIX_.'tab` WHERE `class_name` = \''.pSQL($classname).'\'') AND file_exists(_PS_MODULE_DIR_.'/'.$module.'/'.$classname.'.php'))
if ($module = Db::getInstance()->getValue('SELECT `module` FROM `'._DB_PREFIX_.'tab` WHERE `class_name` = \''.pSQL($classname).'\'') && file_exists(_PS_MODULE_DIR_.'/'.$module.'/'.$classname.'.php'))
include_once(_PS_MODULE_DIR_.'/'.$module.'/'.$classname.'.php');
elseif (file_exists(_PS_ADMIN_DIR_.'/tabs/'.$classname.'.php'))
include_once('tabs/'.$classname.'.php');
@@ -378,8 +378,8 @@ abstract class AdminTabCore
$adminTab->token = $this->token;
/* Extra variables addition */
if (!empty($extraVars) AND is_array($extraVars))
foreach ($extraVars AS $varKey => $varValue)
if (!empty($extraVars) && is_array($extraVars))
foreach ($extraVars as $varKey => $varValue)
$adminTab->$varKey = $varValue;
/* Actions management */
@@ -393,7 +393,7 @@ abstract class AdminTabCore
$ok_inc = true;
break;
case 'submitAdd2':
if (Tools::getValue('submitAdd'.$adminTab->table) AND sizeof($adminTab->_errors))
if (Tools::getValue('submitAdd'.$adminTab->table) && count($adminTab->_errors))
$ok_inc = true;
break;
case 'submitDel':
@@ -412,18 +412,18 @@ abstract class AdminTabCore
}
}
$inc = false;
if ((isset($ok_inc) AND $ok_inc) OR !sizeof($actions))
if ((isset($ok_inc) && $ok_inc) || !count($actions))
{
if (!$adminTab->viewAccess())
{
echo Tools::displayError('Access denied');
return false;
}
if (!sizeof($actions))
if (($methodname == 'displayErrors' AND sizeof($adminTab->_errors)) OR $methodname != 'displayErrors')
if (!count($actions))
if (($methodname == 'displayErrors' && count($adminTab->_errors)) || $methodname != 'displayErrors')
echo (isset($this->_includeTabTitle[$key]) ? '<h2>'.$this->_includeTabTitle[$key].'</h2>' : '');
if ($adminTab->_includeVars)
foreach ($adminTab->_includeVars AS $var => $value)
foreach ($adminTab->_includeVars as $var => $value)
$adminTab->$var = $this->$value;
$adminTab->$methodname();
$inc = true;
@@ -446,7 +446,7 @@ abstract class AdminTabCore
/* Class specific validation rules */
$rules = call_user_func(array($className, 'getValidationRules'), $className);
if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang'])))
if ((count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
{
/* Language() instance determined by default language */
$defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
@@ -456,49 +456,49 @@ abstract class AdminTabCore
}
/* Checking for required fields */
foreach ($rules['required'] AS $field)
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
if (!Tools::getValue($this->identifier) OR ($field != 'passwd' AND $field != 'no-picture'))
foreach ($rules['required'] as $field)
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is required');
/* Checking for multilingual required fields */
foreach ($rules['requiredLang'] AS $fieldLang)
if (($empty = Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) === false OR $empty !== '0' AND empty($empty))
foreach ($rules['requiredLang'] as $fieldLang)
if (($empty = Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) === false || $empty !== '0' && empty($empty))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).'</b> '.$this->l('is required at least in').' '.$defaultLanguage->name;
/* Checking for maximum fields sizes */
foreach ($rules['size'] AS $field => $maxLength)
if (Tools::getValue($field) !== false AND Tools::strlen(Tools::getValue($field)) > $maxLength)
foreach ($rules['size'] as $field => $maxLength)
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $maxLength)
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is too long').' ('.$maxLength.' '.$this->l('chars max').')';
/* Checking for maximum multilingual fields size */
foreach ($rules['sizeLang'] AS $fieldLang => $maxLength)
foreach ($languages AS $language)
if (Tools::getValue($fieldLang.'_'.$language['id_lang']) !== false AND Tools::strlen(Tools::getValue($fieldLang.'_'.$language['id_lang'])) > $maxLength)
foreach ($rules['sizeLang'] as $fieldLang => $maxLength)
foreach ($languages as $language)
if (Tools::getValue($fieldLang.'_'.$language['id_lang']) !== false && Tools::strlen(Tools::getValue($fieldLang.'_'.$language['id_lang'])) > $maxLength)
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' ('.$language['name'].')</b> '.$this->l('is too long').' ('.$maxLength.' '.$this->l('chars max, html chars including').')';
/* Overload this method for custom checking */
$this->_childValidation();
/* Checking for fields validity */
foreach ($rules['validate'] AS $field => $function)
if (($value = Tools::getValue($field)) !== false AND ($field != 'passwd'))
foreach ($rules['validate'] as $field => $function)
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
if (!Validate::$function($value))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is invalid');
/* Checking for passwd_old validity */
if (($value = Tools::getValue('passwd')) != false)
{
if ($className == 'Employee' AND !Validate::isPasswdAdmin($value))
if ($className == 'Employee' && !Validate::isPasswdAdmin($value))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), 'passwd', $className).'</b> '.$this->l('is invalid');
elseif ($className == 'Customer' AND !Validate::isPasswd($value))
elseif ($className == 'Customer' && !Validate::isPasswd($value))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), 'passwd', $className).'</b> '.$this->l('is invalid');
}
/* Checking for multilingual fields validity */
foreach ($rules['validateLang'] AS $fieldLang => $function)
foreach ($languages AS $language)
if (($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])) !== false AND !empty($value))
foreach ($rules['validateLang'] as $fieldLang => $function)
foreach ($languages as $language)
if (($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])) !== false && !empty($value))
if (!Validate::$function($value))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).' ('.$language['name'].')</b> '.$this->l('is invalid');
}
@@ -522,16 +522,16 @@ abstract class AdminTabCore
if (key_exists('dir', $this->fieldImageSettings))
{
$dir = $this->fieldImageSettings['dir'].'/';
if (file_exists(_PS_IMG_DIR_.$dir.$id.'.'.$this->imageType) AND !unlink(_PS_IMG_DIR_.$dir.$id.'.'.$this->imageType))
if (file_exists(_PS_IMG_DIR_.$dir.$id.'.'.$this->imageType) && !unlink(_PS_IMG_DIR_.$dir.$id.'.'.$this->imageType))
return false;
}
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_'.$id.'.'.$this->imageType) AND !unlink(_PS_TMP_IMG_DIR_.$this->table.'_'.$id.'.'.$this->imageType))
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_'.$id.'.'.$this->imageType) && !unlink(_PS_TMP_IMG_DIR_.$this->table.'_'.$id.'.'.$this->imageType))
return false;
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$id.'.'.$this->imageType) AND !unlink(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$id.'.'.$this->imageType))
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$id.'.'.$this->imageType) && !unlink(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$id.'.'.$this->imageType))
return false;
$types = ImageType::getImagesTypes();
foreach ($types AS $imageType)
if (file_exists(_PS_IMG_DIR_.$dir.$id.'-'.stripslashes($imageType['name']).'.'.$this->imageType) AND !unlink(_PS_IMG_DIR_.$dir.$id.'-'.stripslashes($imageType['name']).'.'.$this->imageType))
foreach ($types as $imageType)
if (file_exists(_PS_IMG_DIR_.$dir.$id.'-'.stripslashes($imageType['name']).'.'.$this->imageType) && !unlink(_PS_IMG_DIR_.$dir.$id.'-'.stripslashes($imageType['name']).'.'.$this->imageType))
return false;
return true;
}
@@ -581,10 +581,10 @@ abstract class AdminTabCore
{
if ($this->tabAccess['delete'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings))
if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings))
{
// check if request at least one object with noZeroObject
if (isset($object->noZeroObject) AND sizeof(call_user_func(array($this->className, $object->noZeroObject))) <= 1)
if (isset($object->noZeroObject) && count(call_user_func(array($this->className, $object->noZeroObject))) <= 1)
$this->_errors[] = Tools::displayError('You need at least one object.').' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.');
else
{
@@ -612,14 +612,14 @@ abstract class AdminTabCore
}
/* Change object statuts (active, inactive) */
elseif ((isset($_GET['status'.$this->table]) OR isset($_GET['status'])) AND Tools::getValue($this->identifier))
elseif ((isset($_GET['status'.$this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()))
{
if ($object->toggleStatus())
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token);
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token);
else
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
}
@@ -640,7 +640,7 @@ abstract class AdminTabCore
$this->_errors[] = Tools::displayError('Failed to update the position.');
else
Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.$token);
Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token);
Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$token);
}
/* Delete multiple objects */
elseif (Tools::getValue('submitDel'.$this->table))
@@ -650,9 +650,9 @@ abstract class AdminTabCore
if (isset($_POST[$this->table.'Box']))
{
$object = new $this->className();
if (isset($object->noZeroObject) AND
if (isset($object->noZeroObject) &&
// Check if all object will be deleted
(sizeof(call_user_func(array($this->className, $object->noZeroObject))) <= 1 OR sizeof($_POST[$this->table.'Box']) == sizeof(call_user_func(array($this->className, $object->noZeroObject)))))
(count(call_user_func(array($this->className, $object->noZeroObject))) <= 1 || count($_POST[$this->table.'Box']) == count(call_user_func(array($this->className, $object->noZeroObject)))))
$this->_errors[] = Tools::displayError('You need at least one object.').' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.');
else
{
@@ -663,7 +663,7 @@ abstract class AdminTabCore
{
$toDelete = new $this->className($id);
$toDelete->deleted = 1;
$result = $result AND $toDelete->update();
$result = $result && $toDelete->update();
}
}
else
@@ -686,20 +686,20 @@ abstract class AdminTabCore
{
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
if (!count($this->_errors))
{
$id = (int)(Tools::getValue($this->identifier));
/* Object update */
if (isset($id) AND !empty($id))
if (isset($id) && !empty($id))
{
if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee') AND Tools::isSubmit('updateemployee')))
if ($this->tabAccess['edit'] === '1' || ($this->table == 'employee' && $this->context->employee->id == Tools::getValue('id_employee') && Tools::isSubmit('updateemployee')))
{
$object = new $this->className($id);
if (Validate::isLoadedObject($object))
{
/* Specific to objects which must not be deleted */
if ($this->deleted AND $this->beforeDelete($object))
if ($this->deleted && $this->beforeDelete($object))
{
// Create new one with old objet values
$objectNew = new $this->className($object->id);
@@ -729,8 +729,10 @@ abstract class AdminTabCore
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
elseif ($this->postImage($object->id) AND !sizeof($this->_errors))
elseif ($this->postImage($object->id) && !count($this->_errors))
{
if ($this->table == 'group')
$this->updateRestrictions($object->id);
$parent_id = (int)(Tools::getValue('id_parent', 1));
// Specific back redirect
if ($back = Tools::getValue('back'))
@@ -762,14 +764,15 @@ abstract class AdminTabCore
{
$object = new $this->className();
$this->copyFromPost($object, $this->table);
// d($object);
if (!$object->add())
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND !sizeof($this->_errors) AND $this->_redirect)
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) && $this->postImage($object->id) && !count($this->_errors) && $this->_redirect)
{
$parent_id = (int)(Tools::getValue('id_parent', 1));
$this->afterAdd($object);
$this->updateAssoShop($object->id);
if ($this->table == 'group')
$this->updateRestrictions($object->id);
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token);
@@ -791,7 +794,7 @@ abstract class AdminTabCore
elseif (isset($_POST['submitReset'.$this->table]))
{
$filters = $this->context->cookie->getFamily($this->table.'Filter_');
foreach ($filters AS $cookieKey => $filter)
foreach ($filters as $cookieKey => $filter)
if (strncmp($cookieKey, $this->table.'Filter_', 7 + Tools::strlen($this->table)) == 0)
{
$key = substr($cookieKey, 7 + Tools::strlen($this->table));
@@ -817,13 +820,13 @@ abstract class AdminTabCore
}
/* Manage list filtering */
elseif (Tools::isSubmit('submitFilter'.$this->table) OR $this->context->cookie->{'submitFilter'.$this->table} !== false)
elseif (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
{
$_POST = array_merge($this->context->cookie->getFamily($this->table.'Filter_'), (isset($_POST) ? $_POST : array()));
foreach ($_POST AS $key => $value)
foreach ($_POST as $key => $value)
{
/* Extracting filters from $_POST on key filter_ */
if ($value != NULL AND !strncmp($key, $this->table.'Filter_', 7 + Tools::strlen($this->table)))
if ($value != NULL && !strncmp($key, $this->table.'Filter_', 7 + Tools::strlen($this->table)))
{
$key = Tools::substr($key, 7 + Tools::strlen($this->table));
/* Table alias could be specified using a ! eg. alias!field */
@@ -832,7 +835,7 @@ abstract class AdminTabCore
if ($field = $this->filterToField($key, $filter))
{
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
if (($type == 'date' OR $type == 'datetime') AND is_string($value))
if (($type == 'date' || $type == 'datetime') && is_string($value))
$value = unserialize($value);
$key = isset($tmpTab[1]) ? $tmpTab[0].'.`'.bqSQL($tmpTab[1]).'`' : '`'.bqSQL($tmpTab[0]).'`';
if (array_key_exists('tmpTableFilter', $field))
@@ -845,7 +848,7 @@ abstract class AdminTabCore
/* Only for date filtering (from, to) */
if (is_array($value))
{
if (isset($value[0]) AND !empty($value[0]))
if (isset($value[0]) && !empty($value[0]))
{
if (!Validate::isDate($value[0]))
$this->_errors[] = Tools::displayError('\'from:\' date format is invalid (YYYY-MM-DD)');
@@ -853,7 +856,7 @@ abstract class AdminTabCore
$sqlFilter .= ' AND '.$key.' >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
}
if (isset($value[1]) AND !empty($value[1]))
if (isset($value[1]) && !empty($value[1]))
{
if (!Validate::isDate($value[1]))
$this->_errors[] = Tools::displayError('\'to:\' date format is invalid (YYYY-MM-DD)');
@@ -864,20 +867,20 @@ abstract class AdminTabCore
else
{
$sqlFilter .= ' AND ';
if ($type == 'int' OR $type == 'bool')
$sqlFilter .= (($key == $this->identifier OR $key == '`'.$this->identifier.'`' OR $key == '`active`') ? 'a.' : '').pSQL($key).' = '.(int)($value).' ';
if ($type == 'int' || $type == 'bool')
$sqlFilter .= (($key == $this->identifier || $key == '`'.$this->identifier.'`' || $key == '`active`') ? 'a.' : '').pSQL($key).' = '.(int)($value).' ';
elseif ($type == 'decimal')
$sqlFilter .= (($key == $this->identifier OR $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' = '.(float)($value).' ';
$sqlFilter .= (($key == $this->identifier || $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' = '.(float)($value).' ';
elseif ($type == 'select')
$sqlFilter .= (($key == $this->identifier OR $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' = \''.pSQL($value).'\' ';
$sqlFilter .= (($key == $this->identifier || $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' = \''.pSQL($value).'\' ';
else
$sqlFilter .= (($key == $this->identifier OR $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' LIKE \'%'.pSQL($value).'%\' ';
$sqlFilter .= (($key == $this->identifier || $key == '`'.$this->identifier.'`') ? 'a.' : '').pSQL($key).' LIKE \'%'.pSQL($value).'%\' ';
}
}
}
}
}
elseif(Tools::isSubmit('submitFields') AND $this->requiredDatabase AND $this->tabAccess['add'] === '1' AND $this->tabAccess['delete'] === '1')
elseif(Tools::isSubmit('submitFields') && $this->requiredDatabase && $this->tabAccess['add'] === '1' && $this->tabAccess['delete'] === '1')
{
if (!is_array($fields = Tools::getValue('fieldsBox')))
$fields = array();
@@ -905,7 +908,7 @@ abstract class AdminTabCore
return ;
$assos = array();
foreach ($_POST AS $k => $row)
foreach ($_POST as $k => $row)
{
if (!preg_match('/^checkBox'.Tools::toCamelCase($type, true).'Asso_'.$this->table.'_([0-9]+)?_([0-9]+)$/Ui', $k, $res))
continue;
@@ -914,7 +917,7 @@ abstract class AdminTabCore
}
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.$this->table.'_'.$type.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : ''));
foreach ($assos AS $asso)
foreach ($assos as $asso)
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.$this->table.'_'.$type.' (`'.pSQL($this->identifier).'`, id_'.$type.')
VALUES('.(int)$asso['id_object'].', '.(int)$asso['id_'.$type].')');
}
@@ -936,36 +939,36 @@ abstract class AdminTabCore
$fields = $categoryData['fields'];
/* Check required fields */
foreach ($fields AS $field => $values)
if (isset($values['required']) AND $values['required'] && !isset($_POST['configUseDefault'][$field]))
if (isset($values['type']) AND $values['type'] == 'textLang')
foreach ($fields as $field => $values)
if (isset($values['required']) && $values['required'] && !isset($_POST['configUseDefault'][$field]))
if (isset($values['type']) && $values['type'] == 'textLang')
{
foreach ($languages as $language)
if (($value = Tools::getValue($field.'_'.$language['id_lang'])) == false AND (string)$value != '0')
if (($value = Tools::getValue($field.'_'.$language['id_lang'])) == false && (string)$value != '0')
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
}
elseif (($value = Tools::getValue($field)) == false AND (string)$value != '0')
elseif (($value = Tools::getValue($field)) == false && (string)$value != '0')
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
/* Check fields validity */
foreach ($fields AS $field => $values)
if (isset($values['type']) AND $values['type'] == 'textLang')
foreach ($fields as $field => $values)
if (isset($values['type']) && $values['type'] == 'textLang')
{
foreach ($languages as $language)
if (Tools::getValue($field.'_'.$language['id_lang']) AND isset($values['validation']))
if (Tools::getValue($field.'_'.$language['id_lang']) && isset($values['validation']))
if (!Validate::$values['validation'](Tools::getValue($field.'_'.$language['id_lang'])))
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is invalid.');
}
elseif (Tools::getValue($field) AND isset($values['validation']))
elseif (Tools::getValue($field) && isset($values['validation']))
if (!Validate::$values['validation'](Tools::getValue($field)))
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is invalid.');
/* Default value if null */
foreach ($fields AS $field => $values)
if (!Tools::getValue($field) AND isset($values['default']))
foreach ($fields as $field => $values)
if (!Tools::getValue($field) && isset($values['default']))
$_POST[$field] = $values['default'];
if (1||!sizeof($this->_errors))
if (1||!count($this->_errors))
{
foreach ($fields as $key => $options)
{
@@ -1046,7 +1049,7 @@ abstract class AdminTabCore
protected function uploadImage($id, $name, $dir, $ext = false, $width = NULL, $height = NULL)
{
if (isset($_FILES[$name]['tmp_name']) AND !empty($_FILES[$name]['tmp_name']))
if (isset($_FILES[$name]['tmp_name']) && !empty($_FILES[$name]['tmp_name']))
{
// Delete old image
if (Validate::isLoadedObject($object = $this->loadObject()))
@@ -1059,7 +1062,7 @@ abstract class AdminTabCore
$max_size = isset($this->maxImageSize) ? $this->maxImageSize : 0;
if ($error = checkImage($_FILES[$name], Tools::getMaxUploadSize($max_size)))
$this->_errors[] = $error;
elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES[$name]['tmp_name'], $tmpName))
elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES[$name]['tmp_name'], $tmpName))
return false;
else
{
@@ -1067,7 +1070,7 @@ abstract class AdminTabCore
// Copy new image
if (!imageResize($tmpName, _PS_IMG_DIR_.$dir.$id.'.'.$this->imageType, (int)$width, (int)$height, ($ext ? $ext : $this->imageType)))
$this->_errors[] = Tools::displayError('An error occurred while uploading image.');
if (sizeof($this->_errors))
if (count($this->_errors))
return false;
if ($this->afterImageUpload())
{
@@ -1085,7 +1088,7 @@ abstract class AdminTabCore
protected function uploadIco($name, $dest)
{
if (isset($_FILES[$name]['tmp_name']) AND !empty($_FILES[$name]['tmp_name']))
if (isset($_FILES[$name]['tmp_name']) && !empty($_FILES[$name]['tmp_name']))
{
/* Check ico validity */
if ($error = checkIco($_FILES[$name]))
@@ -1095,7 +1098,7 @@ abstract class AdminTabCore
elseif(!copy($_FILES[$name]['tmp_name'], $dest))
$this->_errors[] = Tools::displayError('an error occurred while uploading favicon: '.$_FILES[$name]['tmp_name'].' to '.$dest);
}
return !sizeof($this->_errors) ? true : false;
return !count($this->_errors) ? true : false;
}
/**
@@ -1106,13 +1109,13 @@ abstract class AdminTabCore
*/
protected function postImage($id)
{
if (isset($this->fieldImageSettings['name']) AND isset($this->fieldImageSettings['dir']))
if (isset($this->fieldImageSettings['name']) && isset($this->fieldImageSettings['dir']))
return $this->uploadImage($id, $this->fieldImageSettings['name'], $this->fieldImageSettings['dir'].'/');
elseif (!empty($this->fieldImageSettings))
foreach ($this->fieldImageSettings AS $image)
if (isset($image['name']) AND isset($image['dir']))
foreach ($this->fieldImageSettings as $image)
if (isset($image['name']) && isset($image['dir']))
$this->uploadImage($id, $image['name'], $image['dir'].'/');
return !sizeof($this->_errors) ? true : false;
return !count($this->_errors) ? true : false;
}
/**
@@ -1124,25 +1127,25 @@ abstract class AdminTabCore
protected function copyFromPost(&$object, $table)
{
/* Classical fields */
foreach ($_POST AS $key => $value)
if (key_exists($key, $object) AND $key != 'id_'.$table)
foreach ($_POST as $key => $value)
if (key_exists($key, $object) && $key != 'id_'.$table)
{
/* Do not take care of password field if empty */
if ($key == 'passwd' AND Tools::getValue('id_'.$table) AND empty($value))
if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value))
continue;
/* Automatically encrypt password in MD5 */
if ($key == 'passwd' AND !empty($value))
if ($key == 'passwd' && !empty($value))
$value = Tools::encrypt($value);
$object->{$key} = $value;
}
/* Multilingual fields */
$rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object));
if (sizeof($rules['validateLang']))
if (count($rules['validateLang']))
{
$languages = Language::getLanguages(false);
foreach ($languages AS $language)
foreach (array_keys($rules['validateLang']) AS $field)
foreach ($languages as $language)
foreach (array_keys($rules['validateLang']) as $field)
if (isset($_POST[$field.'_'.(int)($language['id_lang'])]))
$object->{$field}[(int)($language['id_lang'])] = $_POST[$field.'_'.(int)($language['id_lang'])];
}
@@ -1153,7 +1156,7 @@ abstract class AdminTabCore
*/
public function displayErrors()
{
if ($nbErrors = count($this->_errors) AND $this->_includeContainer)
if ($nbErrors = count($this->_errors) && $this->_includeContainer)
{
echo '<script type="text/javascript">
$(document).ready(function() {
@@ -1171,7 +1174,7 @@ abstract class AdminTabCore
else
{
echo $nbErrors.' '.$this->l('errors').'<br /><ol>';
foreach ($this->_errors AS $error)
foreach ($this->_errors as $error)
echo '<li>'.$error.'</li>';
echo '</ol>';
}
@@ -1269,8 +1272,8 @@ abstract class AdminTabCore
$this->context->cookie->{$this->table.'_pagination'} = $limit;
/* Check params validity */
if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)
OR !is_numeric($start) OR !is_numeric($limit)
if (!Validate::isOrderBy($orderBy) || !Validate::isOrderWay($orderWay)
OR !is_numeric($start) || !is_numeric($limit)
OR !Validate::isUnsignedId($id_lang))
die(Tools::displayError('get list params is not valid'));
@@ -1309,7 +1312,7 @@ abstract class AdminTabCore
else if (Context::shop() == Shop::CONTEXT_GROUP)
{
$assos = GroupShop::getAssoTables();
if (isset($assos[$this->table]) AND $assos[$this->table]['type'] == 'group_shop')
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
{
$filterKey = $assos[$this->table]['type'];
$idenfierShop = array($this->context->shop->getGroupID());
@@ -1360,9 +1363,9 @@ abstract class AdminTabCore
*/
public function displayImage($id, $image, $size, $id_image = NULL, $token = NULL, $disableCache = false)
{
if (!isset($token) OR empty($token))
if (!isset($token) || empty($token))
$token = $this->token;
if ($id AND file_exists($image))
if ($id && file_exists($image))
echo '
<div id="image" >
'.cacheImage($image, $this->table.'_'.(int)($id).'.'.$this->imageType, $size, $this->imageType, $disableCache).'
@@ -1382,7 +1385,7 @@ abstract class AdminTabCore
$isCms = true;
$id_cat = Tools::getValue('id_'.($isCms ? 'cms_' : '').'category');
if (!isset($token) OR empty($token))
if (!isset($token) || empty($token))
$token = $this->token;
/* Determine total page number */
@@ -1419,7 +1422,7 @@ abstract class AdminTabCore
<select name="pagination">';
/* Choose number of results per page */
$selectedPagination = Tools::getValue('pagination', (isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : NULL));
foreach ($this->_pagination AS $value)
foreach ($this->_pagination as $value)
echo '<option value="'.(int)($value).'"'.($selectedPagination == $value ? ' selected="selected"' : (($selectedPagination == NULL && $value == $this->_pagination[1]) ? ' selected="selected2"' : '')).'>'.(int)($value).'</option>';
echo '
</select>
@@ -1436,7 +1439,7 @@ abstract class AdminTabCore
<td>';
/* Display column names and arrows for ordering (ASC, DESC) */
if (array_key_exists($this->identifier,$this->identifiersDnd) AND $this->_orderBy == 'position')
if (array_key_exists($this->identifier,$this->identifiersDnd) && $this->_orderBy == 'position')
{
echo '
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
@@ -1448,24 +1451,24 @@ abstract class AdminTabCore
<script type="text/javascript" src="../js/admin-dnd.js"></script>
';
}
echo '<table'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
echo '<table'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) && ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
<thead>
<tr class="nodrag nodrop">
<th>';
if ($this->delete)
echo ' <input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \''.$this->table.'Box[]\', this.checked)" />';
echo ' </th>';
foreach ($this->fieldsDisplay AS $key => $params)
foreach ($this->fieldsDisplay as $key => $params)
{
echo ' <th '.(isset($params['widthColumn']) ? 'style="width: '.$params['widthColumn'].'px"' : '').'>'.$params['title'];
if (!isset($params['orderby']) OR $params['orderby'])
if (!isset($params['orderby']) || $params['orderby'])
{
// Cleaning links
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
self::$currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', self::$currentIndex);
echo ' <br />
<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id_cat.'&'.$this->table.'Orderby='.urlencode($key).'&'.$this->table.'Orderway=desc&token='.$token.'"><img border="0" src="../img/admin/down'.((isset($this->_orderBy) AND ($key == $this->_orderBy) AND ($this->_orderWay == 'DESC')) ? '_d' : '').'.gif" /></a>
<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id_cat.'&'.$this->table.'Orderby='.urlencode($key).'&'.$this->table.'Orderway=asc&token='.$token.'"><img border="0" src="../img/admin/up'.((isset($this->_orderBy) AND ($key == $this->_orderBy) AND ($this->_orderWay == 'ASC')) ? '_d' : '').'.gif" /></a>';
<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id_cat.'&'.$this->table.'Orderby='.urlencode($key).'&'.$this->table.'Orderway=desc&token='.$token.'"><img border="0" src="../img/admin/down'.((isset($this->_orderBy) && ($key == $this->_orderBy) && ($this->_orderWay == 'DESC')) ? '_d' : '').'.gif" /></a>
<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id_cat.'&'.$this->table.'Orderby='.urlencode($key).'&'.$this->table.'Orderway=asc&token='.$token.'"><img border="0" src="../img/admin/up'.((isset($this->_orderBy) && ($key == $this->_orderBy) && ($this->_orderWay == 'ASC')) ? '_d' : '').'.gif" /></a>';
}
echo ' </th>';
}
@@ -1476,7 +1479,7 @@ abstract class AdminTabCore
}
/* Check if object can be modified, deleted or detailed */
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
if ($this->edit || $this->delete || ($this->view && $this->view !== 'noActionColumn'))
echo ' <th style="width: 52px">'.$this->l('Actions').'</th>';
echo ' </tr>
<tr class="nodrag nodrop" style="height: 35px;">
@@ -1489,7 +1492,7 @@ abstract class AdminTabCore
$keyPress = 'onkeypress="formSubmit(event, \'submitFilterButton_'.$this->table.'\');"';
/* Filters (input, select, date or bool) */
foreach ($this->fieldsDisplay AS $key => $params)
foreach ($this->fieldsDisplay as $key => $params)
{
$width = (isset($params['width']) ? ' style="width: '.(int)($params['width']).'px;"' : '');
echo '<td'.(isset($params['align']) ? ' class="'.$params['align'].'"' : '').'>';
@@ -1497,7 +1500,7 @@ abstract class AdminTabCore
$params['type'] = 'text';
$value = Tools::getValue($this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key));
if (isset($params['search']) AND !$params['search'])
if (isset($params['search']) && !$params['search'])
{
echo '--</td>';
continue;
@@ -1509,7 +1512,7 @@ abstract class AdminTabCore
<select name="'.$this->table.'Filter_'.$key.'">
<option value="">--</option>
<option value="1"'.($value == 1 ? ' selected="selected"' : '').'>'.$this->l('Yes').'</option>
<option value="0"'.(($value == 0 AND $value != '') ? ' selected="selected"' : '').'>'.$this->l('No').'</option>
<option value="0"'.(($value == 0 && $value != '') ? ' selected="selected"' : '').'>'.$this->l('No').'</option>
</select>';
break;
@@ -1517,7 +1520,7 @@ abstract class AdminTabCore
case 'datetime':
if (is_string($value))
$value = unserialize($value);
if (!Validate::isCleanHtml($value[0]) OR !Validate::isCleanHtml($value[1]))
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1]))
$value = '';
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
$nameId = str_replace('!', '__', $name);
@@ -1531,11 +1534,11 @@ abstract class AdminTabCore
if (isset($params['filter_key']))
{
echo '<select onchange="$(\'#submitFilter'.$this->table.'\').focus();$(\'#submitFilter'.$this->table.'\').click();" name="'.$this->table.'Filter_'.$params['filter_key'].'" '.(isset($params['width']) ? 'style="width: '.$params['width'].'px"' : '').'>
<option value=""'.(($value == 0 AND $value != '') ? ' selected="selected"' : '').'>--</option>';
if (isset($params['select']) AND is_array($params['select']))
foreach ($params['select'] AS $optionValue => $optionDisplay)
<option value=""'.(($value == 0 && $value != '') ? ' selected="selected"' : '').'>--</option>';
if (isset($params['select']) && is_array($params['select']))
foreach ($params['select'] as $optionValue => $optionDisplay)
{
echo '<option value="'.$optionValue.'"'.((isset($_POST[$this->table.'Filter_'.$params['filter_key']]) AND Tools::getValue($this->table.'Filter_'.$params['filter_key']) == $optionValue AND Tools::getValue($this->table.'Filter_'.$params['filter_key']) != '') ? ' selected="selected"' : '').'>'.$optionDisplay.'</option>';
echo '<option value="'.$optionValue.'"'.((isset($_POST[$this->table.'Filter_'.$params['filter_key']]) && Tools::getValue($this->table.'Filter_'.$params['filter_key']) == $optionValue && Tools::getValue($this->table.'Filter_'.$params['filter_key']) != '') ? ' selected="selected"' : '').'>'.$optionDisplay.'</option>';
}
echo '</select>';
break;
@@ -1555,7 +1558,7 @@ abstract class AdminTabCore
echo '<td>--</td>';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
if ($this->edit || $this->delete || ($this->view && $this->view !== 'noActionColumn'))
echo '<td class="center">--</td>';
echo '</tr>
@@ -1573,7 +1576,7 @@ abstract class AdminTabCore
{
$this->displayTop();
if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd))
if ($this->edit && (!isset($this->noAdd) || !$this->noAdd))
$this->displayAddButton();
/* Append when we get a syntax error in SQL query */
@@ -1585,8 +1588,8 @@ abstract class AdminTabCore
/* Display list header (filtering, pagination and column names) */
$this->displayListHeader();
if (!sizeof($this->_list))
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
if (!count($this->_list))
echo '<tr><td class="center" colspan="'.(count($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
/* Show the content of the table */
$this->displayListContent();
@@ -1609,7 +1612,7 @@ abstract class AdminTabCore
$id_category = 1; // default categ
$irow = 0;
if ($this->_list AND isset($this->fieldsDisplay['position']))
if ($this->_list && isset($this->fieldsDisplay['position']))
{
$positions = array_map(create_function('$elem', 'return (int)$elem[\'position\'];'), $this->_list);
sort($positions);
@@ -1620,34 +1623,34 @@ abstract class AdminTabCore
if (preg_match('/cms/Ui', $this->identifier))
$isCms = true;
$keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
foreach ($this->_list AS $tr)
foreach ($this->_list as $tr)
{
$id = $tr[$this->identifier];
echo '<tr'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>
echo '<tr'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) && $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>
<td class="center">';
if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete)))
if ($this->delete && (!isset($this->_listSkipDelete) || !in_array($id, $this->_listSkipDelete)))
echo '<input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" />';
echo '</td>';
foreach ($this->fieldsDisplay AS $key => $params)
foreach ($this->fieldsDisplay as $key => $params)
{
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
echo '
<td '.(isset($params['position']) ? ' id="td_'.(isset($id_category) AND $id_category ? $id_category : 0).'_'.$id.'"' : '').' class="'.((!isset($this->noLink) OR !$this->noLink) ? 'pointer' : '').((isset($params['position']) AND $this->_orderBy == 'position')? ' dragHandle' : ''). (isset($params['align']) ? ' '.$params['align'] : '').'" ';
if (!isset($params['position']) AND (!isset($this->noLink) OR !$this->noLink))
<td '.(isset($params['position']) ? ' id="td_'.(isset($id_category) && $id_category ? $id_category : 0).'_'.$id.'"' : '').' class="'.((!isset($this->noLink) || !$this->noLink) ? 'pointer' : '').((isset($params['position']) && $this->_orderBy == 'position')? ' dragHandle' : ''). (isset($params['align']) ? ' '.$params['align'] : '').'" ';
if (!isset($params['position']) && (!isset($this->noLink) || !$this->noLink))
echo ' onclick="document.location = \''.self::$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : '');
else
echo '>';
if (isset($params['active']) AND isset($tr[$key]))
if (isset($params['active']) && isset($tr[$key]))
$this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product'));
elseif (isset($params['activeVisu']) AND isset($tr[$key]))
elseif (isset($params['activeVisu']) && isset($tr[$key]))
echo '<img src="../img/admin/'.($tr[$key] ? 'enabled.gif' : 'disabled.gif').'"
alt="'.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).'" />';
elseif (isset($params['position']))
{
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
if ($this->_orderBy == 'position' && $this->_orderWay != 'DESC')
{
echo '<a'.(!($tr[$key] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '').' href="'.self::$currentIndex.
echo '<a'.(!($tr[$key] != $positions[count($positions) - 1]) ? ' style="display: none;"' : '').' href="'.self::$currentIndex.
'&'.$keyToGet.'='.(int)($id_category).'&'.$this->identifiersDnd[$this->identifier].'='.$id.'
&way=1&position='.(int)($tr['position'] + 1).'&token='.($token!=NULL ? $token : $this->token).'">
<img src="../img/admin/'.($this->_orderWay == 'ASC' ? 'down' : 'up').'.gif"
@@ -1676,15 +1679,15 @@ abstract class AdminTabCore
echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
}
elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default'])))
elseif (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
echo '<img src="../img/admin/'.(isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'].'" alt="'.$tr[$key]).'" title="'.$tr[$key].'" />';
elseif (isset($params['price']))
echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency), false);
elseif (isset($params['float']))
echo rtrim(rtrim($tr[$key], '0'), '.');
elseif (isset($params['type']) AND $params['type'] == 'date')
elseif (isset($params['type']) && $params['type'] == 'date')
echo Tools::displayDate($tr[$key], $this->context->language->id);
elseif (isset($params['type']) AND $params['type'] == 'datetime')
elseif (isset($params['type']) && $params['type'] == 'datetime')
echo Tools::displayDate($tr[$key], $this->context->language->id, true);
elseif (isset($tr[$key]))
{
@@ -1710,14 +1713,14 @@ abstract class AdminTabCore
echo '<td class="center" '.(($name != $tr['shop_name']) ? 'title="'.$tr['shop_name'].'"' : '').'>'.$name.'</td>';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
if ($this->edit || $this->delete || ($this->view && $this->view !== 'noActionColumn'))
{
echo '<td class="center" style="white-space: nowrap;">';
if ($this->view)
$this->_displayViewLink($token, $id);
if ($this->edit)
$this->_displayEditLink($token, $id);
if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete)))
if ($this->delete && (!isset($this->_listSkipDelete) || !in_array($id, $this->_listSkipDelete)))
$this->_displayDeleteLink($token, $id);
if ($this->duplicate)
$this->_displayDuplicate($token, $id);
@@ -1736,7 +1739,7 @@ abstract class AdminTabCore
protected function _displayEnableLink($token, $id, $value, $active, $id_category = NULL, $id_product = NULL)
{
echo '<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
((int)$id_category AND (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token!=NULL ? $token : $this->token).'">
((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token!=NULL ? $token : $this->token).'">
<img src="../img/admin/'.($value ? 'enabled.gif' : 'disabled.gif').'"
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
}
@@ -1796,7 +1799,7 @@ abstract class AdminTabCore
</table>
<input type="hidden" name="token" value="'.($token ? $token : $this->token).'" />
</form>';
if (isset($this->_includeTab) AND sizeof($this->_includeTab))
if (isset($this->_includeTab) && count($this->_includeTab))
echo '<br /><br />';
}
@@ -1943,7 +1946,7 @@ abstract class AdminTabCore
public function displayOptionTypeSelect($key, $field, $value)
{
echo '<select name="'.$key.'"'.(isset($field['js']) === true ? ' onchange="'.$field['js'].'"' : '').' id="'.$key.'">';
foreach ($field['list'] AS $k => $option)
foreach ($field['list'] as $k => $option)
echo '<option value="'.(isset($option['cast']) ? $option['cast']($option[$field['identifier']]) : $option[$field['identifier']]).'"'.(($value == $option[$field['identifier']]) ? ' selected="selected"' : '').'>'.$option['name'].'</option>';
echo '</select>';
}
@@ -2028,7 +2031,7 @@ abstract class AdminTabCore
';*/
$i = 0;
foreach ($field['list'] AS $theme)
foreach ($field['list'] as $theme)
{
echo '<td class="center" style="width: 180px; padding:0px 20px 20px 0px;">';
echo '<input type="radio" name="'.$key.'" id="'.$key.'_'.$theme['name'].'_on" style="vertical-align: text-bottom;" value="'.$theme['name'].'"'.(_THEME_NAME_ == $theme['name'] ? 'checked="checked"' : '').' />';
@@ -2038,7 +2041,7 @@ abstract class AdminTabCore
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">';
echo '</label>';
echo '</td>';
if (isset($field['max']) AND ($i +1 ) % $field['max'] == 0)
if (isset($field['max']) && ($i +1 ) % $field['max'] == 0)
echo '</tr><tr>';
$i++;
}
@@ -2156,11 +2159,11 @@ abstract class AdminTabCore
*/
protected function getFieldValue($obj, $key, $id_lang = NULL, $id_shop = null)
{
if (!$id_shop AND $obj->isLangMultishop())
if (!$id_shop && $obj->isLangMultishop())
$id_shop = Context::getContext()->shop->getID();
if ($id_lang)
$defaultValue = ($obj->id AND isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
$defaultValue = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
else
$defaultValue = isset($obj->{$key}) ? $obj->{$key} : '';
@@ -2178,7 +2181,7 @@ abstract class AdminTabCore
$useLangFromCookie = false;
$this->_languages = Language::getLanguages(false);
if ($allowEmployeeFormLang)
foreach ($this->_languages AS $lang)
foreach ($this->_languages as $lang)
if ($this->context->cookie->employee_form_lang == $lang['id_lang'])
$useLangFromCookie = true;
if (!$useLangFromCookie)
@@ -2194,7 +2197,7 @@ abstract class AdminTabCore
$(document).ready(function() {
id_language = '.$this->_defaultFormLanguage.';
languages = new Array();';
foreach ($this->_languages AS $k => $language)
foreach ($this->_languages as $k => $language)
echo '
languages['.$k.'] = {
id_lang: '.(int)$language['id_lang'].',
@@ -2267,7 +2270,7 @@ abstract class AdminTabCore
public function checkToken()
{
$token = Tools::getValue('token');
return (!empty($token) AND $token === $this->token);
return (!empty($token) && $token === $this->token);
}
/**
@@ -2282,7 +2285,7 @@ abstract class AdminTabCore
*/
public function displayFlags($languages, $default_language, $ids, $id, $return = false, $use_vars_instead_of_ids = false)
{
if (sizeof($languages) == 1)
if (count($languages) == 1)
return false;
$output = '
<div class="displayed_flag">
@@ -2304,8 +2307,8 @@ abstract class AdminTabCore
protected function filterToField($key, $filter)
{
foreach ($this->fieldsDisplay AS $field)
if (array_key_exists('filter_key', $field) AND $field['filter_key'] == $key)
foreach ($this->fieldsDisplay as $field)
if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key)
return $field;
if (array_key_exists($filter, $this->fieldsDisplay))
return $this->fieldsDisplay[$filter];
@@ -2314,7 +2317,7 @@ abstract class AdminTabCore
protected function warnDomainName()
{
if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') AND $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL'))
if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') && $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL'))
$this->displayWarning($this->l('Your are currently connected with the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'.
$this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' <span style="color: #CC0000;">'.Configuration::get('PS_SHOP_DOMAIN').'</span><br />
<a href="index.php?tab=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#SEO%20%26%20URLs">'.
@@ -2332,7 +2335,7 @@ abstract class AdminTabCore
$assos = array();
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`';
foreach (Db::getInstance()->ExecuteS($sql) AS $row)
foreach (Db::getInstance()->ExecuteS($sql) as $row)
$assos[$row['id_'.$type]][] = $row[$this->identifier];
$html = <<<EOF
+62
View File
@@ -170,6 +170,7 @@ class GroupCore extends ObjectModel
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'category_group` WHERE `id_group` = '.(int)$this->id);
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'group_reduction` WHERE `id_group` = '.(int)$this->id);
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_group_reduction_cache` WHERE `id_group` = '.(int)$this->id);
$this->truncateRestrictionsModules($this->id);
Discount::deleteByIdGroup((int)$this->id);
// Refresh cache of feature detachable
@@ -225,6 +226,67 @@ class GroupCore extends ObjectModel
WHERE `id_group` != 1
');
}
/**
* Truncate all modules restrictions for the group
* @param integer id_group
* @return boolean result
*/
public static function truncateModulesRestrictions($id_group)
{
return Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'group_module_restriction`
WHERE `id_group` = '.(int)$id_group);
}
/**
* Truncate all restrictions by module
* @param integer id_module
* @return boolean result
*/
public static function truncateRestrictionsByModule($id_module)
{
return Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'group_module_restriction`
WHERE `id_module` = '.(int)$id_module);
}
/**
* Adding restrictions modules to the group with id $id_group
* @param integer id_group
* @param array modules
* @param integer authorized
*/
public static function addModulesRestrictions($id_group, $modules, $authorized)
{
if (!is_array($modules))
return false;
else
{
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
foreach ($modules as $mod)
$sql .= '("'.(int)$id_group.'", "'.(int)Module::getModuleIdByName($mod).'", "'.(int)$authorized.'"),';
// removing last comma to avoid SQL error
$sql = substr($sql, 0, strlen($sql) - 1);
Db::getInstance()->Execute($sql);
}
}
/**
* Add restrictions for a new module
* We authorize every groups to the new module
* @param integer id_module
*/
public static function addRestrictionsForModule($id_module)
{
$groups = Group::getGroups(Context::getContext()->language->id);
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
foreach ($groups as $g)
$sql .= '("'.(int)$g['id_group'].'", "'.(int)$id_module.'", "1"),';
// removing last comma to avoid SQL error
$sql = substr($sql, 0, strlen($sql) - 1);
Db::getInstance()->Execute($sql);
}
}
+65 -15
View File
@@ -181,6 +181,8 @@ abstract class ModuleCore
WHERE id_tab = (SELECT `id_tab` FROM '._DB_PREFIX_.'tab WHERE class_name = \'AdminModules\' LIMIT 1)
AND a.`view` = 0
)');
// Adding Restrictions for client groups
Group::addRestrictionsForModule($this->id);
return true;
}
@@ -211,6 +213,9 @@ abstract class ModuleCore
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'module_access` WHERE `id_module` = '.(int)$this->id);
// Remove restrictions for client groups
Group::truncateRestrictionsByModule($this->id);
return Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'module`
WHERE `id_module` = '.(int)$this->id);
@@ -579,7 +584,7 @@ abstract class ModuleCore
$memory_limit = Tools::getMemoryLimit();
foreach ($modules_dir AS $module)
foreach ($modules_dir as $module)
{
// Memory usage checking
if (function_exists('memory_get_usage') && $memory_limit !== -1)
@@ -600,7 +605,7 @@ abstract class ModuleCore
$needNewConfigFile = (filemtime($configFile) < filemtime(_PS_MODULE_DIR_.$module.'/'.$module.'.php'));
else
$needNewConfigFile = true;
if ($useConfig AND $xml_exist)
if ($useConfig && $xml_exist)
{
libxml_use_internal_errors(true);
$xml_module = simplexml_load_file($configFile);
@@ -608,7 +613,7 @@ abstract class ModuleCore
$errors[] = '['.$module.'] '.Tools::displayError('Error found in config file:').' '.htmlentities($error->message);
libxml_clear_errors();
if (!count($errors) AND (int)$xml_module->need_instance == 0 AND !$needNewConfigFile)
if (!count($errors) && (int)$xml_module->need_instance == 0 && !$needNewConfigFile)
{
$file = _PS_MODULE_DIR_.$module.'/'.Context::getContext()->language->iso_code.'.php';
if (Tools::file_exists_cache($file) AND include_once($file))
@@ -761,7 +766,7 @@ abstract class ModuleCore
return Db::getInstance()->ExecuteS($sql);
}
/*
/**
* Execute modules for specified hook
*
* @param string $hook_name Hook Name
@@ -771,13 +776,13 @@ abstract class ModuleCore
public static function hookExec($hook_name, $hookArgs = array(), $id_module = NULL)
{
$context = Context::getContext();
if ((!empty($id_module) AND !Validate::isUnsignedId($id_module)) OR !Validate::isHookName($hook_name))
if ((!empty($id_module) && !Validate::isUnsignedId($id_module)) || !Validate::isHookName($hook_name))
die(Tools::displayError());
$live_edit = false;
if (!isset($hookArgs['cookie']) OR !$hookArgs['cookie'])
if (!isset($hookArgs['cookie']) || !$hookArgs['cookie'])
$hookArgs['cookie'] = $context->cookie;
if (!isset($hookArgs['cart']) OR !$hookArgs['cart'])
if (!isset($hookArgs['cart']) || !$hookArgs['cart'])
$hookArgs['cart'] = $context->cart;
$hook_name = strtolower($hook_name);
@@ -785,15 +790,26 @@ abstract class ModuleCore
{
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
$list = $context->shop->getListOfID();
if (isset($context->customer))
$groups = $context->customer->getGroups();
$sql = 'SELECT h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm
ON hm.`id_module` = m.`id_module`
ON hm.`id_module` = m.`id_module`';
if (isset($context->customer))
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'group_module_restriction` gmr
ON gmr.`id_module` = m.`id_module`';
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'hook` h
ON hm.`id_hook` = h.`id_hook`
WHERE (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).')
AND hm.id_shop IN('.implode(', ', $list).')';
if (isset($context->customer))
$sql .= '
AND (gmr.`authorized` = 1 AND gmr.`id_group` IN('.implode(', ', $groups).'))';
$sql .= '
GROUP BY hm.id_hook, hm.id_module
ORDER BY hm.`position`';
$result = $db->ExecuteS($sql, false);
@@ -814,9 +830,9 @@ abstract class ModuleCore
$altern = 0;
$output = '';
foreach (self::$_hookModulesCache[$hook_name] AS $array)
foreach (self::$_hookModulesCache[$hook_name] as $array)
{
if ($id_module AND $id_module != $array['id_module'])
if ($id_module && $id_module != $array['id_module'])
continue;
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
continue;
@@ -824,7 +840,7 @@ abstract class ModuleCore
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
if (in_array(Dispatcher::getInstance()->getController(), $exceptions))
continue;
if (isset($context->employee) AND !$moduleInstance->getPermission('view', $context->employee))
if (isset($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
continue;
if (is_callable(array($moduleInstance, 'hook'.$hook_name)))
@@ -832,7 +848,7 @@ abstract class ModuleCore
$hookArgs['altern'] = ++$altern;
$display = call_user_func(array($moduleInstance, 'hook'.$hook_name), $hookArgs);
if ($array['live_edit'] && ((Tools::isSubmit('live_edit') AND Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))))
if ($array['live_edit'] && ((Tools::isSubmit('live_edit') && Tools::getValue('ad') && (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))))
{
$live_edit = true;
$output .= '<script type="text/javascript"> modules_list.push(\''.$moduleInstance->name.'\');</script>
@@ -882,6 +898,8 @@ abstract class ModuleCore
$context = Context::getContext();
$id_customer = $context->customer->id;
$billing = new Address((int)$context->cart->id_address_invoice);
if (isset($context->customer))
$groups = $context->customer->getGroups();
$list = Context::getContext()->shop->getListOfID();
$sql = 'SELECT DISTINCT h.`id_hook`, m.`name`, hm.`position`
@@ -890,13 +908,21 @@ abstract class ModuleCore
INNER JOIN `'._DB_PREFIX_.'module_group` mg ON (m.`id_module` = mg.`id_module`)
INNER JOIN `'._DB_PREFIX_.'customer_group` cg on (cg.`id_group` = mg.`id_group` AND cg.`id_customer` = '.(int)$context->customer->id.')
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`';
if (isset($context->customer))
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'group_module_restriction` gmr ON gmr.`id_module` = m.`id_module`';
$sql .= '
WHERE h.`name` = \'payment\'
AND mc.id_country = '.(int)($billing->id_country).'
AND mc.id_shop = '.(int)$context->shop->getID(true).'
AND mg.id_shop = '.(int)$context->shop->getID(true).'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).')
AND hm.id_shop IN('.implode(', ', $list).')';
if (isset($context->customer))
$sql .= '
AND (gmr.`authorized` = 1 AND gmr.`id_group` IN('.implode(', ', $groups).'))';
$sql .= '
GROUP BY hm.id_hook, hm.id_module
ORDER BY hm.`position`, m.`name` DESC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
@@ -1276,5 +1302,29 @@ abstract class ModuleCore
}
return (bool)$cache_permissions[$employee->id_profile][$id_module][$variable];
}
/**
* get Unauthorized modules for a client group
* @param integer group_id
*/
public static function getAuthorizedModules($group_id)
{
return Db::getInstance()->ExecuteS('
SELECT m.id_module, m.name FROM `'._DB_PREFIX_.'group_module_restriction` gmr
LEFT JOIN `'._DB_PREFIX_.'module` m ON (m.`id_module` = gmr.`id_module`)
WHERE gmr.`id_group` = '.(int) $group_id.'
AND gmr.`authorized` = 1
');
}
/**
* get id module by name
* @param string name
* @return integer id
*/
public static function getModuleIdByName($name)
{
return Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "'.pSQL($name).'"');
}
}
+7
View File
@@ -1954,3 +1954,10 @@ PRIMARY KEY (`id_discount`, `id_shop`),
KEY `id_shop` (`id_shop`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_group_module_restriction` (
`id_group` INT(11) UNSIGNED NOT NULL ,
`id_module` INT(11) UNSIGNED NOT NULL ,
`authorized` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_group`,`id_module`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+9 -88
View File
@@ -20,20 +20,6 @@ $_LANGADM['AdminAccess05fe96d753968b151a15b748140e4467'] = 'Les permissions du p
$_LANGADM['AdminAccessbf17ac149e2e7a530c677e9bd51d3fd2'] = 'Modules';
$_LANGADM['AdminAccessf1206f9fadc5ce41694f69129aecac26'] = 'Configurer';
$_LANGADM['AdminAccess501faad2df9c231576549a068fcf61ca'] = 'Pas de modules installés';
$_LANGADM['AdminAliases9ab81f57823f6aeb02362291f23883e6'] = 'Alias';
$_LANGADM['AdminAliases13348442cc6a27032d2b4aa28b75a5d3'] = 'Rechercher';
$_LANGADM['AdminAliasesec53a8c4f07baed5d8825072c89799be'] = 'Statut';
$_LANGADM['AdminAliasesa66ec6983e578c3ac4663171b39d168b'] = 'les 2 champs sont requis';
$_LANGADM['AdminAliases792fd33273f5b3dbbcc6bd5de52b7e20'] = 'n\'est pas un résultat valide';
$_LANGADM['AdminAliases9d2e974b83d9090b463dbcb2ef32ab51'] = 'n\'est pas un alias valide';
$_LANGADM['AdminAliasesa1f687d813c4e0c415cb5137fcb156c1'] = 'Alias :';
$_LANGADM['AdminAliasesb5d71393255d0337cc587ba074b18b06'] = 'Entrez chaque alias séparé par une virgule (\',\')';
$_LANGADM['AdminAliases6f4d4902bdc97012907f5d8c9ee1611a'] = '(ex : \'prestashop,preztashop,prestasohp\')';
$_LANGADM['AdminAliases3e053943605d9e4bf7dd7588ea19e9d2'] = 'Caractères interdits :';
$_LANGADM['AdminAliases5aac38deec604d81565722cc5a2a6be1'] = 'Résultat :';
$_LANGADM['AdminAliases01d2aac5d20787a1e873f2bdc79b514a'] = 'Recherche ce mot à la place.';
$_LANGADM['AdminAliases38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminAliases19f823c6453c2b1ffd09cb715214813d'] = 'Champs requis';
$_LANGADM['AdminAttachmentsb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminAttachments49ee3087348e8d44e1feda1917443987'] = 'Nom';
$_LANGADM['AdminAttachments0b27918290ff5323bea1e3b78a9cf04e'] = 'Fichier';
@@ -997,27 +983,6 @@ $_LANGADM['AdminGeolocation49ee3087348e8d44e1feda1917443987'] = 'Nom';
$_LANGADM['AdminGeolocationa79a12d2d7ab4c5524e33e62a568d77c'] = 'Liste des adresses IP autorisées';
$_LANGADM['AdminGeolocation5e23ef5156fb0aca3cb2cc23fed2e267'] = 'Vous pouvez ajouter plusieurs adresse IP, ces adresses auront toujours la possibilité de voir votre boutique (par exemple: les adresses IP des Google bot).';
$_LANGADM['AdminGeolocation911bac7fe508d2b815eab0612120b564'] = 'Adresses IP autorisées:';
$_LANGADM['AdminGroupShopb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminGroupShope25b163360646e8f71af8a8ee0fad1a3'] = 'Pays';
$_LANGADM['AdminGroupShop00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Activé';
$_LANGADM['AdminGroupShop791a9f4aec774fbe5591d239f3cf0113'] = 'Groupe de boutiques';
$_LANGADM['AdminGroupShopfa2428e247e092ba7b8380481f5d2c23'] = 'Vous ne pouvez pas éditer ce groupe de boutiques lorque que vous avez plus d\'une boutique';
$_LANGADM['AdminGroupShop677c9a43ef87f39833e514afc74569be'] = 'Nom du groupe de boutiques';
$_LANGADM['AdminGroupShop5b55607ff39362e86c0693626a6cc20f'] = 'Partager les clients';
$_LANGADM['AdminGroupShopb9f5c797ebbf55adccdd8539a65a0241'] = 'Désactivé';
$_LANGADM['AdminGroupShop934514d7bd6af6a23fca1b985ec2d640'] = 'Partager les comptes clients entre les différentes boutiques de ce groupe';
$_LANGADM['AdminGroupShop97dd1ad98c5cdd8fae3bbe74174979f0'] = 'Stock partagé';
$_LANGADM['AdminGroupShop468c3f9dcd67b3f768d2161908d820eb'] = 'Stock partagé entre les magasins de ce groupe';
$_LANGADM['AdminGroupShopa23a8100bb34ea482c8fb134da89710e'] = 'Partager les commandes';
$_LANGADM['AdminGroupShop6cbbf7ff5d60b20ff3b8dcb3484eafdb'] = 'Partager les commandes et les paniers entre les différentes boutiques de ce groupe (vous ne pouvez partager les commandes que si vous partagez les clients et les stocks)';
$_LANGADM['AdminGroupShop24a23d787190f2c4812ff9ab11847a72'] = 'Statut:';
$_LANGADM['AdminGroupShop37c0e2b9736bc4cc2005f7be3fd66fe5'] = 'Activer ou désactiver la boutique';
$_LANGADM['AdminGroupShop38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminGroupShop19f823c6453c2b1ffd09cb715214813d'] = 'Champ obligatoire';
$_LANGADM['AdminGroupShop775a3ab6add326ef93f2382f49f9e500'] = 'Groupes d\'attributs';
$_LANGADM['AdminGroupShop287234a1ff35a314b5b6bc4e5828e745'] = 'Attributs';
$_LANGADM['AdminGroupShopdad1f8d794ee0dd7753fe75e73b78f31'] = 'Zones';
$_LANGADM['AdminGroupShop817b32b9fa482c23e9413b150b5e6d47'] = 'Ajouter un nouveau groupe de boutiques';
$_LANGADM['AdminGroupsb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminGroups49ee3087348e8d44e1feda1917443987'] = 'Nom';
$_LANGADM['AdminGroups104d9898c04874d0fbac36e125fa1369'] = 'Réduction';
@@ -1048,6 +1013,14 @@ $_LANGADM['AdminGroups56a8a9eb05f9014da51a4f9b57322ac7'] = 'Catégorie :';
$_LANGADM['AdminGroups60c4a9a7f56f6b9669f84977ebd0f93d'] = 'Seuls les produits qui ont cette catégorie par défaut seront ajoutés';
$_LANGADM['AdminGroups567183b8b1122180690be51cc6df2b74'] = 'Réduction (en %) :';
$_LANGADM['AdminGroups1fe63847218648baf13474e3d25747bb'] = 'Ajouter';
$_LANGADM['AdminGroups016269c0d83a19a19a2ee0a4294740b4'] = 'Tout déselectionner';
$_LANGADM['AdminGroups45e96c0a422ce8a1a6ec1bd5eb9625c6'] = 'Tout sélectionner';
$_LANGADM['AdminGroupsa47b91fe1f53e018f1cfd3cbf093bee7'] = 'Restrictions des modules';
$_LANGADM['AdminGroups8c4284091367c3213217fd939c84a15d'] = 'Modules non autorisés :';
$_LANGADM['AdminGroups7f83df9cd29577d544efd9ff66d7118a'] = 'Autoriser';
$_LANGADM['AdminGroups40382ca2b15ff499eb4e5c101424bc81'] = 'Modules autorisés :';
$_LANGADM['AdminGroups968e7b7e746e504c627990e6a1cfca21'] = 'Ne pas autoriser';
$_LANGADM['AdminGroupsb32029c03a7163e885f3d31457d6554e'] = 'Mettre à jour les restrictions';
$_LANGADM['AdminGroupsdaab80c5dadc81fa2d019c562f805994'] = 'Sexe';
$_LANGADM['AdminGroups1ec5f5ec77c51a968271b2ca9862907d'] = 'e-mail';
$_LANGADM['AdminGroups9c37b7b6ff829e977df287900543ea54'] = 'Date de naissance';
@@ -2566,8 +2539,8 @@ $_LANGADM['AdminScenesb56c3bda503a8dc4be356edb0cc31793'] = 'Tout replier';
$_LANGADM['AdminScenes5ffd7a335dd836b3373f5ec570a58bdc'] = 'Tout étendre';
$_LANGADM['AdminScenes5e9df908eafa83cb51c0a3720e8348c7'] = 'Tout cocher';
$_LANGADM['AdminScenes9747d23c8cc358c5ef78c51e59cd6817'] = 'Tout décocher';
$_LANGADM['AdminScenes8c38776925f7cf41c090646a43157024'] = 'Catégories :';
$_LANGADM['AdminScenesf16b5952df8d25ea30b25ff95ee8fedf'] = 'Boutiques associées';
$_LANGADM['AdminScenes8c38776925f7cf41c090646a43157024'] = 'Catégories :';
$_LANGADM['AdminScenesdf41d831253828e9852a25c72393fde8'] = 'Enregistrez la scène';
$_LANGADM['AdminScenesf5dae0e1b3d4bc66fadd2840b4f79227'] = 'Veuillez ajouter une image pour continuer';
$_LANGADM['AdminScenes19f823c6453c2b1ffd09cb715214813d'] = 'Champs requis';
@@ -2634,13 +2607,6 @@ $_LANGADM['AdminSearchConfad24ffca4f9e9c0c7e80fe1512df6db9'] = 'Pertinence';
$_LANGADM['AdminSearchConfb528cee25edcbf2257878a5aead21a1d'] = 'Le \"poids\" d\'un mot représente son importance et sa pertinence pour le classement des produits lorsque un utilisateur fait une recherche.';
$_LANGADM['AdminSearchConf157ce71733eb58af6770c47cfbab1732'] = 'Un mot avec un poids de 8 aura 4 fois plus de valeur qu\'un mot avec un poids de 2.';
$_LANGADM['AdminSearchConfc0e9eaafe9282fe99cb85cf791a2dd8e'] = 'Ainsi, il est conseillé de mettre un poids bien supérieur pour les mots qui figurent dans le nom ou la référence du produit plutôt que ceux de la description ou de la catégorie, pour que la recherche soit la plus précise et pertinente possible.';
$_LANGADM['AdminSearchEnginesb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminSearchEngines9aa1b03934893d7134a660af4204f2a9'] = 'Serveur';
$_LANGADM['AdminSearchEnginesb864759d534539519ceaa2c03a39d4c2'] = 'Variable GET';
$_LANGADM['AdminSearchEnginesb6f05e5ddde1ec63d992d61144452dfa'] = 'Réferrant';
$_LANGADM['AdminSearchEngines52e1c423b768c6e9850d70f3a41aca1d'] = 'Variable $_GET';
$_LANGADM['AdminSearchEngines38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminSearchEngines19f823c6453c2b1ffd09cb715214813d'] = 'Champs requis';
$_LANGADM['AdminShipping1d8ca7f442e6d4ad3da5cb61b84284fc'] = 'Frais de manutention';
$_LANGADM['AdminShippingc9722f74f95451816de0f8ca3259ae44'] = 'Frais de port offerts à partir de';
$_LANGADM['AdminShipping780c462e85ba4399a5d42e88f69a15ca'] = 'Facturation';
@@ -2706,31 +2672,6 @@ $_LANGADM['AdminShop99104e1966b34f0320d33c5892946a82'] = 'Importer les informati
$_LANGADM['AdminShop8409f0f4c1b13db73d10a0f148b67dda'] = 'Importer les informations de la boutique';
$_LANGADM['AdminShopff8be7dc0dfd076e494b88721b257237'] = 'Utilisez cette option pour associer les données (produits, modules etc) de la même façon que la boutique sélectionnée';
$_LANGADM['AdminShop652342e19bf26f8d1b350e60aad3e3bf'] = 'Ajouter une nouvelle boutique';
$_LANGADM['AdminShopUrlb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminShopUrleae639a70006feff484a39363c977e24'] = 'Domaine';
$_LANGADM['AdminShopUrl7e01d4a0c1fa89814ea68649a506eeee'] = 'Domaine SSL';
$_LANGADM['AdminShopUrl3840cd8f73026713059f0ed0562c5493'] = 'Uri';
$_LANGADM['AdminShopUrle93c33bd1341ab74195430daeb63db13'] = 'Nom de la boutique';
$_LANGADM['AdminShopUrl676e457154510d142765d535fbf11df0'] = 'URL principale';
$_LANGADM['AdminShopUrl00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Activé';
$_LANGADM['AdminShopUrl809ba9a802624b3958a53090a72d9c7a'] = 'URL de la boutique';
$_LANGADM['AdminShopUrl102c89334ecf0958f2065978d05748fd'] = 'URI physique';
$_LANGADM['AdminShopUrl5a70b8f93f7c6992c283ee62cdfb78ab'] = 'Dossier du magasin sur votre serveur. Laissez ce champ vide si votre magasin n\'est pas installé dans un sous dossier.';
$_LANGADM['AdminShopUrl8ba460441234cdf94377a0818485f414'] = 'URI virtuelle';
$_LANGADM['AdminShopUrlb483b64288977921afe330ac8e387e9b'] = 'Ce dossier virtuel ne doit pas exister sur votre serveur, et sera utilisé pour associer une URL à votre magasin.';
$_LANGADM['AdminShopUrlf6e7829277b67d5a8805d6728a810362'] = 'L\'URL rewriting doit être activé sur votre serveur pour utiliser cette fonctionalité.';
$_LANGADM['AdminShopUrl6c2f1301971c801a2d1390c39680116f'] = 'L\'URL de votre magasin sera';
$_LANGADM['AdminShopUrl9f82518d468b9fee614fcc92f76bb163'] = 'Boutique';
$_LANGADM['AdminShopUrl9efaaad2d5b51cd643529cd6872e169a'] = 'URL principale:';
$_LANGADM['AdminShopUrlb9f5c797ebbf55adccdd8539a65a0241'] = 'Désactivé';
$_LANGADM['AdminShopUrl3648bf7fbf02a7ae9cdfecf803561031'] = 'Si vous choisissez cette URL comme URL principale pour cette boutique, toutes les autres URL de cette boutiques seront redirigées vers celle ci (vous ne pouvez avoir qu\'une URL principale par magasin).';
$_LANGADM['AdminShopUrl134a0349fbc36ef37c862a7321e5e142'] = 'Puisque la boutique sélectionné ne possède aucune URL principale, l\'URL que vous créez sera automatiquement mise en tant qu\'URL principale';
$_LANGADM['AdminShopUrl681a2f774a1323b8c265610dc0a0d5cb'] = 'La boutique sélectionnée a déjà une URL principale, si vous choisissez l\'URL courante comme étant principale pour cette boutique, l\'ancienne URL principale sera remise en tant qu\'URL normale';
$_LANGADM['AdminShopUrl24a23d787190f2c4812ff9ab11847a72'] = 'Statut:';
$_LANGADM['AdminShopUrlad02fa652079de031f48cc5cf9396598'] = 'Activer ou désactiver l\'URL';
$_LANGADM['AdminShopUrl38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminShopUrl19f823c6453c2b1ffd09cb715214813d'] = 'Champ obligatoire';
$_LANGADM['AdminShopUrl241da03b3b26160119804f9067f45a1c'] = 'Ajouter une nouvelle URL de magasin';
$_LANGADM['AdminSlipb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminSlip6fde42aa0857eb92fc0d0c3fb1c6c8b7'] = 'ID Commande';
$_LANGADM['AdminSlip446faa7da2d42ba4ffeda73cb119dd91'] = 'Date d\'émission';
@@ -2749,26 +2690,6 @@ $_LANGADM['AdminSlip4351cfebe4b61d8aa5efa1d020710005'] = 'Voir';
$_LANGADM['AdminSlip0071aa279bd1583754a544277740f047'] = 'Supprimer l\'objet';
$_LANGADM['AdminSlipd1457b72c3fb323a2671125aef3eab5d'] = ' ?';
$_LANGADM['AdminSlipf2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
$_LANGADM['AdminStatesb718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_LANGADM['AdminStates49ee3087348e8d44e1feda1917443987'] = 'Nom';
$_LANGADM['AdminStatesad68f9bafd9bf2dcf3865dac55662fd5'] = 'Code ISO';
$_LANGADM['AdminStatesb3ff996fe5c77610359114835baf9b38'] = 'Zone';
$_LANGADM['AdminStatesb8464cdd84b5f068ad72bf5c4f32163d'] = 'Etats';
$_LANGADM['AdminStates4e140ba723a03baa6948340bf90e2ef6'] = 'Nom :';
$_LANGADM['AdminStates457885792537d3f4a056e776fa721a3d'] = 'Nom de l\'état à afficher dans les adresses et les factures';
$_LANGADM['AdminStates3af4c1797da60fd50670ddbb669fc0aa'] = 'Code ISO :';
$_LANGADM['AdminStates2dcd278c8503e295e186209fffd676f7'] = 'Code ISO de 1 à 4 lettres (vérifiez sur Wikipedia si vous ne savez pas)';
$_LANGADM['AdminStatesf64be5eef68442a8f50cf535b92ad3e4'] = 'Pays :';
$_LANGADM['AdminStates19ce4359133c8a012b572413ea8b58ea'] = 'Pays dans lequel l\'état, la région ou la ville sont situés';
$_LANGADM['AdminStatese6e42855066e7a3ae050b2c698021b14'] = 'Zone :';
$_LANGADM['AdminStates29b8e6e52c0384bf57dcc6b975d8b39c'] = 'Zone géographique où cet état est localisé';
$_LANGADM['AdminStatesec92dbe75bbcc2fbf4cad6302df97c19'] = 'Utilisée pour le transport';
$_LANGADM['AdminStates24a23d787190f2c4812ff9ab11847a72'] = 'Statut :';
$_LANGADM['AdminStates00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Activé';
$_LANGADM['AdminStatesb9f5c797ebbf55adccdd8539a65a0241'] = 'Désactivé';
$_LANGADM['AdminStatesd42225935a374f1249f2a45ebed00772'] = 'Activé ou désactivé';
$_LANGADM['AdminStates38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminStates19f823c6453c2b1ffd09cb715214813d'] = 'Champs requis';
$_LANGADM['AdminStatsConf6e7b34fa59e1bd229b207892956dc41c'] = 'Jamais';
$_LANGADM['AdminStatsConfd2ce009594dcc60befa6a4e6cbeb71fc'] = 'Semaine';
$_LANGADM['AdminStatsConf7cbb885aa1164b390a0bc050a64e1812'] = 'Mois';