Fix: les classes dans le PEAR embarqué avait était renommé en DOLIPEAR. Cependant, il resté encore des référence en PEAR.

This commit is contained in:
Laurent Destailleur 2006-11-11 14:03:38 +00:00
parent 5f31e7892d
commit b144f3af52
9 changed files with 74 additions and 62 deletions

View File

@ -18,8 +18,10 @@
// //
// $Id$ // $Id$
// //
require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php";
//require_once "PEAR.php"; //require_once "PEAR.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php";
define("AUTH_IDLED", -1); define("AUTH_IDLED", -1);
define("AUTH_EXPIRED", -2); define("AUTH_EXPIRED", -2);

View File

@ -74,7 +74,7 @@ class Auth_Container_DB extends Auth_Container
$this->_parseOptions($dsn); $this->_parseOptions($dsn);
if (empty($this->options['dsn'])) { if (empty($this->options['dsn'])) {
PEAR::raiseError('No connection parameters specified!'); DOLIPEAR::raiseError('No connection parameters specified!');
} }
} else { } else {
$this->options['dsn'] = $dsn; $this->options['dsn'] = $dsn;
@ -98,9 +98,9 @@ class Auth_Container_DB extends Auth_Container
} elseif (get_parent_class($dsn) == "db_common") { } elseif (get_parent_class($dsn) == "db_common") {
$this->db = $dsn; $this->db = $dsn;
} elseif (DB::isError($dsn)) { } elseif (DB::isError($dsn)) {
return PEAR::raiseError($dsn->getMessage(), $dsn->getCode()); return DOLIPEAR::raiseError($dsn->getMessage(), $dsn->getCode());
} else { } 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, 41,
PEAR_ERROR_RETURN, PEAR_ERROR_RETURN,
null, null,
@ -228,7 +228,7 @@ class Auth_Container_DB extends Auth_Container
// Prepare for a database query // Prepare for a database query
$err = $this->_prepare(); $err = $this->_prepare();
if ($err !== true) { 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 // 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); $res = $this->db->getRow($query, $query_params, DB_FETCHMODE_ASSOC);
if (DB::isError($res)) { if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode()); return DOLIPEAR::raiseError($res->getMessage(), $res->getCode());
} }
if (!is_array($res)) { if (!is_array($res)) {
$this->activeUser = ''; $this->activeUser = '';
@ -281,7 +281,7 @@ class Auth_Container_DB extends Auth_Container
{ {
$err = $this->_prepare(); $err = $this->_prepare();
if ($err !== true) { if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode()); return DOLIPEAR::raiseError($err->getMessage(), $err->getCode());
} }
$retVal = array(); $retVal = array();
@ -301,7 +301,7 @@ class Auth_Container_DB extends Auth_Container
$res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC);
if (DB::isError($res)) { if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode()); return DOLIPEAR::raiseError($res->getMessage(), $res->getCode());
} else { } else {
foreach ($res as $user) { foreach ($res as $user) {
$user['username'] = $user[$this->options['usernamecol']]; $user['username'] = $user[$this->options['usernamecol']];
@ -355,7 +355,7 @@ class Auth_Container_DB extends Auth_Container
$res = $this->query($query); $res = $this->query($query);
if (DB::isError($res)) { if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode()); return DOLIPEAR::raiseError($res->getMessage(), $res->getCode());
} else { } else {
return true; return true;
} }
@ -383,7 +383,7 @@ class Auth_Container_DB extends Auth_Container
$res = $this->query($query); $res = $this->query($query);
if (DB::isError($res)) { if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode()); return DOLIPEAR::raiseError($res->getMessage(), $res->getCode());
} else { } else {
return true; return true;
} }

View File

@ -24,6 +24,7 @@
//require_once "PEAR.php"; //require_once "PEAR.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php";
// {{{ constants // {{{ constants
// {{{ error codes // {{{ error codes
/* /*
@ -682,32 +683,32 @@ class DB_result
/** /**
* DB_result constructor. * DB_result constructor.
* @param resource &$dbh DB object reference * @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 * @param array $options assoc array with optional result options
*/ */
function DB_result(&$dbh, $result, $options = array()) function DB_result(&$dbh, $result, $options = array())
{ {
$this->dbh = &$dbh; $this->dbh = &$dbh;
$this->result = $result; $this->result = $result;
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
$this->setOption($key, $value); $this->setOption($key, $value);
} }
$this->limit_type = $dbh->features['limit']; $this->limit_type = $dbh->features['limit'];
$this->autofree = $dbh->options['autofree']; $this->autofree = $dbh->options['autofree'];
$this->fetchmode = $dbh->fetchmode; $this->fetchmode = $dbh->fetchmode;
$this->fetchmode_object_class = $dbh->fetchmode_object_class; $this->fetchmode_object_class = $dbh->fetchmode_object_class;
} }
function setOption($key, $value = null) function setOption($key, $value = null)
{ {
switch ($key) { switch ($key) {
case 'limit_from': case 'limit_from':
$this->limit_from = $value; break; $this->limit_from = $value; break;
case 'limit_count'; case 'limit_count';
$this->limit_count = $value; break; $this->limit_count = $value; break;
} }
} }
// }}} // }}}
// {{{ fetchRow() // {{{ fetchRow()
@ -728,7 +729,7 @@ class DB_result
if ($fetchmode === DB_FETCHMODE_OBJECT) { if ($fetchmode === DB_FETCHMODE_OBJECT) {
$fetchmode = DB_FETCHMODE_ASSOC; $fetchmode = DB_FETCHMODE_ASSOC;
$object_class = $this->fetchmode_object_class; $object_class = $this->fetchmode_object_class;
} }
if ($this->limit_from !== null) { if ($this->limit_from !== null) {
if ($this->row_counter === null) { if ($this->row_counter === null) {
$this->row_counter = $this->limit_from; $this->row_counter = $this->limit_from;
@ -742,7 +743,7 @@ class DB_result
} }
if ($this->row_counter >= ( if ($this->row_counter >= (
$this->limit_from + $this->limit_count)) $this->limit_from + $this->limit_count))
{ {
if ($this->autofree) { if ($this->autofree) {
$this->free(); $this->free();
} }
@ -752,23 +753,23 @@ class DB_result
$rownum = $this->row_counter; $rownum = $this->row_counter;
} }
$this->row_counter++; $this->row_counter++;
} }
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res === DB_OK) { if ($res === DB_OK) {
if (isset($object_class)) { if (isset($object_class)) {
// default mode specified in DB_common::fetchmode_object_class property // default mode specified in DB_common::fetchmode_object_class property
if ($object_class == 'stdClass') { if ($object_class == 'stdClass') {
$arr = (object) $arr; $arr = (object) $arr;
} else { } else {
$arr = &new $object_class($arr); $arr = &new $object_class($arr);
} }
} }
return $arr; return $arr;
} }
if ($res == null && $this->autofree) { if ($res == null && $this->autofree) {
$this->free(); $this->free();
} }
return $res; return $res;
} }
// }}} // }}}
@ -807,7 +808,7 @@ class DB_result
} }
if ($this->row_counter >= ( if ($this->row_counter >= (
$this->limit_from + $this->limit_count)) $this->limit_from + $this->limit_count))
{ {
if ($this->autofree) { if ($this->autofree) {
$this->free(); $this->free();
} }
@ -818,23 +819,23 @@ class DB_result
} }
$this->row_counter++; $this->row_counter++;
} }
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res === DB_OK) { if ($res === DB_OK) {
if (isset($object_class)) { if (isset($object_class)) {
// default mode specified in DB_common::fetchmode_object_class property // default mode specified in DB_common::fetchmode_object_class property
if ($object_class == 'stdClass') { if ($object_class == 'stdClass') {
$arr = (object) $arr; $arr = (object) $arr;
} else { } else {
$arr = new $object_class($arr); $arr = new $object_class($arr);
} }
} }
return DB_OK; return DB_OK;
} }
if ($res == null && $this->autofree) { if ($res == null && $this->autofree) {
$this->free(); $this->free();
} }
return $res; return $res;
} }
// }}} // }}}

View File

@ -26,6 +26,7 @@
* inherited by all such. * inherited by all such.
*/ */
//require_once "PEAR.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/PEAR.php";
class DB_common extends DOLIPEAR class DB_common extends DOLIPEAR
@ -683,14 +684,14 @@ class DB_common extends DOLIPEAR
* @see prepare() * @see prepare()
*/ */
function freePrepared($stmt) function freePrepared($stmt)
{ {
// Free the internal prepared vars // Free the internal prepared vars
if (isset($this->prepare_tokens[$stmt])) { if (isset($this->prepare_tokens[$stmt])) {
unset($this->prepare_tokens[$stmt]); unset($this->prepare_tokens[$stmt]);
unset($this->prepare_types[$stmt]); unset($this->prepare_types[$stmt]);
unset($this->prepared_queries[$stmt]); unset($this->prepared_queries[$stmt]);
return true; return true;
} }
return false; return false;
} }

View File

@ -19,8 +19,10 @@
// $Id$ // $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/PEAR.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Container.php";
/** /**
* Storage driver for fetching login data from LDAP * Storage driver for fetching login data from LDAP
@ -176,7 +178,7 @@ class Auth_Container_LDAP extends Auth_Container
function Auth_Container_LDAP($params) function Auth_Container_LDAP($params)
{ {
if (false === extension_loaded('ldap')) { 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(); $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) { 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__); $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) { if ((@call_user_func_array('ldap_bind', $bind_params)) == false) {
$this->_debug(); $this->_debug();
$this->_disconnect(); $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__); $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 base ist still not set, raise error
if ($this->options['basedn'] == "") { 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; return true;
} }

View File

@ -25,6 +25,7 @@
// $Id$ // $Id$
// //
// require_once 'DB/common.php';
require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php";
/** /**

View File

@ -22,6 +22,8 @@
// $Id$ // $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/common.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/ldap2.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/ldap2.php";

View File

@ -29,6 +29,7 @@
// be registered here. // be registered here.
// //
//require_once 'DB/common.php';
require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/DB/common.php";
class DB_mysql extends DB_common class DB_mysql extends DB_common
@ -563,11 +564,11 @@ class DB_mysql extends DB_common
return $res; return $res;
} }
// insert yields value 1, nextId call will generate ID 2 // insert yields value 1, nextId call will generate ID 2
$res = $this->query("INSERT INTO ${seqname} VALUES(0)"); $res = $this->query("INSERT INTO ${seqname} VALUES(0)");
if (DB::isError($res)) { if (DB::isError($res)) {
return $res; return $res;
} }
// so reset to zero // so reset to zero
return $this->query("UPDATE ${seqname} SET id = 0;"); return $this->query("UPDATE ${seqname} SET id = 0;");
} }

View File

@ -23,7 +23,9 @@
// extension. // 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 class DB_pgsql extends DB_common
{ {