dolibarr  7.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 <http://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 $langs->loadLangs(array("admin","other","blockedlog"));
31 
32 if (! $user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
33 
34 $action = GETPOST('action','alpha');
35 $backtopage = GETPOST('backtopage', 'alpha');
36 
37 
38 /*
39  * Actions
40  */
41 
42 if (preg_match('/set_(.*)/',$action,$reg))
43 {
44  $code=$reg[1];
45  $values = GETPOST($code);
46  if(is_array($values))$values = implode(',', $values);
47 
48  if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0)
49  {
50  header("Location: ".$_SERVER["PHP_SELF"]);
51  exit;
52  }
53  else
54  {
55  dol_print_error($db);
56  }
57 }
58 
59 if (preg_match('/del_(.*)/',$action,$reg))
60 {
61  $code=$reg[1];
62  if (dolibarr_del_const($db, $code, 0) > 0)
63  {
64  Header("Location: ".$_SERVER["PHP_SELF"]);
65  exit;
66  }
67  else
68  {
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 
81 llxHeader('',$langs->trans("BlockedLogSetup"));
82 
83 $linkback='';
84 if (GETPOST('withtab','alpha'))
85 {
86  $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
87 }
88 
89 print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback);
90 
91 if (GETPOST('withtab','alpha'))
92 {
94  dol_fiche_head($head, 'blockedlog', '', -1);
95 }
96 
97 
98 print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
99 
100 print '<br>';
101 
102 print '<table class="noborder" width="100%">';
103 print '<tr class="liste_titre">';
104 print '<td>'.$langs->trans("Key").'</td>';
105 print '<td>'.$langs->trans("Value").'</td>';
106 print "</tr>\n";
107 
108 print '<tr class="oddeven">';
109 print '<td class="titlefield">';
110 print $langs->trans("CompanyInitialKey").'</td><td>';
111 print $block_static->getSignature();
112 print '</td></tr>';
113 
114 if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
115  // Example with a yes / no select
116  print '<tr class="oddeven">';
117  print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
118  print '<td align="right" width="300">';
119  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
120  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
121  print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
122  print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="'.$conf->global->BLOCKEDLOG_AUTHORITY_URL.'" size="40" />';
123  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
124  print '</form>';
125  print '</td></tr>';
126 }
127 
128 print '<tr class="oddeven">';
129 print '<td>'.$langs->trans("BlockedLogDisableNotAllowedForCountry").'</td>';
130 print '<td>';
131 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
132 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
133 print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
134 
135 $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
136 $sql.= " FROM ".MAIN_DB_PREFIX."c_country";
137 $sql.= " WHERE active > 0";
138 
139 $countryArray=array();
140 $resql=$db->query($sql);
141 if ($resql)
142 {
143  while ($obj = $db->fetch_object($resql))
144  {
145  $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:''));
146  }
147 }
148 
149 $seledted = empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) ? array() : explode(',',$conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);
150 
151 print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted);
152 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
153 print '</form>';
154 
155 print '</td>';
156 
157 
158 print '<tr class="oddeven">';
159 print '<td class="titlefield">';
160 print $langs->trans("ListOfTrackedEvents").'</td><td>';
161 $arrayoftrackedevents=$block_static->trackedevents;
162 foreach($arrayoftrackedevents as $key => $val)
163 {
164  print $key.' - '.$langs->trans($val).'<br>';
165 }
166 
167 print '</td></tr>';
168 
169 print '</tr>';
170 
171 print '</table>';
172 
173 if (GETPOST('withtab','alpha'))
174 {
175  dol_fiche_end();
176 }
177 
178 print '<br><br>';
179 
180 llxFooter();
181 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:485
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
blockedlogadmin_prepare_head()
Define head array for tabs of blockedlog tools setup pages.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
Definition: admin.lib.php:410
dol_fiche_end($notab=0)
Show tab footer of a card.
Class to manage Blocked Log.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013