PageRenderTime 136ms CodeModel.GetById 87ms app.highlight 37ms RepoModel.GetById 1ms app.codeStats 1ms

/adminstrator/tabs/AdminModules.php

http://marocmall.googlecode.com/
PHP | 987 lines | 891 code | 53 blank | 43 comment | 103 complexity | e6dc0ba38997bd02d0c2ed429e9ffda6 MD5 | raw file
  1<?php
  2/*
  3* 2007-2011 PrestaShop 
  4*
  5* NOTICE OF LICENSE
  6*
  7* This source file is subject to the Open Software License (OSL 3.0)
  8* that is bundled with this package in the file LICENSE.txt.
  9* It is also available through the world-wide-web at this URL:
 10* http://opensource.org/licenses/osl-3.0.php
 11* If you did not receive a copy of the license and are unable to
 12* obtain it through the world-wide-web, please send an email
 13* to license@prestashop.com so we can send you a copy immediately.
 14*
 15* DISCLAIMER
 16*
 17* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 18* versions in the future. If you wish to customize PrestaShop for your
 19* needs please refer to http://www.prestashop.com for more information.
 20*
 21*  @author PrestaShop SA <contact@prestashop.com>
 22*  @copyright  2007-2011 PrestaShop SA
 23*  @version  Release: $Revision: 9038 $
 24*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25*  International Registered Trademark & Property of PrestaShop SA
 26*/
 27
 28include_once(PS_ADMIN_DIR.'/../tools/tar/Archive_Tar.php');
 29
 30class AdminModules extends AdminTab
 31{
 32	/** @var array map with $_GET keywords and their callback */
 33	private $map = array(
 34		'install' => 'install',
 35		'uninstall' => 'uninstall',
 36		'configure' => 'getContent',
 37		'delete' => 'delete'
 38	);
 39	
 40	private $listTabModules;
 41	private $listPartnerModules = array();
 42	private $listNativeModules = array();
 43	private $_moduleCacheFile = '/config/modules_list.xml';
 44 	public $xml_modules_list = 'http://www.prestashop.com/xml/modules_list.xml';
 45	static private $MAX_DISP_AUTHOR = 20;		// maximum length to display
 46	
 47
 48	public function __construct()
 49	{
 50		parent::__construct();
 51		
 52		$this->listTabModules['administration'] = $this->l('Administration');
 53		$this->listTabModules['advertising_marketing'] = $this->l('Advertising & Marketing');
 54		$this->listTabModules['analytics_stats'] = $this->l('Analytics & Stats');
 55		$this->listTabModules['billing_invoicing'] = $this->l('Billing & Invoicing');
 56		$this->listTabModules['checkout'] = $this->l('Checkout');
 57		$this->listTabModules['content_management'] = $this->l('Content Management');
 58		$this->listTabModules['export'] = $this->l('Export');
 59		$this->listTabModules['front_office_features'] = $this->l('Front Office Features');
 60		$this->listTabModules['i18n_localization'] = $this->l('I18n & Localization');
 61		$this->listTabModules['merchandizing'] = $this->l('Merchandizing');
 62		$this->listTabModules['migration_tools'] = $this->l('Migration Tools');
 63		$this->listTabModules['payments_gateways'] = $this->l('Payments & Gateways');
 64		$this->listTabModules['payment_security'] = $this->l('Payment Security');
 65		$this->listTabModules['pricing_promotion'] = $this->l('Pricing & Promotion');
 66		$this->listTabModules['quick_bulk_update'] = $this->l('Quick / Bulk update');
 67		$this->listTabModules['search_filter'] = $this->l('Search & Filter');
 68		$this->listTabModules['seo'] = $this->l('SEO');
 69		$this->listTabModules['shipping_logistics'] = $this->l('Shipping & Logistics');
 70		$this->listTabModules['slideshows'] = $this->l('Slideshows');
 71		$this->listTabModules['smart_shopping'] = $this->l('Smart Shopping');
 72		$this->listTabModules['market_place'] = $this->l('Market Place');
 73		$this->listTabModules['social_networks'] = $this->l('Social Networks');
 74		$this->listTabModules['others'] = $this->l('Other Modules');
 75		
 76		if (file_exists(_PS_ROOT_DIR_.$this->_moduleCacheFile))
 77			$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->_moduleCacheFile);
 78		else
 79			$xmlModules = false;
 80
 81		if ($xmlModules)
 82		{
 83		 foreach($xmlModules->children() as $xmlModule)
 84		 {
 85				if ($xmlModule->attributes() == 'native')
 86		 		foreach($xmlModule->children() as $module)
 87		 			foreach($module->attributes() as $key => $value)
 88		 			if ($key == 'name')
 89		 				$this->listNativeModules[] = (string)$value;
 90		 	if ($xmlModule->attributes() == 'partner')
 91		 		foreach($xmlModule->children() as $module)
 92		 			foreach($module->attributes() as $key => $value)
 93		 			if ($key == 'name')
 94		 				$this->listPartnerModules[] = (string)$value;
 95			}
 96		}
 97	}
 98
 99	/** if modules_list.xml is outdated, 
100	 * this function will re-upload it from prestashop.com
101	 *
102	 * @return null
103	 */
104	public function ajaxProcessRefreshModuleList()
105	{
106		//refresh modules_list.xml every week
107		if (!$this->isFresh()) 
108		{
109			$this->refresh();
110			$this->status = 'refresh';
111		}
112		else
113			$this->status = 'cache';
114	}
115
116	public function displayAjaxRefreshModuleList()
117	{
118		echo Tools::jsonEncode(array('status' => $this->status));
119	}
120	
121	public function postProcess()
122	{
123		global $currentIndex, $cookie;
124
125		$id_employee = (int)($cookie->id_employee);
126		$filter_conf = Configuration::getMultiple(array(
127												'PS_SHOW_TYPE_MODULES_'.$id_employee,
128												'PS_SHOW_COUNTRY_MODULES_'.$id_employee,
129												'PS_SHOW_INSTALLED_MODULES_'.$id_employee,
130												'PS_SHOW_ENABLED_MODULES_'.$id_employee
131												));
132		//reset filtre
133		if (Tools::isSubmit('desactive') && isset($filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee] != 'enabledDisabled')
134			$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');
135			
136		if (Tools::isSubmit('active') && isset($filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee] != 'enabledDisabled')
137			$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');
138			
139		if (Tools::isSubmit('uninstall') && isset($filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee] != 'installedUninstalled')
140			$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]);
141			
142		if (Tools::isSubmit('install') && isset($filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee] != 'installedUninstalled')
143			$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]);
144		
145		
146		if (Tools::isSubmit('filterModules'))
147		{
148			$this->setFilterModules(Tools::getValue('module_type'), Tools::getValue('country_module_value'), Tools::getValue('module_install'), Tools::getValue('module_status'));
149			Tools::redirectAdmin($currentIndex.'&token='.$this->token);
150		}
151		elseif (Tools::isSubmit('resetFilterModules'))
152		{
153			$this->resetFilterModules();
154			Tools::redirectAdmin($currentIndex.'&token='.$this->token);
155		}
156		if (Tools::isSubmit('active'))
157		{
158		 	if ($this->tabAccess['edit'] === '1')
159			{
160				$module = Module::getInstanceByName(Tools::getValue('module_name'));
161				if (Validate::isLoadedObject($module))
162				{
163					$module->enable();
164					Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
165				} else
166					$this->_errors[] = Tools::displayError('Cannot load module object');
167			} else
168				$this->_errors[] = Tools::displayError('You do not have permission to add here.');
169		}
170		elseif (Tools::isSubmit('desactive'))
171		{
172		 	if ($this->tabAccess['edit'] === '1')
173			{
174				$module = Module::getInstanceByName(Tools::getValue('module_name'));
175				if (Validate::isLoadedObject($module))
176				{
177					$module->disable();
178					Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
179				} else
180					$this->_errors[] = Tools::displayError('Cannot load module object');
181			} else
182				$this->_errors[] = Tools::displayError('You do not have permission to add here.');
183		}
184		elseif (Tools::isSubmit('reset'))
185		{
186			if ($this->tabAccess['edit'] === '1')
187			{
188				$module = Module::getInstanceByName(Tools::getValue('module_name'));
189				if (Validate::isLoadedObject($module))
190				{
191					if ($module->uninstall())
192						if ($module->install())
193							Tools::redirectAdmin($currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
194						else
195							$this->_errors[] = Tools::displayError('Cannot install module');
196					else
197						$this->_errors[] = Tools::displayError('Cannot uninstall module');
198											
199				} else
200					$this->_errors[] = Tools::displayError('Cannot load module object');
201			} else
202				$this->_errors[] = Tools::displayError('You do not have permission to add here.');
203
204		}
205		/* Automatically copy a module from external URL and unarchive it in the appropriated directory */
206		if (Tools::isSubmit('submitDownload'))
207		{
208		 	if ($this->tabAccess['add'] === '1')
209			{
210				if (Validate::isModuleUrl($url = Tools::getValue('url'), $this->_errors))
211				{
212					if (!@copy($url, _PS_MODULE_DIR_.basename($url)))
213						$this->_errors[] = Tools::displayError('404 Module not found');
214					else
215						$this->extractArchive(_PS_MODULE_DIR_.basename($url));
216				}
217			}
218			else
219				$this->_errors[] = Tools::displayError('You do not have permission to add here.');
220		}
221		if (Tools::isSubmit('submitDownload2'))
222		{
223		 	if ($this->tabAccess['add'] === '1')
224			{
225				if (!isset($_FILES['file']['tmp_name']) OR empty($_FILES['file']['tmp_name']))
226					$this->_errors[] = $this->l('no file selected');
227				elseif (substr($_FILES['file']['name'], -4) != '.tar' AND substr($_FILES['file']['name'], -4) != '.zip' AND substr($_FILES['file']['name'], -4) != '.tgz' AND substr($_FILES['file']['name'], -7) != '.tar.gz')
228					$this->_errors[] = Tools::displayError('Unknown archive type');
229				elseif (!@copy($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name']))
230					$this->_errors[] = Tools::displayError('An error occurred while copying archive to module directory.');
231				else
232					$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name']);
233			}
234			else
235				$this->_errors[] = Tools::displayError('You do not have permission to add here.');
236		}
237		if (Tools::isSubmit('deleteModule'))
238		{
239		 	if ($this->tabAccess['delete'] === '1')
240			{
241				if (Tools::getValue('module_name') != '')
242				{
243					$moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name'));
244					$this->recursiveDeleteOnDisk($moduleDir);
245					Tools::redirectAdmin($currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module'));
246				}
247				Tools::redirectAdmin($currentIndex.'&token='.$this->token);
248			}
249			else
250				$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
251		}
252
253		/* Call appropriate module callback */
254		else
255		{
256		 	$return = false;
257			foreach ($this->map as $key => $method)
258			{
259				$modules = Tools::getValue($key);
260				if (strpos($modules, '|'))
261					$modules = explode('|', $modules);
262				else
263					$modules = empty($modules) ? false : array($modules);
264				$module_errors = array();
265				if ($modules)
266					foreach ($modules AS $name)
267					{
268						if (!($module = Module::getInstanceByName(urldecode($name))))
269							$this->_errors[] = $this->l('module not found');
270						elseif ($key == 'install' AND $this->tabAccess['add'] !== '1')
271							$this->_errors[] = Tools::displayError('You do not have permission to add here.');
272						elseif ($key == 'uninstall' AND $this->tabAccess['delete'] !== '1')
273							$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
274						elseif ($key == 'configure' AND $this->tabAccess['edit'] !== '1')
275							$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
276						elseif ($key == 'install' AND Module::isInstalled($module->name))
277							$this->_errors[] = Tools::displayError('This module is already installed : ').$module->name;
278						elseif ($key == 'uninstall' AND !Module::isInstalled($module->name))
279							$this->_errors[] = Tools::displayError('This module is already uninstalled : ').$module->name;
280						elseif (($echo = $module->{$method}()) AND ($key == 'configure') AND Module::isInstalled($module->name))
281						{
282							$backlink = $currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
283							$hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id;
284							$tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang=';
285							
286							$toolbar = '
287							<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center">
288								<tr>
289									<th>'.$this->l('Module').' <span style="color: green;">'.$module->name.'</span></th>
290									<th><a href="'.$backlink.'" style="padding:5px 10px">'.$this->l('Back').'</a></th>
291									<th><a href="'.$hooklink.'" style="padding:5px 10px">'.$this->l('Manage hooks').'</a></th>
292									<th style="padding:5px 10px">'.$this->l('Manage translations:').' ';
293									foreach (Language::getLanguages(false) AS $language)
294										$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>';
295							$toolbar .= '
296									</th>
297								</tr>
298							</table>';
299							
300							echo 
301							$toolbar.'
302							<div class="clear">&nbsp;</div>'.$echo.'<div class="clear">&nbsp;</div>
303							'.$toolbar;
304						}
305						elseif ($echo)
306							$return = ($method == 'install' ? 12 : 13);
307						elseif ($echo === false)
308							$module_errors[] = $name;
309						if ($key != 'configure' AND isset($_GET['bpay']))
310							Tools::redirectAdmin('index.php?tab=AdminPayment&token='.Tools::getAdminToken('AdminPayment'.(int)(Tab::getIdFromClassName('AdminPayment')).(int)($cookie->id_employee)));
311					}
312				if (sizeof($module_errors))
313				{
314					// If error during module installation, no redirection
315					$htmlError = '';
316
317					foreach ($module_errors AS $module_error)
318						$htmlError .= '<li>'.$module_error.'</li>';
319					$htmlError .= '</ul>';
320					$this->_errors[] = sprintf(Tools::displayError('The following module(s) were not installed successfully: %s'), $htmlError);
321				}
322			}
323			if ($return)
324				Tools::redirectAdmin($currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
325		}
326	}
327
328	function extractArchive($file)
329	{
330		global $currentIndex;
331		$success = false;
332		if (substr($file, -4) == '.zip')
333		{
334			if (!Tools::ZipExtract($file, _PS_MODULE_DIR_))
335				$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
336		}
337		else
338		{
339			$archive = new Archive_Tar($file);
340			if ($archive->extract(_PS_MODULE_DIR_))
341				$success = true;
342			else
343				$this->_errors[] = Tools::displayError('Error while extracting module (file may be corrupted).');
344		}
345		
346		@unlink($file);
347		if ($success)
348			Tools::redirectAdmin($currentIndex.'&conf=8'.'&token='.$this->token);
349	}
350	
351	public function display()
352	{
353		if (!isset($_GET['configure']) AND !isset($_GET['delete']) OR sizeof($this->_errors) )
354			$this->displayList();
355	}
356
357	public function displayJavascript()
358	{
359		global $currentIndex;
360
361		echo '<script type="text/javascript" src="'._PS_JS_DIR_.'jquery/jquery.autocomplete.js"></script>
362			<script type="text/javascript" src="'._PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js"></script>
363
364		<script type="text/javascript">
365			function getPrestaStore(){if (getE("prestastore").style.display!=\'block\')return;$.post("'.dirname($currentIndex).'/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})}
366			function truncate_author(author)
367			{
368				return ((author.length > '.self::$MAX_DISP_AUTHOR.') ? author.substring(0, '.self::$MAX_DISP_AUTHOR.')+"..." : author);
369			}
370			function modules_management(action)
371			{
372				var modules = document.getElementsByName(\'modules\');
373				var module_list = \'\';
374				for (var i = 0; i < modules.length; i++)
375				{
376					if (modules[i].checked == true)
377					{
378						rel = modules[i].getAttribute(\'rel\');
379						if (rel != "false" && action == "uninstall")
380						{
381							if (!confirm(rel))
382								return false;
383						}
384						module_list += \'|\'+modules[i].value;
385					}
386				}
387				document.location.href=\''.$currentIndex.'&token='.$this->token.'&\'+action+\'=\'+module_list.substring(1, module_list.length);
388			}	
389			$(\'document\').ready( function() {
390				$(\'input[name="filtername"]\').autocomplete(moduleList, {
391					minChars: 0,
392					width: 310,
393					matchContains: true,
394					highlightItem: true,
395					formatItem: function(row, i, max, term) {
396						return "<img src=\"../modules/"+row.name+"/logo.gif\" style=\"float:left;margin:5px\"><strong>" + row.displayName + "</strong>"+((row.author != \'\') ? " '.$this->l("by").' "+ truncate_author(row.author) :"") + "<br /><span style=\'font-size: 80%;\'>"+ row.desc +"</span>";
397					},
398					formatResult: function(row) {
399						return row.displayName;
400					}
401				});
402				$(\'input[name="filtername"]\').result(function(event, data, formatted) {
403				 $(\'#filternameForm\').submit();
404				});
405			});';
406
407			// the following to get modules_list.xml from prestashop.com
408			echo '$(document).ready(function(){
409				try
410				{
411					resAjax = $.ajax({
412							type:"POST",
413							url : "'. str_replace('index','ajax-tab',$currentIndex) . '",
414							async: true,
415							data : {
416								ajaxMode : "1",
417								ajax : "1",
418								token : "'.$this->token.'",
419								tab : "AdminModules",
420								action : "refreshModuleList"
421							},
422							success : function(res,textStatus,jqXHR)
423							{
424								// res.status  = cache or refresh
425							},
426							error: function(res,textStatus,jqXHR)
427							{
428								alert("TECHNICAL ERROR"+res);
429							}
430						});
431				}
432				catch(e){}
433			});	
434		</script>';
435	}
436
437	public static function sortModule($a, $b)
438	{
439	    if (sizeof($a) == sizeof($b)) {
440	        return 0;
441	    }
442	    return (sizeof($a) < sizeof($b)) ? -1 : 1;
443	}
444	
445
446	/**
447	 * Used for retreiving author name from submited field authorModules[name]
448	 * @param String $value value to be clean
449	 *
450	 * @return String cleant value: name
451	 */
452	private function _getSubmitedModuleAuthor($value)
453	{
454		$value = str_replace('authorModules[', '', $value);
455		$value = str_replace("\'", "'", $value);
456
457		$value = substr($value, 0, -1);
458		return $value;
459	}
460
461	/**
462	 * Used for building option group
463	 * @param Array $authors contains modules authors
464	 * @param String $fieldName name of optiongroup 
465	 * @return String built comp
466	 */
467
468	private function _buildModuleAuthorsOptGroup($authors, $fieldName = "UNDEFINED")
469	{
470		$out = '<optgroup label="'.$this->l('Authors').'">';
471		foreach($authors as $author_item => $status)
472		{
473			$author_item = Tools::htmlentitiesUTF8($author_item);
474			$disp_author = $this->_getDispAuthor($author_item);
475
476			$out .= '<option value="'.$fieldName.'['.$author_item. ']"'. (($status === "selected") ? ' selected>' : '>').$disp_author .'</option>';
477		}
478		$out .= '</optgroup>';
479		return $out;
480	}
481
482	/**
483	 * Used for truncating  author name to display it nicely
484	 * @param String $author original  author
485	 * @return String truncated author name
486	 */
487	private function _getDispAuthor($author)
488	{
489		return ((strlen($author) > self::$MAX_DISP_AUTHOR) ? substr($author, 0, self::$MAX_DISP_AUTHOR).'...' : $author);
490	}
491
492
493	public function displayList()
494	{
495		global $currentIndex, $cookie;
496	
497		$modulesAuthors = array();	
498		$autocompleteList = 'var moduleList = [';
499		
500		$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee));
501		$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee));
502		$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee));
503		$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee));
504
505		$nameCountryDefault = Country::getNameById($cookie->id_lang, Configuration::get('PS_COUNTRY_DEFAULT'));
506		$isoCountryDefault = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
507		
508		$serialModules = '';
509		$modules = Module::getModulesOnDisk(true);
510
511		foreach ($modules AS $module)
512		{
513			if (!in_array($module->name, $this->listNativeModules))
514				$serialModules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
515
516			$moduleAuthor = $module->author;
517			if (!empty($moduleAuthor)&& ($moduleAuthor != ""))
518				$modulesAuthors[(string)$moduleAuthor] = true;
519		}
520
521		$serialModules = urlencode($serialModules);
522		
523		$filterName = Tools::getValue('filtername');
524		if (!empty($filterName))
525		{
526			echo '
527			<script type="text/javascript">
528				$(document).ready(function() {	
529					$(\'#all_open\').hide();
530					$(\'#all_close\').show();			 
531					$(\'.tab_module_content\').each(function(){
532						$(this).slideDown();
533						$(\'.header_module_img\').each(function(){
534							$(this).attr(\'src\', \'../img/admin/less.png\');
535						});
536					});
537				});
538			</script>';
539		}
540
541		//filter module list
542		foreach($modules as $key => $module)
543		{
544			switch ($showTypeModules)
545			{
546				case 'nativeModules':
547					if (!in_array($module->name, $this->listNativeModules))
548						unset($modules[$key]);
549				break;
550				case 'partnerModules':
551					if (!in_array($module->name, $this->listPartnerModules))
552						unset($modules[$key]);
553				break;
554				case 'otherModules':
555					if (in_array($module->name, $this->listPartnerModules) OR in_array($module->name, $this->listNativeModules))
556						unset($modules[$key]);
557				break;
558				default:
559					if (strpos($showTypeModules, 'authorModules[') !== false)
560					{
561						$author_selected = $this->_getSubmitedModuleAuthor($showTypeModules);
562						$modulesAuthors[$author_selected] = 'selected';		// setting selected author in authors set
563						if (empty($module->author) || $module->author != $author_selected)
564							unset($modules[$key]);
565					}
566
567				break;
568
569			}
570					
571			switch ($showInstalledModules)
572			{
573				case 'installed':
574					if (!$module->id)
575						unset($modules[$key]);
576				break;
577				case 'unistalled':
578					if ($module->id)
579						unset($modules[$key]);
580				break;
581			}
582			
583			switch ($showEnabledModules)
584			{
585				case 'enabled':
586					if (!$module->active)
587						unset($modules[$key]);
588				break;
589				case 'disabled':
590					if ($module->active)
591						unset($modules[$key]);
592				break;
593			}		
594			
595			if ($showCountryModules)		
596				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))))
597					unset($modules[$key]);
598			
599			if (!empty($filterName))
600				if (stristr($module->name, $filterName) === false AND stristr($module->displayName, $filterName) === false AND stristr($module->description, $filterName) === false)
601					unset($modules[$key]);
602		}
603		
604		foreach($modules as $module)
605			$autocompleteList .= Tools::jsonEncode(array(
606				'displayName' => (string)$module->displayName,
607				'desc' => (string)$module->description,
608				'name' => (string)$module->name,
609				'author' => (string)$module->author
610			)).', ';
611		
612		$autocompleteList = rtrim($autocompleteList, ' ,').'];';
613		// Display CSS Fancy Box
614		echo '<link href="'._PS_CSS_DIR_.'jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />';
615		echo '<script type="text/javascript">'.$autocompleteList.'</script>';
616		$this->displayJavascript();
617		
618		echo '
619		<span onclick="$(\'#module_install\').slideToggle()" style="cursor:pointer"><img src="../img/admin/add.gif" alt="'.$this->l('Add a new module').'" class="middle" />
620			'.$this->l('Add a module from my computer').'
621		</span>
622		&nbsp;|&nbsp;';
623		echo '<a href="index.php?tab=AdminAddonsMyAccount&token='.Tools::getAdminTokenLite('AdminAddonsMyAccount').'">
624			<img src="https://addons.prestashop.com/modules.php?'.(isset($_SERVER['SERVER_ADDR']) ? 'server='.ip2long($_SERVER['SERVER_ADDR']).'&' : '').'mods='.$serialModules.'" alt="Add" class="middle" />
625			'.$this->l('Add a module from PrestaShop Addons').'
626		</a>';
627		echo '<form action="'.$currentIndex.'&token='.$this->token.'" method="post" id="filternameForm" style="float:right"><input type="text" name="filtername" value="'.Tools::htmlentitiesUTF8(Tools::getValue('filtername')).'" /> <input type="submit" value="'.$this->l('Search').'" class="button" /></form>
628		<div class="clear">&nbsp;</div>
629		<div id="module_install" style="width:900px; '.((Tools::isSubmit('submitDownload') OR Tools::isSubmit('submitDownload2')) ? '' : 'display: none;').'">
630			<fieldset>
631				<legend><img src="../img/admin/add.gif" alt="'.$this->l('Add a new module').'" class="middle" /> '.$this->l('Add a new module').'</legend>
632				<p>'.$this->l('The module must be either a zip file or a tarball.').'</p>
633				<hr />
634				<div style="float:right;margin-right:50px;border-left:solid 1px #DFD5C3">
635					<form action="'.$currentIndex.'&token='.$this->token.'" method="post" enctype="multipart/form-data">
636						<label style="width: 100px">'.$this->l('Module file').'</label>
637						<div class="margin-form" style="padding-left: 140px">
638							<input type="file" name="file" />
639							<p>'.$this->l('Upload the module from your computer.').'</p>
640						</div>
641						<div class="margin-form" style="padding-left: 140px">
642							<input type="submit" name="submitDownload2" value="'.$this->l('Upload this module').'" class="button" />
643						</div>
644					</form>
645				</div>
646				<div>
647				<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
648					<label style="width: 100px">'.$this->l('Module URL').'</label>
649					<div class="margin-form" style="padding-left: 140px">
650						<input type="text" name="url" style="width: 200px;" value="'.(Tools::getValue('url') ? Tools::getValue('url') : 'http://').'" />
651						<p>'.$this->l('Download the module directly from a website.').'</p>
652					</div>
653					<div class="margin-form" style="padding-left: 140px">
654						<input type="submit" name="submitDownload" value="'.$this->l('Download this module').'" class="button" />
655					</div>
656				</form>
657				</div>
658			</fieldset>
659			<br />
660		</div>';
661		if (Configuration::get('PRESTASTORE_LIVE'))
662			echo '
663			<div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1">
664			</div>';
665
666		/* Scan modules directories and load modules classes */
667		$warnings = array();
668		$orderModule = array();
669	    $irow = 0;
670		foreach ($modules AS $module)
671			$orderModule[(isset($module->tab) AND !empty($module->tab) AND array_key_exists(strval($module->tab), $this->listTabModules)) ? strval($module->tab) : 'others' ][] = $module;
672		uasort($orderModule,array('AdminModules', 'sortModule'));
673		
674		$concatWarning = array();
675		foreach ($orderModule AS $tabModule)
676			foreach ($tabModule AS $module)
677				if ($module->active AND $module->warning)
678					$warnings[] ='<a href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'">'.$module->displayName.'</a> - '.stripslashes(pSQL($module->warning));
679		$this->displayWarning($warnings);
680		echo '<form method="POST">
681			<table cellpadding="0" cellspacing="0" style="width:100%;;margin-bottom:5px;">
682				<tr>
683					<th style="border-right:solid 1px;border:inherit">
684						<span class="button" style="padding:0.4em;">
685							<a id="all_open" class="module_toggle_all" style="display:inherit;text-decoration:none;" href="#">
686								<span style="padding-right:0.5em">
687									<img src="../img/admin/more.png" alt="" />
688								</span>
689								<span id="all_open">'.$this->l('Open all tabs').'</span>
690							</a>
691							<a id="all_close" class="module_toggle_all" style="display:none;text-decoration:none;" href="#">
692								<span style="padding-right:0.5em">
693									<img src="../img/admin/less.png" alt="" />
694								</span>
695								<span id="all_open">'.$this->l('Close all tabs').'</span>
696							</a>
697						</span>
698					</th>
699					<th colspan="3" style="border:inherit">
700						<select name="module_type">
701							<option value="allModules" '.($showTypeModules == 'allModules' ? 'selected="selected"' : '').'>'.$this->l('All Modules').'</option>
702							<option value="nativeModules" '.($showTypeModules == 'nativeModules' ? 'selected="selected"' : '').'>'.$this->l('Native Modules').'</option>
703							<option value="partnerModules" '.($showTypeModules == 'partnerModules' ? 'selected="selected"' : '').'>'.$this->l('Partners Modules').'</option>'
704.$this->_buildModuleAuthorsOptGroup($modulesAuthors, 'authorModules')
705.'
706							<option value="otherModules" '.($showTypeModules == 'otherModules' ? 'selected="selected"' : '').'>'.$this->l('Others Modules').'</option>
707						</select>
708						&nbsp;
709						<select name="module_install">
710							<option value="installedUninstalled" '.($showInstalledModules == 'installedUninstalled' ? 'selected="selected"' : '').'>'.$this->l('Installed & Uninstalled').'</option>
711							<option value="installed" '.($showInstalledModules == 'installed' ? 'selected="selected"' : '').'>'.$this->l('Installed Modules').'</option>
712							<option value="unistalled" '.($showInstalledModules == 'unistalled' ? 'selected="selected"' : '').'>'.$this->l('Uninstalled Modules').'</option>
713						</select>
714						&nbsp;
715						<select name="module_status">
716							<option value="enabledDisabled" '.($showEnabledModules == 'enabledDisabled' ? 'selected="selected"' : '').'>'.$this->l('Enabled & Disabled').'</option>
717							<option value="enabled" '.($showEnabledModules == 'enabled' ? 'selected="selected"' : '').'>'.$this->l('Enabled Modules').'</option>
718							<option value="disabled" '.($showEnabledModules == 'disabled' ? 'selected="selected"' : '').'>'.$this->l('Disabled Modules').'</option>
719						</select>
720						&nbsp;
721						<select name="country_module_value">
722							<option value="0" >'.$this->l('All countries').'</option>
723							<option value="1" '.($showCountryModules == 1 ? 'selected="selected"' : '').'>'.$this->l('Current country:').' '.$nameCountryDefault.'</option>
724						</select>
725					</th>
726					<th style="border:inherit">
727						<div style="float:right">
728							<input type="submit" class="button" name="resetFilterModules" value="'.$this->l('Reset').'">
729							<input type="submit" class="button" name="filterModules" value="'.$this->l('Filter').'">
730						</div>
731					</th>
732			  	</tr>
733			</table>
734			</form>';
735		echo $this->displaySelectedFilter();
736		if ($tab_module = Tools::getValue('tab_module'))
737			if (array_key_exists($tab_module, $this->listTabModules))
738				$goto = $tab_module;
739			else
740				$goto = 'others';
741		else
742			$goto = false;
743			
744		echo '
745  		<script src="'.__PS_BASE_URI__.'js/jquery/jquery.scrollTo-1.4.2-min.js"></script>
746		<script>
747		 $(document).ready(function() {
748		 
749		 $(\'.header_module_toggle, .module_toggle_all\').unbind(\'click\').click(function(){
750		 	var id = $(this).attr(\'id\');
751			if (id == \'all_open\')
752				$(\'.tab_module_content\').each(function(){
753					$(this).slideDown();
754					$(\'#all_open\').hide();
755					$(\'#all_close\').show();
756					$(\'.header_module_img\').each(function(){
757						$(this).attr(\'src\', \'../img/admin/less.png\');
758					});
759				});
760			else if (id == \'all_close\')
761				$(\'.tab_module_content\').each(function(){
762					$(\'#all_open\').show();
763					$(\'#all_close\').hide();
764					$(this).slideUp();
765					$(\'.header_module_img\').each(function(){
766						$(this).attr(\'src\', \'../img/admin/more.png\');
767					});
768				});
769			else
770			{
771				if ($(\'#\'+id+\'_content\').css(\'display\') == \'none\')
772		 			$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/less.png\');
773		 		else
774		 			$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/more.png\');
775		 		
776		 		$(\'#\'+$(this).attr(\'id\')+\'_content\').slideToggle();
777		 	}
778		 	return false;
779		 });
780		'.(!$goto ? '': 'if ($(\'#'.$goto.'_content\').length > 0) $(\'#'.$goto.'_content\').slideToggle( function (){
781		$(\'#'.$goto.'_img\').attr(\'src\', \'../img/admin/less.png\');
782		'.(!$goto ? '' : 'if ($("#modgo_'.Tools::getValue('module_name').'").length > 0) $.scrollTo($("#modgo_'.Tools::getValue('module_name').'"), 300 , 
783		{onAfter:function(){
784			$("#modgo_'.Tools::getValue('module_name').'").fadeTo(100, 0, function (){
785				$(this).fadeTo(100, 0, function (){
786					$(this).fadeTo(50, 1, function (){
787						$(this).fadeTo(50, 0, function (){
788							$(this).fadeTo(50, 1 )}
789								)}
790							)}
791						)}
792					)}
793				});').'
794		});').'
795		
796			});
797		 </script>';
798		if (!empty($orderModule))
799		{
800			/* Browse modules by tab type */
801			foreach ($orderModule AS $tab => $tabModule)
802			{
803				echo '
804				<div id="'.$tab.'" class="header_module">
805				<span class="nbr_module" style="width:100px;text-align:right">'.sizeof($tabModule).' '.((sizeof($tabModule) > 1) ? $this->l('modules') : $this->l('module')).'</span>
806					<a class="header_module_toggle" id="'.$tab.'" href="modgo_'.$tab.'" style="margin-left: 5px;">
807						<span style="padding-right:0.5em">
808						<img class="header_module_img" id="'.$tab.'_img" src="../img/admin/more.png" alt="" />
809						</span>'.$this->listTabModules[$tab].'</a> 
810				</div>
811				<div id="'.$tab.'_content" class="tab_module_content" style="display:none;border:solid 1px #CCC">';
812				/* Display modules for each tab type */
813				foreach ($tabModule as $module)
814				{
815					echo '<div id="modgo_'.$module->name.'" title="' . $module->name . '">';
816					if ($module->id)
817					{
818						$img = '<img src="../img/admin/module_install.png" alt="'.$this->l('Module enabled').'" title="'.$this->l('Module enabled').'" />';
819						if ($module->warning)
820							$img = '<img src="../img/admin/module_warning.png" alt="'.$this->l('Module installed but with warnings').'" title="'.$this->l('Module installed but with warnings').'" />';
821						if (!$module->active)
822							$img = '<img src="../img/admin/module_disabled.png" alt="'.$this->l('Module disabled').'" title="'.$this->l('Module disabled').'" />';
823					} else
824						$img = '<img src="../img/admin/module_notinstall.png" alt="'.$this->l('Module not installed').'" title="'.$this->l('Module not installed').'" />';
825					$disp_author = $this->_getDispAuthor($module->author);
826					$disp_author = (empty($disp_author)) ? '' :  ' '.$this->l('by').' <i>'.Tools::htmlentitiesUTF8($disp_author).'</i>';
827					echo '<table style="width:100%" cellpadding="0" cellspacing="0" >
828					<tr'.($irow % 2 ? ' class="alt_row"' : '').' style="height: 42px;">
829						<td style="padding-right: 10px;padding-left:10px;width:30px">
830							<input type="checkbox" name="modules" value="'.urlencode($module->name).'" '.(empty($module->confirmUninstall) ? 'rel="false"' : 'rel="'.addslashes($module->confirmUninstall).'"').' />
831						</td>
832						<td style="padding:2px 4px 2px 10px;width:500px"><img src="../modules/'.$module->name.'/logo.gif" alt="" /> <b>'.stripslashes($module->displayName).'</b>'.($module->version ? ' v'.$module->version.(strpos($module->version, '.') !== false ? '' : '.0') : '').$disp_author.'<br />'.stripslashes($module->description).'</td>
833						<td rowspan="2">';
834						if (Tools::getValue('module_name') == $module->name)
835							$this->displayConf();
836						echo '</td>
837						<td class="center" style="width:60px" rowspan="2">';
838					if ($module->id)
839						echo '<a href="'.$currentIndex.'&token='.$this->token.'&module_name='.$module->name.'&'.($module->active ? 'desactive' : 'active').'">';
840					echo $img;
841					if ($module->id)
842						'</a>';
843					$href = $currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
844					echo '
845						</td>
846						<td class="center" width="120" rowspan="2">'.((!$module->id)
847						? '<input type="button" class="button small" name="Install" value="'.$this->l('Install').'"
848						onclick="javascript:document.location.href=\''.$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'\'">'
849						: '<input type="button" class="button small" name="Uninstall" value="'.$this->l('Uninstall').'"
850						onclick="'.((!method_exists($module, 'onclickOption')) ? ((empty($module->confirmUninstall)) ? '' : 'if (confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\''.$href.'\'' : $module->onclickOption('uninstall', $href)).'">').'</td>
851						
852					</tr>
853					<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
854						<td style="padding-left:50px;padding-bottom:5px;padding-top:5px" colspan="2">'.$this->displayOptions($module).'</td>
855					</tr>
856					</table>
857					</div>';
858				}
859				echo '</div>';
860			}
861			echo '
862				<div style="margin-top: 12px; width:600px;">
863					<input type="button" class="button big" value="'.$this->l('Install the selection').'" onclick="modules_management(\'install\')"/>
864					<input type="button" class="button big" value="'.$this->l('Uninstall the selection').'" onclick="modules_management(\'uninstall\')" />
865				</div>
866				<br />
867				<table cellpadding="0" cellspacing="0" class="table" style="width:100%;">
868					<tr style="height:35px;background-color:#EEEEEE">
869						<td><strong>'.$this->l('Icon legend').' : </strong></td>
870						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_install.png" />&nbsp;&nbsp;'.$this->l('Module installed and enabled').'</td>
871						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_disabled.png" />&nbsp;&nbsp;'.$this->l('Module installed but disabled').'</td>
872						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_warning.png" />&nbsp;&nbsp;'.$this->l('Module installed but with warnings').'</td>
873						<td style="text-align:center"><img src="../img/admin/module_notinstall.png" />&nbsp;&nbsp;'.$this->l('Module not installed').'</td>
874					</tr>
875				</table>
876			<div style="clear:both">&nbsp;</div>';
877		}
878		else
879			echo '<table cellpadding="0" cellspacing="0" class="table" style="width:100%;"><tr><td align="center">'.$this->l('No module found').'</td></tr></table>';
880	}
881	
882	
883	public function recursiveDeleteOnDisk($dir)
884	{
885		if (strpos(realpath($dir), realpath(_PS_MODULE_DIR_)) === false)
886			return ;
887		if (is_dir($dir)) 
888		{
889			$objects = scandir($dir);
890			foreach ($objects as $object)
891				if ($object != "." && $object != "..")
892				{
893					if (filetype($dir."/".$object) == "dir")
894						$this->recursiveDeleteOnDisk($dir."/".$object);
895					else
896						unlink($dir."/".$object);
897				}
898			reset($objects);
899			rmdir($dir);
900		}
901	}
902	
903	public function displayOptions($module)
904	{
905		global $currentIndex;
906		$return = '';
907		$href = $currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&tab_module='.$module->tab;
908
909		$hrefDelete = $currentIndex.'&deleteModule='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
910		$return .= '<a class="action_module_delete" '.(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>&nbsp;&nbsp;';
911		
912		if ((int)($module->id))
913			$return .= '<a class="action_module" '.($module->active && method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('desactive', $href).'"' : '').' href="'.$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'desactive' : 'active').'&tab_module='.$module->tab.'">'.($module->active ? $this->l('Disable') : $this->l('Enable')).'</a>&nbsp;&nbsp;';
914		
915		if ((int)($module->id) AND $module->active)
916			$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('reset', $href).'"' : '').' href="'.$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'">'.$this->l('Reset').'</a>&nbsp;&nbsp;';
917		
918		if ((int)($module->id) AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND (int)$module->is_configurable)))
919			$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Configure').'</a>&nbsp;&nbsp;';
920		
921		return $return;
922	}
923	
924	public function isFresh($timeout = 604800000)
925	{
926		if (file_exists(_PS_ROOT_DIR_ . $this->_moduleCacheFile))
927			return ((time() - filemtime(_PS_ROOT_DIR_ . $this->_moduleCacheFile)) < $timeout);
928		else
929			return false;
930	}
931	
932	public function refresh()
933	{
934		return file_put_contents(_PS_ROOT_DIR_.$this->_moduleCacheFile, Tools::file_get_contents($this->xml_modules_list));
935	}
936	
937	public function displaySelectedFilter()
938	{
939		global $cookie;
940		$selected_filter = '';
941		$id_employee = (int)($cookie->id_employee);
942		
943		$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee));
944		$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee));
945		$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee));
946		$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee));
947		$selected_filter .= ($showTypeModules == 'allModules' ? $this->l('All Modules').' - ' : '').
948							($showTypeModules == 'nativeModules' ? $this->l('Native Modules').' - ' : '').
949							($showTypeModules == 'partnerModules' ? $this->l('Partners Modules').' - ' : '').
950							($showTypeModules == 'otherModules' ? $this->l('Others Modules').' - ' : '').
951							($showInstalledModules == 'installedUninstalled' ? $this->l('Installed & Uninstalled').' - ' : '').
952							($showInstalledModules == 'installed' ? $this->l('Installed Modules').' - ' : '').
953							($showInstalledModules == 'unistalled' ? $this->l('Uninstalled Modules').' - ' : '').
954							($showEnabledModules == 'enabledDisabled' ? $this->l('Enabled & Disabled').' - ' : '').
955							($showEnabledModules == 'enabled' ? $this->l('Enabled Modules').' - ' : '').
956							($showEnabledModules == 'disabled' ? $this->l('Disabled Modules').' - ' : '').
957							($showCountryModules === 1 ? $this->l('Current country:').' '.$nameCountryDefault.' - ' : '').
958							($showCountryModules === 0 ? $this->l('All countries').' - ' : '');
959
960		if (strlen($selected_filter) != 0)
961			$selected_filter = '<div class="hint" style="display:block;background:#DDE9F7 no-repeat 6px 5px url(../img/admin/filter.png);"><b>'.$this->l('Selected filters').' : </b>'.rtrim($selected_filter, ' - ').'</div>';
962		return $selected_filter;
963	}
964	
965	private function setFilterModules($module_type, $country_module_value, $module_install, $module_status)
966	{
967		global $cookie;
968		
969		Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee), $module_type);
970		Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee), $country_module_value);
971		Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee), $module_install);
972		Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee), $module_status);
973	}
974	
975	private function resetFilterModules()
976	{
977		global $cookie;
978		
979		Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee), 'allModules');
980		Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee), 0);
981		Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee), 'installedUninstalled');
982		Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee), 'enabledDisabled');
983	}
984	
985}
986
987