diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 98ef64fa994..78e533d639f 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -28,7 +28,6 @@ include_once("./inc.php"); -$grant_query=''; $etape = 2; $ok = 0; @@ -63,7 +62,6 @@ if($dolibarr_main_db_type == "mysql") else { require_once($dolibarr_main_document_root . "/lib/pgsql.lib.php"); - require_once($dolibarr_main_document_root . "/lib/grant.postgres.php"); $choix=2; } @@ -262,7 +260,10 @@ if ($_POST["action"] == "set") if ($ok) { // Droits sur les tables - if ($grant_query) { // Non null si postgresql + $grant_query=$db->getGrantForUserQuery($dolibarr_main_db_user); + + if ($grant_query) // Seules les bases qui en ont besoin le definisse + { if ($db->query($grant_query)) { print "Grant User".$langs->trans("OK").""; diff --git a/htdocs/lib/grant.postgres.php b/htdocs/lib/grant.postgres.php deleted file mode 100644 index 9fb6366f728..00000000000 --- a/htdocs/lib/grant.postgres.php +++ /dev/null @@ -1,67 +0,0 @@ - - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ - * - */ - -/** - \file htdocs/lib/grant.postgres.php - \brief Effectue les GRANT sur toutes les tables - \author Sebastien Di Cintio - \author Benoit Mortier - \version $Revision$ - -*/ - -$conf = "../conf/conf.php"; - -if (file_exists($conf)) -{ - include($conf); - -} -$nom =$dolibarr_main_db_user; - - -// Scan tables pour générer le grant -$dir = "../../pgsql/tables"; - -$handle=opendir($dir); -$table_list=""; -while (($file = readdir($handle))!==false) -{ - if (! ereg("^mysql",$file,$reg) && ! ereg("\.key\.sql",$file) && ereg("^(.*)\.sql",$file,$reg)) - { - if ($table_list) { - $table_list.=", ".$reg[0]; - } - else { - $table_list.=$reg[0]; - } - } -} - -// Genere le grant_query -$grant_query = "GRANT ALL ON $table_list TO \"$nom\";"; -//print $grant_query; - -?> diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index d0b427d1339..db2e5e9eb8c 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -202,6 +202,16 @@ class DoliDb $row=$this->fetch_row($resql); return $row[0]; } + + + /** + \brief Renvoie la commande sql qui donne les droits sur les tables + \return string Requete sql + */ + function getGrantForUserQuery($databaseuser) + { + return ''; + } /** diff --git a/htdocs/lib/pgsql.lib.php b/htdocs/lib/pgsql.lib.php index 590dfa081f7..885a4568174 100644 --- a/htdocs/lib/pgsql.lib.php +++ b/htdocs/lib/pgsql.lib.php @@ -164,6 +164,58 @@ class DoliDb return $this->db; } + + /** + \brief Renvoie la version du serveur + \return string Chaine version + */ + function getVersion() + { + return '?'; + } + + + /** + \brief Renvoie l'id de la connection + \return string Id connection + */ + function getConnectId() + { + return '?'; + } + + + /** + \brief Renvoie la commande sql qui donne les droits à user sur les tables + \param databaseuse User à autoriser + \return string Requete sql + */ + function getGrantForUserQuery($databaseuser) + { + // Scan tables pour générer le grant + $dir = DOL_DOCUMENT_ROOT."/pgsql/tables"; + + $handle=opendir($dir); + $table_list=""; + while (($file = readdir($handle))!==false) + { + if (! ereg("\.key\.sql",$file) && ereg("^(.*)\.sql",$file,$reg)) + { + if ($table_list) { + $table_list.=", ".$reg[0]; + } + else { + $table_list.=$reg[0]; + } + } + } + + // Genere le grant_query + $grant_query = 'GRANT ALL ON '.$table_list.' TO "'.$databaseuser.'";'; + return $grant_query; + } + + /** \brief Création d'une nouvelle base de donnée \param database nom de la database à créer