PageRenderTime 58ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/adminstrator/tabs/AdminModules.php

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