// 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
|
||||
* @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
|
||||
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
|
||||
@@ -446,6 +446,8 @@ class HookCore extends ObjectModel
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($use_push && !$moduleInstance->allow_push)
|
||||
continue;
|
||||
// Check which / if method is callable
|
||||
$hook_callable = is_callable(array($moduleInstance, 'hook'.$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;
|
||||
|
||||
if ($use_push && isset($moduleInstance->push_filename) && file_exists($moduleInstance->push_filename))
|
||||
Tools::waitUntilFileIsModified($moduleInstance->push_filename, $moduleInstance->push_time_limit);
|
||||
|
||||
// Call hook method
|
||||
if ($hook_callable)
|
||||
$display = $moduleInstance->{'hook'.$hook_name}($hook_args);
|
||||
else if ($hook_retro_callable)
|
||||
elseif ($hook_retro_callable)
|
||||
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
|
||||
// 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')))
|
||||
|
||||
@@ -119,6 +119,10 @@ abstract class ModuleCore
|
||||
/** @var Smarty_Data */
|
||||
protected $smarty;
|
||||
|
||||
/** @var allow push */
|
||||
public $allow_push;
|
||||
|
||||
public $push_time_limit = 180;
|
||||
|
||||
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
|
||||
|
||||
@@ -1643,7 +1647,8 @@ abstract class ModuleCore
|
||||
{
|
||||
$this->smarty->assign(array(
|
||||
'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)
|
||||
|
||||
@@ -89,6 +89,6 @@ class AdminDashboardControllerCore extends AdminController
|
||||
'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;
|
||||
});
|
||||
|
||||
refreshDashboard();
|
||||
refreshDashboard(false);
|
||||
});
|
||||
|
||||
function refreshDashboard(module_name)
|
||||
function refreshDashboard(use_push)
|
||||
{
|
||||
module_list = new Array();
|
||||
|
||||
@@ -50,16 +50,19 @@ function refreshDashboard(module_name)
|
||||
$(this).addClass('loading');
|
||||
});
|
||||
}
|
||||
console.log(module_list);
|
||||
|
||||
for (var module_id in module_list)
|
||||
{
|
||||
if (use_push && !$('#'+module_list[module_id]).hasClass('allow_push'))
|
||||
continue;
|
||||
|
||||
$.ajax({
|
||||
url : dashboard_ajax_url,
|
||||
data : {
|
||||
ajax:true,
|
||||
action:'refreshDashboard',
|
||||
module:module_list[module_id],
|
||||
dashboard_use_push:parseInt(dashboard_use_push)
|
||||
dashboard_use_push:Number(use_push)
|
||||
},
|
||||
dataType: 'json',
|
||||
success : function(widgets){
|
||||
@@ -68,7 +71,7 @@ function refreshDashboard(module_name)
|
||||
window[data_type](widget_name, widgets[widget_name][data_type]);
|
||||
|
||||
if (parseInt(dashboard_use_push) == 1)
|
||||
refreshDashboard();
|
||||
refreshDashboard(true);
|
||||
},
|
||||
error : function(data){
|
||||
//@TODO display errors
|
||||
@@ -89,7 +92,7 @@ function setDashboardDateRange(action)
|
||||
success : function(jsonData){
|
||||
if (!jsonData.has_errors)
|
||||
{
|
||||
refreshDashboard();
|
||||
refreshDashboard(false);
|
||||
$('#datepickerFrom').val(jsonData.date_from);
|
||||
$('#datepickerTo').val(jsonData.date_to);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class Dashactivity extends Module
|
||||
$this->version = '0.1';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->push_filename = _PS_CACHE_DIR_.'push/activity';
|
||||
$this->allow_push = true;
|
||||
$this->push_time_limit = 180;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -64,9 +66,6 @@ class Dashactivity extends Module
|
||||
|
||||
public function hookDashboardData($params)
|
||||
{
|
||||
if ($params['dashboard_use_push'])
|
||||
Tools::waitUntilFileIsModified($this->push_filename, 30);
|
||||
|
||||
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||
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)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<section id="dashactivity" class="panel widget">
|
||||
<section id="dashactivity" class="panel widget{if $allow_push} allow_push{/if}">
|
||||
<div class="panel-heading">
|
||||
<i class="icon-time"></i> {l s='Recent Activity'}
|
||||
<span class="panel-heading-action">
|
||||
|
||||
Reference in New Issue
Block a user