dolibarr  7.0.0-beta
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@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 $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_(.*)/',$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_(.*)/',$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">'.$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 $var=true;
169 foreach ($dirmodels as $reldir)
170 {
171  foreach (array('','/doc') as $valdir)
172  {
173  $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir);
174  if (is_dir($dir))
175  {
176  $handle=opendir($dir);
177  if (is_resource($handle))
178  {
179  while (($file = readdir($handle))!==false)
180  {
181  $filelist[]=$file;
182  }
183  closedir($handle);
184  arsort($filelist);
185 
186  foreach($filelist as $file)
187  {
188  if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
189  {
190 
191  if (file_exists($dir.'/'.$file))
192  {
193  $name = substr($file, 4, dol_strlen($file) -16);
194  $classname = substr($file, 0, dol_strlen($file) -12);
195 
196  require_once $dir.'/'.$file;
197  $module = new $classname($db);
198 
199  $modulequalified=1;
200  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
201  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
202 
203  if ($modulequalified)
204  {
205  $var = !$var;
206  print '<tr class="oddeven"><td width="100">';
207  print (empty($module->name)?$name:$module->name);
208  print "</td><td>\n";
209  if (method_exists($module,'info')) print $module->info($langs);
210  else print $module->description;
211  print '</td>';
212 
213  // Active
214  if (in_array($name, $def))
215  {
216  print '<td align="center">'."\n";
217  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
218  print img_picto($langs->trans("Enabled"),'switch_on');
219  print '</a>';
220  print '</td>';
221  }
222  else
223  {
224  print '<td align="center">'."\n";
225  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>';
226  print "</td>";
227  }
228 
229  // Defaut
230  print '<td align="center">';
231  if ($conf->global->USERGROUP_ADDON_PDF == $name)
232  {
233  print img_picto($langs->trans("Default"),'on');
234  }
235  else
236  {
237  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>';
238  }
239  print '</td>';
240 
241  // Info
242  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
243  $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
244  if ($module->type == 'pdf')
245  {
246  $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
247  }
248  $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
249  $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
250  $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
251  $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
252  $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
253  $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
254 
255 
256  print '<td align="center">';
257  print $form->textwithpicto('',$htmltooltip,1,0);
258  print '</td>';
259 
260  // Preview
261  print '<td align="center">';
262  if ($module->type == 'pdf')
263  {
264  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
265  }
266  else
267  {
268  print img_object($langs->trans("PreviewNotAvailable"),'generic');
269  }
270  print '</td>';
271 
272  print "</tr>\n";
273  }
274  }
275  }
276  }
277  }
278  }
279  }
280 }
281 
282 print '</table>';
283 print "<br>";
284 
285 dol_fiche_end();
286 
287 llxFooter();
288 $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
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.