Skip to content

Commit

Permalink
Evarisk#3884 [Dashboard] fix: use template instead of repetitive actions
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed May 15, 2024
1 parent 9125cbb commit 82a09d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
21 changes: 4 additions & 17 deletions view/digiriskelement/digiriskelement_informations.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
$object = new DigiriskElement($db);
$dashboard = new SaturneDashboard($db, $moduleNameLowerCase);

$upload_dir = $conf->digiriskdolibarr->multidir_output[$conf->entity ?? 1];

$hookmanager->initHooks(['digiriskelementinformations', 'digiriskelementview', 'globalcard']); // Note that conf->hooks_modules contains array

// Load object
Expand All @@ -71,23 +73,8 @@
}

if (empty($resHook)) {
if ($action == 'adddashboardinfo' || $action == 'closedashboardinfo') {
$data = json_decode(file_get_contents('php://input'), true);
$dashboardWidgetName = $data['dashboardWidgetName'];
$confName = $moduleNameUpperCase . '_DISABLED_DASHBOARD_INFO';
$visible = json_decode($user->conf->$confName);

if ($action == 'adddashboardinfo') {
unset($visible->$dashboardWidgetName);
} else {
$visible->$dashboardWidgetName = 0;
}

$tabParam[$confName] = json_encode($visible);

dol_set_user_param($db, $conf, $user, $tabParam);
$action = '';
}
// Actions closenotice, adddashboardinfo, closedashboardinfo, generate_csv
require_once __DIR__ . '/../../../saturne/core/tpl/actions/dashboard_actions.tpl.php';
}

/*
Expand Down
25 changes: 10 additions & 15 deletions view/digiriskstandard/digiriskstandard_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

$object->fetch($conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD);

$upload_dir = $conf->digiriskdolibarr->multidir_output[$conf->entity ?? 1];

$hookmanager->initHooks(array('digiriskelementcard', 'digiriskstandardview', 'globalcard')); // Note that conf->hooks_modules contains array

// Security check - Protection if external user
Expand All @@ -69,22 +71,15 @@
* Actions
*/

if ($action == 'adddashboardinfo' || $action == 'closedashboardinfo') {
$data = json_decode(file_get_contents('php://input'), true);
$dashboardWidgetName = $data['dashboardWidgetName'];
$confName = $moduleNameUpperCase . '_DISABLED_DASHBOARD_INFO';
$visible = json_decode($user->conf->$confName);

if ($action == 'adddashboardinfo') {
unset($visible->$dashboardWidgetName);
} else {
$visible->$dashboardWidgetName = 0;
}

$tabParam[$confName] = json_encode($visible);
$parameters = [];
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks.
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}

dol_set_user_param($db, $conf, $user, $tabParam);
$action = '';
if (empty($reshook)) {
// Actions closenotice, adddashboardinfo, closedashboardinfo, generate_csv
require_once __DIR__ . '/../../../saturne/core/tpl/actions/dashboard_actions.tpl.php';
}

/*
Expand Down

0 comments on commit 82a09d9

Please sign in to comment.