dolibarr  16.0.5
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  *
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.'/blockedlog/lib/blockedlog.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 
30 // Load translation files required by the page
31 $langs->loadLangs(array("admin", "other", "blockedlog"));
32 
33 if (!$user->admin || empty($conf->blockedlog->enabled)) {
35 }
36 
37 $action = GETPOST('action', 'aZ09');
38 $backtopage = GETPOST('backtopage', 'alpha');
39 
40 $withtab = GETPOST('withtab', 'int');
41 
42 
43 /*
44  * Actions
45  */
46 
47 $reg = array();
48 if (preg_match('/set_(.*)/', $action, $reg)) {
49  $code = $reg[1];
50  $values = GETPOST($code);
51  if (is_array($values)) {
52  $values = implode(',', $values);
53  }
54 
55  if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
56  header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
57  exit;
58  } else {
59  dol_print_error($db);
60  }
61 }
62 
63 if (preg_match('/del_(.*)/', $action, $reg)) {
64  $code = $reg[1];
65  if (dolibarr_del_const($db, $code, 0) > 0) {
66  Header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
67  exit;
68  } else {
69  dol_print_error($db);
70  }
71 }
72 
73 
74 /*
75  * View
76  */
77 
78 $form = new Form($db);
79 $block_static = new BlockedLog($db);
80 $block_static->loadTrackedEvents();
81 
82 $title = $langs->trans("BlockedLogSetup");
83 $help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
84 
85 llxHeader('', $title, $help_url);
86 
87 $linkback = '';
88 if ($withtab) {
89  $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
90 }
91 
92 print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback);
93 
94 if ($withtab) {
96  print dol_get_fiche_head($head, 'blockedlog', '', -1);
97 }
98 
99 
100 print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
101 
102 print '<br>';
103 
104 print '<table class="noborder centpercent">';
105 print '<tr class="liste_titre">';
106 print '<td>'.$langs->trans("Key").'</td>';
107 print '<td>'.$langs->trans("Value").'</td>';
108 print "</tr>\n";
109 
110 print '<tr class="oddeven">';
111 print '<td class="titlefield">';
112 print $langs->trans("CompanyInitialKey").'</td><td>';
113 print $block_static->getSignature();
114 print '</td></tr>';
115 
116 if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
117  // Example with a yes / no select
118  print '<tr class="oddeven">';
119  print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
120  print '<td class="right" width="300">';
121 
122  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
123  print '<input type="hidden" name="token" value="'.newToken().'">';
124  print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
125  print '<input type="hidden" name="withtab" value="'.$withtab.'">';
126  print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="'.$conf->global->BLOCKEDLOG_AUTHORITY_URL.'" size="40" />';
127  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
128  print '</form>';
129 
130  print '</td></tr>';
131 }
132 
133 print '<tr class="oddeven">';
134 print '<td>'.$langs->trans("BlockedLogDisableNotAllowedForCountry").'</td>';
135 print '<td>';
136 
137 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
138 print '<input type="hidden" name="token" value="'.newToken().'">';
139 print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
140 print '<input type="hidden" name="withtab" value="'.$withtab.'">';
141 
142 $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
143 $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
144 $sql .= " WHERE active > 0";
145 
146 $countryArray = array();
147 $resql = $db->query($sql);
148 if ($resql) {
149  while ($obj = $db->fetch_object($resql)) {
150  $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 : ''));
151  }
152 }
153 
154 $seledted = empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) ? array() : explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);
155 
156 print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted);
157 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
158 print '</form>';
159 
160 print '</td>';
161 
162 
163 print '<tr class="oddeven">';
164 print '<td class="titlefield">';
165 print $langs->trans("ListOfTrackedEvents").'</td><td>';
166 $arrayoftrackedevents = $block_static->trackedevents;
167 foreach ($arrayoftrackedevents as $key => $val) {
168  print $key.' - '.$langs->trans($val).'<br>';
169 }
170 
171 print '</td></tr>';
172 
173 print '</tr>';
174 
175 print '</table>';
176 
177 if ($withtab) {
178  print dol_get_fiche_end();
179 }
180 
181 print '<br><br>';
182 
183 // End of page
184 llxFooter();
185 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
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
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
blockedlogadmin_prepare_head
blockedlogadmin_prepare_head()
Define head array for tabs of blockedlog tools setup pages.
Definition: blockedlog.lib.php:29
BlockedLog
Class to manage Blocked Log.
Definition: blockedlog.class.php:26
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
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
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