// push changes
This commit is contained in:
+7
-2
@@ -387,7 +387,7 @@ class HookCore extends ObjectModel
|
|||||||
* @param int $id_module Execute hook for this module only
|
* @param int $id_module Execute hook for this module only
|
||||||
* @return string modules output
|
* @return string modules output
|
||||||
*/
|
*/
|
||||||
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true)
|
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true, $use_push = false)
|
||||||
{
|
{
|
||||||
// Check arguments validity
|
// Check arguments validity
|
||||||
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
|
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
|
||||||
@@ -446,6 +446,8 @@ class HookCore extends ObjectModel
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($use_push && !$moduleInstance->allow_push)
|
||||||
|
continue;
|
||||||
// Check which / if method is callable
|
// Check which / if method is callable
|
||||||
$hook_callable = is_callable(array($moduleInstance, 'hook'.$hook_name));
|
$hook_callable = is_callable(array($moduleInstance, 'hook'.$hook_name));
|
||||||
$hook_retro_callable = is_callable(array($moduleInstance, 'hook'.$retro_hook_name));
|
$hook_retro_callable = is_callable(array($moduleInstance, 'hook'.$retro_hook_name));
|
||||||
@@ -453,10 +455,13 @@ class HookCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$hook_args['altern'] = ++$altern;
|
$hook_args['altern'] = ++$altern;
|
||||||
|
|
||||||
|
if ($use_push && isset($moduleInstance->push_filename) && file_exists($moduleInstance->push_filename))
|
||||||
|
Tools::waitUntilFileIsModified($moduleInstance->push_filename, $moduleInstance->push_time_limit);
|
||||||
|
|
||||||
// Call hook method
|
// Call hook method
|
||||||
if ($hook_callable)
|
if ($hook_callable)
|
||||||
$display = $moduleInstance->{'hook'.$hook_name}($hook_args);
|
$display = $moduleInstance->{'hook'.$hook_name}($hook_args);
|
||||||
else if ($hook_retro_callable)
|
elseif ($hook_retro_callable)
|
||||||
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
|
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
|
||||||
// Live edit
|
// Live edit
|
||||||
if (!$array_return && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
|
if (!$array_return && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ abstract class ModuleCore
|
|||||||
/** @var Smarty_Data */
|
/** @var Smarty_Data */
|
||||||
protected $smarty;
|
protected $smarty;
|
||||||
|
|
||||||
|
/** @var allow push */
|
||||||
|
public $allow_push;
|
||||||
|
|
||||||
|
public $push_time_limit = 180;
|
||||||
|
|
||||||
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
|
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
|
||||||
|
|
||||||
@@ -1643,7 +1647,8 @@ abstract class ModuleCore
|
|||||||
{
|
{
|
||||||
$this->smarty->assign(array(
|
$this->smarty->assign(array(
|
||||||
'module_dir' => __PS_BASE_URI__.'modules/'.basename($file, '.php').'/',
|
'module_dir' => __PS_BASE_URI__.'modules/'.basename($file, '.php').'/',
|
||||||
'module_template_dir' => ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/'
|
'module_template_dir' => ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/',
|
||||||
|
'allow_push' => $this->allow_push
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($cacheId !== null)
|
if ($cacheId !== null)
|
||||||
|
|||||||
@@ -89,6 +89,6 @@ class AdminDashboardControllerCore extends AdminController
|
|||||||
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
|
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
|
||||||
);
|
);
|
||||||
|
|
||||||
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true)));
|
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,10 @@ $(document).ready( function () {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
refreshDashboard();
|
refreshDashboard(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function refreshDashboard(module_name)
|
function refreshDashboard(use_push)
|
||||||
{
|
{
|
||||||
module_list = new Array();
|
module_list = new Array();
|
||||||
|
|
||||||
@@ -50,16 +50,19 @@ function refreshDashboard(module_name)
|
|||||||
$(this).addClass('loading');
|
$(this).addClass('loading');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(module_list);
|
|
||||||
for (var module_id in module_list)
|
for (var module_id in module_list)
|
||||||
{
|
{
|
||||||
|
if (use_push && !$('#'+module_list[module_id]).hasClass('allow_push'))
|
||||||
|
continue;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : dashboard_ajax_url,
|
url : dashboard_ajax_url,
|
||||||
data : {
|
data : {
|
||||||
ajax:true,
|
ajax:true,
|
||||||
action:'refreshDashboard',
|
action:'refreshDashboard',
|
||||||
module:module_list[module_id],
|
module:module_list[module_id],
|
||||||
dashboard_use_push:parseInt(dashboard_use_push)
|
dashboard_use_push:Number(use_push)
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success : function(widgets){
|
success : function(widgets){
|
||||||
@@ -68,7 +71,7 @@ function refreshDashboard(module_name)
|
|||||||
window[data_type](widget_name, widgets[widget_name][data_type]);
|
window[data_type](widget_name, widgets[widget_name][data_type]);
|
||||||
|
|
||||||
if (parseInt(dashboard_use_push) == 1)
|
if (parseInt(dashboard_use_push) == 1)
|
||||||
refreshDashboard();
|
refreshDashboard(true);
|
||||||
},
|
},
|
||||||
error : function(data){
|
error : function(data){
|
||||||
//@TODO display errors
|
//@TODO display errors
|
||||||
@@ -89,7 +92,7 @@ function setDashboardDateRange(action)
|
|||||||
success : function(jsonData){
|
success : function(jsonData){
|
||||||
if (!jsonData.has_errors)
|
if (!jsonData.has_errors)
|
||||||
{
|
{
|
||||||
refreshDashboard();
|
refreshDashboard(false);
|
||||||
$('#datepickerFrom').val(jsonData.date_from);
|
$('#datepickerFrom').val(jsonData.date_from);
|
||||||
$('#datepickerTo').val(jsonData.date_to);
|
$('#datepickerTo').val(jsonData.date_to);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ class Dashactivity extends Module
|
|||||||
$this->version = '0.1';
|
$this->version = '0.1';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->push_filename = _PS_CACHE_DIR_.'push/activity';
|
$this->push_filename = _PS_CACHE_DIR_.'push/activity';
|
||||||
|
$this->allow_push = true;
|
||||||
|
$this->push_time_limit = 180;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
@@ -64,9 +66,6 @@ class Dashactivity extends Module
|
|||||||
|
|
||||||
public function hookDashboardData($params)
|
public function hookDashboardData($params)
|
||||||
{
|
{
|
||||||
if ($params['dashboard_use_push'])
|
|
||||||
Tools::waitUntilFileIsModified($this->push_filename, 30);
|
|
||||||
|
|
||||||
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||||
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
<section id="dashactivity" class="panel widget{if $allow_push} allow_push{/if}">
|
||||||
<section id="dashactivity" class="panel widget">
|
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="icon-time"></i> {l s='Recent Activity'}
|
<i class="icon-time"></i> {l s='Recent Activity'}
|
||||||
<span class="panel-heading-action">
|
<span class="panel-heading-action">
|
||||||
|
|||||||
Reference in New Issue
Block a user