dolibarr  20.0.0-beta
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 
26 // Load Dolibarr environment
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('admin', 'blockedlog', 'other'));
34 
35 // Access Control
36 if (!$user->admin || empty($conf->blockedlog->enabled)) {
38 }
39 
40 // Get Parameters
41 $action = GETPOST('action', 'aZ09');
42 $backtopage = GETPOST('backtopage', 'alpha');
43 $withtab = GETPOSTINT('withtab');
44 
45 
46 /*
47  * Actions
48  */
49 
50 $reg = array();
51 if (preg_match('/set_(.*)/', $action, $reg)) {
52  $code = $reg[1];
53  $values = GETPOST($code);
54  if (is_array($values)) {
55  $values = implode(',', $values);
56  }
57 
58  if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
59  header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
60  exit;
61  } else {
62  dol_print_error($db);
63  }
64 }
65 
66 if (preg_match('/del_(.*)/', $action, $reg)) {
67  $code = $reg[1];
68  if (dolibarr_del_const($db, $code, 0) > 0) {
69  header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
70  exit;
71  } else {
72  dol_print_error($db);
73  }
74 }
75 
76 
77 /*
78  * View
79  */
80 
81 $form = new Form($db);
82 $block_static = new BlockedLog($db);
83 $block_static->loadTrackedEvents();
84 
85 $title = $langs->trans("BlockedLogSetup");
86 $help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
87 
88 llxHeader('', $title, $help_url);
89 
90 $linkback = '';
91 if ($withtab) {
92  $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
93 }
94 
95 print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback);
96 
97 if ($withtab) {
99  print dol_get_fiche_head($head, 'blockedlog', '', -1);
100 }
101 
102 
103 print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
104 
105 print '<br>';
106 
107 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
108 print '<table class="noborder centpercent">';
109 print '<tr class="liste_titre">';
110 print '<td>'.$langs->trans("Key").'</td>';
111 print '<td>'.$langs->trans("Value").'</td>';
112 print "</tr>\n";
113 
114 print '<tr class="oddeven">';
115 print '<td class="titlefield">';
116 print $langs->trans("CompanyInitialKey").'</td><td>';
117 print $block_static->getSignature();
118 print '</td></tr>';
119 
120 if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY')) {
121  // Example with a yes / no select
122  print '<tr class="oddeven">';
123  print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
124  print '<td class="right" width="300">';
125 
126  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
127  print '<input type="hidden" name="token" value="'.newToken().'">';
128  print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
129  print '<input type="hidden" name="withtab" value="'.$withtab.'">';
130  print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="' . getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL').'" size="40" />';
131  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
132  print '</form>';
133 
134  print '</td></tr>';
135 }
136 
137 print '<tr class="oddeven">';
138 print '<td>'.$langs->trans("BlockedLogDisableNotAllowedForCountry").'</td>';
139 print '<td>';
140 
141 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
142 print '<input type="hidden" name="token" value="'.newToken().'">';
143 print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
144 print '<input type="hidden" name="withtab" value="'.$withtab.'">';
145 
146 $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
147 $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
148 $sql .= " WHERE active > 0";
149 
150 $countryArray = array();
151 $resql = $db->query($sql);
152 if ($resql) {
153  while ($obj = $db->fetch_object($resql)) {
154  $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 : ''));
155  }
156 }
157 
158 $selected = !getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY') ? array() : explode(',', getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY'));
159 
160 print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $selected);
161 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
162 print '</form>';
163 
164 print '</td>';
165 
166 
167 print '<tr class="oddeven">';
168 print '<td class="titlefield">';
169 print $langs->trans("ListOfTrackedEvents").'</td><td>';
170 $arrayoftrackedevents = $block_static->trackedevents;
171 foreach ($arrayoftrackedevents as $key => $val) {
172  print $key.' - '.$langs->trans($val).'<br>';
173 }
174 
175 print '</td></tr>';
176 
177 print '</tr>';
178 
179 print '</table>';
180 print '</div>';
181 
182 if ($withtab) {
183  print dol_get_fiche_end();
184 }
185 
186 print '<br><br>';
187 
188 // End of page
189 llxFooter();
190 $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).
Definition: admin.lib.php:656
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:580
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
blockedlogadmin_prepare_head()
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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
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.
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...
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.