dolibarr  13.0.2
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 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', 'aZ09');
42 $value = GETPOST('value', 'alpha');
43 $type = 'group';
44 
45 /*
46  * Action
47  */
48 
49 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
50 
51 if ($action == 'set_default')
52 {
53  $ret = addDocumentModel($value, $type, $label, $scandir);
54  $res = true;
55 } elseif ($action == 'del_default')
56 {
57  $ret = delDocumentModel($value, $type);
58  if ($ret > 0)
59  {
60  if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity);
61  }
62  $res = true;
63 }
64 
65 // Set default model
66 elseif ($action == 'setdoc')
67 {
68  if (dolibarr_set_const($db, "USERGROUP_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity))
69  {
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  {
79  $ret = addDocumentModel($value, $type, $label, $scandir);
80  }
81  $res = true;
82 } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
83 {
84  $code = $reg[1];
85  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
86  {
87  header("Location: ".$_SERVER["PHP_SELF"]);
88  exit;
89  } else {
90  dol_print_error($db);
91  }
92 } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
93 {
94  $code = $reg[1];
95  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
96  {
97  header("Location: ".$_SERVER["PHP_SELF"]);
98  exit;
99  } else {
100  dol_print_error($db);
101  }
102 }
103 /*
104  * View
105  */
106 
107 $help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
108 llxHeader('', $langs->trans("UsersSetup"), $help_url);
109 
110 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
111 print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup');
112 
113 
114 $head = user_admin_prepare_head();
115 
116 print dol_get_fiche_head($head, 'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user');
117 
118 
119 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
120 
121 $form = new Form($db);
122 
123 // Defini tableau def des modeles
124 $def = array();
125 $sql = "SELECT nom";
126 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
127 $sql .= " WHERE type = '".$db->escape($type)."'";
128 $sql .= " AND entity = ".$conf->entity;
129 $resql = $db->query($sql);
130 if ($resql)
131 {
132  $i = 0;
133  $num_rows = $db->num_rows($resql);
134  while ($i < $num_rows)
135  {
136  $array = $db->fetch_array($resql);
137  array_push($def, $array[0]);
138  $i++;
139  }
140 } else {
141  dol_print_error($db);
142 }
143 
144 print load_fiche_titre($langs->trans("GroupsDocModules"), '', '');
145 
146 print '<table class="noborder centpercent">';
147 print '<tr class="liste_titre">';
148 print '<td>'.$langs->trans("Name").'</td>';
149 print '<td>'.$langs->trans("Description").'</td>';
150 print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
151 print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
152 print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
153 print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
154 print "</tr>\n";
155 
156 clearstatcache();
157 
158 foreach ($dirmodels as $reldir)
159 {
160  foreach (array('', '/doc') as $valdir)
161  {
162  $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir);
163  if (is_dir($dir))
164  {
165  $handle = opendir($dir);
166  if (is_resource($handle))
167  {
168  while (($file = readdir($handle)) !== false)
169  {
170  $filelist[] = $file;
171  }
172  closedir($handle);
173  arsort($filelist);
174 
175  foreach ($filelist as $file)
176  {
177  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
178  {
179  if (file_exists($dir.'/'.$file))
180  {
181  $name = substr($file, 4, dol_strlen($file) - 16);
182  $classname = substr($file, 0, dol_strlen($file) - 12);
183 
184  require_once $dir.'/'.$file;
185  $module = new $classname($db);
186 
187  $modulequalified = 1;
188  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
189  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
190 
191  if ($modulequalified)
192  {
193  print '<tr class="oddeven"><td width="100">';
194  print (empty($module->name) ? $name : $module->name);
195  print "</td><td>\n";
196  if (method_exists($module, 'info')) print $module->info($langs);
197  else print $module->description;
198  print '</td>';
199 
200  // Active
201  if (in_array($name, $def))
202  {
203  print '<td class="center">'."\n";
204  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&amp;token='.newToken().'&amp;value='.$name.'">';
205  print img_picto($langs->trans("Enabled"), 'switch_on');
206  print '</a>';
207  print '</td>';
208  } else {
209  print '<td class="center">'."\n";
210  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
211  print "</td>";
212  }
213 
214  // Defaut
215  print '<td class="center">';
216  if ($conf->global->USERGROUP_ADDON_PDF == $name)
217  {
218  print img_picto($langs->trans("Default"), 'on');
219  } else {
220  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
221  }
222  print '</td>';
223 
224  // Info
225  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
226  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
227  if ($module->type == 'pdf')
228  {
229  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
230  }
231  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
232  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
233  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
234 
235 
236  print '<td class="center">';
237  print $form->textwithpicto('', $htmltooltip, 1, 0);
238  print '</td>';
239 
240  // Preview
241  print '<td class="center">';
242  if ($module->type == 'pdf')
243  {
244  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
245  } else {
246  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
247  }
248  print '</td>';
249 
250  print "</tr>\n";
251  }
252  }
253  }
254  }
255  }
256  }
257  }
258 }
259 
260 print '</table>';
261 print "<br>";
262 
263 print dol_get_fiche_end();
264 
265 // End of page
266 llxFooter();
267 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1748
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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:575
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
Definition: admin.lib.php:1717
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:499
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
user_admin_prepare_head()
Prepare array with list of tabs.
llxFooter()
Empty footer.
Definition: wrapper.php:59