dolibarr  9.0.0
user.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7  * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('admin', 'members', 'users'));
37 if (! $user->admin) accessforbidden();
38 
39 $extrafields = new ExtraFields($db);
40 
41 $action = GETPOST('action','alpha');
42 $backtopage = GETPOST('backtopage', 'alpha');
43 
44 $value = GETPOST('value','alpha');
45 $type='user';
46 
47 
48 /*
49  * Action
50  */
51 
52 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53 
54 if ($action == 'set_default')
55 {
56  $ret = addDocumentModel($value, $type, $label, $scandir);
57  $res = true;
58 }
59 
60 elseif ($action == 'del_default')
61 {
62  $ret = delDocumentModel($value, $type);
63  if ($ret > 0)
64  {
65  if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT',$conf->entity);
66  }
67  $res = true;
68 }
69 
70 // Set default model
71 elseif ($action == 'setdoc')
72 {
73  if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT",$value,'chaine',0,'',$conf->entity))
74  {
75  // La constante qui a ete lue en avant du nouveau set
76  // on passe donc par une variable pour avoir un affichage coherent
77  $conf->global->USER_ADDON_PDF_ODT = $value;
78  }
79 
80  // On active le modele
81  $ret = delDocumentModel($value, $type);
82  if ($ret > 0)
83  {
84  $ret = addDocumentModel($value, $type, $label, $scandir);
85  }
86  $res = true;
87 }
88 elseif (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
89 {
90  $code=$reg[1];
91  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
92  {
93  header("Location: ".$_SERVER["PHP_SELF"]);
94  exit;
95  }
96  else
97  {
98  dol_print_error($db);
99  }
100 }
101 
102 elseif (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
103 {
104  $code=$reg[1];
105  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
106  {
107  header("Location: ".$_SERVER["PHP_SELF"]);
108  exit;
109  }
110  else
111  {
112  dol_print_error($db);
113  }
114 }
115 //Set hide closed customer into combox or select
116 elseif ($action == 'sethideinactiveuser')
117 {
118  $status = GETPOST('status','alpha');
119 
120  if (dolibarr_set_const($db, "USER_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0)
121  {
122  header("Location: ".$_SERVER["PHP_SELF"]);
123  exit;
124  }
125  else
126  {
127  dol_print_error($db);
128  }
129 }
130 
131 /*
132  * View
133  */
134 
135 $form = new Form($db);
136 
137 $help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
138 llxHeader('',$langs->trans("UsersSetup"),$help_url);
139 
140 $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
141 print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup');
142 
143 
145 
146 dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), -1, 'user');
147 
148 print '<table class="noborder" width="100%">';
149 print '<tr class="liste_titre">';
150 print '<td>'.$langs->trans("Description").'</td>';
151 print '<td align="center" width="20">&nbsp;</td>';
152 print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
153 print '</tr>';
154 
155 
156 // Mail required for members
157 
158 print '<tr class="oddeven">';
159 print '<td>'.$langs->trans("UserMailRequired").'</td>';
160 print '<td align="center" width="20">&nbsp;</td>';
161 
162 print '<td align="center" width="100">';
163 if ($conf->use_javascript_ajax)
164 {
165  print ajax_constantonoff('USER_MAIL_REQUIRED');
166 }
167 else
168 {
169  if (empty($conf->global->USER_MAIL_REQUIRED))
170  {
171  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_USER_MAIL_REQUIRED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
172  }
173  else
174  {
175  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_USER_MAIL_REQUIRED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
176  }
177 }
178 print '</td></tr>';
179 
180 print '</table>';
181 
182 print '<br>';
183 
184 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
185 
186 $form=new Form($db);
187 
188 // Defini tableau def des modeles
189 $def = array();
190 $sql = "SELECT nom";
191 $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
192 $sql.= " WHERE type = '".$type."'";
193 $sql.= " AND entity = ".$conf->entity;
194 $resql=$db->query($sql);
195 if ($resql)
196 {
197  $i = 0;
198  $num_rows=$db->num_rows($resql);
199  while ($i < $num_rows)
200  {
201  $array = $db->fetch_array($resql);
202  array_push($def, $array[0]);
203  $i++;
204  }
205 }
206 else
207 {
208  dol_print_error($db);
209 }
210 
211 print '<table class="noborder" width="100%">';
212 print '<tr class="liste_titre">';
213 print '<td>'.$langs->trans("Name").'</td>';
214 print '<td>'.$langs->trans("Description").'</td>';
215 print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
216 print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
217 print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
218 print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
219 print "</tr>\n";
220 
221 clearstatcache();
222 
223 foreach ($dirmodels as $reldir)
224 {
225  foreach (array('','/doc') as $valdir)
226  {
227  $dir = dol_buildpath($reldir."core/modules/user".$valdir);
228  if (is_dir($dir))
229  {
230  $handle=opendir($dir);
231  if (is_resource($handle))
232  {
233  while (($file = readdir($handle))!==false)
234  {
235  $filelist[]=$file;
236  }
237  closedir($handle);
238  arsort($filelist);
239 
240  foreach($filelist as $file)
241  {
242  if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
243  {
244 
245  if (file_exists($dir.'/'.$file))
246  {
247  $name = substr($file, 4, dol_strlen($file) -16);
248  $classname = substr($file, 0, dol_strlen($file) -12);
249 
250  require_once $dir.'/'.$file;
251  $module = new $classname($db);
252 
253  $modulequalified=1;
254  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
255  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
256 
257  if ($modulequalified)
258  {
259  print '<tr class="oddeven"><td width="100">';
260  print (empty($module->name)?$name:$module->name);
261  print "</td><td>\n";
262  if (method_exists($module,'info')) print $module->info($langs);
263  else print $module->description;
264  print '</td>';
265 
266  // Active
267  if (in_array($name, $def))
268  {
269  print '<td align="center">'."\n";
270  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
271  print img_picto($langs->trans("Enabled"),'switch_on');
272  print '</a>';
273  print '</td>';
274  }
275  else
276  {
277  print '<td align="center">'."\n";
278  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
279  print "</td>";
280  }
281 
282  // Defaut
283  print '<td align="center">';
284  if ($conf->global->USER_ADDON_PDF == $name)
285  {
286  print img_picto($langs->trans("Default"),'on');
287  }
288  else
289  {
290  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
291  }
292  print '</td>';
293 
294  // Info
295  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
296  $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
297  if ($module->type == 'pdf')
298  {
299  $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
300  }
301  $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
302  $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
303  $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
304  $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
305  $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
306  $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
307 
308 
309  print '<td align="center">';
310  print $form->textwithpicto('',$htmltooltip,1,0);
311  print '</td>';
312 
313  // Preview
314  print '<td align="center">';
315  if ($module->type == 'pdf')
316  {
317  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
318  }
319  else
320  {
321  print img_object($langs->trans("PreviewNotAvailable"),'generic');
322  }
323  print '</td>';
324 
325  print "</tr>\n";
326  }
327  }
328  }
329  }
330  }
331  }
332  }
333 }
334 
335 print '</table>';
336 print "<br>";
337 
338 dol_fiche_end();
339 
340 // End of page
341 llxFooter();
342 $db->close();
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1643
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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:1053
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:510
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1609
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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 standard extra fields.
Class to manage generation of HTML components Only common components must be here.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:435
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
On/off button for constant.
Definition: ajax.lib.php:484
user_admin_prepare_head()
Prepare array with list of tabs.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)