26include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
47 $this->rights_class =
'blockedlog';
51 $this->family =
"base";
53 $this->module_position =
'76';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
56 $this->
description =
"Enable a log on some business events into an unalterable log. This module may be mandatory for some countries.";
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->picto =
'blockedlog';
66 $this->dirs = array();
70 $this->config_page_url = array(
'blockedlog.php?withtab=1@blockedlog');
74 $this->hidden =
false;
75 $this->depends = array(
'always'=>
'modFacture');
76 $this->requiredby = array();
77 $this->conflictwith = array();
78 $this->langfiles = array(
'blockedlog');
80 $this->warnings_activation = array();
81 $this->warnings_activation_ext = array();
82 $this->warnings_unactivation = array(
'FR'=>
'BlockedLogAreRequiredByYourCountryLegislation');
98 && in_array((empty(
$mysoc->country_code) ?
'' :
$mysoc->country_code), explode(
',',
getDolGlobalString(
'BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY')))
103 $this->
const = array(
104 1=>array(
'BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY',
'chaine',
'FR',
'This is list of country code where the module may be mandatory', 0,
'current', 0)
109 $this->tabs = array();
113 $this->boxes = array();
117 $this->rights = array();
120 $this->rights[$r][0] = $this->numero + $r;
121 $this->rights[$r][1] =
'Read archived events and fingerprints';
122 $this->rights[$r][3] = 0;
123 $this->rights[$r][4] =
'read';
124 $this->rights[$r][5] =
'';
129 $this->menu[$r] = array(
130 'fk_menu'=>
'fk_mainmenu=tools',
132 'leftmenu'=>
'blockedlogbrowser',
134 'titre'=>
'BrowseBlockedLog',
135 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth"'),
136 'url'=>
'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser',
137 'langs'=>
'blockedlog',
139 'enabled'=>
'isModEnabled("blockedlog")',
140 'perms'=>
'$user->hasRight("blockedlog", "read")',
155 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
169 public function init($options =
'')
176 require_once DOL_DOCUMENT_ROOT .
'/blockedlog/class/blockedlog.class.php';
182 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
183 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
186 $s = $b->canBeEnabled();
194 if (empty($hmac_encoded_secret_key)) {
196 $hmac_secret_key =
'BLOCKEDLOGHMAC'.getRandomPassword(
true);
198 $result =
dolibarr_set_const($this->db,
'BLOCKEDLOG_HMAC_KEY', $hmac_secret_key,
'chaine', 0,
'The secret key for HMAC used for blockedlog record', $conf->entity);
202 $this->db->rollback();
208 $hmac_secret_key =
dolDecrypt($hmac_encoded_secret_key);
210 if (! preg_match(
'/^BLOCKEDLOGHMAC/', $hmac_secret_key)) {
211 $this->error =
'Error: Failed to decode the crypted value of the parameter BLOCKEDLOG_HMAC_KEY using the $dolibarr_main_crypt_key. A value was found in config parameters in database but decoding failed. May be the database data were restored onto another environment and the coding/decoding key $dolibarr_main_dolcrypt_key was not restored with the same value in conf.php file.';
212 $this->error .=
'Restore the value of $dolibarr_main_crypt_key that was used for encryption in database and restart the migration.';
213 $this->error .=
'If you don\'t use the Unalterable Log module, you can also remove the BLOCKEDLOG_HMAC_KEY entry from llx_const table. If you use the Unalterable Log, this is not possible because this will invalidate all past record.';
214 $this->db->rollback();
229 $object->entity = $conf->entity;
233 $action =
'MODULE_SET';
234 $result = $b->setObjectData(
$object, $action, 0, $user,
null);
237 $this->error = $b->error;
238 $this->errors = $b->errors;
242 $res = $b->create($user);
244 $this->error = $b->error;
245 $this->errors = $b->errors;
249 return $this->
_init($sql, $options);
260 public function remove($options =
'')
267 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
269 dol_syslog(
"modBlockedLog::remove option=".$options, LOG_DEBUG);
275 $object->entity = $conf->entity;
277 $object->label =
'Module disabled';
280 $result = $b->setObjectData(
$object,
'MODULE_RESET', 0, $user,
null);
282 $this->error = $b->error;
283 $this->errors = $b->errors;
287 if ($b->alreadyUsed(1)) {
289 if ($options !=
'forcedisable' && !$b->canBeDisabled()) {
292 $this->error = $langs->trans(
'DisablingBlockedLogIsNotallowedOnceUsedExceptOnFullreset', $langs->transnoentitiesnoconv(
'BlockedLog'));
296 $res = $b->create($user,
'0000000000');
299 $res = $b->create($user);
302 $this->error = $b->error;
303 $this->errors = $b->errors;
307 return $this->
_remove($sql, $options);
317 public function getDesc($foruseinpopupdesc = 0)
320 $langs->load(
"admin");
323 $s = $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
325 if ($foruseinpopupdesc) {
326 $langs->load(
"blockedlog");
329 $s .=
info_admin($langs->trans(
"UnalterableLogTool1FR"), 0, 0,
'warning');
if(! $sortfield) if(! $sortorder) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
isALNEQualifiedVersion($ignoredev=0, $ignoremodule=0)
Return if the version is a candidate version to get the LNE certification and if the prerequisites ar...
isBlockedLogUsed($ignoresystem=0)
Return if the blocked log was already used to block some events.
Class to manage Blocked Log.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Class to describe a BlockedLog module.
init($options='')
Function called when module is enabled.
alreadyUsed()
Check if module was already used before unactivation linked to warnings_unactivation property.
getDesc($foruseinpopupdesc=0)
Overwrite the common getDesc() method.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.