blockedlog.class.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. /* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
  3. * Copyright (C) 2017-2020 Laurent Destailleur <eldy@destailleur.fr>
  4. * Copyright (C) 2022 charlene benke <charlene@patas-monkey.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * See https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
  20. */
  21. /**
  22. * Class to manage Blocked Log
  23. */
  24. class BlockedLog
  25. {
  26. /**
  27. * Id of the log
  28. * @var int
  29. */
  30. public $id;
  31. /**
  32. * Entity
  33. * @var int
  34. */
  35. public $entity;
  36. /**
  37. * @var string Error message
  38. */
  39. public $error = '';
  40. /**
  41. * @var string[] Error codes (or messages)
  42. */
  43. public $errors = array();
  44. /**
  45. * Unique fingerprint of the log
  46. * @var string
  47. */
  48. public $signature = '';
  49. /**
  50. * Unique fingerprint of the line log content
  51. * @var string
  52. */
  53. public $signature_line = '';
  54. public $amounts = null;
  55. /**
  56. * trigger action
  57. * @var string
  58. */
  59. public $action = '';
  60. /**
  61. * Object element
  62. * @var string
  63. */
  64. public $element = '';
  65. /**
  66. * Object id
  67. * @var int
  68. */
  69. public $fk_object = 0;
  70. /**
  71. * Log certified by remote authority or not
  72. * @var boolean
  73. */
  74. public $certified = false;
  75. /**
  76. * Author
  77. * @var int
  78. */
  79. public $fk_user = 0;
  80. /**
  81. * @var integer|string date_creation
  82. */
  83. public $date_creation;
  84. /**
  85. * @var integer|string $date_modification;
  86. */
  87. public $date_modification;
  88. public $date_object = 0;
  89. public $ref_object = '';
  90. public $object_data = null;
  91. public $object_version = '';
  92. public $user_fullname = '';
  93. /**
  94. * Array of tracked event codes
  95. * @var string[]
  96. */
  97. public $trackedevents = array();
  98. /**
  99. * Constructor
  100. *
  101. * @param DoliDB $db Database handler
  102. */
  103. public function __construct(DoliDB $db)
  104. {
  105. $this->db = $db;
  106. }
  107. /**
  108. * Load list of tracked events into $this->trackedevents.
  109. *
  110. * @return int Always 1
  111. */
  112. public function loadTrackedEvents()
  113. {
  114. global $conf;
  115. $this->trackedevents = array();
  116. // Customer Invoice/Facture / Payment
  117. if (isModEnabled('facture')) {
  118. $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE';
  119. $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE';
  120. $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL';
  121. $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload';
  122. $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview';
  123. $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE';
  124. $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE';
  125. }
  126. /* Supplier
  127. // Supplier Invoice / Payment
  128. if (isModEnabled("fournisseur")) {
  129. $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate';
  130. $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete';
  131. $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
  132. $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
  133. $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
  134. $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate';
  135. $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate';
  136. }
  137. */
  138. // Donation
  139. if (isModEnabled('don')) {
  140. $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE';
  141. $this->trackedevents['DON_DELETE'] = 'logDON_DELETE';
  142. //$this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL';
  143. $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE';
  144. $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE';
  145. }
  146. /*
  147. // Salary
  148. if (!empty($conf->salary->enabled)) {
  149. $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate';
  150. $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate';
  151. $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate';
  152. }
  153. */
  154. // Members
  155. if (isModEnabled('adherent')) {
  156. $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE';
  157. $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY';
  158. $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE';
  159. }
  160. // Bank
  161. if (isModEnabled("banque")) {
  162. $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE';
  163. $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY';
  164. $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE';
  165. }
  166. // Cashdesk
  167. // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all external POS modules
  168. $moduleposenabled = (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
  169. if ($moduleposenabled) {
  170. $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE';
  171. }
  172. // Add more action to track from a conf variable
  173. // For example: STOCK_MOVEMENT,...
  174. if (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED)) {
  175. $tmparrayofmoresupportedevents = explode(',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED);
  176. foreach ($tmparrayofmoresupportedevents as $val) {
  177. $this->trackedevents[$val] = 'log'.$val;
  178. }
  179. }
  180. return 1;
  181. }
  182. /**
  183. * Try to retrieve source object (it it still exists).
  184. *
  185. * @return string URL string of source object
  186. */
  187. public function getObjectLink()
  188. {
  189. global $langs;
  190. if ($this->element === 'facture') {
  191. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  192. $object = new Facture($this->db);
  193. if ($object->fetch($this->fk_object) > 0) {
  194. return $object->getNomUrl(1);
  195. } else {
  196. $this->error++;
  197. }
  198. }
  199. if ($this->element === 'invoice_supplier') {
  200. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  201. $object = new FactureFournisseur($this->db);
  202. if ($object->fetch($this->fk_object) > 0) {
  203. return $object->getNomUrl(1);
  204. } else {
  205. $this->error++;
  206. }
  207. } elseif ($this->element === 'payment') {
  208. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  209. $object = new Paiement($this->db);
  210. if ($object->fetch($this->fk_object) > 0) {
  211. return $object->getNomUrl(1);
  212. } else {
  213. $this->error++;
  214. }
  215. } elseif ($this->element === 'payment_supplier') {
  216. require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
  217. $object = new PaiementFourn($this->db);
  218. if ($object->fetch($this->fk_object) > 0) {
  219. return $object->getNomUrl(1);
  220. } else {
  221. $this->error++;
  222. }
  223. } elseif ($this->element === 'payment_donation') {
  224. require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
  225. $object = new PaymentDonation($this->db);
  226. if ($object->fetch($this->fk_object) > 0) {
  227. return $object->getNomUrl(1);
  228. } else {
  229. $this->error++;
  230. }
  231. } elseif ($this->element === 'payment_various') {
  232. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
  233. $object = new PaymentVarious($this->db);
  234. if ($object->fetch($this->fk_object) > 0) {
  235. return $object->getNomUrl(1);
  236. } else {
  237. $this->error++;
  238. }
  239. } elseif ($this->element === 'don' || $this->element === 'donation') {
  240. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  241. $object = new Don($this->db);
  242. if ($object->fetch($this->fk_object) > 0) {
  243. return $object->getNomUrl(1);
  244. } else {
  245. $this->error++;
  246. }
  247. } elseif ($this->element === 'subscription') {
  248. require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
  249. $object = new Subscription($this->db);
  250. if ($object->fetch($this->fk_object) > 0) {
  251. return $object->getNomUrl(1);
  252. } else {
  253. $this->error++;
  254. }
  255. } elseif ($this->element === 'cashcontrol') {
  256. require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
  257. $object = new CashControl($this->db);
  258. if ($object->fetch($this->fk_object) > 0) {
  259. return $object->getNomUrl(1);
  260. } else {
  261. $this->error++;
  262. }
  263. } elseif ($this->element === 'stockmouvement') {
  264. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
  265. $object = new MouvementStock($this->db);
  266. if ($object->fetch($this->fk_object) > 0) {
  267. return $object->getNomUrl(1);
  268. } else {
  269. $this->error++;
  270. }
  271. } elseif ($this->action == 'MODULE_SET') {
  272. return '<i class="opacitymedium">'.$langs->trans("BlockedLogEnabled").'</i>';
  273. } elseif ($this->action == 'MODULE_RESET') {
  274. if ($this->signature == '0000000000') {
  275. return '<i class="opacitymedium">'.$langs->trans("BlockedLogDisabled").'</i>';
  276. } else {
  277. return '<i class="opacitymedium">'.$langs->trans("BlockedLogDisabledBis").'</i>';
  278. }
  279. }
  280. return '<i class="opacitymedium">'.$langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object).'</i>';
  281. }
  282. /**
  283. * try to retrieve user author
  284. * @return string
  285. */
  286. public function getUser()
  287. {
  288. global $langs, $cachedUser;
  289. if (empty($cachedUser)) {
  290. $cachedUser = array();
  291. }
  292. if (empty($cachedUser[$this->fk_user])) {
  293. $u = new User($this->db);
  294. if ($u->fetch($this->fk_user) > 0) {
  295. $cachedUser[$this->fk_user] = $u;
  296. }
  297. }
  298. if (!empty($cachedUser[$this->fk_user])) {
  299. return $cachedUser[$this->fk_user]->getNomUrl(1);
  300. }
  301. return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user);
  302. }
  303. /**
  304. * Populate properties of log from object data
  305. *
  306. * @param Object $object object to store
  307. * @param string $action action
  308. * @param string $amounts amounts
  309. * @param User $fuser User object (forced)
  310. * @return int >0 if OK, <0 if KO
  311. */
  312. public function setObjectData(&$object, $action, $amounts, $fuser = null)
  313. {
  314. global $langs, $user, $mysoc;
  315. if (is_object($fuser)) {
  316. $user = $fuser;
  317. }
  318. // Generic fields
  319. // action
  320. $this->action = $action;
  321. // amount
  322. $this->amounts = $amounts;
  323. // date
  324. if ($object->element == 'payment' || $object->element == 'payment_supplier') {
  325. $this->date_object = empty($object->datepaye) ? $object->date : $object->datepaye;
  326. } elseif ($object->element == 'payment_salary') {
  327. $this->date_object = $object->datev;
  328. } elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') {
  329. $this->date_object = empty($object->datepaid) ? $object->datep : $object->datepaid;
  330. } elseif ($object->element == 'subscription') {
  331. $this->date_object = $object->dateh;
  332. } elseif ($object->element == 'cashcontrol') {
  333. $this->date_object = $object->date_creation;
  334. } elseif (property_exists($object, 'date')) {
  335. // Generic case
  336. $this->date_object = $object->date;
  337. } elseif (property_exists($object, 'datem')) {
  338. // Generic case (second chance, for example for stock movement)
  339. $this->date_object = $object->datem;
  340. }
  341. // ref
  342. $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases
  343. // type of object
  344. $this->element = $object->element;
  345. // id of object
  346. $this->fk_object = $object->id;
  347. // Set object_data
  348. $this->object_data = new stdClass();
  349. // Add fields to exclude
  350. $arrayoffieldstoexclude = array(
  351. 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'model_pdf', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
  352. 'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged',
  353. 'array_languages',
  354. 'childtables',
  355. 'contact_ids',
  356. 'context',
  357. 'labelStatus',
  358. 'labelStatusShort',
  359. 'linkedObjectsIds',
  360. 'linkedObjects',
  361. 'fk_delivery_address',
  362. 'projet', // There is already ->fk_project
  363. 'restrictiononfksoc',
  364. 'specimen',
  365. );
  366. // Add more fields to exclude depending on object type
  367. if ($this->element == 'cashcontrol') {
  368. $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
  369. 'name', 'lastname', 'firstname', 'region', 'region_id', 'region_code', 'state', 'state_id', 'state_code', 'country', 'country_id', 'country_code',
  370. 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2',
  371. 'barcode_type', 'barcode_type_code', 'barcode_type_label', 'barcode_type_coder', 'mode_reglement_id', 'cond_reglement_id', 'mode_reglement', 'cond_reglement', 'shipping_method_id',
  372. 'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines'));
  373. }
  374. // Add thirdparty info
  375. if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) {
  376. $object->fetch_thirdparty();
  377. }
  378. if (!empty($object->thirdparty)) {
  379. $this->object_data->thirdparty = new stdClass();
  380. foreach ($object->thirdparty as $key => $value) {
  381. if (in_array($key, $arrayoffieldstoexclude)) {
  382. continue; // Discard some properties
  383. }
  384. if (!in_array($key, array(
  385. 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
  386. 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
  387. ))) {
  388. continue; // Discard if not into a dedicated list
  389. }
  390. if (!is_object($value) && !is_null($value) && $value !== '') {
  391. $this->object_data->thirdparty->$key = $value;
  392. }
  393. }
  394. }
  395. // Add company info
  396. if (!empty($mysoc)) {
  397. $this->object_data->mycompany = new stdClass();
  398. foreach ($mysoc as $key => $value) {
  399. if (in_array($key, $arrayoffieldstoexclude)) {
  400. continue; // Discard some properties
  401. }
  402. if (!in_array($key, array(
  403. 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
  404. 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
  405. ))) {
  406. continue; // Discard if not into a dedicated list
  407. }
  408. if (!is_object($value) && !is_null($value) && $value !== '') {
  409. $this->object_data->mycompany->$key = $value;
  410. }
  411. }
  412. }
  413. // Add user info
  414. if (!empty($user)) {
  415. $this->fk_user = $user->id;
  416. $this->user_fullname = $user->getFullName($langs);
  417. }
  418. // Field specific to object
  419. if ($this->element == 'facture') {
  420. foreach ($object as $key => $value) {
  421. if (in_array($key, $arrayoffieldstoexclude)) {
  422. continue; // Discard some properties
  423. }
  424. if (!in_array($key, array(
  425. 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines'
  426. ))) {
  427. continue; // Discard if not into a dedicated list
  428. }
  429. if ($key == 'lines') {
  430. $lineid = 0;
  431. foreach ($value as $tmpline) { // $tmpline is object FactureLine
  432. $lineid++;
  433. foreach ($tmpline as $keyline => $valueline) {
  434. if (!in_array($keyline, array(
  435. 'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2'
  436. ))) {
  437. continue; // Discard if not into a dedicated list
  438. }
  439. if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) { // To avoid warning
  440. $this->object_data->invoiceline[$lineid] = new stdClass();
  441. }
  442. if (!is_object($valueline) && !is_null($valueline) && $valueline !== '') {
  443. $this->object_data->invoiceline[$lineid]->$keyline = $valueline;
  444. }
  445. }
  446. }
  447. } elseif (!is_object($value) && !is_null($value) && $value !== '') {
  448. $this->object_data->$key = $value;
  449. }
  450. }
  451. if (!empty($object->newref)) {
  452. $this->object_data->ref = $object->newref;
  453. }
  454. } elseif ($this->element == 'invoice_supplier') {
  455. foreach ($object as $key => $value) {
  456. if (in_array($key, $arrayoffieldstoexclude)) {
  457. continue; // Discard some properties
  458. }
  459. if (!in_array($key, array(
  460. 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public'
  461. ))) {
  462. continue; // Discard if not into a dedicated list
  463. }
  464. if (!is_object($value) && !is_null($value) && $value !== '') {
  465. $this->object_data->$key = $value;
  466. }
  467. }
  468. if (!empty($object->newref)) {
  469. $this->object_data->ref = $object->newref;
  470. }
  471. } elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various') {
  472. $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
  473. $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
  474. $this->object_data->ref = $object->ref;
  475. $this->object_data->date = $datepayment;
  476. $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
  477. if (!empty($object->num_payment)) {
  478. $this->object_data->payment_num = $object->num_payment;
  479. }
  480. if (!empty($object->note_private)) {
  481. $this->object_data->note_private = $object->note_private;
  482. }
  483. //$this->object_data->fk_account = $object->fk_account;
  484. //var_dump($this->object_data);exit;
  485. $totalamount = 0;
  486. // Loop on each invoice payment amount (payment_part)
  487. if (is_array($object->amounts) && !empty($object->amounts)) {
  488. $paymentpartnumber = 0;
  489. foreach ($object->amounts as $objid => $amount) {
  490. if (empty($amount)) {
  491. continue;
  492. }
  493. $totalamount += $amount;
  494. $tmpobject = null;
  495. if ($this->element == 'payment_supplier') {
  496. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  497. $tmpobject = new FactureFournisseur($this->db);
  498. } elseif ($this->element == 'payment') {
  499. include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  500. $tmpobject = new Facture($this->db);
  501. } elseif ($this->element == 'payment_donation') {
  502. include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  503. $tmpobject = new Don($this->db);
  504. } elseif ($this->element == 'payment_various') {
  505. include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
  506. $tmpobject = new PaymentVarious($this->db);
  507. }
  508. if (!is_object($tmpobject)) {
  509. continue;
  510. }
  511. $result = $tmpobject->fetch($objid);
  512. if ($result <= 0) {
  513. $this->error = $tmpobject->error;
  514. $this->errors = $tmpobject->errors;
  515. dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR);
  516. return -1;
  517. }
  518. $paymentpart = new stdClass();
  519. $paymentpart->amount = $amount;
  520. if (!in_array($this->element, array('payment_donation', 'payment_various'))) {
  521. $result = $tmpobject->fetch_thirdparty();
  522. if ($result == 0) {
  523. $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id;
  524. $this->errors[] = $this->error;
  525. dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
  526. return -1;
  527. } elseif ($result < 0) {
  528. $this->error = $tmpobject->error;
  529. $this->errors = $tmpobject->errors;
  530. return -1;
  531. }
  532. $paymentpart->thirdparty = new stdClass();
  533. foreach ($tmpobject->thirdparty as $key => $value) {
  534. if (in_array($key, $arrayoffieldstoexclude)) {
  535. continue; // Discard some properties
  536. }
  537. if (!in_array($key, array(
  538. 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
  539. 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
  540. ))) {
  541. continue; // Discard if not into a dedicated list
  542. }
  543. if (!is_object($value) && !is_null($value) && $value !== '') {
  544. $paymentpart->thirdparty->$key = $value;
  545. }
  546. }
  547. }
  548. // Init object to avoid warnings
  549. if ($this->element == 'payment_donation') {
  550. $paymentpart->donation = new stdClass();
  551. } else {
  552. $paymentpart->invoice = new stdClass();
  553. }
  554. if ($this->element != 'payment_various') {
  555. foreach ($tmpobject as $key => $value) {
  556. if (in_array($key, $arrayoffieldstoexclude)) {
  557. continue; // Discard some properties
  558. }
  559. if (!in_array($key, array(
  560. 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public'
  561. ))) {
  562. continue; // Discard if not into a dedicated list
  563. }
  564. if (!is_object($value) && !is_null($value) && $value !== '') {
  565. if ($this->element == 'payment_donation') {
  566. $paymentpart->donation->$key = $value;
  567. } elseif ($this->element == 'payment_various') {
  568. $paymentpart->various->$key = $value;
  569. } else {
  570. $paymentpart->invoice->$key = $value;
  571. }
  572. }
  573. }
  574. $paymentpartnumber++; // first payment will be 1
  575. $this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
  576. }
  577. }
  578. } elseif (!empty($object->amount)) {
  579. $totalamount = $object->amount;
  580. }
  581. $this->object_data->amount = $totalamount;
  582. if (!empty($object->newref)) {
  583. $this->object_data->ref = $object->newref;
  584. }
  585. } elseif ($this->element == 'payment_salary') {
  586. $this->object_data->amounts = array($object->amount);
  587. if (!empty($object->newref)) {
  588. $this->object_data->ref = $object->newref;
  589. }
  590. } elseif ($this->element == 'subscription') {
  591. foreach ($object as $key => $value) {
  592. if (in_array($key, $arrayoffieldstoexclude)) {
  593. continue; // Discard some properties
  594. }
  595. if (!in_array($key, array(
  596. 'id', 'datec', 'dateh', 'datef', 'fk_adherent', 'amount', 'import_key', 'statut', 'note'
  597. ))) {
  598. continue; // Discard if not into a dedicated list
  599. }
  600. if (!is_object($value) && !is_null($value) && $value !== '') {
  601. $this->object_data->$key = $value;
  602. }
  603. }
  604. if (!empty($object->newref)) {
  605. $this->object_data->ref = $object->newref;
  606. }
  607. } elseif ($this->element == 'stockmouvement') {
  608. foreach ($object as $key => $value) {
  609. if (in_array($key, $arrayoffieldstoexclude)) {
  610. continue; // Discard some properties
  611. }
  612. if (!is_object($value) && !is_null($value) && $value !== '') {
  613. $this->object_data->$key = $value;
  614. }
  615. }
  616. } else {
  617. // Generic case
  618. foreach ($object as $key => $value) {
  619. if (in_array($key, $arrayoffieldstoexclude)) {
  620. continue; // Discard some properties
  621. }
  622. if (!is_object($value) && !is_null($value) && $value !== '') {
  623. $this->object_data->$key = $value;
  624. }
  625. }
  626. if (!empty($object->newref)) {
  627. $this->object_data->ref = $object->newref;
  628. }
  629. }
  630. return 1;
  631. }
  632. /**
  633. * Get object from database
  634. *
  635. * @param int $id Id of object to load
  636. * @return int >0 if OK, <0 if KO, 0 if not found
  637. */
  638. public function fetch($id)
  639. {
  640. global $langs;
  641. if (empty($id)) {
  642. $this->error = 'BadParameter';
  643. return -1;
  644. }
  645. $sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
  646. $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version";
  647. $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b";
  648. if ($id) {
  649. $sql .= " WHERE b.rowid = ".((int) $id);
  650. }
  651. $resql = $this->db->query($sql);
  652. if ($resql) {
  653. $obj = $this->db->fetch_object($resql);
  654. if ($obj) {
  655. $this->id = $obj->rowid;
  656. $this->entity = $obj->entity;
  657. $this->ref = $obj->rowid;
  658. $this->date_creation = $this->db->jdate($obj->date_creation);
  659. $this->tms = $this->db->jdate($obj->tms);
  660. $this->amounts = (double) $obj->amounts;
  661. $this->action = $obj->action;
  662. $this->element = $obj->element;
  663. $this->fk_object = $obj->fk_object;
  664. $this->date_object = $this->db->jdate($obj->date_object);
  665. $this->ref_object = $obj->ref_object;
  666. $this->fk_user = $obj->fk_user;
  667. $this->user_fullname = $obj->user_fullname;
  668. $this->object_data = $this->dolDecodeBlockedData($obj->object_data);
  669. $this->object_version = $obj->object_version;
  670. $this->signature = $obj->signature;
  671. $this->signature_line = $obj->signature_line;
  672. $this->certified = ($obj->certified == 1);
  673. return 1;
  674. } else {
  675. $langs->load("blockedlog");
  676. $this->error = $langs->trans("RecordNotFound");
  677. return 0;
  678. }
  679. } else {
  680. $this->error = $this->db->error();
  681. return -1;
  682. }
  683. }
  684. /**
  685. * Decode data
  686. *
  687. * @param string $data Data to unserialize
  688. * @param string $mode 0=unserialize, 1=json_decode
  689. * @return string Value unserialized
  690. */
  691. public function dolDecodeBlockedData($data, $mode = 0)
  692. {
  693. try {
  694. //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  695. $aaa = unserialize($data);
  696. } catch (Exception $e) {
  697. //print $e->getErrs);
  698. }
  699. return $aaa;
  700. }
  701. /**
  702. * Set block certified by authority
  703. *
  704. * @return boolean
  705. */
  706. public function setCertified()
  707. {
  708. $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".((int) $this->id));
  709. if (!$res) {
  710. return false;
  711. }
  712. return true;
  713. }
  714. /**
  715. * Create blocked log in database.
  716. *
  717. * @param User $user Object user that create
  718. * @param int $forcesignature Force signature (for example '0000000000' when we disabled the module)
  719. * @return int <0 if KO, >0 if OK
  720. */
  721. public function create($user, $forcesignature = '')
  722. {
  723. global $conf, $langs, $hookmanager;
  724. $langs->load('blockedlog');
  725. $error = 0;
  726. // Clean data
  727. $this->amounts = (double) $this->amounts;
  728. dol_syslog(get_class($this).'::create action='.$this->action.' fk_user='.$this->fk_user.' user_fullname='.$this->user_fullname, LOG_DEBUG);
  729. // Check parameters/properties
  730. if (!isset($this->amounts)) { // amount can be 0 for some events (like when module is disabled)
  731. $this->error = $langs->trans("BlockLogNeedAmountsValue");
  732. dol_syslog($this->error, LOG_WARNING);
  733. return -1;
  734. }
  735. if (empty($this->element)) {
  736. $this->error = $langs->trans("BlockLogNeedElement");
  737. dol_syslog($this->error, LOG_WARNING);
  738. return -2;
  739. }
  740. if (empty($this->action)) {
  741. $this->error = $langs->trans("BadParameterWhenCallingCreateOfBlockedLog");
  742. dol_syslog($this->error, LOG_WARNING);
  743. return -3;
  744. }
  745. if (empty($this->fk_user)) {
  746. $this->user_fullname = '(Anonymous)';
  747. }
  748. $this->date_creation = dol_now();
  749. $this->db->begin();
  750. $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done
  751. $keyforsignature = $this->buildKeyForSignature();
  752. include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  753. $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
  754. $this->signature = dol_hash($previoushash.$keyforsignature, '5');
  755. if ($forcesignature) {
  756. $this->signature = $forcesignature;
  757. }
  758. //var_dump($keyforsignature);var_dump($previoushash);var_dump($this->signature_line);var_dump($this->signature);
  759. $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog (";
  760. $sql .= " date_creation,";
  761. $sql .= " action,";
  762. $sql .= " amounts,";
  763. $sql .= " signature,";
  764. $sql .= " signature_line,";
  765. $sql .= " element,";
  766. $sql .= " fk_object,";
  767. $sql .= " date_object,";
  768. $sql .= " ref_object,";
  769. $sql .= " object_data,";
  770. $sql .= " object_version,";
  771. $sql .= " certified,";
  772. $sql .= " fk_user,";
  773. $sql .= " user_fullname,";
  774. $sql .= " entity";
  775. $sql .= ") VALUES (";
  776. $sql .= "'".$this->db->idate($this->date_creation)."',";
  777. $sql .= "'".$this->db->escape($this->action)."',";
  778. $sql .= $this->amounts.",";
  779. $sql .= "'".$this->db->escape($this->signature)."',";
  780. $sql .= "'".$this->db->escape($this->signature_line)."',";
  781. $sql .= "'".$this->db->escape($this->element)."',";
  782. $sql .= $this->fk_object.",";
  783. $sql .= "'".$this->db->idate($this->date_object)."',";
  784. $sql .= "'".$this->db->escape($this->ref_object)."',";
  785. $sql .= "'".$this->db->escape(serialize($this->object_data))."',";
  786. $sql .= "'".$this->db->escape($this->object_version)."',";
  787. $sql .= "0,";
  788. $sql .= $this->fk_user.",";
  789. $sql .= "'".$this->db->escape($this->user_fullname)."',";
  790. $sql .= ($this->entity ? $this->entity : $conf->entity);
  791. $sql .= ")";
  792. $res = $this->db->query($sql);
  793. if ($res) {
  794. $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog");
  795. if ($id > 0) {
  796. $this->id = $id;
  797. $this->db->commit();
  798. return $this->id;
  799. } else {
  800. $this->db->rollback();
  801. return -2;
  802. }
  803. } else {
  804. $this->error = $this->db->error();
  805. $this->db->rollback();
  806. return -1;
  807. }
  808. // The commit will release the lock so we can insert nex record
  809. }
  810. /**
  811. * Check if current signature still correct compared to the value in chain
  812. *
  813. * @param string $previoushash If previous signature hash is known, we can provide it to avoid to make a search of it in database.
  814. * @param int $returnarray 1=Return array of details, 2=Return array of details including keyforsignature, 0=Boolean
  815. * @return boolean|array True if OK, False if KO
  816. */
  817. public function checkSignature($previoushash = '', $returnarray = 0)
  818. {
  819. if (empty($previoushash)) {
  820. $previoushash = $this->getPreviousHash(0, $this->id);
  821. }
  822. // Recalculate hash
  823. $keyforsignature = $this->buildKeyForSignature();
  824. //$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
  825. $signature = dol_hash($previoushash.$keyforsignature, '5');
  826. //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature);
  827. $res = ($signature === $this->signature);
  828. if (!$res) {
  829. $this->error = 'Signature KO';
  830. }
  831. if ($returnarray) {
  832. if ($returnarray == 1) {
  833. unset($keyforsignature);
  834. return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash);
  835. } else { // Consume much memory ($keyforsignature is a large var)
  836. return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature'=>$keyforsignature);
  837. }
  838. } else {
  839. unset($keyforsignature);
  840. return $res;
  841. }
  842. }
  843. /**
  844. * Return a string for signature.
  845. * Note: rowid of line not included as it is not a business data and this allow to make backup of a year
  846. * and restore it into another database with different id wihtout comprimising checksums
  847. *
  848. * @return string Key for signature
  849. */
  850. private function buildKeyForSignature()
  851. {
  852. //print_r($this->object_data);
  853. if (((int) $this->object_version) > 12) {
  854. return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true);
  855. } else {
  856. return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true);
  857. }
  858. }
  859. /**
  860. * Get previous signature/hash in chain
  861. *
  862. * @param int $withlock 1=With a lock
  863. * @param int $beforeid ID of a record
  864. * @return string Hash of previous record (if beforeid is defined) or hash of last record (if beforeid is 0)
  865. */
  866. public function getPreviousHash($withlock = 0, $beforeid = 0)
  867. {
  868. global $conf;
  869. $previoussignature = '';
  870. $sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog";
  871. $sql .= " WHERE entity=".$conf->entity;
  872. if ($beforeid) {
  873. $sql .= " AND rowid < ".(int) $beforeid;
  874. }
  875. $sql .= " ORDER BY rowid DESC LIMIT 1";
  876. $sql .= ($withlock ? " FOR UPDATE " : "");
  877. $resql = $this->db->query($sql);
  878. if ($resql) {
  879. $obj = $this->db->fetch_object($resql);
  880. if ($obj) {
  881. $previoussignature = $obj->signature;
  882. }
  883. } else {
  884. dol_print_error($this->db);
  885. exit;
  886. }
  887. if (empty($previoussignature)) {
  888. // First signature line (line 0)
  889. $previoussignature = $this->getSignature();
  890. }
  891. return $previoussignature;
  892. }
  893. /**
  894. * Return array of log objects (with criterias)
  895. *
  896. * @param string $element element to search
  897. * @param int $fk_object id of object to search
  898. * @param int $limit max number of element, 0 for all
  899. * @param string $sortfield sort field
  900. * @param string $sortorder sort order
  901. * @param int $search_fk_user id of user(s)
  902. * @param int $search_start start time limit
  903. * @param int $search_end end time limit
  904. * @param string $search_ref search ref
  905. * @param string $search_amount search amount
  906. * @param string $search_code search code
  907. * @return array|int Array of object log or <0 if error
  908. */
  909. public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref = '', $search_amount = '', $search_code = '')
  910. {
  911. global $conf;
  912. //global $cachedlogs;
  913. /* $cachedlogs allow fastest search */
  914. //if (empty($cachedlogs)) $cachedlogs = array();
  915. if ($element == 'all') {
  916. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
  917. WHERE entity=".$conf->entity;
  918. } elseif ($element == 'not_certified') {
  919. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
  920. WHERE entity=".$conf->entity." AND certified = 0";
  921. } elseif ($element == 'just_certified') {
  922. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
  923. WHERE entity=".$conf->entity." AND certified = 1";
  924. } else {
  925. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
  926. WHERE entity=".$conf->entity." AND element='".$this->db->escape($element)."'";
  927. }
  928. if ($fk_object) {
  929. $sql .= natural_search("rowid", $fk_object, 1);
  930. }
  931. if ($search_fk_user > 0) {
  932. $sql .= natural_search("fk_user", $search_fk_user, 2);
  933. }
  934. if ($search_start > 0) {
  935. $sql .= " AND date_creation >= '".$this->db->idate($search_start)."'";
  936. }
  937. if ($search_end > 0) {
  938. $sql .= " AND date_creation <= '".$this->db->idate($search_end)."'";
  939. }
  940. if ($search_ref != '') {
  941. $sql .= natural_search("ref_object", $search_ref);
  942. }
  943. if ($search_amount != '') {
  944. $sql .= natural_search("amounts", $search_amount, 1);
  945. }
  946. if ($search_code != '' && $search_code != '-1') {
  947. $sql .= natural_search("action", $search_code, 3);
  948. }
  949. $sql .= $this->db->order($sortfield, $sortorder);
  950. $sql .= $this->db->plimit($limit + 1); // We want more, because we will stop into loop later with error if we reach max
  951. $res = $this->db->query($sql);
  952. if ($res) {
  953. $results = array();
  954. $i = 0;
  955. while ($obj = $this->db->fetch_object($res)) {
  956. $i++;
  957. if ($i > $limit) {
  958. // Too many record, we will consume too much memory
  959. return -2;
  960. }
  961. //if (!isset($cachedlogs[$obj->rowid]))
  962. //{
  963. $b = new BlockedLog($this->db);
  964. $b->fetch($obj->rowid);
  965. //$b->loadTrackedEvents();
  966. //$cachedlogs[$obj->rowid] = $b;
  967. //}
  968. //$results[] = $cachedlogs[$obj->rowid];
  969. $results[] = $b;
  970. }
  971. return $results;
  972. }
  973. return -1;
  974. }
  975. /**
  976. * Return the signature (hash) of the "genesis-block" (Block 0).
  977. *
  978. * @return string Signature of genesis-block for current conf->entity
  979. */
  980. public function getSignature()
  981. {
  982. global $db, $conf, $mysoc;
  983. if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint
  984. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  985. require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  986. require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
  987. $fingerprint = dol_hash(print_r($mysoc, true).getRandomPassword(1), '5');
  988. dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity);
  989. $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
  990. }
  991. return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
  992. }
  993. /**
  994. * Check if module was already used or not for at least one recording.
  995. *
  996. * @param int $ignoresystem Ignore system events for the test
  997. * @return bool
  998. */
  999. public function alreadyUsed($ignoresystem = 0)
  1000. {
  1001. global $conf;
  1002. $result = false;
  1003. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog";
  1004. $sql .= " WHERE entity = ".$conf->entity;
  1005. if ($ignoresystem) {
  1006. $sql .= " AND action not in ('MODULE_SET','MODULE_RESET')";
  1007. }
  1008. $sql .= $this->db->plimit(1);
  1009. $res = $this->db->query($sql);
  1010. if ($res !== false) {
  1011. $obj = $this->db->fetch_object($res);
  1012. if ($obj) {
  1013. $result = true;
  1014. }
  1015. } else {
  1016. dol_print_error($this->db);
  1017. }
  1018. dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result);
  1019. return $result;
  1020. }
  1021. }