dolibarr 19.0.3
usergroup.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 <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35
36// Load translation files required by the page
37$langs->loadLangs(array("admin", "members", "users"));
38if (!$user->admin) {
40}
41
42$extrafields = new ExtraFields($db);
43
44$action = GETPOST('action', 'aZ09');
45$value = GETPOST('value', 'alpha');
46$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
47
48$type = 'group';
49
50/*
51 * Action
52 */
53
54include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
55
56if ($action == 'set_default') {
57 $ret = addDocumentModel($value, $type, $label, $scandir);
58 $res = true;
59} elseif ($action == 'del_default') {
60 $ret = delDocumentModel($value, $type);
61 if ($ret > 0) {
62 if (getDolGlobalString('USERGROUP_ADDON_PDF_ODT') == "$value") {
63 dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity);
64 }
65 }
66 $res = true;
67} elseif ($action == 'setdoc') {
68 // Set default model
69 if (dolibarr_set_const($db, "USERGROUP_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) {
70 // La constante qui a ete lue en avant du nouveau set
71 // on passe donc par une variable pour avoir un affichage coherent
72 $conf->global->USERGROUP_ADDON_PDF_ODT = $value;
73 }
74
75 // On active le modele
76 $ret = delDocumentModel($value, $type);
77 if ($ret > 0) {
78 $ret = addDocumentModel($value, $type, $label, $scandir);
79 }
80 $res = true;
81} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
82 $code = $reg[1];
83 if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
84 header("Location: ".$_SERVER["PHP_SELF"]);
85 exit;
86 } else {
87 dol_print_error($db);
88 }
89} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
90 $code = $reg[1];
91 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
92 header("Location: ".$_SERVER["PHP_SELF"]);
93 exit;
94 } else {
95 dol_print_error($db);
96 }
97}
98/*
99 * View
100 */
101
102$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
103llxHeader('', $langs->trans("UsersSetup"), $help_url);
104
105$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
106print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup');
107
108
110
111print dol_get_fiche_head($head, 'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user');
112
113
114$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
115
116$form = new Form($db);
117
118// Defini tableau def des modeles
119$def = array();
120$sql = "SELECT nom";
121$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
122$sql .= " WHERE type = '".$db->escape($type)."'";
123$sql .= " AND entity = ".$conf->entity;
124$resql = $db->query($sql);
125if ($resql) {
126 $i = 0;
127 $num_rows = $db->num_rows($resql);
128 while ($i < $num_rows) {
129 $array = $db->fetch_array($resql);
130 array_push($def, $array[0]);
131 $i++;
132 }
133} else {
134 dol_print_error($db);
135}
136
137print load_fiche_titre($langs->trans("GroupsDocModules"), '', '');
138
139print '<table class="noborder centpercent">';
140print '<tr class="liste_titre">';
141print '<td>'.$langs->trans("Name").'</td>';
142print '<td>'.$langs->trans("Description").'</td>';
143print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
144print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
145print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
146print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
147print "</tr>\n";
148
149clearstatcache();
150
151foreach ($dirmodels as $reldir) {
152 foreach (array('', '/doc') as $valdir) {
153 $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir);
154 if (is_dir($dir)) {
155 $handle = opendir($dir);
156 if (is_resource($handle)) {
157 while (($file = readdir($handle)) !== false) {
158 $filelist[] = $file;
159 }
160 closedir($handle);
161 arsort($filelist);
162
163 foreach ($filelist as $file) {
164 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
165 if (file_exists($dir.'/'.$file)) {
166 $name = substr($file, 4, dol_strlen($file) - 16);
167 $classname = substr($file, 0, dol_strlen($file) - 12);
168
169 require_once $dir.'/'.$file;
170 $module = new $classname($db);
171
172 $modulequalified = 1;
173 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
174 $modulequalified = 0;
175 }
176 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
177 $modulequalified = 0;
178 }
179
180 if ($modulequalified) {
181 print '<tr class="oddeven"><td width="100">';
182 print(empty($module->name) ? $name : $module->name);
183 print "</td><td>\n";
184 if (method_exists($module, 'info')) {
185 print $module->info($langs);
186 } else {
187 print $module->description;
188 }
189 print '</td>';
190
191 // Active
192 if (in_array($name, $def)) {
193 print '<td class="center">'."\n";
194 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&token='.newToken().'&value='.urlencode($name).'">';
195 print img_picto($langs->trans("Enabled"), 'switch_on');
196 print '</a>';
197 print '</td>';
198 } else {
199 print '<td class="center">'."\n";
200 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&token='.newToken().'&value='.urlencode($name).'&scandir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
201 print "</td>";
202 }
203
204 // Defaut
205 print '<td class="center">';
206 if (getDolGlobalString('USERGROUP_ADDON_PDF') == $name) {
207 print img_picto($langs->trans("Default"), 'on');
208 } else {
209 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>';
210 }
211 print '</td>';
212
213 // Info
214 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
215 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
216 if ($module->type == 'pdf') {
217 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
218 }
219 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
220 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
221 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
222
223
224 print '<td class="center">';
225 print $form->textwithpicto('', $htmltooltip, 1, 0);
226 print '</td>';
227
228 // Preview
229 print '<td class="center">';
230 if ($module->type == 'pdf') {
231 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
232 } else {
233 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
234 }
235 print '</td>';
236
237 print "</tr>\n";
238 }
239 }
240 }
241 }
242 }
243 }
244 }
245}
246
247print '</table>';
248print "<br>";
249
250print dol_get_fiche_end();
251
252// End of page
253llxFooter();
254$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.
$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.