[-] BO : Fixing modules permissions system

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16102 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
fSerny
2012-06-20 15:48:46 +00:00
parent 5e0505cf05
commit ea78daf330
7 changed files with 35 additions and 23 deletions
@@ -122,15 +122,16 @@
var perm = tout[1]; var perm = tout[1];
var id_profile = tout[2]; var id_profile = tout[2];
var enabled = $(this).is(':checked') ? 1 : 0; var enabled = $(this).is(':checked') ? 1 : 0;
var enabled_attr = $(this).is(':checked') ? true : false;
var table = 'table#table_module_'+id_profile; var table = 'table#table_module_'+id_profile;
if (id_module == -1) if (id_module == -1)
$(table+' .ajax-ma-'+perm).each(function(key, value) { $(table+' .ajax-ma-'+perm).each(function(key, value) {
$(this).attr("checked", enabled); $(this).attr("checked", enabled_attr);
}); });
else if (!enabled) else if (!enabled)
$(table+' #ajax-ma-'+perm+'-master').each(function(key, value) { $(table+' #ajax-ma-'+perm+'-master').each(function(key, value) {
$(this).attr("checked", enabled); $(this).attr("checked", enabled_attr);
}); });
$.ajax({ $.ajax({
@@ -24,7 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
{if $add_permission eq '1'}
{if isset($logged_on_addons)} {if isset($logged_on_addons)}
<!--start addons login--> <!--start addons login-->
@@ -70,7 +70,7 @@
{/if} {/if}
{/if} {/if}
{/if}
<!--start filter module--> <!--start filter module-->
<style>.ac_results { border:1px solid #C2C4D9; }</style> <style>.ac_results { border:1px solid #C2C4D9; }</style>
@@ -28,14 +28,17 @@
<div class="toolbarBox toolbarHead"> <div class="toolbarBox toolbarHead">
<ul class="cc_button"> <ul class="cc_button">
{if $add_permission eq '1'}
<li> <li>
<a id="desc-module-new" class="toolbar_btn" href="#top_container" onclick="$('#module_install').slideToggle();" title="{l s='Add new module'}"> <a id="desc-module-new" class="toolbar_btn" href="#top_container" onclick="$('#module_install').slideToggle();" title="{l s='Add new module'}">
<span class="process-icon-new-module" ></span> <span class="process-icon-new-module" ></span>
<div>{l s='Add new module'}</div> <div>{l s='Add new module'}</div>
</a> </a>
</li> </li>
{/if}
</ul> </ul>
<div class="pageTitle"> <div class="pageTitle">
<h3><span id="current_obj" style="font-weight: normal;"><span class="breadcrumb item-0">Module</span> : <span class="breadcrumb item-1">{l s='List of modules'}</span></span></h3> <h3><span id="current_obj" style="font-weight: normal;"><span class="breadcrumb item-0">Module</span> : <span class="breadcrumb item-1">{l s='List of modules'}</span></span></h3>
</div> </div>
@@ -43,7 +46,7 @@
</div> </div>
</div> </div>
{if $add_permission eq '1'}
<div id="module_install" style="width:500px;margin-top:5px;{if !isset($smarty.post.downloadflag)}display: none;{/if}"> <div id="module_install" style="width:500px;margin-top:5px;{if !isset($smarty.post.downloadflag)}display: none;{/if}">
<fieldset> <fieldset>
<legend><img src="../img/admin/add.gif" alt="{l s='Add a new module'}" class="middle" /> {l s='Add a new module'}</legend> <legend><img src="../img/admin/add.gif" alt="{l s='Add a new module'}" class="middle" /> {l s='Add a new module'}</legend>
@@ -63,5 +66,5 @@
</fieldset> </fieldset>
<br /> <br />
</div> </div>
{/if}
+20 -12
View File
@@ -881,15 +881,26 @@ class AdminModulesControllerCore extends AdminController
return $return; return $return;
} }
public function initModulesList($modules) public function initModulesList(&$modules)
{ {
foreach ($modules as $module) foreach ($modules as $k => $module)
{ {
if (!in_array($module->name, $this->list_natives_modules)) // Check add permissions, if add permissions not set, addons modules and non installed modules will not be displayed
$this->serial_modules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n"; if ($this->tabAccess['add'] !== '1' && isset($module->type) && ($module->type != 'addonsNative' || $module->type != 'addonsBought'))
$module_author = $module->author; unset($modules[$k]);
if (!empty($module_author) && ($module_author != '')) else if ($this->tabAccess['add'] !== '1' && (!isset($module->id) || $module->id < 1))
$this->modules_authors[strtolower($module_author)] = 'notselected'; unset($modules[$k]);
else if ($module->id && !Module::getPermissionStatic($module->id, 'view') && !Module::getPermissionStatic($module->id, 'configure'))
unset($modules[$k]);
else
{
// Init serial and modules author list
if (!in_array($module->name, $this->list_natives_modules))
$this->serial_modules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
$module_author = $module->author;
if (!empty($module_author) && ($module_author != ''))
$this->modules_authors[strtolower($module_author)] = 'notselected';
}
} }
$this->serial_modules = urlencode($this->serial_modules); $this->serial_modules = urlencode($this->serial_modules);
} }
@@ -913,11 +924,6 @@ class AdminModulesControllerCore extends AdminController
public function isModuleFiltered($module) public function isModuleFiltered($module)
{ {
// Beware $module could be an instance of Module or stdClass, that expflain the static call
if ($module->id && !Module::getPermissionStatic($module->id, 'view') && !Module::getPermissionStatic($module->id, 'configure'))
return true;
// If action on module, we display it // If action on module, we display it
if (Tools::getValue('module_name') != '' && Tools::getValue('module_name') == $module->name) if (Tools::getValue('module_name') != '' && Tools::getValue('module_name') == $module->name)
return false; return false;
@@ -1168,6 +1174,8 @@ class AdminModulesControllerCore extends AdminController
$tpl_vars['check_url_fopen'] = (ini_get('allow_url_fopen') ? 'ok' : 'ko'); $tpl_vars['check_url_fopen'] = (ini_get('allow_url_fopen') ? 'ok' : 'ko');
$tpl_vars['check_openssl'] = (extension_loaded('openssl') ? 'ok' : 'ko'); $tpl_vars['check_openssl'] = (extension_loaded('openssl') ? 'ok' : 'ko');
$tpl_vars['add_permission'] = $this->tabAccess['add'];
if ($this->logged_on_addons) if ($this->logged_on_addons)
{ {
$tpl_vars['logged_on_addons'] = 1; $tpl_vars['logged_on_addons'] = 1;
+2 -2
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<module> <module>
<name>productcomments</name> <name>productcomments</name>
<displayName><![CDATA[Product Comments]]></displayName> <displayName><![CDATA[Commentaires produits]]></displayName>
<version><![CDATA[2.3]]></version> <version><![CDATA[2.3]]></version>
<description><![CDATA[Allows users to post reviews.]]></description> <description><![CDATA[Permet aux client de commenter les produits.]]></description>
<author><![CDATA[PrestaShop]]></author> <author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab> <tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable> <is_configurable>1</is_configurable>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<module> <module>
<name>statsforecast</name> <name>statsforecast</name>
<displayName><![CDATA[Stats Dashboard]]></displayName> <displayName><![CDATA[Tableau de bord statistiques]]></displayName>
<version><![CDATA[1]]></version> <version><![CDATA[1]]></version>
<description><![CDATA[]]></description> <description><![CDATA[]]></description>
<author><![CDATA[PrestaShop]]></author> <author><![CDATA[PrestaShop]]></author>
+2 -2
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<module> <module>
<name>themeinstallator</name> <name>themeinstallator</name>
<displayName><![CDATA[Import/export a theme]]></displayName> <displayName><![CDATA[Importer / Exporter un th&egrave;me]]></displayName>
<version><![CDATA[1.4]]></version> <version><![CDATA[1.4]]></version>
<description><![CDATA[Export or Install a theme and its modules on your shop.]]></description> <description><![CDATA[Exporter ou importer un th&egrave;me et ses modules sur votre boutique.]]></description>
<author><![CDATA[PrestaShop]]></author> <author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab> <tab><![CDATA[administration]]></tab>
<is_configurable>1</is_configurable> <is_configurable>1</is_configurable>