[+] BO : you can now set detailed permissions for each module in the back end

This commit is contained in:
dMetzger
2011-07-31 16:39:53 +00:00
parent 30b13ea43e
commit 33bbb70bfa
9 changed files with 360 additions and 95 deletions
+1 -2
View File
@@ -40,11 +40,10 @@ if (empty($tab) and !sizeof($_POST))
$_POST['tab'] = 'AdminHome';
$_POST['token'] = Tools::getAdminTokenLite($tab);
}
if ($id_tab = checkingTab($tab))
if ($adminObj = checkingTab($tab))
{
$isoUser = Language::getIsoById(intval($cookie->id_lang));
if (Validate::isLoadedObject($adminObj))
{
$adminObj->ajax = true;
+125 -14
View File
@@ -68,14 +68,14 @@ class AdminAccess extends AdminTab
$currentProfile = (int)($this->getCurrentProfileId());
$tabs = Tab::getTabs($this->context->language->id);
$profiles = Profile::getProfiles($this->context->language->id);
$accesses = Profile::getProfileAccesses($this->context->language->id);
$accesses = Profile::getProfileAccesses($this->context->employee->id_profile);
echo '
<script type="text/javascript">
setLang(Array(\''.$this->l('Profile updated').'\', \''.$this->l('Request failed!').'\', \''.$this->l('Update in progress. Please wait.').'\', \''.$this->l('Server connection failed!').'\'));
</script>
<div id="ajax_confirmation"></div>
<table class="table" cellspacing="0">
<table class="table float" cellspacing="0">
<tr>
<th '.($currentProfile == (int)_PS_ADMIN_PROFILE_ ? 'colspan="6"' : '').'>
<select name="profile" onchange="redirect(\''.Tools::getHttpHost(true, true).self::$currentIndex.'&token='.$this->token.'&profile=\'+this.options[this.selectedIndex].value)">';
@@ -87,17 +87,36 @@ class AdminAccess extends AdminTab
foreach ($tabs AS $tab)
if ($tab['id_tab'] > $tabsize)
$tabsize = $tab['id_tab'];
echo '
</select>
echo ' </select>
</th>';
if ($currentProfile != (int)(_PS_ADMIN_PROFILE_))
echo '
<th class="center">'.$this->l('View').'<br /><input type="checkbox" name="1" id="viewall" onclick="ajax_power(this, \'view\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Add').'<br /><input type="checkbox" name="1" id="addall" onclick="ajax_power(this, \'add\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Edit').'<br /><input type="checkbox" name="1" id="editall" onclick="ajax_power(this, \'edit\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Delete').'<br /><input type="checkbox" name="1" id="deleteall" onclick="ajax_power(this, \'delete\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('All').'<br /><input type="checkbox" name="1" id="allall" onclick="ajax_power(this, \'all\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">
<input type="checkbox" name="1" id="viewall"
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'view\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')"' : 'disabled="disabled"').' />
'.$this->l('View').'
</th>
<th class="center">
<input type="checkbox" name="1" id="addall"
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'add\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')"' : 'disabled="disabled"').' />
'.$this->l('Add').'
</th>
<th class="center">
<input type="checkbox" name="1" id="editall"
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'edit\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')"' : 'disabled="disabled"').' />
'.$this->l('Edit').'
</th>
<th class="center">
<input type="checkbox" name="1" id="deleteall"
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'delete\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')"' : 'disabled="disabled"').' />
'.$this->l('Delete').'
</th>
<th class="center">
<input type="checkbox" name="1" id="allall"
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'all\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')"' : 'disabled="disabled"').' />
'.$this->l('All').'
</th>
</tr>';
if (!sizeof($tabs))
@@ -114,6 +133,10 @@ class AdminAccess extends AdminTab
$this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true, $tabsize, sizeof($tabs));
}
echo '</table>';
if ($currentProfile != (int)(_PS_ADMIN_PROFILE_))
$this->displayModuleAccesses($currentProfile);
echo '<div class="clear">&nbsp;</div>';
}
private function printTabAccess($currentProfile, $tab, $access, $is_child, $tabsize, $tabnumber)
@@ -123,14 +146,102 @@ class AdminAccess extends AdminTab
echo '<tr><td'.($is_child ? '' : ' class="bold"').'>'.($is_child ? ' &raquo; ' : '').$tab['name'].'</td>';
foreach ($perms as $perm)
{
if($this->tabAccess['edit'] == 1)
echo '<td class="center"><input type="checkbox" name="1" id=\''.$perm.(int)($access['id_tab']).'\' class=\''.$perm.' '.(int)($access['id_tab']).'\' onclick="ajax_power(this, \''.$perm.'\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').'/></td>';
if ($this->tabAccess['edit'] == 1)
echo '<td><input type="checkbox" name="1" id=\''.$perm.(int)($access['id_tab']).'\' class=\''.$perm.' '.(int)($access['id_tab']).'\' onclick="ajax_power(this, \''.$perm.'\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').'/></td>';
else
echo '<td class="center"><input type="checkbox" name="1" disabled="disabled" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').' /></td>';
echo '<td><input type="checkbox" name="1" disabled="disabled" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').' /></td>';
$result_accesses += $access[$perm];
}
echo '<td class="center"><input type="checkbox" name="1" id=\'all'.(int)($access['id_tab']).'\' class=\'all '.(int)($access['id_tab']).'\' onclick="ajax_power(this, \'all\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')" '.($result_accesses == 4 ? 'checked="checked"' : '').'/></td></tr>';
echo '<td>
<input type="checkbox" name="1" id=\'all'.(int)($access['id_tab']).'\' class=\'all '.(int)($access['id_tab']).'\'
'.($this->tabAccess['edit'] == 1 ? 'onclick="ajax_power(this, \'all\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')"' : 'disabled="disabled"').'
'.($result_accesses == 4 ? 'checked="checked"' : '').'
/>
</td></tr>';
}
public function ajaxProcess()
{
if (Tools::isSubmit('changeModuleAccess'))
{
if ($action = Tools::getValue('action') AND $variable = Tools::getValue('variable') AND $id_module = (int)Tools::getValue('id_module') AND $id_profile = (int)Tools::getValue('id_profile') AND $this->tabAccess['edit'] == 1)
{
if (!in_array($variable, array('view', 'configure')))
die (Tools::displayErrors('unknown variable'));
$action = ($action == 'true' ? 1 : 0);
if ($id_module == -1)
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'module_access` SET `'.pSQL($variable).'` = '.(int)$action.' WHERE `id_profile` = '.(int)$id_profile);
else
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'module_access` SET `'.pSQL($variable).'` = '.(int)$action.' WHERE `id_module` = '.(int)$id_module.' AND `id_profile` = '.(int)$id_profile);
die ('ok');
}
die ('inconsistent data');
}
}
private function displayModuleAccesses($currentProfile)
{
echo '
<script type="text/javascript">
function changeModuleAccess(checkbox, id_module, variable)
{
getE(\'ajax_confirmation\').innerHTML = \'<span class="bold">\'+lang[2]+\'</span>\';
$.post(
\'ajax-tab.php?tab=AdminAccess&token='.Tools::getAdminTokenLite('AdminAccess').'&changeModuleAccess\',
{id_profile:'.(int)$currentProfile.',id_module:id_module,action:checkbox.checked,variable:variable},
function(r) {
if (r != \'ok\')
getE(\'ajax_confirmation\').innerHTML = \'<span class="bold">'.addslashes(Tools::displayError('An error occurred:')).' \'+lang[1]+\'</span>\';
else
{
getE(\'ajax_confirmation\').innerHTML = \'<span class="bold">\'+lang[0]+\'</span>\';
if (id_module == -1)
$(\'.ajax-ma-\'+variable).each(function(key, value) {
value.checked = checkbox.checked;
});
else if (!checkbox.checked)
$(\'#ajax-ma-\'+variable+\'-master\').each(function(key, value) {
value.checked = checkbox.checked;
});
}
}
);
}
</script>
<table class="table float" cellspacing="0" style="margin-left:20px">
<tr>
<th>'.$this->l('Modules').'</th>
<th class="center"><input type="checkbox" id="ajax-ma-view-master" '.($this->tabAccess['edit'] == 1 ? 'onclick="changeModuleAccess(this, -1, \'view\');"' : 'disabled="disabled"').' /> '.$this->l('View').'</th>
<th class="center"><input type="checkbox" id="ajax-ma-configure-master" '.($this->tabAccess['edit'] == 1 ? 'onclick="changeModuleAccess(this, -1, \'configure\');"' : 'disabled="disabled"').' /> '.$this->l('Configure').'</th>
</tr>';
$modules = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT ma.id_module, m.name, ma.`view`, ma.`configure`
FROM '._DB_PREFIX_.'module_access ma
LEFT JOIN '._DB_PREFIX_.'module m ON ma.id_module = m.id_module
WHERE id_profile = '.(int)$currentProfile.'
ORDER BY m.name');
if (!sizeof($modules))
echo '<tr><td colspan="2">'.$this->l('No modules installed').'</td></tr>';
else
foreach ($modules AS $module)
echo '<tr>
<td>&raquo; '.$module['name'].'</td>
<td>
<input type="checkbox" class="ajax-ma-view"
'.((int)$module['view'] == 1 ? 'checked="checked"' : '').'
'.($this->tabAccess['edit'] == 1 ? 'onclick="changeModuleAccess(this, '.(int)$module['id_module'].', \'view\');"' : 'disabled="disabled"').'
/>
</td>
<td>
<input type="checkbox" class="ajax-ma-configure"
'.((int)$module['configure'] == 1 ? 'checked="checked"' : '').'
'.($this->tabAccess['edit'] == 1 ? 'onclick="changeModuleAccess(this, '.(int)$module['id_module'].', \'configure\');"' : 'disabled="disabled"').'
/>
</td>
</tr>';
echo '</table>';
}
}
+126 -63
View File
@@ -46,21 +46,24 @@ class AdminModules extends AdminTab
function __construct()
{
parent::__construct ();
parent::__construct();
$this->_moduleCacheFile = _PS_ROOT_DIR_.'/config/modules_list.xml';
//refresh modules_list.xml every week
// refresh modules_list.xml every week
if (!$this->isFresh())
$this->refresh();
$this->listTabModules = array('administration' => $this->l('Administration'), 'advertising_marketing' => $this->l('Advertising & Marketing'),
'analytics_stats' => $this->l('Analytics & Stats'), 'billing_invoicing' => $this->l('Billing & Invoicing'), 'checkout' => $this->l('Checkout'),
'content_management' => $this->l('Content Management'), 'export' => $this->l('Export'), 'front_office_features' => $this->l('Front Office Features'),
'i18n_localization' => $this->l('I18n & Localization'), 'merchandizing' => $this->l('Merchandizing'), 'migration_tools' => $this->l('Migration Tools'),
'payments_gateways' => $this->l('Payments & Gateways'), 'payment_security' => $this->l('Payment Security'), 'pricing_promotion' => $this->l('Pricing & Promotion'),
'quick_bulk_update' => $this->l('Quick / Bulk update'), 'search_filter' => $this->l('Search & Filter'), 'seo' => $this->l('SEO'), 'shipping_logistics' => $this->l('Shipping & Logistics'),
'slideshows' => $this->l('Slideshows'), 'smart_shopping' => $this->l('Smart Shopping'), 'market_place' => $this->l('Market Place'), 'social_networks' => $this->l('Social Networks'), 'others'=> $this->l('Other Modules'));
$this->listTabModules = array(
'administration' => $this->l('Administration'), 'advertising_marketing' => $this->l('Advertising & Marketing'),
'analytics_stats' => $this->l('Analytics & Stats'), 'billing_invoicing' => $this->l('Billing & Invoicing'), 'checkout' => $this->l('Checkout'),
'content_management' => $this->l('Content Management'), 'export' => $this->l('Export'), 'front_office_features' => $this->l('Front Office Features'),
'i18n_localization' => $this->l('I18n & Localization'), 'merchandizing' => $this->l('Merchandizing'), 'migration_tools' => $this->l('Migration Tools'),
'payments_gateways' => $this->l('Payments & Gateways'), 'payment_security' => $this->l('Payment Security'), 'pricing_promotion' => $this->l('Pricing & Promotion'),
'quick_bulk_update' => $this->l('Quick / Bulk update'), 'search_filter' => $this->l('Search & Filter'), 'seo' => $this->l('SEO'), 'shipping_logistics' => $this->l('Shipping & Logistics'),
'slideshows' => $this->l('Slideshows'), 'smart_shopping' => $this->l('Smart Shopping'), 'market_place' => $this->l('Market Place'), 'social_networks' => $this->l('Social Networks'),
'others'=> $this->l('Other Modules')
);
$xmlModules = @simplexml_load_file($this->_moduleCacheFile);
@@ -68,25 +71,25 @@ class AdminModules extends AdminTab
if ($xmlModule->attributes() == 'native')
foreach($xmlModule->children() as $module)
foreach($module->attributes() as $key => $value)
if ($key == 'name')
$this->listNativeModules[] = (string)$value;
if ($key == 'name')
$this->listNativeModules[] = (string)$value;
if ($xmlModule->attributes() == 'partner')
foreach($xmlModule->children() as $module)
foreach($module->attributes() as $key => $value)
if ($key == 'name')
$this->listPartnerModules[] = (string)$value;
if ($key == 'name')
$this->listPartnerModules[] = (string)$value;
}
public function postProcess()
{
$id_employee = (int)$this->context->employee->id;
$filter_conf = Configuration::getMultiple(array(
'PS_SHOW_TYPE_MODULES_'.$id_employee,
'PS_SHOW_COUNTRY_MODULES_'.$id_employee,
'PS_SHOW_INSTALLED_MODULES_'.$id_employee,
'PS_SHOW_ENABLED_MODULES_'.$id_employee
));
//reset filtre
'PS_SHOW_TYPE_MODULES_'.$id_employee,
'PS_SHOW_COUNTRY_MODULES_'.$id_employee,
'PS_SHOW_INSTALLED_MODULES_'.$id_employee,
'PS_SHOW_ENABLED_MODULES_'.$id_employee
));
if (Tools::isSubmit('desactive') && isset($filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee] != 'enabledDisabled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee], 'disabled');
@@ -99,7 +102,6 @@ class AdminModules extends AdminTab
if (Tools::isSubmit('install') && isset($filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee] != 'installedUninstalled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], 'installed', $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]);
if (Tools::isSubmit('filterModules'))
{
$this->setFilterModules(Tools::getValue('module_type'), Tools::getValue('country_module_value'), Tools::getValue('module_install'), Tools::getValue('module_status'));
@@ -110,6 +112,7 @@ class AdminModules extends AdminTab
$this->resetFilterModules();
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}
if (Tools::isSubmit('active'))
{
if ($this->tabAccess['edit'] === '1')
@@ -117,9 +120,15 @@ class AdminModules extends AdminTab
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
$module->enable();
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
} else
if (!$module->getPermission('configure'))
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
else
{
$module->enable();
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
}
}
else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
@@ -131,9 +140,15 @@ class AdminModules extends AdminTab
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
$module->disable();
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
} else
if (!$module->getPermission('configure'))
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
else
{
$module->disable();
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
}
}
else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
@@ -145,15 +160,20 @@ class AdminModules extends AdminTab
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
if ($module->uninstall())
if ($module->install())
Tools::redirectAdmin(self::$currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
else
$this->_errors[] = Tools::displayError('Cannot install module');
if (!$module->getPermission('configure'))
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
else
$this->_errors[] = Tools::displayError('Cannot uninstall module');
} else
{
if ($module->uninstall())
if ($module->install())
Tools::redirectAdmin(self::$currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
else
$this->_errors[] = Tools::displayError('Cannot install module');
else
$this->_errors[] = Tools::displayError('Cannot uninstall module');
}
}
else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
@@ -200,11 +220,16 @@ class AdminModules extends AdminTab
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
if (Tools::getValue('enable'))
$module->enable();
if (!$module->getPermission('configure'))
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
else
$module->disable();
Tools::redirectAdmin($this->getCurrentUrl('enable'));
{
if (Tools::getValue('enable'))
$module->enable();
else
$module->disable();
Tools::redirectAdmin($this->getCurrentUrl('enable'));
}
}
else
$this->_errors[] = Tools::displayError('Cannot load module object');
@@ -219,11 +244,16 @@ class AdminModules extends AdminTab
{
if (Tools::getValue('module_name') != '')
{
$moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name'));
$this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module) AND !$module->getPermission('configure'))
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
else
{
$moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name'));
$this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
}
}
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
@@ -247,15 +277,15 @@ class AdminModules extends AdminTab
if (!($module = Module::getInstanceByName(urldecode($name))))
$this->_errors[] = $this->l('module not found');
elseif ($key == 'install' AND $this->tabAccess['add'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
elseif ($key == 'uninstall' AND $this->tabAccess['delete'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
elseif ($key == 'configure' AND $this->tabAccess['edit'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
$this->_errors[] = Tools::displayError('You do not have permission to install a module.');
elseif ($key == 'uninstall' AND ($this->tabAccess['delete'] !== '1' OR !$module->getPermission('configure')))
$this->_errors[] = Tools::displayError('You do not have permission to delete this module.');
elseif ($key == 'configure' AND ($this->tabAccess['edit'] !== '1' OR !$module->getPermission('configure')))
$this->_errors[] = Tools::displayError('You do not have permission to configure this module.');
elseif ($key == 'install' AND Module::isInstalled($module->name))
$this->_errors[] = Tools::displayError('This module is already installed : ').$module->name;
$this->_errors[] = Tools::displayError('This module is already installed:').' '.$module->name;
elseif ($key == 'uninstall' AND !Module::isInstalled($module->name))
$this->_errors[] = Tools::displayError('This module is already uninstalled : ').$module->name;
$this->_errors[] = Tools::displayError('This module is already uninstalled:').' '.$module->name;
else
{
if (((method_exists($module, $method) && ($echo = $module->{$method}())) || ($echo = ' ')) AND $key == 'configure' AND Module::isInstalled($module->name))
@@ -311,12 +341,11 @@ class AdminModules extends AdminTab
}
if (sizeof($module_errors))
{
$htmlError = '';
$htmlError = '<ul>';
foreach ($module_errors AS $module_error)
$htmlError .= '<li>'.$module_error.'</li>';
$htmlError .= '</ul>';
$this->_errors[] = Tools::displayError('The following module(s) were not installed successfully:'.$htmlError);
$this->_errors[] = Tools::displayError('The following module(s) were not installed successfully:').$htmlError;
}
}
if ($return)
@@ -330,9 +359,9 @@ class AdminModules extends AdminTab
if (substr($file, -4) == '.zip')
{
if (!Tools::ZipExtract($file, _PS_MODULE_DIR_))
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
}
else
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
}
else
{
$archive = new Archive_Tar($file);
if ($archive->extract(_PS_MODULE_DIR_))
@@ -505,22 +534,37 @@ class AdminModules extends AdminTab
</script>';
}
//filter module list
foreach($modules as $key => $module)
// Filter module list
foreach ($modules as $key => $module)
{
if ($module->id AND !Module::getPermissionStatic($module->id, 'view') AND !Module::getPermissionStatic($module->id, 'configure'))
{
unset($modules[$key]);
continue;
}
switch ($showTypeModules)
{
case 'nativeModules':
if (!in_array($module->name, $this->listNativeModules))
{
unset($modules[$key]);
continue;
}
break;
case 'partnerModules':
if (!in_array($module->name, $this->listPartnerModules))
{
unset($modules[$key]);
continue;
}
break;
case 'otherModules':
if (in_array($module->name, $this->listPartnerModules) OR in_array($module->name, $this->listNativeModules))
{
unset($modules[$key]);
continue;
}
break;
default:
if (strpos($showTypeModules, 'authorModules[') !== false)
@@ -528,7 +572,10 @@ class AdminModules extends AdminTab
$author_selected = $this->_getSubmitedModuleAuthor($showTypeModules);
$modulesAuthors[$author_selected] = 'selected'; // setting selected author in authors set
if (empty($module->author) || $module->author != $author_selected)
{
unset($modules[$key]);
continue;
}
}
break;
@@ -539,11 +586,17 @@ class AdminModules extends AdminTab
{
case 'installed':
if (!$module->id)
{
unset($modules[$key]);
continue;
}
break;
case 'unistalled':
if ($module->id)
{
unset($modules[$key]);
continue;
}
break;
}
@@ -551,21 +604,31 @@ class AdminModules extends AdminTab
{
case 'enabled':
if (!$module->active)
{
unset($modules[$key]);
continue;
}
break;
case 'disabled':
if ($module->active)
{
unset($modules[$key]);
continue;
}
break;
}
if ($showCountryModules)
if (isset($module->limited_countries) AND !empty($module->limited_countries) AND ((is_array($module->limited_countries) AND sizeof($module->limited_countries) AND !in_array(strtolower($isoCountryDefault), $module->limited_countries)) OR (!is_array($module->limited_countries) AND strtolower($isoCountryDefault) != strval($module->limited_countries))))
unset($modules[$key]);
if ($showCountryModules AND (isset($module->limited_countries) AND !empty($module->limited_countries) AND ((is_array($module->limited_countries) AND sizeof($module->limited_countries) AND !in_array(strtolower($isoCountryDefault), $module->limited_countries)) OR (!is_array($module->limited_countries) AND strtolower($isoCountryDefault) != strval($module->limited_countries)))))
{
unset($modules[$key]);
continue;
}
if (!empty($filterName))
if (stristr($module->name, $filterName) === false AND stristr($module->displayName, $filterName) === false AND stristr($module->description, $filterName) === false)
unset($modules[$key]);
if (!empty($filterName) AND (stristr($module->name, $filterName) === false AND stristr($module->displayName, $filterName) === false AND stristr($module->description, $filterName) === false))
{
unset($modules[$key]);
continue;
}
}
foreach($modules as $module)