events.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/events.php
  20. * \ingroup core
  21. * \brief Log event setup page
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
  27. if (!$user->admin)
  28. accessforbidden();
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("users","admin","other"));
  31. $action=GETPOST('action','aZ09');
  32. $securityevent=new Events($db);
  33. $eventstolog=$securityevent->eventstolog;
  34. /*
  35. * Actions
  36. */
  37. if ($action == "save")
  38. {
  39. $i=0;
  40. $db->begin();
  41. foreach ($eventstolog as $key => $arr)
  42. {
  43. $param='MAIN_LOGEVENTS_'.$arr['id'];
  44. //print "param=".$param." - ".$_POST[$param];
  45. if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0,'',$conf->entity);
  46. else dolibarr_del_const($db,$param,$conf->entity);
  47. }
  48. $db->commit();
  49. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  50. }
  51. /*
  52. * View
  53. */
  54. $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  55. llxHeader('',$langs->trans("Audit"),$wikihelp);
  56. //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  57. print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
  58. print $langs->trans("LogEventDesc", $langs->transnoentitiesnoconv("AdminTools"), $langs->transnoentitiesnoconv("Audit"))."<br>\n";
  59. print "<br>\n";
  60. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  61. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  62. print '<input type="hidden" name="action" value="save">';
  63. $head=security_prepare_head();
  64. dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
  65. print "<table class=\"noborder\" width=\"100%\">";
  66. print "<tr class=\"liste_titre\">";
  67. print "<td colspan=\"2\">".$langs->trans("LogEvents")."</td>";
  68. print "</tr>\n";
  69. // Loop on each event type
  70. foreach ($eventstolog as $key => $arr)
  71. {
  72. if ($arr['id'])
  73. {
  74. print '<tr class="oddeven">';
  75. print '<td>'.$arr['id'].'</td>';
  76. print '<td>';
  77. $key='MAIN_LOGEVENTS_'.$arr['id'];
  78. $value=$conf->global->$key;
  79. print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value?' checked':'').'>';
  80. print '</td></tr>'."\n";
  81. }
  82. }
  83. print '</table>';
  84. dol_fiche_end();
  85. print '<div class="center">';
  86. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  87. print "</div>";
  88. print "</form>\n";
  89. // End of page
  90. llxFooter();
  91. $db->close();