events.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. $langs->load("users");
  30. $langs->load("admin");
  31. $langs->load("other");
  32. $action=GETPOST('action','aZ09');
  33. $securityevent=new Events($db);
  34. $eventstolog=$securityevent->eventstolog;
  35. /*
  36. * Actions
  37. */
  38. if ($action == "save")
  39. {
  40. $i=0;
  41. $db->begin();
  42. foreach ($eventstolog as $key => $arr)
  43. {
  44. $param='MAIN_LOGEVENTS_'.$arr['id'];
  45. //print "param=".$param." - ".$_POST[$param];
  46. if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0,'',$conf->entity);
  47. else dolibarr_del_const($db,$param,$conf->entity);
  48. }
  49. $db->commit();
  50. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  51. }
  52. /*
  53. * View
  54. */
  55. $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  56. llxHeader('',$langs->trans("Audit"),$wikihelp);
  57. //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  58. print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
  59. print $langs->trans("LogEventDesc")."<br>\n";
  60. print "<br>\n";
  61. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  62. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  63. print '<input type="hidden" name="action" value="save">';
  64. $head=security_prepare_head();
  65. dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
  66. $var=true;
  67. print "<table class=\"noborder\" width=\"100%\">";
  68. print "<tr class=\"liste_titre\">";
  69. print "<td colspan=\"2\">".$langs->trans("LogEvents")."</td>";
  70. print "</tr>\n";
  71. // Loop on each event type
  72. foreach ($eventstolog as $key => $arr)
  73. {
  74. if ($arr['id'])
  75. {
  76. print '<tr class="oddeven">';
  77. print '<td>'.$arr['id'].'</td>';
  78. print '<td>';
  79. $key='MAIN_LOGEVENTS_'.$arr['id'];
  80. $value=$conf->global->$key;
  81. print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value?' checked':'').'>';
  82. print '</td></tr>'."\n";
  83. }
  84. }
  85. print '</table>';
  86. dol_fiche_end();
  87. print '<div class="center">';
  88. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  89. print "</div>";
  90. print "</form>\n";
  91. llxFooter();
  92. $db->close();