forked from Wavyzz/dolibarr
Qual: La fonction de grant d'install depandant de la base, je la place dans le gestionnaire de base
This commit is contained in:
@@ -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 "<tr><td>Grant User</td><td>".$langs->trans("OK")."</td></tr>";
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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<EFBFBD>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;
|
||||
|
||||
?>
|
||||
@@ -204,6 +204,16 @@ class DoliDb
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Renvoie la commande sql qui donne les droits sur les tables
|
||||
\return string Requete sql
|
||||
*/
|
||||
function getGrantForUserQuery($databaseuser)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Cr<43>ation d'une nouvelle base de donn<6E>e
|
||||
\param database nom de la database <20> cr<63>er
|
||||
|
||||
@@ -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 <20> user sur les tables
|
||||
\param databaseuse User <20> autoriser
|
||||
\return string Requete sql
|
||||
*/
|
||||
function getGrantForUserQuery($databaseuser)
|
||||
{
|
||||
// Scan tables pour g<>n<EFBFBD>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<43>ation d'une nouvelle base de donn<6E>e
|
||||
\param database nom de la database <20> cr<63>er
|
||||
|
||||
Reference in New Issue
Block a user