Skip to content

Commit

Permalink
#56 [Hook] add: doActions hook for load translation in crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jan 16, 2023
1 parent 1890ff7 commit 450d668
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions class/actions_dolitemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ public function __construct($db)
$this->db = $db;
}

/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadata (context, etc...)
* @param object $object The object to process
* @param string $action Current action (if set). Generally create or edit or null
* @return int 0 < on error, 0 on success, 1 to replace standard code
*/
public function doActions(array $parameters, $object, string $action): int
{
global $langs;

if ($parameters['currentcontext'] == 'cronjoblist') {
if ($action == 'confirm_execute') {
// Translations
$langs->load('dolitemplate@dolitemplate');
}
}

return 0;
}

/**
* Do new actions on PrintTopRightMenu
*
Expand Down
1 change: 1 addition & 0 deletions core/modules/modDolitemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function __construct($db)
'hooks' => array(
'data' => array(
'toprightmenu',
'cronjoblist'
),
),
// Set this to 1 if features of module are opened to external users
Expand Down

0 comments on commit 450d668

Please sign in to comment.