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