From b144f3af5287942ded315094b5c35fd259c360e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Nov 2006 14:03:38 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20les=20classes=20dans=20le=20PEAR=20embar?= =?UTF-8?q?qu=E9=20avait=20=E9tait=20renomm=E9=20en=20DOLIPEAR.=20Cependan?= =?UTF-8?q?t,=20il=20rest=E9=20encore=20des=20r=E9f=E9rence=20en=20PEAR.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/includes/pear/Auth/Auth.php | 4 +- htdocs/includes/pear/Auth/Container/DB.php | 18 +++--- htdocs/includes/pear/DB.php | 73 +++++++++++----------- htdocs/includes/pear/DB/common.php | 11 ++-- htdocs/includes/pear/DB/ldap.php | 12 ++-- htdocs/includes/pear/DB/ldap2.php | 1 + htdocs/includes/pear/DB/ldap3.php | 2 + htdocs/includes/pear/DB/mysql.php | 11 ++-- htdocs/includes/pear/DB/pgsql.php | 4 +- 9 files changed, 74 insertions(+), 62 deletions(-) diff --git a/htdocs/includes/pear/Auth/Auth.php b/htdocs/includes/pear/Auth/Auth.php index cbe7c5fde37..beb1e5a4ea3 100644 --- a/htdocs/includes/pear/Auth/Auth.php +++ b/htdocs/includes/pear/Auth/Auth.php @@ -18,8 +18,10 @@ // // $Id$ // -require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; + //require_once "PEAR.php"; +require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; + define("AUTH_IDLED", -1); define("AUTH_EXPIRED", -2); diff --git a/htdocs/includes/pear/Auth/Container/DB.php b/htdocs/includes/pear/Auth/Container/DB.php index d357e4ccef1..695230bba5b 100644 --- a/htdocs/includes/pear/Auth/Container/DB.php +++ b/htdocs/includes/pear/Auth/Container/DB.php @@ -74,7 +74,7 @@ class Auth_Container_DB extends Auth_Container $this->_parseOptions($dsn); if (empty($this->options['dsn'])) { - PEAR::raiseError('No connection parameters specified!'); + DOLIPEAR::raiseError('No connection parameters specified!'); } } else { $this->options['dsn'] = $dsn; @@ -98,9 +98,9 @@ class Auth_Container_DB extends Auth_Container } elseif (get_parent_class($dsn) == "db_common") { $this->db = $dsn; } elseif (DB::isError($dsn)) { - return PEAR::raiseError($dsn->getMessage(), $dsn->getCode()); + return DOLIPEAR::raiseError($dsn->getMessage(), $dsn->getCode()); } else { - return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, + return DOLIPEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, 41, PEAR_ERROR_RETURN, null, @@ -228,7 +228,7 @@ class Auth_Container_DB extends Auth_Container // Prepare for a database query $err = $this->_prepare(); if ($err !== true) { - return PEAR::raiseError($err->getMessage(), $err->getCode()); + return DOLIPEAR::raiseError($err->getMessage(), $err->getCode()); } // Find if db_fileds contains a *, i so assume all col are selected @@ -249,7 +249,7 @@ class Auth_Container_DB extends Auth_Container $res = $this->db->getRow($query, $query_params, DB_FETCHMODE_ASSOC); if (DB::isError($res)) { - return PEAR::raiseError($res->getMessage(), $res->getCode()); + return DOLIPEAR::raiseError($res->getMessage(), $res->getCode()); } if (!is_array($res)) { $this->activeUser = ''; @@ -281,7 +281,7 @@ class Auth_Container_DB extends Auth_Container { $err = $this->_prepare(); if ($err !== true) { - return PEAR::raiseError($err->getMessage(), $err->getCode()); + return DOLIPEAR::raiseError($err->getMessage(), $err->getCode()); } $retVal = array(); @@ -301,7 +301,7 @@ class Auth_Container_DB extends Auth_Container $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); if (DB::isError($res)) { - return PEAR::raiseError($res->getMessage(), $res->getCode()); + return DOLIPEAR::raiseError($res->getMessage(), $res->getCode()); } else { foreach ($res as $user) { $user['username'] = $user[$this->options['usernamecol']]; @@ -355,7 +355,7 @@ class Auth_Container_DB extends Auth_Container $res = $this->query($query); if (DB::isError($res)) { - return PEAR::raiseError($res->getMessage(), $res->getCode()); + return DOLIPEAR::raiseError($res->getMessage(), $res->getCode()); } else { return true; } @@ -383,7 +383,7 @@ class Auth_Container_DB extends Auth_Container $res = $this->query($query); if (DB::isError($res)) { - return PEAR::raiseError($res->getMessage(), $res->getCode()); + return DOLIPEAR::raiseError($res->getMessage(), $res->getCode()); } else { return true; } diff --git a/htdocs/includes/pear/DB.php b/htdocs/includes/pear/DB.php index 868a150a7cd..4b6d4f5c47c 100644 --- a/htdocs/includes/pear/DB.php +++ b/htdocs/includes/pear/DB.php @@ -24,6 +24,7 @@ //require_once "PEAR.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; + // {{{ constants // {{{ error codes /* @@ -682,32 +683,32 @@ class DB_result /** * DB_result constructor. * @param resource &$dbh DB object reference - * @param resource $result result resource id + * @param resource $result result resource id * @param array $options assoc array with optional result options */ function DB_result(&$dbh, $result, $options = array()) - { + { $this->dbh = &$dbh; - $this->result = $result; - foreach ($options as $key => $value) { - $this->setOption($key, $value); + $this->result = $result; + foreach ($options as $key => $value) { + $this->setOption($key, $value); } $this->limit_type = $dbh->features['limit']; $this->autofree = $dbh->options['autofree']; $this->fetchmode = $dbh->fetchmode; $this->fetchmode_object_class = $dbh->fetchmode_object_class; } - - function setOption($key, $value = null) - { - switch ($key) { - case 'limit_from': - $this->limit_from = $value; break; - case 'limit_count'; - $this->limit_count = $value; break; - } - } + + function setOption($key, $value = null) + { + switch ($key) { + case 'limit_from': + $this->limit_from = $value; break; + case 'limit_count'; + $this->limit_count = $value; break; + } + } // }}} // {{{ fetchRow() @@ -728,7 +729,7 @@ class DB_result if ($fetchmode === DB_FETCHMODE_OBJECT) { $fetchmode = DB_FETCHMODE_ASSOC; $object_class = $this->fetchmode_object_class; - } + } if ($this->limit_from !== null) { if ($this->row_counter === null) { $this->row_counter = $this->limit_from; @@ -742,7 +743,7 @@ class DB_result } if ($this->row_counter >= ( $this->limit_from + $this->limit_count)) - { + { if ($this->autofree) { $this->free(); } @@ -752,23 +753,23 @@ class DB_result $rownum = $this->row_counter; } $this->row_counter++; - } - $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); - if ($res === DB_OK) { - if (isset($object_class)) { + } + $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); + if ($res === DB_OK) { + if (isset($object_class)) { // default mode specified in DB_common::fetchmode_object_class property if ($object_class == 'stdClass') { $arr = (object) $arr; } else { $arr = &new $object_class($arr); - } - } - return $arr; - } + } + } + return $arr; + } if ($res == null && $this->autofree) { $this->free(); } - return $res; + return $res; } // }}} @@ -807,7 +808,7 @@ class DB_result } if ($this->row_counter >= ( $this->limit_from + $this->limit_count)) - { + { if ($this->autofree) { $this->free(); } @@ -818,23 +819,23 @@ class DB_result } $this->row_counter++; - } - $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); - if ($res === DB_OK) { - if (isset($object_class)) { + } + $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); + if ($res === DB_OK) { + if (isset($object_class)) { // default mode specified in DB_common::fetchmode_object_class property if ($object_class == 'stdClass') { $arr = (object) $arr; } else { $arr = new $object_class($arr); - } - } - return DB_OK; - } + } + } + return DB_OK; + } if ($res == null && $this->autofree) { $this->free(); } - return $res; + return $res; } // }}} diff --git a/htdocs/includes/pear/DB/common.php b/htdocs/includes/pear/DB/common.php index 1811a6bde76..c2a930c4e2f 100644 --- a/htdocs/includes/pear/DB/common.php +++ b/htdocs/includes/pear/DB/common.php @@ -26,6 +26,7 @@ * inherited by all such. */ +//require_once "PEAR.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; class DB_common extends DOLIPEAR @@ -683,14 +684,14 @@ class DB_common extends DOLIPEAR * @see prepare() */ function freePrepared($stmt) - { - // Free the internal prepared vars + { + // Free the internal prepared vars if (isset($this->prepare_tokens[$stmt])) { unset($this->prepare_tokens[$stmt]); unset($this->prepare_types[$stmt]); - unset($this->prepared_queries[$stmt]); - return true; - } + unset($this->prepared_queries[$stmt]); + return true; + } return false; } diff --git a/htdocs/includes/pear/DB/ldap.php b/htdocs/includes/pear/DB/ldap.php index 3d82d6cf60e..addb2682978 100644 --- a/htdocs/includes/pear/DB/ldap.php +++ b/htdocs/includes/pear/DB/ldap.php @@ -19,8 +19,10 @@ // $Id$ // -require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Container.php"; +// require_once 'PEAR.php'; +// require_once 'Auth/Container.php'; require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; +require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Container.php"; /** * Storage driver for fetching login data from LDAP @@ -176,7 +178,7 @@ class Auth_Container_LDAP extends Auth_Container function Auth_Container_LDAP($params) { if (false === extension_loaded('ldap')) { - return PEAR::raiseError('Auth_Container_LDAP: LDAP Extension not loaded', 41, PEAR_ERROR_DIE); + return DOLIPEAR::raiseError('Auth_Container_LDAP: LDAP Extension not loaded', 41, PEAR_ERROR_DIE); } $this->_setDefaults(); @@ -207,7 +209,7 @@ class Auth_Container_LDAP extends Auth_Container } if (($this->conn_id = @call_user_func_array('ldap_connect', $conn_params)) === false) { - return PEAR::raiseError('Auth_Container_LDAP: Could not connect to server.', 41, PEAR_ERROR_DIE); + return DOLIPEAR::raiseError('Auth_Container_LDAP: Could not connect to server.', 41, PEAR_ERROR_DIE); } $this->_debug('Successfully connected to server', __LINE__); @@ -229,7 +231,7 @@ class Auth_Container_LDAP extends Auth_Container if ((@call_user_func_array('ldap_bind', $bind_params)) == false) { $this->_debug(); $this->_disconnect(); - return PEAR::raiseError("Auth_Container_LDAP: Could not bind to LDAP server.", 41, PEAR_ERROR_DIE); + return DOLIPEAR::raiseError("Auth_Container_LDAP: Could not bind to LDAP server.", 41, PEAR_ERROR_DIE); } $this->_debug('Binding was successful', __LINE__); } @@ -277,7 +279,7 @@ class Auth_Container_LDAP extends Auth_Container // if base ist still not set, raise error if ($this->options['basedn'] == "") { - return PEAR::raiseError("Auth_Container_LDAP: LDAP search base not specified!", 41, PEAR_ERROR_DIE); + return DOLIPEAR::raiseError("Auth_Container_LDAP: LDAP search base not specified!", 41, PEAR_ERROR_DIE); } return true; } diff --git a/htdocs/includes/pear/DB/ldap2.php b/htdocs/includes/pear/DB/ldap2.php index 12dcbe6ebbd..1e1d07b2234 100644 --- a/htdocs/includes/pear/DB/ldap2.php +++ b/htdocs/includes/pear/DB/ldap2.php @@ -25,6 +25,7 @@ // $Id$ // +// require_once 'DB/common.php'; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; /** diff --git a/htdocs/includes/pear/DB/ldap3.php b/htdocs/includes/pear/DB/ldap3.php index 4bad4c75129..23680a72f26 100644 --- a/htdocs/includes/pear/DB/ldap3.php +++ b/htdocs/includes/pear/DB/ldap3.php @@ -22,6 +22,8 @@ // $Id$ // +// require_once 'DB/common.php'; +// require_once 'DB/ldap2.php'; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/ldap2.php"; diff --git a/htdocs/includes/pear/DB/mysql.php b/htdocs/includes/pear/DB/mysql.php index 53fd4acf7f1..3f48eed3e1b 100644 --- a/htdocs/includes/pear/DB/mysql.php +++ b/htdocs/includes/pear/DB/mysql.php @@ -29,6 +29,7 @@ // be registered here. // +//require_once 'DB/common.php'; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; class DB_mysql extends DB_common @@ -563,11 +564,11 @@ class DB_mysql extends DB_common return $res; } // insert yields value 1, nextId call will generate ID 2 - $res = $this->query("INSERT INTO ${seqname} VALUES(0)"); - if (DB::isError($res)) { - return $res; - } - // so reset to zero + $res = $this->query("INSERT INTO ${seqname} VALUES(0)"); + if (DB::isError($res)) { + return $res; + } + // so reset to zero return $this->query("UPDATE ${seqname} SET id = 0;"); } diff --git a/htdocs/includes/pear/DB/pgsql.php b/htdocs/includes/pear/DB/pgsql.php index 0a4ec093c36..e87cfb7e2cb 100644 --- a/htdocs/includes/pear/DB/pgsql.php +++ b/htdocs/includes/pear/DB/pgsql.php @@ -23,7 +23,9 @@ // extension. // -require_once 'DB/common.php'; +//require_once 'DB/common.php'; +require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; + class DB_pgsql extends DB_common {