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