dolibarr 23.0.3
blockedlog.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
3 * Copyright (C) 2017-2018 Laurent Destailleur <eldy@destailleur.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
27// Load Dolibarr environment
28require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array('admin', 'blockedlog', 'other'));
43
44// Access Control
45if (!$user->admin || !isModEnabled('blockedlog')) {
47}
48
49// Get Parameters
50$action = GETPOST('action', 'aZ09');
51$backtopage = GETPOST('backtopage', 'alpha');
52$withtab = GETPOSTINT('withtab');
53
54
55/*
56 * Actions
57 */
58
59$reg = array();
60if (preg_match('/set_(.*)/', $action, $reg)) {
61 $code = $reg[1];
62 $values = GETPOST($code);
63 if (is_array($values)) {
64 $values = implode(',', $values);
65 }
66
67 if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
68 header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
69 exit;
70 } else {
71 dol_print_error($db);
72 }
73}
74
75if (preg_match('/del_(.*)/', $action, $reg)) {
76 $code = $reg[1];
77 if (dolibarr_del_const($db, $code, 0) > 0) {
78 header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
79 exit;
80 } else {
81 dol_print_error($db);
82 }
83}
84
85
86/*
87 * View
88 */
89
90$form = new Form($db);
91$block_static = new BlockedLog($db);
92$block_static->loadTrackedEvents();
93
94$title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
95$help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
96
97llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-blockedlog page-admin_blockedlog');
98
99$linkback = '';
100if ($withtab) {
101 $linkback = '<a href="'.dolBuildUrl($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
102}
103
104$morehtmlcenter = '';
105
106$registrationnumber = getHashUniqueIdOfRegistration();
107$texttop = '<small class="opacitymedium">'.$langs->trans("RegistrationNumber").':</small> <small>'.dol_trunc($registrationnumber, 10).'</small>';
108
109print load_fiche_titre($title.'<br>'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter);
110
111if ($withtab) {
112 $head = blockedlogadmin_prepare_head(GETPOST('withtab', 'alpha'));
113 print dol_get_fiche_head($head, 'blockedlog', '', -1);
114}
115
116//print $texttop;
117//print '<br><br>';
118
119print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
120
121if (in_array($mysoc->country_code, array('FR'))) {
122 $htmltext = $langs->trans("UnalterableLogTool1FR").'<br>';
123 print info_admin($htmltext, 0, 0, 'warning');
124}
125
126print '<br>';
127
128print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
129print '<table class="noborder centpercent">';
130print '<tr class="liste_titre">';
131print '<td>'.$langs->trans("Key").'</td>';
132print '<td>'.$langs->trans("Value").'</td>';
133print "</tr>\n";
134
135print '<tr class="oddeven">';
136print '<td class="titlefield">';
137print $langs->trans("CompanyInitialKey").'</td><td>';
138print $block_static->getOrInitFirstSignature();
139print '</td></tr>';
140
141/*
142if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY')) {
143 // Example with a yes / no select
144 print '<tr class="oddeven">';
145 print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
146 print '<td class="right" width="300">';
147
148 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
149 print '<input type="hidden" name="token" value="'.newToken().'">';
150 print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
151 print '<input type="hidden" name="withtab" value="'.$withtab.'">';
152 print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="' . getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL').'" size="40" />';
153 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
154 print '</form>';
155
156 print '</td></tr>';
157}
158*/
159
160
161// Show the input of countries not allowed for disabling
162print '<tr class="oddeven">';
163print '<td>';
164print $form->textwithpicto($langs->transnoentitiesnoconv("BlockedLogDisableNotAllowedForCountry"), $langs->transnoentitiesnoconv("BlockedLogDisableNotAllowedForCountry2"));
165print '</td>';
166print '<td>';
167
168print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
169print '<input type="hidden" name="token" value="'.newToken().'">';
170print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
171print '<input type="hidden" name="withtab" value="'.$withtab.'">';
172
173$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
174$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
175$sql .= " WHERE active > 0";
176
177$countryArray = array();
178$resql = $db->query($sql);
179if ($resql) {
180 while ($obj = $db->fetch_object($resql)) {
181 $countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
182 }
183}
184
185$selected = !getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY') ? array() : explode(',', getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY'));
186
187// Can module be disabled
188$canbedisabled = $block_static->canBeDisabled();
189
190print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $selected, 0, 0, '', 0, 0, $canbedisabled ? '' : 'disabled');
191print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"'.($canbedisabled ? '' : ' disabled').'>';
192print '</form>';
193
194print '</td>';
195
196
197print '<tr class="oddeven">';
198print '<td class="titlefield">';
199print $langs->trans("ListOfTrackedEvents").'</td><td>';
200$arrayoftrackedevents = $block_static->trackedevents;
201foreach ($arrayoftrackedevents as $key => $val) {
202 if (preg_match('/^separator/i', $key)) {
203 continue;
204 }
205 print $key.' - ';
206 if (is_array($val)) {
207 print $langs->trans($val['labelhtml']).'<br>';
208 } else {
209 print $langs->trans($val).'<br>';
210 }
211}
212
213print '</td></tr>';
214
215print '</tr>';
216
217print '</table>';
218print '</div>';
219
220if ($withtab) {
221 print dol_get_fiche_end();
222}
223
224print '<br><br>';
225
226// End of page
227llxFooter();
228$db->close();
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
getHashUniqueIdOfRegistration()
Return a hash unique identifier of the registration.
blockedlogadmin_prepare_head($withtabsetup)
Define head array for tabs of blockedlog tools setup pages.
Class to manage Blocked Log.
Class to manage generation of HTML components Only common components must be here.
global $mysoc
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.