[ 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/telephonie/script/tools/ -> permissions.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: permissions.php,v 1.8 2005/12/07 15:13:40 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/tools/permissions.php,v $
  20   *
  21   * Positionne les permissions sur les societes
  22   */
  23  
  24  /****************************************************************
  25   * ATTENTION ce script est un script personnel à NE PAS UTILISER
  26   * sur vos bases sans modification, il est distribué à titre
  27   * d'exemple uniquement !
  28   ****************************************************************/
  29  require  ("../../../master.inc.php");
  30  
  31  $sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe";
  32  $resql = $db->query($sql);
  33    
  34  if ( $resql )
  35  {
  36    while ($row = $db->fetch_row($resql))
  37      {
  38        
  39        $sqlu = "REPLACE INTO llx_societe_perms";
  40        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  41        $sqlu .= " VALUES (".$row[0].", 1,1,1,1)";
  42        $resqlu = $db->query($sqlu);
  43  
  44        $sqlu = "REPLACE INTO llx_societe_perms";
  45        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  46        $sqlu .= " VALUES (".$row[0].",2,1,0,0)";
  47        $resqlu = $db->query($sqlu);
  48  
  49        $sqlu = "REPLACE INTO llx_societe_perms";
  50        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  51        $sqlu .= " VALUES (".$row[0].", 5,1,1,1)";
  52        $resqlu = $db->query($sqlu);
  53  
  54        $sqlu = "REPLACE INTO llx_societe_perms";
  55        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  56        $sqlu .= " VALUES (".$row[0].", 9,1,1,1)";
  57        $resqlu = $db->query($sqlu);
  58  
  59        $sqlu = "REPLACE INTO llx_societe_perms";
  60        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  61        $sqlu .= " VALUES (".$row[0].",16,1,1,1)";
  62        $resqlu = $db->query($sqlu);
  63  
  64        $sqlu = "REPLACE INTO llx_societe_perms";
  65        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  66        $sqlu .= " VALUES (".$row[0].",18,1,0,0)";
  67        $resqlu = $db->query($sqlu);
  68  
  69        $sqlu = "REPLACE INTO llx_societe_perms";
  70        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  71        $sqlu .= " VALUES (".$row[0].",29,1,0,0)";
  72        $resqlu = $db->query($sqlu);
  73  
  74        $sqlu = "REPLACE INTO llx_societe_perms";
  75        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  76        $sqlu .= " VALUES (".$row[0].",33,1,0,0)";
  77        $resqlu = $db->query($sqlu);
  78  
  79        $sqlu = "REPLACE INTO llx_societe_perms";
  80        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
  81        $sqlu .= " VALUES (".$row[0].",34,1,0,0)";
  82        $resqlu = $db->query($sqlu);
  83      }
  84    $db->free($resql);
  85  }
  86  else
  87  {
  88    $error++;
  89  }
  90  
  91  /* Speciaux */
  92  $sql = "SELECT fk_client_comm, fk_commercial_sign, fk_commercial_suiv FROM ".MAIN_DB_PREFIX."telephonie_contrat";
  93  $resql = $db->query($sql);
  94    
  95  if ( $resql )
  96  {
  97    while ($row = $db->fetch_row($resql))
  98      {      
  99        $sqlu = "INSERT INTO llx_societe_perms";
 100        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
 101        $sqlu .= " VALUES (".$row[0].",".$row[1].",1,0,0)";
 102        $resqlu = $db->query($sqlu);
 103  
 104        $sqlu = "INSERT INTO llx_societe_perms";
 105        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
 106        $sqlu .= " VALUES (".$row[0].",".$row[2].",1,0,0)";
 107        $resqlu = $db->query($sqlu);
 108      }
 109    $db->free($resql);
 110  }
 111  else
 112  {
 113    $error++;
 114  }
 115  
 116  /* Speciaux */
 117  $sql = "SELECT fk_client_comm, fk_commercial_sign ";
 118  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat ";
 119  $sql .= ", llx_telephonie_distributeur_commerciaux as c";
 120  $sql .= " WHERE fk_commercial_sign = c.fk_user";
 121  $resql = $db->query($sql);
 122    
 123  if ( $resql )
 124  {
 125    while ($row = $db->fetch_row($resql))
 126      {      
 127        $sqlu = "INSERT INTO llx_societe_perms";
 128        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
 129        $sqlu .= " VALUES (".$row[0].",18,1,1,1)";
 130        $resqlu = $db->query($sqlu);
 131      }
 132    $db->free($resql);
 133  }
 134  else
 135  {
 136    print $db->error();
 137  }
 138  
 139  /* Speciaux */
 140  $sql = "SELECT fk_client_comm, fk_commercial_suiv ";
 141  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat ";
 142  $sql .= ", llx_telephonie_distributeur_commerciaux as c";
 143  $sql .= " WHERE fk_commercial_suiv = c.fk_user";
 144  $resql = $db->query($sql);
 145    
 146  if ( $resql )
 147  {
 148    while ($row = $db->fetch_row($resql))
 149      {      
 150        $sqlu = "INSERT INTO llx_societe_perms";
 151        $sqlu .= " (fk_soc, fk_user, pread, pwrite, pperms) ";
 152        $sqlu .= " VALUES (".$row[0].",18,1,1,1)";
 153        $resqlu = $db->query($sqlu);
 154      }
 155    $db->free($resql);
 156  }
 157  else
 158  {
 159    print $db->error();
 160  }
 161  
 162  $db->close();
 163  ?>


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