25include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
46 $this->rights_class =
'blockedlog';
50 $this->family =
"base";
52 $this->module_position =
'76';
54 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
55 $this->
description =
"Enable a log on some business events into an unalterable log. This module may be mandatory for some countries.";
58 $this->version =
'dolibarr';
60 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
'blockedlog';
65 $this->dirs = array();
69 $this->config_page_url = array(
'blockedlog.php?withtab=1@blockedlog');
73 $this->hidden =
false;
74 $this->depends = array(
'always'=>
'modFacture');
75 $this->requiredby = array();
76 $this->conflictwith = array();
77 $this->langfiles = array(
'blockedlog');
79 $this->warnings_activation = array();
80 $this->warnings_activation_ext = array();
81 $this->warnings_unactivation = array(
'FR'=>
'BlockedLogAreRequiredByYourCountryLegislation');
97 && in_array((empty(
$mysoc->country_code) ?
'' :
$mysoc->country_code), explode(
',',
getDolGlobalString(
'BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY')))
102 $this->
const = array(
103 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)
108 $this->tabs = array();
112 $this->boxes = array();
116 $this->rights = array();
119 $this->rights[$r][0] = $this->numero + $r;
120 $this->rights[$r][1] =
'Read archived events and fingerprints';
121 $this->rights[$r][3] = 0;
122 $this->rights[$r][4] =
'read';
123 $this->rights[$r][5] =
'';
128 $this->menu[$r] = array(
129 'fk_menu'=>
'fk_mainmenu=tools',
131 'leftmenu'=>
'blockedlogbrowser',
133 'titre'=>
'BrowseBlockedLog',
134 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth"'),
135 'url'=>
'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser',
136 'langs'=>
'blockedlog',
138 'enabled'=>
'isModEnabled("blockedlog")',
139 'perms'=>
'$user->hasRight("blockedlog", "read")',
154 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
168 public function init($options =
'')
175 require_once DOL_DOCUMENT_ROOT .
'/blockedlog/class/blockedlog.class.php';
181 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
182 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
185 $s = $b->canBeEnabled();
193 if (empty($hmac_encoded_secret_key)) {
195 $hmac_secret_key =
'BLOCKEDLOGHMAC'.getRandomPassword(
true);
197 $result =
dolibarr_set_const($this->db,
'BLOCKEDLOG_HMAC_KEY', $hmac_secret_key,
'chaine', 0,
'The secret key for HMAC used for blockedlog record', 0);
201 $this->db->rollback();
207 $hmac_secret_key =
dolDecrypt($hmac_encoded_secret_key);
209 if (! preg_match(
'/^BLOCKEDLOGHMAC/', $hmac_secret_key)) {
210 $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.';
211 $this->error .=
'Restore the value of $dolibarr_main_crypt_key that was used for encryption in database and restart the migration.';
212 $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.';
213 $this->db->rollback();
228 $object->entity = $conf->entity;
232 $action =
'MODULE_SET';
233 $result = $b->setObjectData(
$object, $action, 0, $user,
null);
236 $this->error = $b->error;
237 $this->errors = $b->errors;
241 $res = $b->create($user);
243 $this->error = $b->error;
244 $this->errors = $b->errors;
248 return $this->
_init($sql, $options);
259 public function remove($options =
'')
266 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
268 dol_syslog(
"modBlockedLog::remove option=".$options, LOG_DEBUG);
274 $object->entity = $conf->entity;
276 $object->label =
'Module disabled';
279 $result = $b->setObjectData(
$object,
'MODULE_RESET', 0, $user,
null);
281 $this->error = $b->error;
282 $this->errors = $b->errors;
286 if ($b->alreadyUsed(1)) {
288 if ($options !=
'forcedisable' && !$b->canBeDisabled()) {
291 $this->error = $langs->trans(
'DisablingBlockedLogIsNotallowedOnceUsedExceptOnFullreset', $langs->transnoentitiesnoconv(
'BlockedLog'));
295 $res = $b->create($user,
'0000000000');
298 $res = $b->create($user);
301 $this->error = $b->error;
302 $this->errors = $b->errors;
306 return $this->
_remove($sql, $options);
316 public function getDesc($foruseinpopupdesc = 0)
319 $langs->load(
"admin");
322 $s = $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
324 if ($foruseinpopupdesc) {
325 $langs->load(
"blockedlog");
328 $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.