dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("admin");
36 $langs->load("members");
37 $langs->load("users");
38 if (! $user->admin) accessforbidden();
39 
40 $extrafields = new ExtraFields($db);
41 
42 $action = GETPOST('action','alpha');
43 $backtopage = GETPOST('backtopage', 'alpha');
44 
45 $value = GETPOST('value','alpha');
46 $type='user';
47 
48 
49 /*
50  * Action
51  */
52 
53 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
54 
55 if ($action == 'set_default')
56 {
57  $ret = addDocumentModel($value, $type, $label, $scandir);
58  $res = true;
59 }
60 
61 elseif ($action == 'del_default')
62 {
63  $ret = delDocumentModel($value, $type);
64  if ($ret > 0)
65  {
66  if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT',$conf->entity);
67  }
68  $res = true;
69 }
70 
71 // Set default model
72 elseif ($action == 'setdoc')
73 {
74  if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT",$value,'chaine',0,'',$conf->entity))
75  {
76  // La constante qui a ete lue en avant du nouveau set
77  // on passe donc par une variable pour avoir un affichage coherent
78  $conf->global->USER_ADDON_PDF_ODT = $value;
79  }
80 
81  // On active le modele
82  $ret = delDocumentModel($value, $type);
83  if ($ret > 0)
84  {
85  $ret = addDocumentModel($value, $type, $label, $scandir);
86  }
87  $res = true;
88 }
89 elseif (preg_match('/set_(.*)/',$action,$reg))
90 {
91  $code=$reg[1];
92  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
93  {
94  header("Location: ".$_SERVER["PHP_SELF"]);
95  exit;
96  }
97  else
98  {
99  dol_print_error($db);
100  }
101 }
102 
103 elseif (preg_match('/del_(.*)/',$action,$reg))
104 {
105  $code=$reg[1];
106  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
107  {
108  header("Location: ".$_SERVER["PHP_SELF"]);
109  exit;
110  }
111  else
112  {
113  dol_print_error($db);
114  }
115 }
116 //Set hide closed customer into combox or select
117 elseif ($action == 'sethideinactiveuser')
118 {
119  $status = GETPOST('status','alpha');
120 
121  if (dolibarr_set_const($db, "USER_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0)
122  {
123  header("Location: ".$_SERVER["PHP_SELF"]);
124  exit;
125  }
126  else
127  {
128  dol_print_error($db);
129  }
130 }
131 
132 /*
133  * View
134  */
135 
136 $form = new Form($db);
137 
138 $help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
139 llxHeader('',$langs->trans("UsersSetup"),$help_url);
140 
141 $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
142 print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup');
143 
144 
146 
147 dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), -1, 'user');
148 
149 print '<table class="noborder" width="100%">';
150 print '<tr class="liste_titre">';
151 print '<td>'.$langs->trans("Description").'</td>';
152 print '<td align="center" width="20">&nbsp;</td>';
153 print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
154 print '</tr>';
155 
156 
157 // Mail required for members
158 
159 print '<tr class="oddeven">';
160 print '<td>'.$langs->trans("UserMailRequired").'</td>';
161 print '<td align="center" width="20">&nbsp;</td>';
162 
163 print '<td align="center" width="100">';
164 if ($conf->use_javascript_ajax)
165 {
166  print ajax_constantonoff('USER_MAIL_REQUIRED');
167 }
168 else
169 {
170  if (empty($conf->global->USER_MAIL_REQUIRED))
171  {
172  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_USER_MAIL_REQUIRED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
173  }
174  else
175  {
176  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_USER_MAIL_REQUIRED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
177  }
178 }
179 print '</td></tr>';
180 
181 print '</table>';
182 
183 print '<br>';
184 
185 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
186 
187 $form=new Form($db);
188 
189 // Defini tableau def des modeles
190 $def = array();
191 $sql = "SELECT nom";
192 $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
193 $sql.= " WHERE type = '".$type."'";
194 $sql.= " AND entity = ".$conf->entity;
195 $resql=$db->query($sql);
196 if ($resql)
197 {
198  $i = 0;
199  $num_rows=$db->num_rows($resql);
200  while ($i < $num_rows)
201  {
202  $array = $db->fetch_array($resql);
203  array_push($def, $array[0]);
204  $i++;
205  }
206 }
207 else
208 {
209  dol_print_error($db);
210 }
211 
212 print '<table class="noborder" width="100%">';
213 print '<tr class="liste_titre">';
214 print '<td>'.$langs->trans("Name").'</td>';
215 print '<td>'.$langs->trans("Description").'</td>';
216 print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
217 print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
218 print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
219 print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
220 print "</tr>\n";
221 
222 clearstatcache();
223 
224 foreach ($dirmodels as $reldir)
225 {
226  foreach (array('','/doc') as $valdir)
227  {
228  $dir = dol_buildpath($reldir."core/modules/user".$valdir);
229  if (is_dir($dir))
230  {
231  $handle=opendir($dir);
232  if (is_resource($handle))
233  {
234  while (($file = readdir($handle))!==false)
235  {
236  $filelist[]=$file;
237  }
238  closedir($handle);
239  arsort($filelist);
240 
241  foreach($filelist as $file)
242  {
243  if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
244  {
245 
246  if (file_exists($dir.'/'.$file))
247  {
248  $name = substr($file, 4, dol_strlen($file) -16);
249  $classname = substr($file, 0, dol_strlen($file) -12);
250 
251  require_once $dir.'/'.$file;
252  $module = new $classname($db);
253 
254  $modulequalified=1;
255  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
256  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
257 
258  if ($modulequalified)
259  {
260  print '<tr class="oddeven"><td width="100">';
261  print (empty($module->name)?$name:$module->name);
262  print "</td><td>\n";
263  if (method_exists($module,'info')) print $module->info($langs);
264  else print $module->description;
265  print '</td>';
266 
267  // Active
268  if (in_array($name, $def))
269  {
270  print '<td align="center">'."\n";
271  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
272  print img_picto($langs->trans("Enabled"),'switch_on');
273  print '</a>';
274  print '</td>';
275  }
276  else
277  {
278  print '<td align="center">'."\n";
279  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>';
280  print "</td>";
281  }
282 
283  // Defaut
284  print '<td align="center">';
285  if ($conf->global->USER_ADDON_PDF == $name)
286  {
287  print img_picto($langs->trans("Default"),'on');
288  }
289  else
290  {
291  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>';
292  }
293  print '</td>';
294 
295  // Info
296  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
297  $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
298  if ($module->type == 'pdf')
299  {
300  $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
301  }
302  $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
303  $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
304  $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
305  $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
306  $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
307  $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
308 
309 
310  print '<td align="center">';
311  print $form->textwithpicto('',$htmltooltip,1,0);
312  print '</td>';
313 
314  // Preview
315  print '<td align="center">';
316  if ($module->type == 'pdf')
317  {
318  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
319  }
320  else
321  {
322  print img_object($langs->trans("PreviewNotAvailable"),'generic');
323  }
324  print '</td>';
325 
326  print "</tr>\n";
327  }
328  }
329  }
330  }
331  }
332  }
333  }
334 }
335 
336 print '</table>';
337 print "<br>";
338 
339 dol_fiche_end();
340 
341 llxFooter();
342 $db->close();
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1540
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1506
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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 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'une constante dans la base de donnees.
Definition: admin.lib.php:410
dol_fiche_end($notab=0)
Show tab footer of a card.
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
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print
Draft customers invoices.
Definition: index.php:91
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
On/off button for constant.
Definition: ajax.lib.php:500
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
user_admin_prepare_head()
Prepare array with list of tabs.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.