cvs: pear /Auth_PrefManager2 PrefManager2.php
| From: | Jon Wood | Date: | Tue, 29 Jun 2004 17:57:14 +0000 |
| Subject: | cvs: pear /Auth_PrefManager2 PrefManager2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-21264@lists.php.net to get a copy of this message | ||
jellybob Tue Jun 29 13:57:14 2004 EDT
Modified files:
/pear/Auth_PrefManager2 PrefManager2.php
Log:
* Added error codes for the DB container.
* Added an _exists methods to check if a preference exists.
http://cvs.php.net/diff.php/pear/Auth_PrefManager2/PrefManager2.php?r1=1.6&r2=1.7&ty=u
Index: pear/Auth_PrefManager2/PrefManager2.php
diff -u pear/Auth_PrefManager2/PrefManager2.php:1.6 pear/Auth_PrefManager2/PrefManager2.php:1.7
--- pear/Auth_PrefManager2/PrefManager2.php:1.6 Tue Jun 29 12:56:31 2004
+++ pear/Auth_PrefManager2/PrefManager2.php Tue Jun 29 13:57:14 2004
@@ -15,7 +15,7 @@
// | Paul M. Jones <pmjones@ciaweb.net> |
// +----------------------------------------------------------------------+
//
-// $Id: PrefManager2.php,v 1.6 2004/06/29 16:56:31 jellybob Exp $
+// $Id: PrefManager2.php,v 1.7 2004/06/29 17:57:14 jellybob Exp $
/**
* Used for error handling.
@@ -27,6 +27,9 @@
*/
define('AUTH_PREFMANAGER2_CONTAINER_NOT_FOUND', -1);
define('AUTH_PREFMANAGER2_NOT_IMPLEMENTED', -2);
+define('AUTH_PREFMANAGER2_DB_NO_DSN', -3);
+define('AUTH_PREFMANAGER2_DB_CONNECT_FAILED', -4);
+define('AUTH_PREFMANAGER2_DB_QUERY_FAILED', -5);
/**#@-*/
/**
@@ -36,7 +39,10 @@
$GLOBALS['_Auth_PrefManager2']['err'] = array(
'en' => array(
AUTH_PREFMANAGER2_CONTAINER_NOT_FOUND => 'The container you requested could not
be loaded.',
- AUTH_PREFMANAGER2_NOT_IMPLEMENTED => 'This container doesn\'t implement
this method.'
+ AUTH_PREFMANAGER2_NOT_IMPLEMENTED => 'This container doesn\'t implement
this method.',
+ AUTH_PREFMANAGER2_DB_NO_DSN => 'You must provide a DSN to connect to.',
+ AUTH_PREFMANAGER2_DB_CONNECT_FAILED => 'A connection couldn\'t be
established with the database.',
+ AUTH_PREFMANAGER2_DB_QUERY_FAILED => 'A database query failed.'
)
);
}
@@ -201,10 +207,10 @@
}
if (!is_null($value = $this->_get($owner, $preference, $application))) {
- return $this->_unprepare($value);
+ return $this->_decodeValue($value);
} else {
if ($returnDefaults && $options['return_defaults']) {
- return $this->getDefaultPref($preference, $application);
+ return $this->getPref($preference, null, $application);
}
}
}
@@ -230,7 +236,7 @@
$application = $this->_options['default_app'];
}
- return $this->_set($owner, $preference, $this->_prepare($value), $application);
+ return $this->_set($owner, $preference, $this->_encodeValue($value), $application);
}
/**
@@ -312,6 +318,26 @@
}
/**
+ * Checks if the specified preference exists in the data container.
+ * This method should be overridden by container classes to do whatever
+ * needs doing.
+ *
+ * Returns null if an error occurs.
+ *
+ * @param string $owner The owner to delete the preference for.
+ * @param string $preference The name of the preference to delete.
+ * @param string $application The application to delete from.
+ * @return bool Does the pref exist?
+ * @access protected
+ * @abstract
+ */
+ function _exists($owner, $preference, $application)
+ {
+ $this->_throwError(AUTH_PREFMANAGER2_NOT_IMPLEMENTED);
+ return null;
+ }
+
+ /**
* Prepares a value for saving in the data container.
* Containers that override this method should always call
* parent::_encodeValue() to do serialization.
@@ -396,7 +422,7 @@
* @return void
* @access protected
*/
- function _throwError($code, $level = 'error', $params = array())
+ function _throwError($code, $level = 'error', $params = array(), $repackage = null)
{
$locale = isset($this->_errorMessages['_Auth_PrefManager2'][$this->locale])
? $this->locale : 'en';