import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Zend_Auth_Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbTable.php 8862 2008-03-16 15:36:00Z thomas $
|
||||
* @version $Id: DbTable.php 14899 2009-04-14 22:04:56Z ralph $
|
||||
*/
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ require_once 'Zend/Auth/Result.php';
|
||||
*/
|
||||
class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
{
|
||||
|
||||
/**
|
||||
* Database Connection
|
||||
*
|
||||
@ -53,6 +54,11 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
*/
|
||||
protected $_zendDb = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Db_Select
|
||||
*/
|
||||
protected $_dbSelect = null;
|
||||
|
||||
/**
|
||||
* $_tableName - the table name to check
|
||||
*
|
||||
@ -101,7 +107,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
* @var array
|
||||
*/
|
||||
protected $_authenticateResultInfo = null;
|
||||
|
||||
|
||||
/**
|
||||
* $_resultRow - Results of database authentication query
|
||||
*
|
||||
@ -225,6 +231,20 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDbSelect() - Return the preauthentication Db Select object for userland select query modification
|
||||
*
|
||||
* @return Zend_Db_Select
|
||||
*/
|
||||
public function getDbSelect()
|
||||
{
|
||||
if ($this->_dbSelect == null) {
|
||||
$this->_dbSelect = $this->_zendDb->select();
|
||||
}
|
||||
|
||||
return $this->_dbSelect;
|
||||
}
|
||||
|
||||
/**
|
||||
* getResultRowObject() - Returns the result row as a stdClass object
|
||||
*
|
||||
@ -237,7 +257,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
if (!$this->_resultRow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$returnObject = new stdClass();
|
||||
|
||||
if (null !== $returnColumns) {
|
||||
@ -271,7 +291,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
}
|
||||
|
||||
/**
|
||||
* authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to
|
||||
* authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to
|
||||
* attempt an authenication. Previous to this call, this adapter would have already
|
||||
* been configured with all nessissary information to successfully connect to a database
|
||||
* table and attempt to find a record matching the provided identity.
|
||||
@ -284,11 +304,11 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
$this->_authenticateSetup();
|
||||
$dbSelect = $this->_authenticateCreateSelect();
|
||||
$resultIdentities = $this->_authenticateQuerySelect($dbSelect);
|
||||
|
||||
|
||||
if ( ($authResult = $this->_authenticateValidateResultset($resultIdentities)) instanceof Zend_Auth_Result) {
|
||||
return $authResult;
|
||||
}
|
||||
|
||||
|
||||
$authResult = $this->_authenticateValidateResult(array_shift($resultIdentities));
|
||||
return $authResult;
|
||||
}
|
||||
@ -323,13 +343,13 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
require_once 'Zend/Auth/Adapter/Exception.php';
|
||||
throw new Zend_Auth_Adapter_Exception($exception);
|
||||
}
|
||||
|
||||
|
||||
$this->_authenticateResultInfo = array(
|
||||
'code' => Zend_Auth_Result::FAILURE,
|
||||
'identity' => $this->_identity,
|
||||
'messages' => array()
|
||||
);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -342,12 +362,12 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
protected function _authenticateCreateSelect()
|
||||
{
|
||||
// build credential expression
|
||||
if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, "?") === false)) {
|
||||
if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, '?') === false)) {
|
||||
$this->_credentialTreatment = '?';
|
||||
}
|
||||
|
||||
$credentialExpression = new Zend_Db_Expr(
|
||||
'(CASE WHEN ' .
|
||||
'(CASE WHEN ' .
|
||||
$this->_zendDb->quoteInto(
|
||||
$this->_zendDb->quoteIdentifier($this->_credentialColumn, true)
|
||||
. ' = ' . $this->_credentialTreatment, $this->_credential
|
||||
@ -357,7 +377,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
);
|
||||
|
||||
// get select
|
||||
$dbSelect = $this->_zendDb->select();
|
||||
$dbSelect = clone $this->getDbSelect();
|
||||
$dbSelect->from($this->_tableName, array('*', $credentialExpression))
|
||||
->where($this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?', $this->_identity);
|
||||
|
||||
@ -421,7 +441,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
}
|
||||
|
||||
/**
|
||||
* _authenticateValidateResult() - This method attempts to validate that the record in the
|
||||
* _authenticateValidateResult() - This method attempts to validate that the record in the
|
||||
* result set is indeed a record that matched the identity provided to this adapter.
|
||||
*
|
||||
* @param array $resultIdentity
|
||||
@ -442,7 +462,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
||||
$this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
|
||||
return $this->_authenticateCreateAuthResult();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _authenticateCreateAuthResult() - This method creates a Zend_Auth_Result object
|
||||
* from the information that has been collected during the authenticate() attempt.
|
||||
|
Reference in New Issue
Block a user