[+] BO : AdminModules Preferences
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 998 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 998 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -29,5 +29,9 @@
|
||||
{$module_content}
|
||||
{else}
|
||||
{include file='controllers/modules/js.tpl'}
|
||||
{include file='controllers/modules/page.tpl'}
|
||||
{if isset($smarty.get.select) && $smarty.get.select eq 'favorites'}
|
||||
{include file='controllers/modules/favorites.tpl'}
|
||||
{else}
|
||||
{include file='controllers/modules/page.tpl'}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<div id="productBox">
|
||||
|
||||
{include file='controllers/modules/header.tpl'}
|
||||
|
||||
<a href="index.php?controller={$smarty.get.controller|htmlentities}&token={$smarty.get.token|htmlentities}"><img src="themes/default/img/modules_view_layout_sidebar_grey.png" alt="{l s='Normal view'}" border="0" /></a>
|
||||
<img src="themes/default/img/modules_view_table_select_row.png" alt="{l s='Favorites view'}" border="0" /><br />
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="moduleContainer" style="padding:0px;margin:0px;padding-top:15px">
|
||||
|
||||
<table cellspacing="0" cellpadding="0" style="width: 100%; margin-bottom:10px;" class="table" id="">
|
||||
<col width="20px">
|
||||
<col width="180px">
|
||||
<col width="320px">
|
||||
<col width="80px">
|
||||
<col width="100px">
|
||||
<col width="70px">
|
||||
<col width="70px">
|
||||
<col width="70px">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="nodrag nodrop">
|
||||
<th class="center">Logo</th>
|
||||
<th>Nom du module</th>
|
||||
<th>Description</th>
|
||||
<th>Etat</th>
|
||||
<th>Catégories</th>
|
||||
<th>Intérêt</th>
|
||||
<th>Favori</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$modules key=km item=module}
|
||||
<tr{if $km % 2 eq 0} class="alt_row"{/if}>
|
||||
<td><img src="{if isset($module->image)}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}" width="16" height="16" /></td>
|
||||
<td>{$module->displayName}</td>
|
||||
<td>{$module->description|truncate:80:'…'}</td>
|
||||
<td>{if isset($module->id) && $module->id gt 0}<span class="setup">{l s='Installed'}</span>{else}<span class="setup non-install">{l s='Not Installed'}</span>{/if}</td>
|
||||
<td>{$module->categoryName}</td>
|
||||
<td>
|
||||
<select name="i_{$module->name}" class="moduleFavorite" style="width:50px">
|
||||
<option value="" selected="selected">---</option>
|
||||
<option value="1" {if isset($module->preferences.interest) && $module->preferences.interest eq '1'}selected="selected"{/if}>Yes</option>
|
||||
<option value="0" {if isset($module->preferences.interest) && $module->preferences.interest eq '0'}selected="selected"{/if}>No</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="f_{$module->name}" class="moduleFavorite" style="width:50px">
|
||||
<option value="" selected="selected">---</option>
|
||||
<option value="1" {if isset($module->preferences.favorite) && $module->preferences.favorite eq '1'}selected="selected"{/if}>Yes</option>
|
||||
<option value="0" {if isset($module->preferences.favorite) && $module->preferences.favorite eq '0'}selected="selected"{/if}>No</option>
|
||||
</select>
|
||||
</td>
|
||||
<td id="r_{$module->name}"> </td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -24,6 +24,39 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
|
||||
{if !isset($logged_on_addons)}
|
||||
|
||||
{if $check_url_fopen eq 'ko' OR $check_curl eq 'ko' OR $check_openssl eq 'ko'}
|
||||
|
||||
<div class="warn">
|
||||
<b>{l s='If you want to be able to fully use the AdminModules pannel and have free modules available, you should enable the following configuration on your server :'}</b><br />
|
||||
{if $check_url_fopen eq 'ko'}- {l s='Enable allow_url_fopen'}<br />{/if}
|
||||
{if $check_curl eq 'ko'}- {l s='Enable php curl extension'}<br />{/if}
|
||||
{if $check_openssl eq 'ko'}- {l s='Enable php openssl extension'}<br />{/if}
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
<!--start addons login-->
|
||||
<div class="filter-module" id="addons_login_div">
|
||||
|
||||
<p>{l s='You have a PrestaShop Addons account ?'}</p>
|
||||
<form id="addons_login_form" method="post">
|
||||
<label>{l s='Login Addons'} :</label> <input type="text" value="" id="username_addons" autocomplete="off" class="ac_input">
|
||||
<label>{l s= 'Password Addons'} :</label> <input type="password" value="" id="password_addons" autocomplete="off" class="ac_input">
|
||||
<input type="submit" class="button" id="addons_login_button" value="{l s='Log in'}">
|
||||
<span id="addons_loading" style="color:red"></span>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--end addons login-->
|
||||
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
<!--start filter module-->
|
||||
<style>.ac_results { border:1px solid #C2C4D9; }</style>
|
||||
<div class="filter-module">
|
||||
|
||||
@@ -70,34 +70,4 @@
|
||||
<br />
|
||||
</div>
|
||||
|
||||
{if !isset($logged_on_addons)}
|
||||
|
||||
{if $check_url_fopen eq 'ko' OR $check_curl eq 'ko' OR $check_openssl eq 'ko'}
|
||||
|
||||
<div class="warn">
|
||||
<b>{l s='If you want to be able to fully use the AdminModules pannel and have free modules available, you should enable the following configuration on your server :'}</b><br />
|
||||
{if $check_url_fopen eq 'ko'}- {l s='Enable allow_url_fopen'}<br />{/if}
|
||||
{if $check_curl eq 'ko'}- {l s='Enable php curl extension'}<br />{/if}
|
||||
{if $check_openssl eq 'ko'}- {l s='Enable php openssl extension'}<br />{/if}
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
<!--start addons login-->
|
||||
<div class="filter-module" id="addons_login_div">
|
||||
|
||||
<p>{l s='You have a PrestaShop Addons account ?'}</p>
|
||||
<form id="addons_login_form" method="post">
|
||||
<label>{l s='Login Addons'} :</label> <input type="text" value="" id="username_addons" autocomplete="off" class="ac_input">
|
||||
<label>{l s= 'Password Addons'} :</label> <input type="password" value="" id="password_addons" autocomplete="off" class="ac_input">
|
||||
<input type="submit" class="button" id="addons_login_button" value="{l s='Log in'}">
|
||||
<span id="addons_loading" style="color:red"></span>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--end addons login-->
|
||||
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
var ajaxCurrentIndex = '{$ajaxCurrentIndex}';
|
||||
var by = '{l s='by'}';
|
||||
var errorLogin = '{l s='Could not login to Addons'}';
|
||||
var confirmPreferencesSaved = '{l s='Preferences saved'}';
|
||||
{if isset($smarty.get.anchor)}var anchor = '{$smarty.get.anchor|htmlentities|replace:'(':''|replace:')':''|replace:'{':''|replace:'}':''}';{else}var anchor = '';{/if}
|
||||
|
||||
|
||||
@@ -279,6 +280,48 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// Method to save favorites preferences
|
||||
$('.moduleFavorite').change(function()
|
||||
{
|
||||
var value_pref = $(this).val();
|
||||
var module_pref = $(this).attr('name');
|
||||
var action_pref = module_pref.substring(0, 1);
|
||||
module_pref = module_pref.substring(2, module_pref.length);
|
||||
try
|
||||
{
|
||||
resAjax = $.ajax({
|
||||
type:"POST",
|
||||
url : ajaxCurrentIndex,
|
||||
async: true,
|
||||
data : {
|
||||
ajax : "1",
|
||||
token : token,
|
||||
controller : "AdminModules",
|
||||
action : "saveFavoritePreferences",
|
||||
action_pref : action_pref,
|
||||
module_pref : module_pref,
|
||||
value_pref : value_pref
|
||||
},
|
||||
success : function(data)
|
||||
{
|
||||
// res.status = cache or refresh
|
||||
if (data == 'OK')
|
||||
$('#r_' + module_pref).html(confirmPreferencesSaved);
|
||||
},
|
||||
error: function(res,textStatus,jqXHR)
|
||||
{
|
||||
//jAlert("TECHNICAL ERROR"+res);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(e){}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
@@ -29,13 +29,25 @@
|
||||
{include file='controllers/modules/header.tpl'}
|
||||
{include file='controllers/modules/filters.tpl'}
|
||||
|
||||
<br />
|
||||
<img src="themes/default/img/modules_view_layout_sidebar.png" alt="{l s='Normal view'}" border="0" />
|
||||
<a href="index.php?controller={$smarty.get.controller|htmlentities}&token={$smarty.get.token|htmlentities}&select=favorites"><img src="themes/default/img/modules_view_table_select_row_grey.png" alt="{l s='Favorites view'}" border="0" /></a><br />
|
||||
|
||||
<div id="container">
|
||||
<!--start sidebar module-->
|
||||
<div class="sidebar">
|
||||
<div class="categorieTitle">
|
||||
<h3>{l s='Categories'}</h3>
|
||||
<div class="subHeadline">{$nb_modules}</div>
|
||||
<div class="subHeadline"> </div>
|
||||
<ul class="categorieList">
|
||||
<li {if isset($categoryFiltered.favorites)}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink">
|
||||
<div class="categorieWidth"><a href="{$currentIndex}&token={$token}&filterCategory=favorites"><span><b>{l s='Favorites'}</b></span></a></div>
|
||||
<div class="count"><b>{$nb_modules_favorites}</b></div>
|
||||
</li>
|
||||
<li {if count($categoryFiltered) lte 0}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink">
|
||||
<div class="categorieWidth"><a href="{$currentIndex}&token={$token}&unfilterCategory=yes"><span><b>{l s='Total'}</b></span></a></div>
|
||||
<div class="count"><b>{$nb_modules}</b></div>
|
||||
</li>
|
||||
{foreach from=$list_modules_categories item=module_category key=module_category_key}
|
||||
<li {if isset($categoryFiltered[$module_category_key])}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink">
|
||||
<div class="categorieWidth"><a href="{$currentIndex}&token={$token}&{if isset($categoryFiltered[$module_category_key])}un{/if}filterCategory={$module_category_key}"><span>{$module_category.name}</span></a></div>
|
||||
|
||||
@@ -273,7 +273,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
public function ajaxProcessLogOnAddonsWebservices()
|
||||
{
|
||||
$content = $this->addonsRequest('check_customer', array('username_addons' => pSQL(trim(Tools::getValue('username_addons'))), 'password_addons' => pSQL(trim(Tools::getValue('password_addons')))));
|
||||
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
||||
$xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
|
||||
if (!$xml)
|
||||
die('KO');
|
||||
$result = strtoupper((string)$xml->success);
|
||||
@@ -305,6 +305,31 @@ class AdminModulesControllerCore extends AdminController
|
||||
die('OK');
|
||||
}
|
||||
|
||||
public function ajaxProcessSaveFavoritePreferences()
|
||||
{
|
||||
$action = Tools::getValue('action_pref');
|
||||
$value = Tools::getValue('value_pref');
|
||||
$module = Tools::getValue('module_pref');
|
||||
$id_module_preference = (int)Db::getInstance()->getValue('SELECT `id_module_preference` FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee.' AND `module` = \''.pSQL($module).'\'');
|
||||
if ($id_module_preference > 0)
|
||||
{
|
||||
if ($action == 'i')
|
||||
$update = array('interest' => ($value == '' ? null : (int)$value));
|
||||
if ($action == 'f')
|
||||
$update = array('favorite' => ($value == '' ? null : (int)$value));
|
||||
Db::getInstance()->update('module_preference', $update, '`id_employee` = '.(int)$this->id_employee.' AND `module` = \''.pSQL($module).'\'', 0, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert = array('id_employee' => (int)$this->id_employee, 'module' => pSQL($module), 'interest' => null, 'favorite' => null);
|
||||
if ($action == 'i')
|
||||
$insert['interest'] = ($value == '' ? null : (int)$value);
|
||||
if ($action == 'f')
|
||||
$insert['favorite'] = ($value == '' ? null : (int)$value);
|
||||
Db::getInstance()->insert('module_preference', $insert, true);
|
||||
}
|
||||
die('OK');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -570,7 +595,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
{
|
||||
$file = $f['file'];
|
||||
$content = Tools::file_get_contents(_PS_ROOT_DIR_.$file);
|
||||
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
||||
$xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
|
||||
foreach ($xml->module as $modaddons)
|
||||
if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0))
|
||||
{
|
||||
@@ -817,8 +842,21 @@ class AdminModulesControllerCore extends AdminController
|
||||
{
|
||||
if (stristr($module->name, $filter_name) === false && stristr($module->displayName, $filter_name) === false && stristr($module->description, $filter_name) === false)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Filter on interest
|
||||
if ((int)Db::getInstance()->getValue('SELECT `id_module_preference` FROM `'._DB_PREFIX_.'module_preference` WHERE `module` = \''.pSQL($module->name).'\' AND `id_employee` = '.(int)$this->id_employee.' AND `interest` = 0') > 0)
|
||||
return true;
|
||||
|
||||
|
||||
// Filter on favorites
|
||||
if (Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee) == 'favorites')
|
||||
{
|
||||
if ((int)Db::getInstance()->getValue('SELECT `id_module_preference` FROM `'._DB_PREFIX_.'module_preference` WHERE `module` = \''.pSQL($module->name).'\' AND `id_employee` = '.(int)$this->id_employee.' AND `favorite` = 1 AND (`interest` = 1 OR `interest` IS NULL)') > 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -894,11 +932,26 @@ class AdminModulesControllerCore extends AdminController
|
||||
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
|
||||
if (count($filterCategories) > 0)
|
||||
foreach ($filterCategories as $fc)
|
||||
$categoryFiltered[$fc] = 1;
|
||||
|
||||
if (!empty($fc))
|
||||
$categoryFiltered[$fc] = 1;
|
||||
|
||||
foreach ($this->list_modules_categories as $k => $v)
|
||||
$this->list_modules_categories[$k]['nb'] = 0;
|
||||
|
||||
|
||||
|
||||
// Retrieve Modules Preferences
|
||||
$modules_preferences = '';
|
||||
$modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
|
||||
foreach ($modules_preferences_tmp as $k => $v)
|
||||
{
|
||||
if ($v['interest'] == null)
|
||||
unset($v['interest']);
|
||||
if ($v['favorite'] == null)
|
||||
unset($v['favorite']);
|
||||
$modules_preferences[$v['module']] = $v;
|
||||
}
|
||||
|
||||
|
||||
// Retrieve Modules List
|
||||
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons);
|
||||
$this->initModulesList($modules);
|
||||
@@ -939,7 +992,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
)).', ';
|
||||
|
||||
// Apply filter
|
||||
if ($this->isModuleFiltered($module))
|
||||
if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites')
|
||||
unset($modules[$km]);
|
||||
else
|
||||
{
|
||||
@@ -956,6 +1009,8 @@ class AdminModulesControllerCore extends AdminController
|
||||
$modules[$km]->options['uninstall_onclick'] = ((!method_exists($module, 'onclickOption')) ? ((empty($module->confirmUninstall)) ? '' : 'return confirm(\''.addslashes($module->confirmUninstall).'\');') : $module->onclickOption('uninstall', $modules[$km]->options['uninstall_url']));
|
||||
if (Tools::getValue('module_name') == $module->name && (int)Tools::getValue('conf') > 0)
|
||||
$modules[$km]->message = $this->_conf[(int)Tools::getValue('conf')];
|
||||
if (isset($modules_preferences[$modules[$km]->name]))
|
||||
$modules[$km]->preferences = $modules_preferences[$modules[$km]->name];
|
||||
}
|
||||
unset($object);
|
||||
}
|
||||
@@ -993,6 +1048,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
$tpl_vars['modules'] = $modules;
|
||||
$tpl_vars['nb_modules'] = $this->nb_modules_total;
|
||||
$tpl_vars['nb_modules_favorites'] = Db::getInstance()->getValue('SELECT COUNT(`id_module_preference`) FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee.' AND `favorite` = 1 AND (`interest` = 1 OR `interest` IS NULL)');
|
||||
$tpl_vars['nb_modules_installed'] = $this->nb_modules_installed;
|
||||
$tpl_vars['nb_modules_uninstalled'] = $tpl_vars['nb_modules'] - $tpl_vars['nb_modules_installed'];
|
||||
$tpl_vars['nb_modules_activated'] = $this->nb_modules_activated;
|
||||
|
||||
@@ -2374,3 +2374,13 @@ CREATE TABLE `PREFIX_category_shop` (
|
||||
PRIMARY KEY (`id_category`, `id_shop`),
|
||||
UNIQUE KEY `id_category_shop` (`id_category`,`id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_module_preference` (
|
||||
`id_module_preference` int(11) NOT NULL auto_increment,
|
||||
`id_employee` int(11) NOT NULL,
|
||||
`module` varchar(255) NOT NULL,
|
||||
`interest` tinyint(1) default NULL,
|
||||
`favorite` tinyint(1) default NULL,
|
||||
PRIMARY KEY (`id_module_preference`),
|
||||
UNIQUE KEY `employee_module` (`id_employee`, `module`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -20,3 +20,14 @@ CREATE TABLE `PREFIX_category_shop` (
|
||||
|
||||
|
||||
/* PHP:generate_root_category_for_multishop(); */;
|
||||
|
||||
|
||||
CREATE TABLE `PREFIX_module_preference` (
|
||||
`id_module_preference` int(11) NOT NULL auto_increment,
|
||||
`id_employee` int(11) NOT NULL,
|
||||
`module` varchar(255) NOT NULL,
|
||||
`interest` tinyint(1) default NULL,
|
||||
`favorite` tinyint(1) default NULL,
|
||||
PRIMARY KEY (`id_module_preference`),
|
||||
UNIQUE KEY `employee_module` (`id_employee`, `module`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>watermark</name>
|
||||
<displayName><![CDATA[Watermark]]></displayName>
|
||||
<version><![CDATA[0.1]]></version>
|
||||
<version><![CDATA[0.2]]></version>
|
||||
<description><![CDATA[Protect image by watermark.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[administration]]></tab>
|
||||
|
||||
Reference in New Issue
Block a user