events.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/events.php
  19. * \ingroup core
  20. * \brief Log event setup page
  21. */
  22. require("../main.inc.php");
  23. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  24. require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/class/events.class.php");
  26. if (!$user->admin)
  27. accessforbidden();
  28. $langs->load("users");
  29. $langs->load("admin");
  30. $langs->load("other");
  31. $action=GETPOST("action");
  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. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  50. }
  51. /*
  52. * View
  53. */
  54. llxHeader('',$langs->trans("Audit"));
  55. //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  56. print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
  57. print $langs->trans("LogEventDesc")."<br>\n";
  58. print "<br>\n";
  59. $head=security_prepare_head();
  60. dol_fiche_head($head, 'audit', $langs->trans("Security"));
  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. $var=true;
  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. $var=!$var;
  75. print '<tr '.$bc[$var].'>';
  76. print '<td>'.$arr['id'].'</td>';
  77. print '<td>';
  78. $key='MAIN_LOGEVENTS_'.$arr['id'];
  79. $value=$conf->global->$key;
  80. print '<input '.$bc[$var].' type="checkbox" name="'.$key.'" value="1"'.($value?' checked="true"':'').'>';
  81. print '</td></tr>'."\n";
  82. }
  83. }
  84. print '</table>';
  85. print '<br><center>';
  86. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  87. print "</center>";
  88. print "</form>\n";
  89. print '</div>';
  90. dol_htmloutput_mesg($mesg);
  91. $db->close();
  92. llxFooter();
  93. ?>