mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-24 13:54:28 +01:00
184 lines
5.3 KiB
PHP
184 lines
5.3 KiB
PHP
<?php
|
|
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
* Copyright (C) ---Replace with your own copyright and developer email---
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* \file htdocs/blockedlog/class/actions_blockedlog.class.php
|
|
* \ingroup blockedlog
|
|
* \brief Hooks for module blockedlog
|
|
*/
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php';
|
|
|
|
/**
|
|
* Class ActionsBlockedlog
|
|
*/
|
|
class ActionsBlockedlog extends CommonHookActions
|
|
{
|
|
/**
|
|
* @var DoliDB Database handler.
|
|
*/
|
|
public $db;
|
|
|
|
/**
|
|
* @var string Error code (or message)
|
|
*/
|
|
public $error = '';
|
|
|
|
/**
|
|
* @var string[] Errors
|
|
*/
|
|
public $errors = array();
|
|
|
|
|
|
/**
|
|
* @var mixed[] Hook results. Propagated to $hookmanager->resArray for later reuse
|
|
*/
|
|
public $results = array();
|
|
|
|
/**
|
|
* @var ?string String displayed by executeHook() immediately after return
|
|
*/
|
|
public $resprints;
|
|
|
|
/**
|
|
* @var int Priority of hook (50 is used if value is not defined)
|
|
*/
|
|
public $priority;
|
|
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param DoliDB $db Database handler
|
|
*/
|
|
public function __construct($db)
|
|
{
|
|
$this->db = $db;
|
|
}
|
|
|
|
|
|
/**
|
|
* Execute action before PDF (document) creation
|
|
*
|
|
* @param array<string,mixed> $parameters Array of parameters
|
|
* @param CommonObject $object Object output on PDF
|
|
* @param string $action 'add', 'update', 'view'
|
|
* @return int Return integer <0 if KO,
|
|
* =0 if OK but we want to process standard actions too,
|
|
* >0 if OK and we want to replace standard actions.
|
|
*/
|
|
public function beforePDFCreation($parameters, &$object, &$action)
|
|
{
|
|
global $conf, $user, $langs;
|
|
global $hookmanager;
|
|
|
|
$outputlangs = $langs;
|
|
|
|
$ret = 0;
|
|
$deltemp = array();
|
|
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
|
|
|
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
|
// @phan-suppress-next-line PhanPluginEmptyStatementIf
|
|
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {
|
|
// do something only for the context 'somecontext1' or 'somecontext2'
|
|
}
|
|
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Execute action after PDF (document) creation
|
|
*
|
|
* @param array<string,mixed> $parameters Array of parameters
|
|
* @param CommonDocGenerator $pdfhandler PDF builder handler
|
|
* @param string $action 'add', 'update', 'view'
|
|
* @return int Return integer <0 if KO,
|
|
* =0 if OK but we want to process standard actions too,
|
|
* >0 if OK and we want to replace standard actions.
|
|
*/
|
|
public function afterPDFCreation($parameters, &$pdfhandler, &$action)
|
|
{
|
|
global $conf, $user, $langs;
|
|
global $hookmanager;
|
|
|
|
$outputlangs = $langs;
|
|
|
|
$ret = 0;
|
|
$deltemp = array();
|
|
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
|
|
|
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
|
// @phan-suppress-next-line PhanPluginEmptyStatementIf
|
|
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {
|
|
// do something only for the context 'somecontext1' or 'somecontext2'
|
|
}
|
|
|
|
return $ret;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Overload the loadDataForCustomReports function : returns data to complete the customreport tool
|
|
*
|
|
* @param array<string,mixed> $parameters Hook metadata (context, etc...)
|
|
* @param ?string $action Current action (if set). Generally create or edit or null
|
|
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
|
|
* @return int Return integer < 0 on error, 0 on success, 1 to replace standard code
|
|
*/
|
|
/*
|
|
public function loadDataForCustomReports($parameters, &$action, $hookmanager)
|
|
{
|
|
global $langs;
|
|
|
|
$langs->load("mymodule@mymodule");
|
|
|
|
$this->results = array();
|
|
|
|
$head = array();
|
|
$h = 0;
|
|
|
|
if ($parameters['tabfamily'] == 'mymodule') {
|
|
$head[$h][0] = dol_buildpath('/module/index.php', 1);
|
|
$head[$h][1] = $langs->trans("Home");
|
|
$head[$h][2] = 'home';
|
|
$h++;
|
|
|
|
$this->results['title'] = $langs->trans("MyModule");
|
|
$this->results['picto'] = 'mymodule@mymodule';
|
|
}
|
|
|
|
$head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
|
|
$head[$h][1] = $langs->trans("CustomReports");
|
|
$head[$h][2] = 'customreports';
|
|
|
|
$this->results['head'] = $head;
|
|
|
|
$arrayoftypes = array();
|
|
//$arrayoftypes['mymodule_myobject'] = array('label' => 'MyObject', 'picto'=>'myobject@mymodule', 'ObjectClassName' => 'MyObject', 'enabled' => isModEnabled('mymodule'), 'ClassPath' => "/mymodule/class/myobject.class.php", 'langs'=>'mymodule@mymodule')
|
|
|
|
$this->results['arrayoftype'] = $arrayoftypes;
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
/* Add other hook methods here... */
|
|
}
|