events.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/events.php
  20. * \ingroup core
  21. * \brief Log event setup page
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
  28. if (!$user->admin) {
  29. accessforbidden();
  30. }
  31. // Load translation files required by the page
  32. $langs->loadLangs(array("users", "admin", "other"));
  33. $action = GETPOST('action', 'aZ09');
  34. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'auditeventslist'; // To manage different context of search
  35. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  36. // Load variable for pagination
  37. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  38. $sortfield = GETPOST('sortfield', 'aZ09comma');
  39. $sortorder = GETPOST('sortorder', 'aZ09comma');
  40. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  41. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  42. $page = 0;
  43. } // If $page is not defined, or '' or -1 or if we click on clear filters
  44. $offset = $limit * $page;
  45. $pageprev = $page - 1;
  46. $pagenext = $page + 1;
  47. $securityevent = new Events($db);
  48. $eventstolog = $securityevent->eventstolog;
  49. /*
  50. * Actions
  51. */
  52. if ($action == "save") {
  53. $i = 0;
  54. $db->begin();
  55. foreach ($eventstolog as $key => $arr) {
  56. $param = 'MAIN_LOGEVENTS_'.$arr['id'];
  57. if (GETPOST($param, 'alphanohtml')) {
  58. dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  59. } else {
  60. dolibarr_del_const($db, $param, $conf->entity);
  61. }
  62. }
  63. $db->commit();
  64. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  65. }
  66. /*
  67. * View
  68. */
  69. $form = new Form($db);
  70. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  71. $selectedfields = '';
  72. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  73. $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  74. llxHeader('', $langs->trans("Audit"), $wikihelp);
  75. //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  76. print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
  77. print '<span class="opacitymedium">'.$langs->trans("LogEventDesc", $langs->transnoentitiesnoconv("AdminTools"), $langs->transnoentitiesnoconv("Audit"))."</span><br>\n";
  78. print "<br>\n";
  79. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  80. print '<input type="hidden" name="token" value="'.newToken().'">';
  81. print '<input type="hidden" name="action" value="save">';
  82. $head = security_prepare_head();
  83. print dol_get_fiche_head($head, 'audit', '', -1);
  84. print '<br>';
  85. print '<table class="noborder centpercent">';
  86. print '<tr class="liste_titre">';
  87. print getTitleFieldOfList("TrackableSecurityEvents", 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, '')."\n";
  88. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  89. print '</tr>'."\n";
  90. // Loop on each event type
  91. foreach ($eventstolog as $key => $arr) {
  92. if ($arr['id']) {
  93. print '<tr class="oddeven">';
  94. print '<td>'.$arr['id'].'</td>';
  95. print '<td class="center">';
  96. $key = 'MAIN_LOGEVENTS_'.$arr['id'];
  97. $value = empty($conf->global->$key) ? '' : $conf->global->$key;
  98. print '<input class="oddeven checkforselect" type="checkbox" name="'.$key.'" value="1"'.($value ? ' checked' : '').'>';
  99. print '</td></tr>'."\n";
  100. }
  101. }
  102. print '</table>';
  103. print '<div class="center">';
  104. print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
  105. print '</div>';
  106. print dol_get_fiche_end();
  107. print "</form>\n";
  108. // End of page
  109. llxFooter();
  110. $db->close();