dolibarr  16.0.5
events.php
Go to the documentation of this file.
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 
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
29 
30 
31 if (!$user->admin) {
33 }
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array("users", "admin", "other"));
37 
38 $action = GETPOST('action', 'aZ09');
39 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'auditeventslist'; // To manage different context of search
40 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
41 
42 // Load variable for pagination
43 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
44 $sortfield = GETPOST('sortfield', 'aZ09comma');
45 $sortorder = GETPOST('sortorder', 'aZ09comma');
46 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
47 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
48  $page = 0;
49 } // If $page is not defined, or '' or -1 or if we click on clear filters
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 
54 $securityevent = new Events($db);
55 $eventstolog = $securityevent->eventstolog;
56 
57 
58 /*
59  * Actions
60  */
61 
62 if ($action == "save") {
63  $i = 0;
64 
65  $db->begin();
66 
67  foreach ($eventstolog as $key => $arr) {
68  $param = 'MAIN_LOGEVENTS_'.$arr['id'];
69  if (GETPOST($param, 'alphanohtml')) {
70  dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity);
71  } else {
72  dolibarr_del_const($db, $param, $conf->entity);
73  }
74  }
75 
76  $db->commit();
77  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
78 }
79 
80 
81 
82 /*
83  * View
84  */
85 
86 $form = new Form($db);
87 
88 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
89 $selectedfields = '';
90 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
91 
92 $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
93 llxHeader('', $langs->trans("Audit"), $wikihelp);
94 
95 //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
96 print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
97 
98 print '<span class="opacitymedium">'.$langs->trans("LogEventDesc", $langs->transnoentitiesnoconv("AdminTools"), $langs->transnoentitiesnoconv("Audit"))."</span><br>\n";
99 print "<br>\n";
100 
101 
102 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
103 print '<input type="hidden" name="token" value="'.newToken().'">';
104 print '<input type="hidden" name="action" value="save">';
105 
106 $head = security_prepare_head();
107 
108 print dol_get_fiche_head($head, 'audit', '', -1);
109 
110 print '<br>';
111 
112 print '<table class="noborder" width="100%">';
113 print "<tr class=\"liste_titre\">";
114 print getTitleFieldOfList("LogEvents", 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, '')."\n";
115 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
116 print "</tr>\n";
117 // Loop on each event type
118 foreach ($eventstolog as $key => $arr) {
119  if ($arr['id']) {
120  print '<tr class="oddeven">';
121  print '<td>'.$arr['id'].'</td>';
122  print '<td class="center">';
123  $key = 'MAIN_LOGEVENTS_'.$arr['id'];
124  $value = empty($conf->global->$key) ? '' : $conf->global->$key;
125  print '<input class="oddeven checkforselect" type="checkbox" name="'.$key.'" value="1"'.($value ? ' checked' : '').'>';
126  print '</td></tr>'."\n";
127  }
128 }
129 print '</table>';
130 
131 print dol_get_fiche_end();
132 
133 print '<div class="center">';
134 print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
135 print '</div>';
136 
137 print "</form>\n";
138 
139 // End of page
140 llxFooter();
141 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
security_prepare_head
security_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:772
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5049
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Events
Events class.
Definition: events.class.php:29
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8136
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59