diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/DataAccess/TAdodbProvider.php | 343 | ||||
-rw-r--r-- | framework/DataAccess/TCreoleProvider.php | 83 | ||||
-rw-r--r-- | framework/DataAccess/TDatabaseProvider.php | 258 | ||||
-rw-r--r-- | framework/DataAccess/TSQLMap.php | 77 | ||||
-rw-r--r-- | framework/Security/TMembershipManager.php | 109 |
5 files changed, 0 insertions, 870 deletions
diff --git a/framework/DataAccess/TAdodbProvider.php b/framework/DataAccess/TAdodbProvider.php deleted file mode 100644 index 9d9453f9..00000000 --- a/framework/DataAccess/TAdodbProvider.php +++ /dev/null @@ -1,343 +0,0 @@ -<?php
-
-Prado::using('System.DataAccess.TDatabaseProvider');
-
-/**
- * Adbodb data access module.
- *
- * Usage:
- * <code>
- * $provider = new TAdodbProvider;
- * $provider->setConnectionString($dsn);
- * $connection = $provider->getConnection();
- * $resultSet = $connection->execute('....');
- * </code>
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: $ $Date: $
- * @package System.DataAccess
- * @since 3.0
- */
-class TAdodbProvider extends TDatabaseProvider
-{
- const FETCH_ASSOCIATIVE='associative';
- const FETCH_NUMERIC='numeric';
- const FETCH_BOTH='both';
- const FETCH_DEFAULT='default';
-
- private $_connection = null;
- private $_cachedir='';
- private $_fetchMode = 'associative';
-
- private static $_hasImported=false;
-
- private $_adodbLibrary='';
-
- public function getConnection()
- {
- if(is_null($this->_connection) || is_null($this->_connection->getProvider()))
- {
- $this->importAdodbLibrary();
- $this->_connection = new TAdodbConnection($this);
- }
- return $this->_connection;
- }
-
- /**
- * @return string the cache directory for adodb module
- */
- public function getCacheDir()
- {
- return $this->_cachedir;
- }
-
- public function getAdodbLibrary()
- {
- if(strlen($this->_adodbLibrary) < 1)
- return dirname(__FILE__).'/adodb';
- else
- return $this->_adodbLibrary;
- }
-
- public function setAdodbLibrary($path)
- {
- $this->_adodbLibrary = Prado::getPathOfNamespace($path);
- }
-
- public function importAdodbLibrary()
- {
- if(!self::$_hasImported)
- {
- require($this->getAdodbLibrary().'/adodb-exceptions.inc.php');
- require($this->getAdodbLibrary().'/adodb.inc.php');
- self::$_hasImported = true;
- }
- }
-
- /**
- * Sets the cache directory for ADODB (in adodb it is
- * called to $ADODB_CACHE_DIR)
- * @param string the cache directory for adodb module
- */
- public function setCacheDir($value)
- {
- $this->_cachedir=$value;
- }
-
- /**
- * @return string fetch mode of query data
- */
- public function getFetchMode()
- {
- return $this->_fetchMode;
- }
-
- /**
- * Sets the fetch mode of query data: Associative, Numeric, Both, Default (default)
- * @param string the fetch mode of query data
- */
- public function setFetchMode($value)
- {
- $value = strtolower($value);
- if($value===self::FETCH_ASSOCIATIVE || $value===self::FETCH_NUMERIC
- || $value===self::FETCH_BOTH)
- $this->_fetchMode=$value;
- else
- $this->_fetchMode=self::FETCH_DEFAULT;
- }
-
-}
-
-/**
- * TAdodbConnection is a wrapper class of the ADODB ADOConnection class.
- * For more information about the ADODB library, see {@link http://adodb.sourceforge.net/}.
- *
- * You can call any method implemented in ADOConnection class via TAdodbConnection,
- * such as TAdodbConnection::FetchRow(), and so on. The method calls
- * will be passed to ADOConnection class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: $ $Date: $
- * @package System.DataAccess
- * @since 3.0
- */
-class TAdodbConnection extends TDbConnection
-{
- private $_connection;
-
- /**
- * Constructor, initialize a new Adodb connection.
- * @param string|TAdodbProvider DSN connection string or a TAdodbProvider
- */
- public function __construct($provider=null)
- {
- parent::__construct($provider);
- if(is_string($provider))
- $this->initProvider($provider);
- }
-
- /**
- * Create a new provider for this connection using the DSN string.
- * @param string DSN connection string.
- */
- protected function initProvider($connectionString)
- {
- $provider = new TAdodbProvider();
- $provider->setConnectionString($connectionString);
- $this->setProvider($provider);
- }
-
- /**
- * Cleanup work before serializing.
- * This is a PHP defined magic method.
- * @return array the names of instance-variables to serialize.
- */
- public function __sleep()
- {
- //close any open connections before serializing.
- $this->close();
- $this->_connection = null;
- return array_keys(get_object_vars($this));
- }
-
- /**
- * This method will be automatically called when unserialization happens.
- * This is a PHP defined magic method.
- */
- public function __wakeup()
- {
- }
-
- /**
- * PHP magic function.
- * This method will pass all method calls to ADOConnection class
- * provided in the ADODB library.
- * @param mixed method name
- * @param mixed method call parameters
- * @param mixed return value of the method call
- */
- public function __call($method, $params)
- {
- if(is_null($this->_connection) || !$this->_connection->IsConnected())
- $this->open();
- return call_user_func_array(array($this->_connection,$method),$params);
- }
-
- public function getIsClosed()
- {
- return is_null($this->_connection) || !$this->_connection->IsConnected();
- }
-
- public function prepare($statement)
- {
- return $this->_connection->prepare($statement);
- }
-
- public function execute($sql, $parameters=array())
- {
- return $this->_connection->execute($sql, $parameters);
- }
-
- /**
- * Start a transaction on this connection.
- */
- public function beginTransaction()
- {
- return $this->_connection->StartTrans();
- }
-
- /**
- * Finish and cleanup transactions.
- */
- public function completeTransaction()
- {
- return $this->connection->CompleteTrans();
- }
-
- /**
- * Fail the current transaction.
- */
- public function failTransaction()
- {
- return $this->connection->FailTrans();
- }
-
- /**
- * @return boolean true if transaction has failed.
- */
- public function getHasTransactionFailed()
- {
- return $this->connection->HasFailedTrans();
- }
-
- public function commit()
- {
- return $this->connection->CommitTrans();
- }
-
-
- public function rollback()
- {
- return $this->connection->RollbackTrans();
- }
-
- /**
- * Establishes a DB connection.
- * An ADOConnection instance will be created if none.
- */
- public function open()
- {
- if($this->getIsClosed())
- {
- $provider = $this->getProvider();
- $provider->importAdodbLibrary();
- if(strlen($provider->getConnectionString()) < 1)
- {
- if(strlen($provider->getDriver()) < 1)
- throw new TDbConnectionException('db_driver_required');
-
- $this->_connection=ADONewConnection($provider->getDriver());
- $this->initConnection();
- }
- else
- $this->_connection=ADONewConnection($provider->getConnectionString());
- $this->initFetchMode();
- $this->initCacheDir();
- }
- return $this->_connection->IsConnected();
- }
-
- /**
- * Complete the database connection.
- */
- protected function initConnection()
- {
- $provider = $this->getProvider();
-
- if($provider->getUsePersistentConnection())
- {
- $this->_connection->PConnect($provider->getHost(),
- $provider->getUsername(),$provider->getPassword(),
- $provider->getDatabase());
- }
- else
- {
- $this->_connection->Connect($provider->getHost(),
- $provider->getUsername(),$provider->getPassword(),
- $provider->getDatabase());
- }
- }
-
- /**
- * Initialize the fetch mode.
- */
- protected function initFetchMode()
- {
- global $ADODB_FETCH_MODE;
- $provider = $this->getProvider();
- if($provider->getFetchMode()===TAdodbProvider::FETCH_ASSOCIATIVE)
- $ADODB_FETCH_MODE=ADODB_FETCH_ASSOC;
- else if($provider->fetchMode===TAdodbProvider::FETCH_NUMERIC)
- $ADODB_FETCH_MODE=ADODB_FETCH_NUM;
- else if($provider->fetchMode===TAdodbProvider::FETCH_BOTH)
- $ADODB_FETCH_MODE=ADODB_FETCH_BOTH;
- else
- $ADODB_FETCH_MODE=ADODB_FETCH_DEFAULT;
- }
-
- /**
- * Initialize the cache directory.
- */
- protected function initCacheDir()
- {
- global $ADODB_CACHE_DIR;
- $provider = $this->getProvider();
- if($provider->getCacheDir()!=='')
- $ADODB_CACHE_DIR=$provider->getCacheDir();
- }
-
- /**
- * Closes the DB connection.
- * You are not required to call this method as PHP will automatically
- * to close any DB connections when exiting a script.
- */
- public function close()
- {
- if(!is_null($this->_connection) && $this->_connection->IsConnected())
- $this->_connection->Close();
- }
-
- /**
- * @param string quote a string to be sent to the database.
- * @param boolean if true it ensure that the variable is not quoted twice,
- * once by quote and once by the magic_quotes_gpc.
- * @return string database specified quoted string
- */
- public function quote($string, $magic_quotes=false)
- {
- return $this->_connection->qstr($string, $magic_quotes);
- }
-
-}
-
-?>
\ No newline at end of file diff --git a/framework/DataAccess/TCreoleProvider.php b/framework/DataAccess/TCreoleProvider.php deleted file mode 100644 index f4ccd4c2..00000000 --- a/framework/DataAccess/TCreoleProvider.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php
-
-Prado::using('System.DataAccess.TDatabaseProvider');
-
-Prado::using('System.DataAccess.creole.*');
-
-class TCreoleProvider extends TDatabaseProvider
-{
- private $_connection = null;
-
- public function getConnection()
- {
- if(is_null($this->_connection))
- $this->_connection = new TCreoleConnection($this);
- return $this->_connection;
- }
-
- public function getConnectionString()
- {
- if(strlen(parent::getConnectionString()) > 0)
- return parent::getConnectionString();
- else
- return $this->generateConnectionString();
- }
-
- protected function generateConnectionString()
- {
- $driver = $this->getDriver();
- $user = $this->getUsername();
- $pass = $this->getPassword();
- $host = $this->getHost();
- $database = $this->getDatabase();
-
- $pass = strlen($pass) > 0 ? ':'.$pass : '';
- $username_password = strlen($user) > 0 ? $user.$pass.'@' : '';
- $database = strlen($database) > 0 ? '/'.$database : '';
-
- return "{$driver}://{$username_password}{$host}{$database}";
- }
-}
-
-class TCreoleConnection extends TDbConnection
-{
- private $_connection = null;
-
- protected function beginDbTransaction()
- {
- }
-
- /**
- * Closes the connection to the database.
- */
- public function close()
- {
- $this->_connection->close();
- }
-
- public function prepare($statement)
- {
- return $this->_connection->prepareStatement($statement);
- }
-
- //public function execute($sql,
-
- /**
- * Opens a database connection with settings provided in the ConnectionString.
- */
- public function open()
- {
- if(is_null($this->_connection))
- {
- $connectionString = $this->getProvider()->getConnectionString();
- if(strlen($connectionString) < 1 || strcmp($connectionString,'://') === 0)
- throw new TDbConnectionException('db_driver_required');
- $class = 'System.DataAccess.creole.creole.Creole';
- $creole = Prado::createComponent($class);
- $this->_connection = $creole->getConnection($connectionString);
- }
- return $this->_connection;
- }
-}
-
-?>
\ No newline at end of file diff --git a/framework/DataAccess/TDatabaseProvider.php b/framework/DataAccess/TDatabaseProvider.php deleted file mode 100644 index ac637d83..00000000 --- a/framework/DataAccess/TDatabaseProvider.php +++ /dev/null @@ -1,258 +0,0 @@ -<?php
-
-/**
- * Database access module.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: $ $Date: $
- * @package System.DataAccess
- * @since 3.0
- */
-abstract class TDatabaseProvider extends TModule
-{
- private $_connectionString = '';
- private $_database='';
- private $_driver='';
- private $_host='';
- private $_username='';
- private $_password='';
- private $_persistent=true;
-
- /**
- * @param string used to open the connection
- */
- public function setConnectionString($value)
- {
- $this->_connectionString = $value;
- }
-
- /**
- * @return string used to open the connection
- */
- public function getConnectionString()
- {
- return $this->_connectionString;
- }
-
- /**
- * @return string the DB driver (mysql, sqlite, etc.)
- */
- public function getDriver()
- {
- return $this->_driver;
- }
-
- /**
- * Sets the DB driver (mysql, sqlite, etc.)
- * @param string the DB driver
- */
- public function setDriver($value)
- {
- $this->_driver=$value;
- }
-
- /**
- * @return string the DB host name/IP (and port number) in the format "host[:port]"
- */
- public function getHost()
- {
- return $this->_host;
- }
-
- /**
- * Sets the DB host name/IP (and port number) in the format "host[:port]"
- * @param string the DB host
- */
- public function setHost($value)
- {
- $this->_host=$value;
- }
-
- /**
- * @return string the DB username
- */
- public function getUsername()
- {
- return $this->_username;
- }
-
- /**
- * Sets the DB username
- * @param string the DB username
- */
- public function setUsername($value)
- {
- $this->_username=$value;
- }
-
- /**
- * @return string the DB password
- */
- public function getPassword()
- {
- return $this->_password;
- }
-
- /**
- * Sets the DB password
- * @param string the DB password
- */
- public function setPassword($value)
- {
- $this->_password=$value;
- }
-
- /**
- * @return string the database name
- */
- public function getDatabase()
- {
- return $this->_database;
- }
-
- /**
- * Sets the database name
- * @param string the database name
- */
- public function setDatabase($value)
- {
- $this->_database=$value;
- }
-
- /**
- * @return boolean whether the DB connection is persistent
- */
- public function getUsePersistentConnection()
- {
- return $this->_persistent;
- }
-
- /**
- * Sets whether the DB connection should be persistent
- * @param boolean whether the DB connection should be persistent
- */
- public function setUsePersistentConnection($value)
- {
- $this->_persistent=$value;
- }
-
- /**
- * @return TDbConnection a database connection
- */
- public abstract function getConnection();
-}
-
-/**
- * A connection (session) with a specific database. SQL statements are executed
- * and results are returned within the context of a connection.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: $ $Date: $
- * @package System.DataAccess
- * @since 3.0
- */
-interface IDbConnection
-{
- /**
- * Closes the connection to the database.
- */
- public function close();
-
- /**
- * @return boolean retrieves whether this connection has been closed.
- */
- public function getIsClosed();
-
- /**
- * Opens a database connection with settings provided in the ConnectionString.
- */
- public function open();
-
- /**
- * @return string creates a prepared statement for sending parameterized
- * SQL statements to the database.
- */
- public function prepare($statement);
-
- /**
- * Executes the SQL statement which may be any kind of SQL statement,
- * including prepared statements.
- * @param string sql query statement
- * @param array subsititution parameters
- * @return mixed result set
- */
- public function execute($sql, $parameters=array());
-
- /**
- * Start a transaction on this connection.
- */
- public function beginTransaction();
-
- /**
- * Finish and cleanup transactions.
- */
- public function completeTransaction();
-
- /**
- * Fail the current transaction.
- */
- public function failTransaction();
-
- /**
- * @return boolean true if transaction has failed.
- */
- public function getHasTransactionFailed();
-
- /**
- * Makes all changes made since the previous commit/rollback permanent and
- * releases any database locks.
- */
- public function commit();
-
- /**
- * Undoes all changes made in the current transaction and releases any
- * database locks
- */
- public function rollback();
-
- /**
- * @param string quote a string to be sent to the database.
- * @param boolean if true it ensure that the variable is not quoted twice,
- * once by quote and once by the magic_quotes_gpc.
- * @return string database specified quoted string
- */
- public function quote($string, $magic_quotes=false);
-
-}
-
-/**
- * Performs the connection to the database using a TDatabaseProvider,
- * executes SQL statements.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: $ $Date: $
- * @package System.DataAccess
- * @since 3.0
- */
-abstract class TDbConnection extends TComponent implements IDbConnection
-{
- private $_provider;
-
- public function __construct($provider)
- {
- if($provider instanceof TDatabaseProvider)
- $this->setProvider($provider);
- }
-
- public function setProvider($provider)
- {
- $this->_provider = $provider;
- }
-
- public function getProvider()
- {
- return $this->_provider;
- }
-}
-
-?>
\ No newline at end of file diff --git a/framework/DataAccess/TSQLMap.php b/framework/DataAccess/TSQLMap.php deleted file mode 100644 index bc9ba1fb..00000000 --- a/framework/DataAccess/TSQLMap.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php
-
-class TSQLMap extends TModule
-{
- private $_SQLMapLibrary='';
- private $_configFile;
- private $_sqlmap;
- private $_provider;
-
- /**
- * File extension of external configuration file
- */
- const CONFIG_FILE_EXT='.config';
-
- public function getSQLMapLibrary()
- {
- if(strlen($this->_SQLMapLibrary) < 1)
- return dirname(__FILE__).'/SQLMap';
- else
- return $this->_SQLMapLibrary;
- }
-
- public function setSQLMapLibrary($path)
- {
- $this->_SQLMapLibrary = Prado::getPathOfNamespace($path);
- }
-
- /**
- * @return string external configuration file. Defaults to null.
- */
- public function getConfigFile()
- {
- return $this->_configFile;
- }
-
- public function init($xml)
- {
- $config = $xml->getElementByTagName('provider');
- $class = $config->getAttribute('class');
- $provider = Prado::createComponent($class);
- $datasource = $config->getElementByTagName('datasource');
- $properties = $datasource->getAttributes();
- foreach($properties as $name=>$value)
- $provider->setSubproperty($name,$value);
- $this->_provider = $provider;
- }
-
- /**
- * @param string external configuration file in namespace format. The file
- * must be suffixed with '.xml'.
- * @throws TInvalidDataValueException if the file is invalid.
- */
- public function setConfigFile($value)
- {
- if(($this->_configFile=Prado::getPathOfNamespace(
- $value,self::CONFIG_FILE_EXT))===null)
- throw new TConfigurationException('sqlmap_configfile_invalid',$value);
- }
-
- protected function configure($configFile)
- {
- include($this->getSQLMapLibrary().'/TSqlMapper.php');
- $builder = new TDomSqlMapBuilder();
- $this->_sqlmap = $builder->configure($configFile);
- if(!is_null($this->_provider))
- $this->_sqlmap->setDataProvider($this->_provider);
- }
-
- public function getClient()
- {
- if(is_null($this->_sqlmap))
- $this->configure($this->getConfigFile());
- return $this->_sqlmap;
- }
-}
-
-?>
\ No newline at end of file diff --git a/framework/Security/TMembershipManager.php b/framework/Security/TMembershipManager.php deleted file mode 100644 index a3c1ae55..00000000 --- a/framework/Security/TMembershipManager.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php
-
-
-interface IMembershipUser
-{
- public function getEmail();
- public function setEmail($value);
- public function getCreationDate();
- public function setCreationDate($value);
- public function getIsApproved();
- public function setIsApproved($value);
- public function getIsLockedOut();
- public function setIsLockedOut($value);
- public function getIsOnline();
- public function setIsOnline($value);
- public function getLastLoginDate();
- public function setLastLoginDate($value);
- public function getLastActivityDate();
- public function setLastActivityDate($value);
- public function getLastLockoutDate();
- public function setLastLockoutDate($value);
- public function getLastPasswordChangedDate();
- public function setLastPasswordChangedDate($value);
- public function getPasswordQuestion();
- public function setPasswordQuestion($value);
- public function getComment();
- public function setComment($value);
-
- public function update();
- public function fetchPassword($passwordAnswer=null);
- public function changePassword($username,$oldPassword,$newPassword);
- public function changePasswordQuestionAndAnswer($username,$password,$newQuestion,$newAnswer);
- public function resetPassword($passwordAnswer=null);
-}
-
-interface IUserManager
-{
-}
-
-
-
-class TMembershipUser extends TUser implements IMembershipUser
-{
-}
-
-interface IRoleProvider
-{
- public function addUsersToRoles($users,$roles);
- public function removeUsersFromRoles($users,$roles);
- public function createRole($role);
- public function deleteRole($role,$throwOnPopulatedRole);
- public function getAllRoles();
- public function getRolesForUser($user);
- public function getUsersInRole($role);
- public function isUserInRole($user,$role);
- public function roleExists($role);
-}
-
-interface IMembershipProvider
-{
- public function getApplicationName();
- public function setApplicationName($value);
-
- public function createUser($username,$password,$email,$question,$answer,$isApproved); // return $key or error status
- public function deleteUser($username,$deleteAllRelatedData);
- public function updateUser($user);
-
- public function changePassword($username,$oldPassword,$newPassword);
- public function changePasswordQuestionAndAnswer($username,$password,$newQuestion,$newAnswer);
-
- public function encryptPassword($password);
- public function decryptPassword($encodedPassword);
- public function encodePassword($password,$format,$salt);
- public function decodePassword($password,$format);
- public function generateSalt();
-
- public function findUsersByEmail($email,$pageIndex,$pageSize);
- public function findUsersByName($email,$pageIndex,$pageSize);
-
- public function getAllUsers($pageIndex,$pageSize);
- public function getUser($username,$userkey,$userIsOnline);
- public function getNumberOfUsersOnline(); //???
- public function getUsernameByEmail($email);
- public function getPassword($username,$answer);
- public function resetPassword($username,$answer);
- public function unlockUser($username);
-
- public function validateUser($username,$password);
-
- public function onValidatingPassword($param);
-
- public function getEnablePasswordReset();
- public function setEnablePasswordReset($value);
- public function getEnablePasswordRetrieval();
- public function setEnablePasswordRetrieval($value);
- public function getMaxInvalidPasswordAttempts();
- public function setMaxInvalidPasswordAttempts($value);
- public function getUsernameFormat();
- public function setUsernameFormat($value);
- public function getPasswordFormat();
- public function setPasswordFormat($value);
- public function getRequiresQuestionAndAnswer();
- public function setRequiresQuestionAndAnswer($value);
- public function getRequiresUniqueEmail();
- public function setRequiresUniqueEmail($value);
-}
-
-
-?>
\ No newline at end of file |