[*] BO : New module interface tab now all html is in tpl
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<ul class="cc_button">
|
<ul class="cc_button">
|
||||||
<li>
|
<li>
|
||||||
<a id="desc-module-new" class="toolbar_btn" href="#" onclick="$('#module_install').slideToggle();return false;" title="Add new">
|
<a id="desc-module-new" class="toolbar_btn" href="#top_container" onclick="$('#module_install').slideToggle();" title="Add new">
|
||||||
<span class="process-icon-new-module" ></span>
|
<span class="process-icon-new-module" ></span>
|
||||||
<div>Add new module</div>
|
<div>Add new module</div>
|
||||||
</a>
|
</a>
|
||||||
@@ -47,12 +47,15 @@
|
|||||||
<h3><span id="current_obj" style="font-weight: normal;"><span class="breadcrumb item-0">Module</span> : <span class="breadcrumb item-1">Liste de 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">Liste de modules</span></span></h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="module_install" style="width:900px;{if !isset($smarty.post.downloadflag)}display: none;{/if}">
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
<p>{'The module must be either a zip file or a tarball.'}</p>
|
<p>{'The module must be either a zip file or a tarball.'}</p>
|
||||||
<hr />
|
<div style="float:left;margin-right:50px">
|
||||||
<div style="float:right;margin-right:50px;border-left:solid 1px #DFD5C3">
|
|
||||||
<form action="{$currentIndex}&token={$token}" method="post" enctype="multipart/form-data">
|
<form action="{$currentIndex}&token={$token}" method="post" enctype="multipart/form-data">
|
||||||
<label style="width: 100px">{l s='Module file'}</label>
|
<label style="width: 100px">{l s='Module file'}</label>
|
||||||
<div class="margin-form" style="padding-left: 140px">
|
<div class="margin-form" style="padding-left: 140px">
|
||||||
@@ -60,7 +63,7 @@
|
|||||||
<p>{l s='Upload the module from your computer.'}</p>
|
<p>{l s='Upload the module from your computer.'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form" style="padding-left: 140px">
|
<div class="margin-form" style="padding-left: 140px">
|
||||||
<input type="submit" name="submitDownload2" value="{l s='Upload this module'}" class="button" />
|
<input type="submit" name="download" value="{l s='Upload this module'}" class="button" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,8 +71,6 @@
|
|||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!--start filter module-->
|
<!--start filter module-->
|
||||||
<div class="filter-module">
|
<div class="filter-module">
|
||||||
@@ -87,14 +88,18 @@
|
|||||||
<option value="allModules" {if $showTypeModules eq 'allModules'}selected="selected"{/if}>{l s='All Modules'}</option>
|
<option value="allModules" {if $showTypeModules eq 'allModules'}selected="selected"{/if}>{l s='All Modules'}</option>
|
||||||
<option value="nativeModules" {if $showTypeModules eq 'nativeModules'}selected="selected"{/if}>{l s='Native Modules'}</option>
|
<option value="nativeModules" {if $showTypeModules eq 'nativeModules'}selected="selected"{/if}>{l s='Native Modules'}</option>
|
||||||
<option value="partnerModules" {if $showTypeModules eq 'partnerModules'}selected="selected"{/if}>{l s='Partners Modules'}</option>
|
<option value="partnerModules" {if $showTypeModules eq 'partnerModules'}selected="selected"{/if}>{l s='Partners Modules'}</option>
|
||||||
{$authorsOptionsList}
|
<optgroup label="{l s='Authors'}">
|
||||||
|
{foreach from=$list_modules_authors key=module_author item=status}
|
||||||
|
<option value="authorModules[{$module_author}]" {if $status eq "selected"}selected{/if}>{$module_author|truncate:20:'...'}</option>
|
||||||
|
{/foreach}
|
||||||
|
</optgroup>
|
||||||
<option value="otherModules" {if $showTypeModules eq 'otherModules'}selected="selected"{/if}>{l s='Others Modules'}</option>
|
<option value="otherModules" {if $showTypeModules eq 'otherModules'}selected="selected"{/if}>{l s='Others Modules'}</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select name="module_install">
|
<select name="module_install">
|
||||||
<option value="installedUninstalled" {if $showInstalledModules eq 'installedUninstalled'}selected="selected"{/if}>{l s='Installed & Uninstalled'}</option>
|
<option value="installedUninstalled" {if $showInstalledModules eq 'installedUninstalled'}selected="selected"{/if}>{l s='Installed & Uninstalled'}</option>
|
||||||
<option value="installed" {if $showInstalledModules eq 'installed'}selected="selected"{/if}>{l s='Installed Modules'}</option>
|
<option value="installed" {if $showInstalledModules eq 'installed'}selected="selected"{/if}>{l s='Installed Modules'}</option>
|
||||||
<option value="unistalled" {if $showInstalledModules eq 'unistalled'}selected="selected"{/if}>{l s='Uninstalled Modules'}</option>
|
<option value="uninstalled" {if $showInstalledModules eq 'uninstalled'}selected="selected"{/if}>{l s='Uninstalled Modules'}</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select name="module_status">
|
<select name="module_status">
|
||||||
@@ -111,8 +116,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-filter">
|
<div class="button-filter">
|
||||||
<input type="submit" value="{l s='Reset'}" name="resetFilterModules" class="button">
|
<input type="submit" value="{l s='Reset'}" name="resetFilterModules" class="button" />
|
||||||
<input type="submit" value="{l s='Filter'}" name="filterModules" class="button">
|
<input type="submit" value="{l s='Filter'}" name="filterModules" class="button" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
@@ -136,6 +141,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="categorieStatus">
|
<div class="categorieStatus">
|
||||||
<h3>Etat du module</h3>
|
<h3>Etat du module</h3>
|
||||||
<div class="subHeadline">{$nb_modules}</div>
|
<div class="subHeadline">{$nb_modules}</div>
|
||||||
|
|||||||
@@ -25,11 +25,15 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
include_once(_PS_ADMIN_DIR_.'/../tools/tar/Archive_Tar.php');
|
include_once(_PS_ADMIN_DIR_.'/../tools/tar/Archive_Tar.php');
|
||||||
|
|
||||||
class AdminModulesControllerCore extends AdminController
|
class AdminModulesControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
/** @var array map with $_GET keywords and their callback */
|
|
||||||
|
/*
|
||||||
|
** @var array map with $_GET keywords and their callback
|
||||||
|
*/
|
||||||
private $map = array(
|
private $map = array(
|
||||||
'install' => 'install',
|
'install' => 'install',
|
||||||
'uninstall' => 'uninstall',
|
'uninstall' => 'uninstall',
|
||||||
@@ -50,6 +54,21 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
private $serial_modules = '';
|
private $serial_modules = '';
|
||||||
private $modules_authors = array();
|
private $modules_authors = array();
|
||||||
|
|
||||||
|
private $id_employee;
|
||||||
|
private $iso_default_country;
|
||||||
|
private $filter_configuration = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Admin Modules Controller Constructor
|
||||||
|
** Init list modules categories
|
||||||
|
** Load id employee
|
||||||
|
** Load filter configuration
|
||||||
|
** Load cache file
|
||||||
|
*/
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@@ -79,38 +98,49 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->list_modules_categories['social_networks']['name'] = $this->l('Social Networks');
|
$this->list_modules_categories['social_networks']['name'] = $this->l('Social Networks');
|
||||||
$this->list_modules_categories['others']['name'] = $this->l('Other Modules');
|
$this->list_modules_categories['others']['name'] = $this->l('Other Modules');
|
||||||
|
|
||||||
|
// Set Id Employee, Iso Default Country and Filter Configuration
|
||||||
|
$this->id_employee = (int)$this->context->employee->id;
|
||||||
|
$this->iso_default_country = $this->context->country->iso_code;
|
||||||
|
$this->filter_configuration = Configuration::getMultiple(array(
|
||||||
|
'PS_SHOW_TYPE_MODULES_'.(int)$this->id_employee,
|
||||||
|
'PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee,
|
||||||
|
'PS_SHOW_INSTALLED_MODULES_'.(int)$this->id_employee,
|
||||||
|
'PS_SHOW_ENABLED_MODULES_'.(int)$this->id_employee,
|
||||||
|
'PS_SHOW_CAT_MODULES_'.(int)$this->id_employee,
|
||||||
|
));
|
||||||
|
|
||||||
// Load cache file modules list (natives and partners modules)
|
// Load cache file modules list (natives and partners modules)
|
||||||
|
$xmlModules = false;
|
||||||
if (file_exists(_PS_ROOT_DIR_.$this->cache_file_modules_list))
|
if (file_exists(_PS_ROOT_DIR_.$this->cache_file_modules_list))
|
||||||
$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->cache_file_modules_list);
|
$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->cache_file_modules_list);
|
||||||
else
|
|
||||||
$xmlModules = false;
|
|
||||||
if ($xmlModules)
|
if ($xmlModules)
|
||||||
{
|
|
||||||
foreach($xmlModules->children() as $xmlModule)
|
foreach($xmlModules->children() as $xmlModule)
|
||||||
{
|
|
||||||
if ($xmlModule->attributes() == 'native')
|
|
||||||
foreach($xmlModule->children() as $module)
|
foreach($xmlModule->children() as $module)
|
||||||
foreach($module->attributes() as $key => $value)
|
foreach($module->attributes() as $key => $value)
|
||||||
if ($key == 'name')
|
{
|
||||||
|
if ($xmlModule->attributes() == 'native' && $key == 'name')
|
||||||
$this->list_natives_modules[] = (string)$value;
|
$this->list_natives_modules[] = (string)$value;
|
||||||
|
if ($xmlModule->attributes() == 'partner' && $key == 'name')
|
||||||
if ($xmlModule->attributes() == 'partner')
|
|
||||||
foreach ($xmlModule->children() as $module)
|
|
||||||
foreach ($module->attributes() as $key => $value)
|
|
||||||
if ($key == 'name')
|
|
||||||
$this->list_partners_modules[] = (string)$value;
|
$this->list_partners_modules[] = (string)$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** if modules_list.xml is outdated,
|
|
||||||
* this function will re-upload it from prestashop.com
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
|
/*
|
||||||
|
** Ajax Request Methods
|
||||||
|
**
|
||||||
|
** if modules_list.xml is outdated,
|
||||||
|
** this function will re-upload it from prestashop.com
|
||||||
|
**
|
||||||
|
** @return null
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function ajaxProcessRefreshModuleList()
|
public function ajaxProcessRefreshModuleList()
|
||||||
{
|
{
|
||||||
//refresh modules_list.xml every week
|
// Refresh modules_list.xml every week
|
||||||
if (!$this->isFresh())
|
if (!$this->isFresh())
|
||||||
{
|
{
|
||||||
if ($this->refresh())
|
if ($this->refresh())
|
||||||
@@ -122,7 +152,6 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->status = 'cache';
|
$this->status = 'cache';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isFresh($timeout = 604800000)
|
public function isFresh($timeout = 604800000)
|
||||||
{
|
{
|
||||||
if (file_exists(_PS_ROOT_DIR_ . $this->_moduleCacheFile))
|
if (file_exists(_PS_ROOT_DIR_ . $this->_moduleCacheFile))
|
||||||
@@ -141,30 +170,18 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
echo Tools::jsonEncode(array('status' => $this->status));
|
echo Tools::jsonEncode(array('status' => $this->status));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setFilterModules($module_type, $country_module_value, $module_install, $module_status)
|
|
||||||
{
|
|
||||||
$this->context = Context::getContext();
|
|
||||||
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)$this->context->employee->id, $module_type);
|
|
||||||
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)$this->context->employee->id, $country_module_value);
|
|
||||||
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)$this->context->employee->id, $module_install);
|
|
||||||
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)$this->context->employee->id, $module_status);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function resetFilterModules()
|
|
||||||
{
|
|
||||||
$this->context = Context::getContext();
|
|
||||||
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)$this->context->employee->id, 'allModules');
|
|
||||||
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)$this->context->employee->id, 0);
|
|
||||||
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)$this->context->employee->id, 'installedUninstalled');
|
|
||||||
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)$this->context->employee->id, 'enabledDisabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get current URL
|
|
||||||
*
|
|
||||||
* @param array $remove List of keys to remove from URL
|
/*
|
||||||
* @return string
|
** Get current URL
|
||||||
|
**
|
||||||
|
** @param array $remove List of keys to remove from URL
|
||||||
|
** @return string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected function getCurrentUrl($remove = array())
|
protected function getCurrentUrl($remove = array())
|
||||||
{
|
{
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
@@ -181,123 +198,150 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _getSubmitedModuleAuthor($value)
|
private function extractArchive($file)
|
||||||
{
|
{
|
||||||
$value = str_replace('authorModules[', '', $value);
|
$success = false;
|
||||||
$value = str_replace("\'", "'", $value);
|
if (substr($file, -4) == '.zip')
|
||||||
|
{
|
||||||
$value = substr($value, 0, -1);
|
if (!Tools::ZipExtract($file, _PS_MODULE_DIR_))
|
||||||
return $value;
|
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$archive = new Archive_Tar($file);
|
||||||
|
if ($archive->extract(_PS_MODULE_DIR_))
|
||||||
|
$success = true;
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
@unlink($file);
|
||||||
{
|
if ($success)
|
||||||
$id_employee = (int)$this->context->employee->id;
|
Tools::redirectAdmin(self::$currentIndex.'&conf=8'.'&token='.$this->token);
|
||||||
$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
|
|
||||||
));
|
|
||||||
|
|
||||||
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');
|
|
||||||
|
|
||||||
if (Tools::isSubmit('active') && 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], 'enabled');
|
|
||||||
|
|
||||||
if (Tools::isSubmit('uninstall') && 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], 'unistalled', $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]);
|
|
||||||
|
|
||||||
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::getValue('filterCategory') != '')
|
|
||||||
{
|
|
||||||
$newFilterCategory = Tools::getValue('filterCategory');
|
|
||||||
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id));
|
|
||||||
|
|
||||||
// Check if category is not already filtered
|
|
||||||
foreach ($filterCategories as $fc)
|
|
||||||
if ($fc == $newFilterCategory)
|
|
||||||
$newFilterCategory = '';
|
|
||||||
|
|
||||||
// Add the new filter
|
|
||||||
if ($newFilterCategory != '')
|
|
||||||
$filterCategories[] = $newFilterCategory;
|
|
||||||
$filterCategories = implode('|', $filterCategories);
|
|
||||||
|
|
||||||
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id, $filterCategories);
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::getValue('unfilterCategory') != '')
|
private function recursiveDeleteOnDisk($dir)
|
||||||
{
|
{
|
||||||
$unfilterCategory = Tools::getValue('unfilterCategory');
|
if (strpos(realpath($dir), realpath(_PS_MODULE_DIR_)) === false)
|
||||||
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id));
|
return ;
|
||||||
|
if (is_dir($dir))
|
||||||
// Remove the category
|
{
|
||||||
foreach ($filterCategories as $k => $fc)
|
$objects = scandir($dir);
|
||||||
if ($fc == $unfilterCategory)
|
foreach ($objects as $object)
|
||||||
unset($filterCategories[$k]);
|
if ($object != "." && $object != "..")
|
||||||
|
{
|
||||||
$filterCategories = implode('|', $filterCategories);
|
if (filetype($dir."/".$object) == "dir")
|
||||||
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id, $filterCategories);
|
$this->recursiveDeleteOnDisk($dir."/".$object);
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
else
|
||||||
|
unlink($dir."/".$object);
|
||||||
|
}
|
||||||
|
reset($objects);
|
||||||
|
rmdir($dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('filterModules'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Filter Configuration Methods
|
||||||
|
** Set and reset filter configuration
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function setFilterModules($module_type, $country_module_value, $module_install, $module_status)
|
||||||
|
{
|
||||||
|
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)$this->id_employee, $module_type);
|
||||||
|
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee, $country_module_value);
|
||||||
|
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)$this->id_employee, $module_install);
|
||||||
|
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)$this->id_employee, $module_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resetFilterModules()
|
||||||
|
{
|
||||||
|
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)$this->id_employee, 'allModules');
|
||||||
|
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee, 0);
|
||||||
|
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)$this->id_employee, 'installedUninstalled');
|
||||||
|
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)$this->id_employee, 'enabledDisabled');
|
||||||
|
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Post Process Filter
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function postProcessFilterModules()
|
||||||
{
|
{
|
||||||
$this->setFilterModules(Tools::getValue('module_type'), Tools::getValue('country_module_value'), Tools::getValue('module_install'), Tools::getValue('module_status'));
|
$this->setFilterModules(Tools::getValue('module_type'), Tools::getValue('country_module_value'), Tools::getValue('module_install'), Tools::getValue('module_status'));
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
elseif (Tools::isSubmit('resetFilterModules'))
|
|
||||||
|
public function postProcessResetFilterModules()
|
||||||
{
|
{
|
||||||
$this->resetFilterModules();
|
$this->resetFilterModules();
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('active'))
|
public function postProcessFilterCategory()
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
// Retrieve filter categories configuration and the new filter category
|
||||||
{
|
$filterCategory = Tools::getValue('filterCategory');
|
||||||
$module = Module::getInstanceByName(Tools::getValue('module_name'));
|
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
|
||||||
if (Validate::isLoadedObject($module))
|
|
||||||
{
|
// Check if category filter not already exists
|
||||||
if (!$module->getPermission('configure'))
|
foreach ($filterCategories as $fc)
|
||||||
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
|
if ($fc == $filterCategories)
|
||||||
else
|
$filterCategories = '';
|
||||||
{
|
|
||||||
$module->enable();
|
// If not, add the new filter
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
if ($filterCategories != '')
|
||||||
|
$filterCategories[] = $filterCategory;
|
||||||
|
$filterCategories = implode('|', $filterCategories);
|
||||||
|
|
||||||
|
// For the moment, we will filter only one category a time
|
||||||
|
$filterCategories = $filterCategory;
|
||||||
|
|
||||||
|
// Save configuration and redirect employee
|
||||||
|
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, $filterCategories);
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
public function postProcessUnfilterCategory()
|
||||||
$this->_errors[] = Tools::displayError('Cannot load module object');
|
|
||||||
} else
|
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
|
||||||
}
|
|
||||||
elseif (Tools::isSubmit('desactive'))
|
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
// Retrieve filter categories configuration and the filter category to remove
|
||||||
{
|
$unfilterCategory = Tools::getValue('unfilterCategory');
|
||||||
$module = Module::getInstanceByName(Tools::getValue('module_name'));
|
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
|
||||||
if (Validate::isLoadedObject($module))
|
|
||||||
{
|
// Remove the filter category
|
||||||
if (!$module->getPermission('configure'))
|
foreach ($filterCategories as $k => $fc)
|
||||||
$this->_errors[] = Tools::displayError('You do not have the permission to use this module');
|
if ($fc == $unfilterCategory)
|
||||||
else
|
unset($filterCategories[$k]);
|
||||||
{
|
|
||||||
$module->disable();
|
// For the moment, we will filter only one category a time
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
$filterCategories = '';
|
||||||
|
|
||||||
|
// Save configuration and redirect employee
|
||||||
|
$filterCategories = implode('|', $filterCategories);
|
||||||
|
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, $filterCategories);
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('Cannot load module object');
|
|
||||||
} else
|
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
|
||||||
}
|
|
||||||
elseif (Tools::isSubmit('reset'))
|
/*
|
||||||
|
** Post Process Module CallBack
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function postProcessReset()
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
if ($this->tabAccess['edit'] === '1')
|
||||||
{
|
{
|
||||||
@@ -319,20 +363,25 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('Cannot load module object');
|
$this->_errors[] = Tools::displayError('Cannot load module object');
|
||||||
} else
|
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Automatically copy a module from external URL and unarchive it in the appropriated directory */
|
else
|
||||||
if (Tools::isSubmit('submitDownload2'))
|
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postProcessDownload()
|
||||||
{
|
{
|
||||||
/* PrestaShop demo mode */
|
// Check the flag
|
||||||
|
if (Tools::getValue('enable') === false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// PrestaShop demo mode
|
||||||
if (_PS_MODE_DEMO_)
|
if (_PS_MODE_DEMO_)
|
||||||
{
|
{
|
||||||
$this->_errors[] = Tools::displayError('This functionnality has been disabled.');
|
$this->_errors[] = Tools::displayError('This functionnality has been disabled.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* PrestaShop demo mode*/
|
|
||||||
|
// Try to upload and unarchive the module
|
||||||
if ($this->tabAccess['add'] === '1')
|
if ($this->tabAccess['add'] === '1')
|
||||||
{
|
{
|
||||||
if (!isset($_FILES['file']['tmp_name']) OR empty($_FILES['file']['tmp_name']))
|
if (!isset($_FILES['file']['tmp_name']) OR empty($_FILES['file']['tmp_name']))
|
||||||
@@ -348,8 +397,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable / disable module
|
public function postProcessEnable()
|
||||||
if (Tools::getValue('enable') !== false)
|
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
if ($this->tabAccess['edit'] === '1')
|
||||||
{
|
{
|
||||||
@@ -374,7 +422,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('deleteModule'))
|
public function postProcessDelete()
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
{
|
{
|
||||||
@@ -395,8 +443,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call appropriate module callback */
|
public function postProcessCallback()
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$return = false;
|
$return = false;
|
||||||
foreach ($this->map as $key => $method)
|
foreach ($this->map as $key => $method)
|
||||||
@@ -438,18 +485,14 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id;
|
$hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id;
|
||||||
$tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang=';
|
$tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang=';
|
||||||
|
|
||||||
$toolbar = '
|
$toolbar = '<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center"><tr>
|
||||||
<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center">
|
|
||||||
<tr>
|
|
||||||
<th>'.$this->l('Module').' <span style="color: green;">'.$module->name.'</span></th>
|
<th>'.$this->l('Module').' <span style="color: green;">'.$module->name.'</span></th>
|
||||||
<th><a href="'.$backlink.'" style="padding:5px 10px">'.$this->l('Back').'</a></th>
|
<th><a href="'.$backlink.'" style="padding:5px 10px">'.$this->l('Back').'</a></th>
|
||||||
<th><a href="'.$hooklink.'" style="padding:5px 10px">'.$this->l('Manage hooks').'</a></th>
|
<th><a href="'.$hooklink.'" style="padding:5px 10px">'.$this->l('Manage hooks').'</a></th>
|
||||||
<th style="padding:5px 10px">'.$this->l('Manage translations:').' ';
|
<th style="padding:5px 10px">'.$this->l('Manage translations:').' ';
|
||||||
foreach (Language::getLanguages(false) AS $language)
|
foreach (Language::getLanguages(false) AS $language)
|
||||||
$toolbar .= '<a href="'.$tradlink.$language['iso_code'].'#'.$module->name.'" style="margin-left:5px"><img src="'._THEME_LANG_DIR_.$language['id_lang'].'.jpg" alt="'.$language['iso_code'].'" title="'.$language['iso_code'].'" /></a>';
|
$toolbar .= '<a href="'.$tradlink.$language['iso_code'].'#'.$module->name.'" style="margin-left:5px"><img src="'._THEME_LANG_DIR_.$language['id_lang'].'.jpg" alt="'.$language['iso_code'].'" title="'.$language['iso_code'].'" /></a>';
|
||||||
$toolbar .= '
|
$toolbar .= '</th></tr>';
|
||||||
</th>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
// Display checkbox in toolbar if multishop
|
// Display checkbox in toolbar if multishop
|
||||||
if (Shop::isFeatureActive())
|
if (Shop::isFeatureActive())
|
||||||
@@ -467,7 +510,6 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$toolbar .= '</th>
|
$toolbar .= '</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$toolbar .= '</table>';
|
$toolbar .= '</table>';
|
||||||
|
|
||||||
// Display configure page
|
// Display configure page
|
||||||
@@ -486,7 +528,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($key != 'configure' && isset($_GET['bpay']))
|
if ($key != 'configure' && isset($_GET['bpay']))
|
||||||
Tools::redirectAdmin('index.php?tab=AdminPayment&token='.Tools::getAdminToken('AdminPayment'.(int)(Tab::getIdFromClassName('AdminPayment')).(int)$this->context->employee->id));
|
Tools::redirectAdmin('index.php?tab=AdminPayment&token='.Tools::getAdminToken('AdminPayment'.(int)(Tab::getIdFromClassName('AdminPayment')).(int)$this->id_employee));
|
||||||
}
|
}
|
||||||
if (count($module_errors))
|
if (count($module_errors))
|
||||||
{
|
{
|
||||||
@@ -502,63 +544,36 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
if ($return)
|
if ($return)
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function extractArchive($file)
|
public function postProcess()
|
||||||
{
|
{
|
||||||
$success = false;
|
// Execute filter or callback methods
|
||||||
if (substr($file, -4) == '.zip')
|
$filterMethods = array('filterModules', 'resetFilterModules', 'filterCategory', 'unfilterCategory');
|
||||||
|
$callbackMethods = array('reset', 'download', 'enable', 'delete');
|
||||||
|
$postProcessMethodsList = array_merge((array)$filterMethods, (array)$callbackMethods);
|
||||||
|
foreach ($postProcessMethodsList as $ppm)
|
||||||
|
if (Tools::isSubmit($ppm))
|
||||||
{
|
{
|
||||||
if (!Tools::ZipExtract($file, _PS_MODULE_DIR_))
|
$ppm = 'postProcess'.ucfirst($ppm);
|
||||||
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
|
if (method_exists($this, $ppm))
|
||||||
}
|
$ppmReturn = $this->$ppm();
|
||||||
else
|
|
||||||
{
|
|
||||||
$archive = new Archive_Tar($file);
|
|
||||||
if ($archive->extract(_PS_MODULE_DIR_))
|
|
||||||
$success = true;
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@unlink($file);
|
// Call appropriate module callback
|
||||||
if ($success)
|
if (!isset($ppmReturn))
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=8'.'&token='.$this->token);
|
$this->postProcessCallback();
|
||||||
}
|
|
||||||
|
|
||||||
public static function sortModule($a, $b)
|
|
||||||
{
|
|
||||||
if (sizeof($a) == sizeof($b)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (sizeof($a) < sizeof($b)) ? -1 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function recursiveDeleteOnDisk($dir)
|
|
||||||
{
|
|
||||||
if (strpos(realpath($dir), realpath(_PS_MODULE_DIR_)) === false)
|
|
||||||
return ;
|
|
||||||
if (is_dir($dir))
|
|
||||||
{
|
|
||||||
$objects = scandir($dir);
|
|
||||||
foreach ($objects as $object)
|
|
||||||
if ($object != "." && $object != "..")
|
|
||||||
{
|
|
||||||
if (filetype($dir."/".$object) == "dir")
|
|
||||||
$this->recursiveDeleteOnDisk($dir."/".$object);
|
|
||||||
else
|
|
||||||
unlink($dir."/".$object);
|
|
||||||
}
|
|
||||||
reset($objects);
|
|
||||||
rmdir($dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO : CHANGE THESE TWO METHODS INTO TPL
|
/*
|
||||||
|
** Display Modules Lists
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
public function displayModuleOptions($module)
|
public function displayModuleOptions($module)
|
||||||
{
|
{
|
||||||
$return = '';
|
$return = '';
|
||||||
@@ -572,26 +587,11 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
if ($module->id AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND $module->is_configurable) OR Shop::isFeatureActive()))
|
if ($module->id AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND $module->is_configurable) OR Shop::isFeatureActive()))
|
||||||
$return .= (!empty($result) ? '|' : '').'<span class="configure-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Configure').'</a></span>';
|
$return .= (!empty($result) ? '|' : '').'<span class="configure-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Configure').'</a></span>';
|
||||||
|
|
||||||
$hrefDelete = self::$currentIndex.'&deleteModule='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
|
$hrefDelete = self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
|
||||||
$return .= (!empty($result) ? '|' : '').'<span class="delete-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('delete', $hrefDelete).'"' : '').' onclick="return confirm(\''.$this->l('This action will permanently remove the module from the server. Are you sure you want to do this ?').'\');" href="'.$hrefDelete.'">'.$this->l('Delete').'</a></span>';
|
$return .= (!empty($result) ? '|' : '').'<span class="delete-module"><a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('delete', $hrefDelete).'"' : '').' onclick="return confirm(\''.$this->l('This action will permanently remove the module from the server. Are you sure you want to do this ?').'\');" href="'.$hrefDelete.'">'.$this->l('Delete').'</a></span>';
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
private function displayModuleAuthorsOptGroup($authors, $fieldName = "UNDEFINED")
|
|
||||||
{
|
|
||||||
$out = '<optgroup label="'.$this->l('Authors').'">';
|
|
||||||
foreach($authors as $author_item => $status)
|
|
||||||
{
|
|
||||||
$author_item = Tools::htmlentitiesUTF8($author_item);
|
|
||||||
$disp_author = ((strlen($author_item) > 20) ? substr($author_item, 0, 20).'...' : $author_item);
|
|
||||||
|
|
||||||
$out .= '<option value="'.$fieldName.'['.$author_item. ']"'. (($status === "selected") ? ' selected>' : '>').$disp_author .'</option>';
|
|
||||||
}
|
|
||||||
$out .= '</optgroup>';
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function initModulesList($modules)
|
public function initModulesList($modules)
|
||||||
{
|
{
|
||||||
@@ -601,7 +601,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->serial_modules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
|
$this->serial_modules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
|
||||||
$module_author = $module->author;
|
$module_author = $module->author;
|
||||||
if (!empty($module_author)&& ($module_author != ""))
|
if (!empty($module_author)&& ($module_author != ""))
|
||||||
$this->modules_authors[(string)$module_author] = true;
|
$this->modules_authors[(string)$module_author] = 'notselected';
|
||||||
}
|
}
|
||||||
$this->serial_modules = urlencode($this->serial_modules);
|
$this->serial_modules = urlencode($this->serial_modules);
|
||||||
}
|
}
|
||||||
@@ -623,18 +623,16 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->list_modules_categories['others']['nb']++;
|
$this->list_modules_categories['others']['nb']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moduleFiltered($module)
|
public function isModuleFiltered($module)
|
||||||
{
|
{
|
||||||
$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)$this->context->employee->id);
|
// Beware $module could be an instance of Module or stdClass, that explain the static call
|
||||||
$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)$this->context->employee->id);
|
if ($module->id AND !Module::getPermissionStatic($module->id, 'view') AND !Module::getPermissionStatic($module->id, 'configure'))
|
||||||
$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)$this->context->employee->id);
|
return true;
|
||||||
$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)$this->context->employee->id);
|
|
||||||
$nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
|
|
||||||
$isoCountryDefault = $this->context->country->iso_code;
|
|
||||||
$filterName = Tools::getValue('filtername');
|
|
||||||
|
|
||||||
|
|
||||||
|
// Filter on module category
|
||||||
$categoryFiltered = array();
|
$categoryFiltered = array();
|
||||||
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id));
|
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
|
||||||
if (count($filterCategories) > 0)
|
if (count($filterCategories) > 0)
|
||||||
foreach ($filterCategories as $fc)
|
foreach ($filterCategories as $fc)
|
||||||
if (!empty($fc))
|
if (!empty($fc))
|
||||||
@@ -643,66 +641,53 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
// Filter on module type and author
|
||||||
// beware $module could be an instance of Module or stdClass, that explain the static call
|
$show_type_modules = $this->filter_configuration['PS_SHOW_TYPE_MODULES_'.(int)$this->id_employee];
|
||||||
if ($module->id AND !Module::getPermissionStatic($module->id, 'view') AND !Module::getPermissionStatic($module->id, 'configure'))
|
if ($show_type_modules == 'nativeModules' && !in_array($module->name, $this->list_natives_modules))
|
||||||
return true;
|
return true;
|
||||||
|
else if ($show_type_modules == 'partnerModules' && !in_array($module->name, $this->list_partners_modules))
|
||||||
switch ($showTypeModules)
|
return true;
|
||||||
|
else if ($show_type_modules == 'otherModules' && (in_array($module->name, $this->list_partners_modules) OR in_array($module->name, $this->list_natives_modules)))
|
||||||
|
return true;
|
||||||
|
else if (strpos($show_type_modules, 'authorModules[') !== false)
|
||||||
{
|
{
|
||||||
case 'nativeModules':
|
// setting selected author in authors set
|
||||||
if (!in_array($module->name, $this->list_natives_modules))
|
$author_selected = substr(str_replace(array('authorModules[', "\'"), array('', "'"), $show_type_modules), 0, -1);
|
||||||
return true;
|
$this->modules_authors[$author_selected] = 'selected';
|
||||||
break;
|
|
||||||
case 'partnerModules':
|
|
||||||
if (!in_array($module->name, $this->list_partners_modules))
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
case 'otherModules':
|
|
||||||
if (in_array($module->name, $this->list_partners_modules) OR in_array($module->name, $this->list_natives_modules))
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (strpos($showTypeModules, 'authorModules[') !== false)
|
|
||||||
{
|
|
||||||
$author_selected = $this->_getSubmitedModuleAuthor($showTypeModules);
|
|
||||||
$modulesAuthors[$author_selected] = 'selected'; // setting selected author in authors set
|
|
||||||
if (empty($module->author) || $module->author != $author_selected)
|
if (empty($module->author) || $module->author != $author_selected)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($showInstalledModules)
|
|
||||||
{
|
|
||||||
case 'installed':
|
|
||||||
if (!$module->id)
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
case 'unistalled':
|
|
||||||
if ($module->id)
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($showEnabledModules)
|
// Filter on install status
|
||||||
{
|
$show_installed_modules = $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_'.(int)$this->id_employee];
|
||||||
case 'enabled':
|
if ($show_installed_modules == 'installed' && !$module->id)
|
||||||
if (!$module->active)
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
if ($show_installed_modules == 'uninstalled' && $module->id)
|
||||||
case 'disabled':
|
|
||||||
if ($module->active)
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)))))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!empty($filterName) AND (stristr($module->name, $filterName) === false AND stristr($module->displayName, $filterName) === false AND stristr($module->description, $filterName) === false))
|
|
||||||
|
// Filter on active status
|
||||||
|
$show_enabled_modules = $this->filter_configuration['PS_SHOW_ENABLED_MODULES_'.(int)$this->id_employee];
|
||||||
|
if ($show_enabled_modules == 'enabled' && !$module->active)
|
||||||
|
return true;
|
||||||
|
if ($show_enabled_modules == 'disabled' && $module->active)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
// Filter on country
|
||||||
|
$show_country_modules = $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee];
|
||||||
|
if ($show_country_modules 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($this->iso_default_country), $module->limited_countries)) OR (!is_array($module->limited_countries) AND strtolower($this->iso_default_country) != strval($module->limited_countries)))))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
// Filter on module name
|
||||||
|
$filter_name = Tools::getValue('filtername');
|
||||||
|
if (!empty($filter_name) AND (stristr($module->name, $filter_name) === false AND stristr($module->displayName, $filter_name) === false AND stristr($module->description, $filter_name) === false))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
// Module has not been filtered
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,14 +699,9 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
// Init
|
// Init
|
||||||
$smarty = $this->context->smarty;
|
$smarty = $this->context->smarty;
|
||||||
$autocompleteList = 'var moduleList = [';
|
$autocompleteList = 'var moduleList = [';
|
||||||
$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)$this->context->employee->id);
|
|
||||||
$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)$this->context->employee->id);
|
|
||||||
$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)$this->context->employee->id);
|
|
||||||
$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)$this->context->employee->id);
|
|
||||||
$nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
|
$nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||||
$isoCountryDefault = $this->context->country->iso_code;
|
|
||||||
$categoryFiltered = array();
|
$categoryFiltered = array();
|
||||||
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->context->employee->id));
|
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
|
||||||
if (count($filterCategories) > 0)
|
if (count($filterCategories) > 0)
|
||||||
foreach ($filterCategories as $fc)
|
foreach ($filterCategories as $fc)
|
||||||
$categoryFiltered[$fc] = 1;
|
$categoryFiltered[$fc] = 1;
|
||||||
@@ -741,7 +721,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->makeModulesStats($module);
|
$this->makeModulesStats($module);
|
||||||
|
|
||||||
// Apply filter
|
// Apply filter
|
||||||
if ($this->moduleFiltered($module))
|
if ($this->isModuleFiltered($module))
|
||||||
unset($modules[$km]);
|
unset($modules[$km]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -777,14 +757,13 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$tpl_vars['ajaxCurrentIndex'] = str_replace('index', 'ajax-tab', self::$currentIndex);
|
$tpl_vars['ajaxCurrentIndex'] = str_replace('index', 'ajax-tab', self::$currentIndex);
|
||||||
$tpl_vars['autocompleteList'] = rtrim($autocompleteList, ' ,').'];';
|
$tpl_vars['autocompleteList'] = rtrim($autocompleteList, ' ,').'];';
|
||||||
|
|
||||||
$tpl_vars['showTypeModules'] = $showTypeModules;
|
$tpl_vars['showTypeModules'] = $this->filter_configuration['PS_SHOW_TYPE_MODULES_'.(int)$this->id_employee];
|
||||||
$tpl_vars['showInstalledModules'] = $showInstalledModules;
|
$tpl_vars['showInstalledModules'] = $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_'.(int)$this->id_employee];
|
||||||
$tpl_vars['showEnabledModules'] = $showEnabledModules;
|
$tpl_vars['showEnabledModules'] = $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_'.(int)$this->id_employee];
|
||||||
$tpl_vars['showCountryModules'] = $showCountryModules;
|
$tpl_vars['showCountryModules'] = $this->filter_configuration['PS_SHOW_ENABLED_MODULES_'.(int)$this->id_employee];
|
||||||
$tpl_vars['nameCountryDefault'] = $nameCountryDefault;
|
$tpl_vars['nameCountryDefault'] = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||||
$tpl_vars['isoCountryDefault'] = $isoCountryDefault;
|
$tpl_vars['isoCountryDefault'] = $this->iso_default_country;
|
||||||
|
|
||||||
$tpl_vars['authorsOptionsList'] = $this->displayModuleAuthorsOptGroup($this->modules_authors, 'authorModules');
|
|
||||||
$tpl_vars['addonsUrl'] = 'index.php?tab=AdminAddonsMyAccount&token='.Tools::getAdminTokenLite('AdminAddonsMyAccount');
|
$tpl_vars['addonsUrl'] = 'index.php?tab=AdminAddonsMyAccount&token='.Tools::getAdminTokenLite('AdminAddonsMyAccount');
|
||||||
$tpl_vars['categoryFiltered'] = $categoryFiltered;
|
$tpl_vars['categoryFiltered'] = $categoryFiltered;
|
||||||
|
|
||||||
@@ -795,6 +774,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$tpl_vars['nb_modules_activated'] = $this->nb_modules_activated;
|
$tpl_vars['nb_modules_activated'] = $this->nb_modules_activated;
|
||||||
$tpl_vars['nb_modules_unactivated'] = $tpl_vars['nb_modules_installed'] - $tpl_vars['nb_modules_activated'];
|
$tpl_vars['nb_modules_unactivated'] = $tpl_vars['nb_modules_installed'] - $tpl_vars['nb_modules_activated'];
|
||||||
$tpl_vars['list_modules_categories'] = $this->list_modules_categories;
|
$tpl_vars['list_modules_categories'] = $this->list_modules_categories;
|
||||||
|
$tpl_vars['list_modules_authors'] = $this->modules_authors;
|
||||||
|
|
||||||
$smarty->assign($tpl_vars);
|
$smarty->assign($tpl_vars);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user