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