[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/admin/ -> perms.php (source)

   1  <?php
   2  /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: perms.php,v 1.16 2005/10/14 21:05:14 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/admin/perms.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/admin/perms.php
  25          \brief      Page d'administration/configuration des permissions par defaut
  26          \version    $Revision: 1.16 $
  27  */
  28  
  29  require ("./pre.inc.php");
  30  
  31  $langs->load("admin");
  32  $langs->load("users");
  33  
  34  if (!$user->admin)
  35    accessforbidden();
  36  
  37  
  38  if ($_GET["action"] == 'add')
  39  {
  40      $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1 WHERE id =".$_GET["pid"];
  41      $db->query($sql);
  42  }
  43  
  44  if ($_GET["action"] == 'remove')
  45  {
  46      $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0 WHERE id =".$_GET["pid"];
  47      $db->query($sql);
  48  }
  49  
  50  
  51  
  52  llxHeader();
  53  
  54  print_fiche_titre($langs->trans("DefaultRights"));
  55  
  56  print $langs->trans("DefaultRightsDesc")."<br><br>\n";
  57  
  58  
  59  print '<table class="noborder" width="100%">';
  60  
  61  
  62  // Charge les modules soumis a permissions
  63  $db->begin();
  64  
  65  $dir = DOL_DOCUMENT_ROOT . "/includes/modules/";
  66  $handle=opendir($dir);
  67  $modules = array();
  68  while (($file = readdir($handle))!==false)
  69  {
  70      if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php')
  71      {
  72          $modName = substr($file, 0, strlen($file) - 10);
  73  
  74          if ($modName)
  75          {
  76              include_once("../includes/modules/$file");
  77              $objMod = new $modName($db);
  78              if ($objMod->rights_class) {
  79  
  80                  $ret=$objMod->insert_permissions();
  81  
  82                  $modules[$objMod->rights_class]=$objMod;
  83                  //print "modules[".$objMod->rights_class."]=$objMod;";
  84              }
  85          }
  86      }
  87  }
  88  
  89  $db->commit();
  90  
  91  
  92  // Affiche lignes des permissions
  93  $sql ="SELECT r.id, r.libelle, r.module, r.bydefault";
  94  $sql.=" FROM ".MAIN_DB_PREFIX."rights_def as r";
  95  $sql.=" WHERE r.libelle NOT LIKE 'tou%'";    // On ignore droits "tous"
  96  $sql.=" ORDER BY r.module, r.id";
  97  
  98  $result = $db->query($sql);
  99  if ($result)
 100  {
 101      $num = $db->num_rows();
 102      $i = 0;
 103      $var=True;
 104      $old = "";
 105      while ($i < $num)
 106      {
 107          $obj = $db->fetch_object($result);
 108  
 109          // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
 110          if (! $modules[$obj->module])
 111          {
 112              $i++;
 113              continue;
 114          }
 115  
 116          if ($old <> $obj->module)
 117          {
 118              // Rupture détectée, on récupère objMod
 119              $objMod=$modules[$obj->module];
 120              $picto=($objMod->picto?$objMod->picto:'generic');
 121  
 122              print '<tr class="liste_titre">';
 123              print '<td>'.$langs->trans("Module").'</td>';
 124              print '<td>'.$langs->trans("Permission").'</td>';
 125              print '<td align="center">'.$langs->trans("Default").'</td>';
 126              print '<td align="center">&nbsp;</td>';
 127              print "</tr>\n";
 128              $old = $obj->module;
 129          }
 130  
 131          $var=!$var;
 132          print '<tr '. $bc[$var].'>';
 133  
 134          print '<td>'.img_object('',$picto).' '.$objMod->getName();
 135  
 136          $perm_libelle=(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle);
 137          print '<td>'.$perm_libelle. '</td>';
 138  
 139          print '<td align="center">';
 140          if ($obj->bydefault == 1)
 141          {
 142  
 143              print img_tick();
 144              print '</td><td>';
 145              print '<a href="perms.php?pid='.$obj->id.'&amp;action=remove">'.img_edit_remove().'</a>';
 146          }
 147          else
 148          {
 149              print '&nbsp;';
 150              print '</td><td>';
 151              print '<a href="perms.php?pid='.$obj->id.'&amp;action=add">'.img_edit_add().'</a>';
 152          }
 153  
 154          print '</td></tr>';
 155          $i++;
 156      }
 157  }
 158  
 159  print '</table>';
 160  print '<br>';
 161  
 162  $db->close();
 163  
 164  llxFooter('$Date: 2005/10/14 21:05:14 $ - $Revision: 1.16 $');
 165  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics