From: <tr...@us...> - 2011-10-15 18:33:22
|
Revision: 7889 http://xoops.svn.sourceforge.net/xoops/?rev=7889&view=rev Author: trabis Date: 2011-10-15 18:33:14 +0000 (Sat, 15 Oct 2011) Log Message: ----------- refactoring class/cache Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/browse.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ads.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ldap.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_provisionning.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_xoops.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/authfactory.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/file.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/memcache.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/model.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xcache.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xoopscache.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/file/file.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/file/xoopsfile.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/preload.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/utility/xoopsutility.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/group.php Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/cachemodel.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/browse.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/browse.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/browse.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -29,7 +29,6 @@ include_once XOOPS_ROOT_PATH . DS . 'include' . DS . 'version.php'; require_once XOOPS_ROOT_PATH . DS . 'class' . DS . 'xoopsload.php'; -XoopsLoad::load('xos_kernel_Xoops2'); $xoops = new xos_kernel_Xoops2(); $xoops->pathTranslation(); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,7 +11,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> @@ -22,7 +22,7 @@ /** * - * @package kernel + * @package class * @subpackage auth * @description Authentification base class * @author Pierre-Eric MENUET <pe...@fr...> @@ -30,35 +30,48 @@ */ class XoopsAuth { - var $_dao; - var $_errors; + /** + * @var XoopsDatase|null + */ + protected $_dao; /** + * @var array + */ + protected $_errors; + + /** + * @var string + */ + protected $auth_method; + + /** * Authentication Service constructor + * + * @param XoopsDatabase|null $dao */ - function XoopsAuth(&$dao) + public function __construct($dao) { $this->_dao = $dao; } /** + * need to be write in the derived class * - * @abstract need to be write in the dervied class + * @return bool */ - function authenticate() + public function authenticate() { $authenticated = false; - return $authenticated; } /** - * add an error - * - * @param string $value error to add - * @access public + * @param int $err_no + * @param string $err_str + * @return void */ - function setErrors($err_no, $err_str) + public function setErrors($err_no, $err_str) { $this->_errors[$err_no] = trim($err_str); } @@ -69,7 +82,7 @@ * @return array an array of errors * @access public */ - function getErrors() + public function getErrors() { return $this->_errors; } @@ -80,11 +93,10 @@ * @return string html listing the errors * @access public */ - function getHtmlErrors() + public function getHtmlErrors() { - global $xoopsConfig; - $ret = '<br>'; - if ($xoopsConfig['debug_mode'] == 1 || $xoopsConfig['debug_mode'] == 2) { + $ret = '<br />'; + if ($GLOBALS['xoopsConfig']['debug_mode'] == 1 || $GLOBALS['xoopsConfig']['debug_mode'] == 2) { if (!empty($this->_errors)) { foreach ($this->_errors as $errstr) { $ret .= $errstr . '<br/>'; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ads.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ads.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ads.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,7 +11,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> @@ -21,45 +21,38 @@ defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** + * XoopsAuthAds * - * @package kernel + * @package class * @subpackage auth * @description Authentification class for Active Directory * @author Pierre-Eric MENUET <pe...@fr...> * @copyright copyright (c) 2000-2003 XOOPS.org */ -include_once $GLOBALS['xoops']->path('class/auth/auth_ldap.php'); - -/** - * XoopsAuthAds - * - * @package - * @author John - * @copyright Copyright (c) 2009 - * @version $Id$ - * @access public - */ class XoopsAuthAds extends XoopsAuthLdap { /** * Authentication Service constructor + * + * @param XoopsDatabase|null $dao + * @return void */ - function XoopsAuthAds(&$dao) + public function _construct(XoopsDatabase $dao = null) { - parent::XoopsAuthLdap($dao); + parent::__construct($dao); } /** * Authenticate user again LDAP directory (Bind) * 2 options : - * Authenticate directly with uname in the DN - * Authenticate with manager, search the dn + * Authenticate directly with uname in the DN + * Authenticate with manager, search the dn * * @param string $uname Username * @param string $pwd Password * @return bool */ - function authenticate($uname, $pwd = null) + public function authenticate($uname, $pwd = null) { $authenticated = false; if (!extension_loaded('ldap')) { @@ -81,7 +74,7 @@ if (!$userUPN) { return false; } - // We bind as user to test the credentials + // We bind as user to test the credentials $authenticated = ldap_bind($this->_ds, $userUPN, $this->cp1252_to_utf8(stripslashes($pwd))); if ($authenticated) { // We load the Xoops User database @@ -107,13 +100,14 @@ * looks like an email address. Very useful for logging on especially in * a large Forest. Note UPN must be unique in the forest. * - * @return userDN or false + * @param $uname + * @return string userDN */ - function getUPN($uname) + public function getUPN($uname) { $userDN = $uname . '@' . $this->ldap_domain_name; return $userDN; } -} // end class +} ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ldap.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ldap.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_ldap.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,7 +11,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> @@ -20,140 +20,193 @@ defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** + * XoopsAuthLdap * - * @package kernel + * @package class * @subpackage auth * @description Authentification class for standard LDAP Server V2 or V3 * @author Pierre-Eric MENUET <pe...@fr...> * @copyright copyright (c) 2000-2003 XOOPS.org */ -if (file_exists($file = $GLOBALS['xoops']->path('class/auth/auth_provisionning.php'))) { - include_once $file; -} - -if (!class_exists('XoopsAuthProvisionning')) { - trigger_error('Required class XoopsAuthProvisionning was not found at line ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING); - return false; -} - -/** - * XoopsAuthLdap - * - * @package - * @author John - * @copyright Copyright (c) 2009 - * @version $Id$ - * @access public - */ class XoopsAuthLdap extends XoopsAuth { - var $cp1252_map = array("\xc2\x80" => "\xe2\x82\xac" , /** - * EURO SIGN + public $cp1252_map = array( + "\xc2\x80" => "\xe2\x82\xac", /** + * EURO SIGN + */ + "\xc2\x82" => "\xe2\x80\x9a", /** + * SINGLE LOW-9 QUOTATION MARK + */ + "\xc2\x83" => "\xc6\x92", /** + * LATIN SMALL LETTER F WITH HOOK + */ + "\xc2\x84" => "\xe2\x80\x9e", /** + * DOUBLE LOW-9 QUOTATION MARK + */ + "\xc2\x85" => "\xe2\x80\xa6", /** + * HORIZONTAL ELLIPSIS + */ + "\xc2\x86" => "\xe2\x80\xa0", /** + * DAGGER + */ + "\xc2\x87" => "\xe2\x80\xa1", /** + * DOUBLE DAGGER + */ + "\xc2\x88" => "\xcb\x86", /** + * MODIFIER LETTER CIRCUMFLEX ACCENT + */ + "\xc2\x89" => "\xe2\x80\xb0", /** + * PER MILLE SIGN + */ + "\xc2\x8a" => "\xc5\xa0", /** + * LATIN CAPITAL LETTER S WITH CARON + */ + "\xc2\x8b" => "\xe2\x80\xb9", /** + * SINGLE LEFT-POINTING ANGLE QUOTATION + */ + "\xc2\x8c" => "\xc5\x92", /** + * LATIN CAPITAL LIGATURE OE + */ + "\xc2\x8e" => "\xc5\xbd", /** + * LATIN CAPITAL LETTER Z WITH CARON + */ + "\xc2\x91" => "\xe2\x80\x98", /** + * LEFT SINGLE QUOTATION MARK + */ + "\xc2\x92" => "\xe2\x80\x99", /** + * RIGHT SINGLE QUOTATION MARK + */ + "\xc2\x93" => "\xe2\x80\x9c", /** + * LEFT DOUBLE QUOTATION MARK + */ + "\xc2\x94" => "\xe2\x80\x9d", /** + * RIGHT DOUBLE QUOTATION MARK + */ + "\xc2\x95" => "\xe2\x80\xa2", /** + * BULLET + */ + "\xc2\x96" => "\xe2\x80\x93", /** + * EN DASH + */ + "\xc2\x97" => "\xe2\x80\x94", /** + * EM DASH + */ + "\xc2\x98" => "\xcb\x9c", /** + * SMALL TILDE + */ + "\xc2\x99" => "\xe2\x84\xa2", /** + * TRADE MARK SIGN + */ + "\xc2\x9a" => "\xc5\xa1", /** + * LATIN SMALL LETTER S WITH CARON + */ + "\xc2\x9b" => "\xe2\x80\xba", /** + * SINGLE RIGHT-POINTING ANGLE QUOTATION + */ + "\xc2\x9c" => "\xc5\x93", /** + * LATIN SMALL LIGATURE OE + */ + "\xc2\x9e" => "\xc5\xbe", /** + * LATIN SMALL LETTER Z WITH CARON + */ + "\xc2\x9f" => "\xc5\xb8" + ); + /** + * LATIN CAPITAL LETTER Y WITH DIAERESIS */ - "\xc2\x82" => "\xe2\x80\x9a" , /** - * SINGLE LOW-9 QUOTATION MARK + + /** + * @var */ - "\xc2\x83" => "\xc6\x92" , /** - * LATIN SMALL LETTER F WITH HOOK + public $ldap_server; + + /** + * @var string */ - "\xc2\x84" => "\xe2\x80\x9e" , /** - * DOUBLE LOW-9 QUOTATION MARK + + public $ldap_port = '389'; + /** + * @var string */ - "\xc2\x85" => "\xe2\x80\xa6" , /** - * HORIZONTAL ELLIPSIS + public $ldap_version = '3'; + + /** + * @var */ - "\xc2\x86" => "\xe2\x80\xa0" , /** - * DAGGER + public $ldap_base_dn; + + /** + * @var */ - "\xc2\x87" => "\xe2\x80\xa1" , /** - * DOUBLE DAGGER + public $ldap_loginname_asdn; + + /** + * @var */ - "\xc2\x88" => "\xcb\x86" , /** - * MODIFIER LETTER CIRCUMFLEX ACCENT + public $ldap_loginldap_attr; + + /** + * @var */ - "\xc2\x89" => "\xe2\x80\xb0" , /** - * PER MILLE SIGN + public $ldap_mail_attr; + + /** + * @var */ - "\xc2\x8a" => "\xc5\xa0" , /** - * LATIN CAPITAL LETTER S WITH CARON + public $ldap_name_attr; + + /** + * @var */ - "\xc2\x8b" => "\xe2\x80\xb9" , /** - * SINGLE LEFT-POINTING ANGLE QUOTATION + public $ldap_surname_attr; + + /** + * @var */ - "\xc2\x8c" => "\xc5\x92" , /** - * LATIN CAPITAL LIGATURE OE + public $ldap_givenname_attr; + + /** + * @var */ - "\xc2\x8e" => "\xc5\xbd" , /** - * LATIN CAPITAL LETTER Z WITH CARON + public $ldap_manager_dn; + + /** + * @var */ - "\xc2\x91" => "\xe2\x80\x98" , /** - * LEFT SINGLE QUOTATION MARK + public $ldap_manager_pass; + + /** + * @var */ - "\xc2\x92" => "\xe2\x80\x99" , /** - * RIGHT SINGLE QUOTATION MARK + public $_ds; + + /** + * @var */ - "\xc2\x93" => "\xe2\x80\x9c" , /** - * LEFT DOUBLE QUOTATION MARK + public $ldap_use_TLS; + + /** + * @var */ - "\xc2\x94" => "\xe2\x80\x9d" , /** - * RIGHT DOUBLE QUOTATION MARK - */ - "\xc2\x95" => "\xe2\x80\xa2" , /** - * BULLET - */ - "\xc2\x96" => "\xe2\x80\x93" , /** - * EN DASH - */ - "\xc2\x97" => "\xe2\x80\x94" , /** - * EM DASH - */ - "\xc2\x98" => "\xcb\x9c" , /** - * SMALL TILDE - */ - "\xc2\x99" => "\xe2\x84\xa2" , /** - * TRADE MARK SIGN - */ - "\xc2\x9a" => "\xc5\xa1" , /** - * LATIN SMALL LETTER S WITH CARON - */ - "\xc2\x9b" => "\xe2\x80\xba" , /** - * SINGLE RIGHT-POINTING ANGLE QUOTATION - */ - "\xc2\x9c" => "\xc5\x93" , /** - * LATIN SMALL LIGATURE OE - */ - "\xc2\x9e" => "\xc5\xbe" , /** - * LATIN SMALL LETTER Z WITH CARON - */ - "\xc2\x9f" => "\xc5\xb8"); + public $ldap_domain_name; + /** - * LATIN CAPITAL LETTER Y WITH DIAERESIS + * @var */ + public $ldap_filter_person; - var $ldap_server; - var $ldap_port = '389'; - var $ldap_version = '3'; - var $ldap_base_dn; - var $ldap_loginname_asdn; - var $ldap_loginldap_attr; - var $ldap_mail_attr; - var $ldap_name_attr; - var $ldap_surname_attr; - var $ldap_givenname_attr; - var $ldap_manager_dn; - var $ldap_manager_pass; - var $_ds; - /** * Authentication Service constructor + * + * @param XoopsDatabase|null $dao */ - function XoopsAuthLdap(&$dao) + public function __construct(XoopsDatabase $dao = null) { $this->_dao = $dao; // The config handler object allows us to look at the configuration options that are stored in the database + /* @var $config_handler XoopsConfigHandler */ $config_handler = xoops_gethandler('config'); $config = $config_handler->getConfigsByCat(XOOPS_CONF_AUTH); - $confcount = count($config); foreach ($config as $key => $val) { $this->$key = $val; } @@ -162,10 +215,10 @@ /** * XoopsAuthLdap::cp1252_to_utf8() * - * @param mixed $str - * @return + * @param string $str + * @return string */ - function cp1252_to_utf8($str) + public function cp1252_to_utf8($str) { return strtr(utf8_encode($str), $this->cp1252_map); } @@ -173,14 +226,14 @@ /** * Authenticate user again LDAP directory (Bind) * 2 options : - * Authenticate directly with uname in the DN - * Authenticate with manager, search the dn + * Authenticate directly with uname in the DN + * Authenticate with manager, search the dn * * @param string $uname Username * @param string $pwd Password * @return bool */ - function authenticate($uname, $pwd = null) + public function authenticate($uname, $pwd = null) { $authenticated = false; if (!extension_loaded('ldap')) { @@ -201,7 +254,7 @@ if (!$userDN) { return false; } - // We bind as user to test the credentials + // We bind as user to test the credentials $authenticated = ldap_bind($this->_ds, $userDN, stripslashes($pwd)); if ($authenticated) { // We load the Xoops User database @@ -219,9 +272,10 @@ /** * Compose the user DN with the configuration. * - * @return userDN or false + * @param $uname + * @return bool|string userDN or false */ - function getUserDN($uname) + public function getUserDN($uname) { $userDN = false; if (!$this->ldap_loginname_asdn) { @@ -247,11 +301,11 @@ /** * Load user from XOOPS Database * - * @return XoopsUser object + * @param string $uname + * @return mixed|string */ - function getFilter($uname) + public function getFilter($uname) { - $filter = ''; if ($this->ldap_filter_person != '') { $filter = str_replace('@@loginname@@', $uname, $this->ldap_filter_person); } else { @@ -263,13 +317,14 @@ /** * XoopsAuthLdap::loadXoopsUser() * - * @param mixed $userdn - * @param mixed $uname - * @param mixed $pwd - * @return + * @param string $userdn + * @param string $uname + * @param string $pwd + * @return bool|XoopsUser */ - function loadXoopsUser($userdn, $uname, $pwd = null) + public function loadXoopsUser($userdn, $uname, $pwd = null) { + $xoopsUser = false; $provisHandler = XoopsAuthProvisionning::getInstance($this); $sr = ldap_read($this->_ds, $userdn, '(objectclass=*)'); $entries = ldap_get_entries($this->_ds, $sr); @@ -280,6 +335,6 @@ } return $xoopsUser; } -} // end class +} ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_provisionning.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_provisionning.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_provisionning.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,34 +11,59 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** + * provide synchronisation method to Xoops User Database * - * @package kernel + * @package class * @subpackage auth * @description Authentification provisionning class. This class is responsible to - * provide synchronisation method to Xoops User Database * @author Pierre-Eric MENUET <pe...@fr...> * @copyright copyright (c) 2000-2003 XOOPS.org */ class XoopsAuthProvisionning { - var $_auth_instance; + /** + * @var XoopsAuth + */ + protected $_auth_instance; /** + * @var bool + */ + public $ldap_provisionning; + + /** + * @var bool + */ + public $ldap_provisionning_upd; + + /** + * var array + */ + public $ldap_field_mapping; + + /** + * @var array + */ + public $ldap_provisionning_group; + + /** * XoopsAuthProvisionning::getInstance() * - * @param mixed $auth_instance - * @return + * @static + * @param XoopsAuth $auth_instance + * @return XoopsAuthProvisionning */ - function getInstance(&$auth_instance) + static function getInstance(XoopsAuth &$auth_instance) { static $provis_instance; if (!isset($provis_instance)) { @@ -49,10 +74,13 @@ /** * Authentication Service constructor + * + * @param XoopsAuth $auth_instance */ - function XoopsAuthProvisionning(&$auth_instance) + public function __construct(XoopsAuth &$auth_instance) { $this->_auth_instance = $auth_instance; + /* @var $config_handler XoopsConfigHandler */ $config_handler = xoops_gethandler('config'); $config = $config_handler->getConfigsByCat(XOOPS_CONF_AUTH); foreach ($config as $key => $val) { @@ -68,10 +96,12 @@ /** * Return a Xoops User Object * - * @return XoopsUser or false + * @param $uname + * @return bool|XoopsUser */ - function getXoopsUser($uname) + public function getXoopsUser($uname) { + /* @var $member_handler XoopsMemberHandler */ $member_handler = xoops_gethandler('member'); $criteria = new Criteria('uname', $uname); $getuser = $member_handler->getUsers($criteria); @@ -85,9 +115,12 @@ /** * Launch the synchronisation process * - * @return bool + * @param $datas + * @param $uname + * @param null $pwd + * @return bool|XoopsUser */ - function sync($datas, $uname, $pwd = null) + public function sync($datas, $uname, $pwd = null) { $xoopsUser = $this->getXoopsUser($uname); if (!$xoopsUser) { // Xoops User Database not exists @@ -109,9 +142,16 @@ * * @return bool */ - function add($datas, $uname, $pwd = null) + /** + * @param array $datas + * @param string $uname + * @param string $pwd + * @return bool|XoopsUser + */ + public function add($datas, $uname, $pwd = null) { $ret = false; + /* @var $member_handler XoopsMemberHandler */ $member_handler = xoops_gethandler('member'); // Create XOOPS Database User $newuser = $member_handler->createUser(); @@ -126,11 +166,12 @@ $tab_mapping = explode('|', $this->ldap_field_mapping); foreach ($tab_mapping as $mapping) { $fields = explode('=', trim($mapping)); - if ($fields[0] && $fields[1]) + if ($fields[0] && $fields[1]) { $newuser->setVar(trim($fields[0]), utf8_decode($datas[trim($fields[1])][0])); + } } if ($member_handler->insertUser($newuser)) { - foreach($this->ldap_provisionning_group as $groupid) { + foreach ($this->ldap_provisionning_group as $groupid) { $member_handler->addUserToGroup($groupid, $newuser->getVar('uid')); } $newuser->unsetNew(); @@ -144,11 +185,16 @@ /** * Modify user information * - * @return bool + * @param XoopsUser $xoopsUser + * @param array $datas + * @param string $uname + * @param string $pwd + * @return bool|XoopsUser */ - function change(&$xoopsUser, $datas, $uname, $pwd = null) + public function change(&$xoopsUser, $datas, $uname, $pwd = null) { $ret = false; + /* @var $member_handler XoopsMemberHandler */ $member_handler = xoops_gethandler('member'); $xoopsUser->setVar('pass', md5(stripslashes($pwd))); $tab_mapping = explode('|', $this->ldap_field_mapping); @@ -171,7 +217,7 @@ * * @return bool */ - function delete() + public function delete() { } @@ -180,7 +226,7 @@ * * @return bool */ - function suspend() + public function suspend() { } @@ -189,7 +235,7 @@ * * @return bool */ - function restore() + public function restore() { } @@ -198,9 +244,9 @@ * * @return bool */ - function resetpwd() + public function resetpwd() { } -} // end class +} ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_xoops.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_xoops.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/auth_xoops.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,7 +11,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> @@ -22,7 +22,7 @@ /** * - * @package kernel + * @package class * @subpackage auth * @description Authentification class for Native XOOPS * @author Pierre-Eric MENUET <pe...@fr...> @@ -32,8 +32,10 @@ { /** * Authentication Service constructor + * + * @param XoopsDatabase|null $dao */ - function XoopsAuthXoops(&$dao) + public function __construct($dao = null) { $this->_dao = $dao; $this->auth_method = 'xoops'; @@ -46,8 +48,9 @@ * @param string $pwd * @return bool */ - function authenticate($uname, $pwd = null) + public function authenticate($uname, $pwd = null) { + /* @var $member_handler XoopsMemberHandler */ $member_handler = xoops_gethandler('member'); $user = $member_handler->loginUser($uname, $pwd); if ($user == false) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/authfactory.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/authfactory.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/auth/authfactory.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -11,7 +11,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class * @subpackage auth * @since 2.0 * @author Pierre-Eric MENUET <pe...@fr...> @@ -36,18 +36,16 @@ * if the class has not been instantiated yet, this will also take * care of that * - * @static - * @return object Reference to the only instance of authentication class + * @param string $uname + * @return XoopsAuth|bool Reference to the only instance of authentication class */ - function getAuthConnection($uname) + static function getAuthConnection($uname) { static $auth_instance; if (!isset($auth_instance)) { + /* @var $config_handler XoopsConfigHandler */ $config_handler = xoops_gethandler('config'); $authConfig = $config_handler->getConfigsByCat(XOOPS_CONF_AUTH); - - include_once $GLOBALS['xoops']->path('class/auth/auth.php'); - if (empty($authConfig['auth_method'])) { // If there is a config error, we use xoops $xoops_auth_method = 'xoops'; } else { @@ -65,7 +63,7 @@ $class = 'XoopsAuth' . ucfirst($xoops_auth_method); if (!class_exists($class)) { - $GLOBALS['xoopsLogger']->triggerError($class, _XO_ER_CLASSNOTFOUND, __FILE__, __LINE__, E_USER_ERROR ); + $GLOBALS['xoopsLogger']->triggerError($class, _XO_ER_CLASSNOTFOUND, __FILE__, __LINE__, E_USER_ERROR); return false; } switch ($xoops_auth_method) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/file.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/file.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/file.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -17,6 +17,7 @@ * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -57,10 +58,10 @@ /** * Instance of File class * - * @var object + * @var XoopsFileHandler * @access private */ - var $file = null; + private $file = null; /** * settings @@ -73,7 +74,7 @@ * @see CacheEngine::__defaults * @access public */ - var $settings = array(); + public $settings = array(); /** * Set to true if FileEngine::init(); and FileEngine::active(); do not fail. @@ -81,7 +82,7 @@ * @var boolean * @access private */ - var $active = false; + private $active = false; /** * True unless FileEngine::active(); fails @@ -89,7 +90,7 @@ * @var boolean * @access private */ - var $init = true; + private $init = true; /** * Initialize the Cache Engine @@ -97,17 +98,19 @@ * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * - * @param array $setting array of setting for the engine - * @return boolean True if the engine has been successfully initialized, false if not + * @param array $settings array of setting for the engine + * @return bool True if the engine has been successfully initialized, false if not * @access public */ - function init($settings = array()) + public function init($settings = array()) { parent::init($settings); - $defaults = array('path' => XOOPS_VAR_PATH . '/caches/xoops_cache' , 'extension' => '.php' , 'prefix' => 'xoops_' , 'lock' => false , 'serialize' => false , 'duration' => 31556926); + $defaults = array( + 'path' => XOOPS_VAR_PATH . '/caches/xoops_cache', 'extension' => '.php', 'prefix' => 'xoops_', + 'lock' => false, 'serialize' => false, 'duration' => 31556926 + ); $this->settings = array_merge($defaults, $this->settings); if (!isset($this->file)) { - XoopsLoad::load('XoopsFile'); $this->file = XoopsFile::getHandler('file', $this->settings['path'] . '/index.html', true); } $this->settings['path'] = $this->file->folder->cd($this->settings['path']); @@ -123,7 +126,7 @@ * @return boolean True if garbage collection was succesful, false on failure * @access public */ - function gc() + public function gc() { return $this->clear(true); } @@ -137,9 +140,9 @@ * @return boolean True if the data was succesfully cached, false on failure * @access public */ - function write($key, $data = null, $duration = null) + public function write($key, $data = null, $duration = null) { - if (!isset($data) || ! $this->init) { + if (!isset($data) || !$this->init) { return false; } @@ -184,9 +187,9 @@ * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @access public */ - function read($key) + public function read($key) { - if ($this->setKey($key) === false || ! $this->init) { + if ($this->setKey($key) === false || !$this->init) { return false; } if ($this->settings['lock']) { @@ -206,11 +209,12 @@ $data = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data); $data = unserialize($data); if (is_array($data)) { - XoopsLoad::load('XoopsUtility'); $data = XoopsUtility::recursive('stripslashes', $data); } - } else if ($data && empty($this->settings['serialize'])) { - $data = eval($data); + } else { + if ($data && empty($this->settings['serialize'])) { + $data = eval($data); + } } $this->file->close(); return $data; @@ -223,9 +227,9 @@ * @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed * @access public */ - function delete($key) + public function delete($key) { - if ($this->setKey($key) === false || ! $this->init) { + if ($this->setKey($key) === false || !$this->init) { return false; } return $this->file->delete(); @@ -238,16 +242,16 @@ * @return boolean True if the cache was succesfully cleared, false otherwise * @access public */ - function clear($check = true) + public function clear($check = true) { if (!$this->init) { return false; } + $dir = dir($this->settings['path']); - if ($check) { - $now = time(); - $threshold = $now - $this->settings['duration']; - } + $now = time(); + $threshold = $now - $this->settings['duration']; + while (($entry = $dir->read()) !== false) { if ($this->setKey(str_replace($this->settings['prefix'], '', $entry)) === false) { continue; @@ -279,7 +283,7 @@ * @return mixed Absolute cache file for the given key or false if erroneous * @access private */ - function setKey($key) + public function setKey($key) { $this->file->folder->cd($this->settings['path']); $this->file->name = $this->settings['prefix'] . $key . $this->settings['extension']; @@ -288,7 +292,9 @@ if (!$this->file->folder->inPath($this->file->pwd(), true)) { return false; } + return true; } + /** * Determine is cache directory is writable * @@ -297,7 +303,7 @@ */ function active() { - if (!$this->active && $this->init && ! is_writable($this->settings['path'])) { + if (!$this->active && $this->init && !is_writable($this->settings['path'])) { $this->init = false; trigger_error(sprintf('%s is not writable', $this->settings['path']), E_USER_WARNING); } else { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/memcache.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/memcache.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/memcache.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -16,8 +16,8 @@ * @since 2.3.0 * @author Taiwen Jiang <ph...@us...> * @version $Id$ + */ - */ defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -45,21 +45,16 @@ * @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008) $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Memcache storage engine for cache - * - * @package cake - * @subpackage cake.cake.libs.cache - */ class XoopsCacheMemcache extends XoopsCacheEngine { /** * Memcache wrapper. * - * @var object + * @var Memcache * @access private */ - var $memcache = null; + private $memcache = null; + /** * settings * servers = string or array of memcache servers, default => 127.0.0.1 @@ -68,18 +63,19 @@ * @var array * @access public */ - var $settings = array(); + public $settings = array(); + /** * Initialize the Cache Engine * * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * - * @param array $setting array of setting for the engine + * @param array $settings array of setting for the engine * @return boolean True if the engine has been successfully initialized, false if not * @access public */ - function init($settings = array()) + public function init($settings = array()) { if (!class_exists('Memcache')) { return false; @@ -87,8 +83,9 @@ parent::init($settings); $defaults = array( 'servers' => array( - '127.0.0.1') , - 'compress' => false); + '127.0.0.1' + ), 'compress' => false + ); $this->settings = array_merge($defaults, $this->settings); if (!$this->settings['compress']) { @@ -96,7 +93,8 @@ } if (!is_array($this->settings['servers'])) { $this->settings['servers'] = array( - $this->settings['servers']); + $this->settings['servers'] + ); } $this->memcache = null; $this->memcache = new Memcache(); @@ -113,6 +111,7 @@ } return false; } + /** * Write data for key into cache * @@ -122,10 +121,11 @@ * @return boolean True if the data was succesfully cached, false on failure * @access public */ - function write($key, &$value, $duration) + public function write($key, &$value, $duration) { return $this->memcache->set($key, $value, $this->settings['compress'], $duration); } + /** * Read a key from the cache * @@ -133,10 +133,11 @@ * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @access public */ - function read($key) + public function read($key) { return $this->memcache->get($key); } + /** * Delete a key from the cache * @@ -144,20 +145,22 @@ * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed * @access public */ - function delete($key) + public function delete($key) { return $this->memcache->delete($key); } + /** * Delete all keys from the cache * * @return boolean True if the cache was succesfully cleared, false otherwise * @access public */ - function clear() + public function clear() { return $this->memcache->flush(); } + /** * Connects to a server in connection pool * @@ -166,7 +169,7 @@ * @return boolean True if memcache server was connected * @access public */ - function connect($host, $port = 11211) + public function connect($host, $port = 11211) { if ($this->memcache->getServerStatus($host, $port) === 0) { if ($this->memcache->connect($host, $port)) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/model.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/model.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/model.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -17,6 +17,7 @@ * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -44,12 +45,6 @@ * @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008) $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Database Storage engine for cache - * - * @package cake - * @subpackage cake.cake.libs.cache - */ class XoopsCacheModel extends XoopsCacheEngine { /** @@ -60,15 +55,15 @@ * @var array * @access public */ - var $settings = array(); + public $settings = array(); /** * Model instance. * - * @var object + * @var XoopsCachemodelHandler * @access private */ - var $model = null; + private $model = null; /** * Model instance. @@ -76,7 +71,7 @@ * @var object * @access private */ - var $fields = array(); + private $fields = array(); /** * Initialize the Cache Engine @@ -84,19 +79,17 @@ * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * - * @param array $setting array of setting for the engine + * @param array $settings array of setting for the engine * @return boolean True if the engine has been successfully initialized, false if not * @access public */ - function init($settings) + public function init($settings) { - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); - parent::init($settings); - $defaults = array('fields' => array('data' , 'expires')); + $defaults = array('fields' => array('data', 'expires')); $this->settings = array_merge($defaults, $this->settings); $this->fields = $this->settings['fields']; - $this->model = new XoopsCacheModelHandler($xoopsDB); + $this->model = xoops_getHandler('cachemodel'); return true; } @@ -104,8 +97,10 @@ * Garbage collection. Permanently remove all expired and deleted data * * @access public + * + * @return bool */ - function gc() + public function gc() { return $this->model->deleteAll(new Criteria($this->fields[1], time, '<= ')); } @@ -119,16 +114,14 @@ * @return boolean True if the data was succesfully cached, false on failure * @access public */ - function write($key, $data, $duration) + public function write($key, $data, $duration) { - // if (isset($this->settings['serialize'])) { $data = serialize($data); - // } - if (! $data) { + if (!$data) { return false; } $cache_obj = $this->model->create(); - $cache_obj->setVar($this->model::KEYNAME, $key); + $cache_obj->setVar($this->model->keyName, $key); $cache_obj->setVar($this->fields[0], $data); $cache_obj->setVar($this->fields[1], time() + $duration); return $this->model->insert($cache_obj); @@ -141,9 +134,9 @@ * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @access public */ - function read($key) + public function read($key) { - $criteria = new CriteriaCompo(new Criteria($this->model::KEYNAME, $key)); + $criteria = new CriteriaCompo(new Criteria($this->model->keyName, $key)); $criteria->add(new Criteria($this->fields[1], time(), ">")); $criteria->setLimit(1); $data = $this->model->getAll($criteria); @@ -160,9 +153,10 @@ * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed * @access public */ - function delete($key) + public function delete($key) { - return $this->model->delete($key); + $criteria = new CriteriaCompo(new Criteria($this->model->keyName, $key)); + return $this->model->deleteAll($criteria); } /** @@ -177,45 +171,4 @@ } } -/** - * XoopsCacheModelObject - * - * @package - * @author John - * @copyright Copyright (c) 2009 - * @version $Id$ - * @access public - */ -class XoopsCacheModelObject extends XoopsObject -{ - function XoopsCacheModelObject() - { - $this->__construct(); - } - - function __construct() - { - parent::__construct(); - $this->initVar('key', XOBJ_DTYPE_TXTBOX); - $this->initVar('data', XOBJ_DTYPE_SOURCE); - $this->initVar('expires', XOBJ_DTYPE_INT); - } -} - -/** - * XoopsCacheModelHandler - * - * @package - * @author John - * @copyright Copyright (c) 2009 - * @version $Id$ - * @access public - */ -class XoopsCacheModelHandler extends XoopsPersistableObjectHandler -{ - const TABLE = 'cache_model'; - const CLASSNAME = 'XoopsCacheModelObject'; - const KEYNAME = 'key'; -} - ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xcache.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xcache.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xcache.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -17,6 +17,7 @@ * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -44,13 +45,6 @@ * @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008) $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Xcache storage engine for cache - * - * @link http://trac.lighttpd.net/xcache/ Xcache - * @package cake - * @subpackage cake.cake.libs.cache - */ class XoopsCacheXcache extends XoopsCacheEngine { /** @@ -61,7 +55,7 @@ * @var array * @access public */ - var $settings = array(); + public $settings = array(); /** * Initialize the Cache Engine @@ -69,11 +63,11 @@ * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * - * @param array $setting array of setting for the engine - * @return boolean True if the engine has been successfully initialized, false if not + * @param array $settings array of setting for the engine + * @return bool True if the engine has been successfully initialized, false if not * @access public */ - function init($settings) + public function init($settings) { parent::init($settings); $defaults = array('PHP_AUTH_USER' => 'cake' , 'PHP_AUTH_PW' => 'cake'); @@ -90,7 +84,7 @@ * @return boolean True if the data was succesfully cached, false on failure * @access public */ - function write($key, &$value, $duration) + public function write($key, &$value, $duration) { return xcache_set($key, $value, $duration); } @@ -102,7 +96,7 @@ * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @access public */ - function read($key) + public function read($key) { if (xcache_isset($key)) { return xcache_get($key); @@ -117,7 +111,7 @@ * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed * @access public */ - function delete($key) + public function delete($key) { return xcache_unset($key); } @@ -128,7 +122,7 @@ * @return boolean True if the cache was succesfully cleared, false otherwise * @access public */ - function clear() + public function clear() { $result = true; $this->__auth(); @@ -149,10 +143,10 @@ * This has to be done because xcache_clear_cache() needs to pass Basic Http Auth * (see xcache.admin configuration settings) * - * @param boolean $ Revert changes + * @param boolean $reverse Revert changes * @access private */ - function __auth($reverse = false) + private function __auth($reverse = false) { static $backup = array(); $keys = array('PHP_AUTH_USER' , 'PHP_AUTH_PW'); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xoopscache.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xoopscache.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/cache/xoopscache.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -17,6 +17,7 @@ * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -30,37 +31,26 @@ /** * Cache engine to use * - * @var object + * @var XoopsCacheEngine * @access protected */ - var $engine = null; - // static $engine = null; + protected $engine = null; - /** * Cache configuration stack * * @var array - * @access private */ - var $configs = array(); + protected $configs = array(); /** * Holds name of the current configuration being used * * @var array - * @access private */ - var $name = null; + protected $name = null; /** - * XoopsCache::__construct() - */ - function __construct() - { - } - - /** * Returns a singleton instance * * @return XoopsCache @@ -80,10 +70,10 @@ * Tries to find and include a file for a cache engine and returns object instance * * @param $name Name of the engine - * @return mixed $engine object or null + * @return XoopsCacheEngine|bool * @access private */ - function loadEngine($name) + private function loadEngine($name) { if (!class_exists('XoopsCache' . ucfirst($name))) { if (file_exists($file = dirname(__FILE__) . '/' . strtolower($name) . '.php')) { @@ -104,7 +94,7 @@ * @return array (engine, settings) on success, false on failure * @access public */ - function config($name = 'default', $settings = array()) + public function config($name = 'default', $settings = array()) { $_this = XoopsCache::getInstance(); if (is_array($name)) { @@ -113,18 +103,23 @@ if (isset($_this->configs[$name])) { $settings = array_merge($_this->configs[$name], $settings); - } else if (!empty($settings)) { - $_this->configs[$name] = $settings; - } else if ($_this->configs !== null && isset($_this->configs[$_this->name])) { - $name = $_this->name; - $settings = $_this->configs[$_this->name]; } else { - $name = 'default'; - if (!empty($_this->configs['default'])) { - $settings = $_this->configs['default']; + if (!empty($settings)) { + $_this->configs[$name] = $settings; } else { - $settings = array( - 'engine' => 'file'); + if ($_this->configs !== null && isset($_this->configs[$_this->name])) { + $name = $_this->name; + $settings = $_this->configs[$_this->name]; + } else { + $name = 'default'; + if (!empty($_this->configs['default'])) { + $settings = $_this->configs['default']; + } else { + $settings = array( + 'engine' => 'file' + ); + } + } } } $engine = 'file'; @@ -153,7 +148,7 @@ * @return boolean True on success, false on failure * @access public */ - function engine($name = 'file', $settings = array()) + public function engine($name = 'file', $settings = array()) { if (!$name) { return false; @@ -168,10 +163,11 @@ } $_this->engine[$name] = new $cacheClass(); } - - if ($_this->engine[$name]->init($settings)) { - if (time() % $_this->engine[$name]->settings['probability'] == 0) { - $_this->engine[$name]->gc(); + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$name]; + if ($engine->init($settings)) { + if (time() % $engine->settings['probability'] == 0) { + $engine->gc(); } return true; } @@ -191,8 +187,9 @@ { $_this = XoopsCache::getInstance(); $config = $_this->config(); - extract($config); - $_this->engine[$engine]->gc(); + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$config['engine']]; + $engine->gc(); } /** @@ -212,19 +209,20 @@ $config = null; if (is_array($duration)) { extract($duration); - } else if (isset($_this->configs[$duration])) { - $config = $duration; - $duration = null; + } else { + if (isset($_this->configs[$duration])) { + $config = $duration; + $duration = null; + } } $config = $_this->config($config); if (!is_array($config)) { return null; } - extract($config); - if (!$_this->isInitialized($engine)) { - trigger_error('Cache write not initialized: ' . $engine); + if (!$_this->isInitialized($config['engine'])) { + trigger_error('Cache write not initialized: ' . $config['engine']); return false; } @@ -237,15 +235,18 @@ } if (!$duration) { - $duration = $settings['duration']; + $duration = $config['settings']['duration']; } $duration = is_numeric($duration) ? intval($duration) : strtotime($duration) - time(); if ($duration < 1) { return false; } - $_this->engine[$engine]->init($settings); - $success = $_this->engine[$engine]->write($key, $value, $duration); + + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$config['engine']]; + $engine->init($config['settings']); + $success = $engine->write($key, $value, $duration); return $success; } @@ -269,14 +270,17 @@ extract($config); - if (!$_this->isInitialized($engine)) { + if (!$_this->isInitialized($config['engine'])) { return false; } if (!$key = $_this->key($key)) { return false; } - $_this->engine[$engine]->init($settings); - $success = $_this->engine[$engine]->read($key); + + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$config['engine']]; + $engine->init($config['settings']); + $success = $engine->read($key); return $success; } @@ -290,13 +294,12 @@ */ static function delete($key, $config = null) { - $key .= '_'.urlencode(XOOPS_URL); + $key .= '_' . urlencode(XOOPS_URL); $_this = XoopsCache::getInstance(); $config = $_this->config($config); - extract($config); - if (!$_this->isInitialized($engine)) { + if (!$_this->isInitialized($config['engine'])) { return false; } @@ -304,8 +307,10 @@ return false; } - $_this->engine[$engine]->init($settings); - $success = $_this->engine[$engine]->delete($key); + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$config['engine']]; + $engine->init($config['settings']); + $success = $engine->delete($key); return $success; } @@ -321,23 +326,24 @@ { $_this = XoopsCache::getInstance(); $config = $_this->config($config); - extract($config); - if (!$_this->isInitialized($engine)) { + if (!$_this->isInitialized($config['engine'])) { return false; } - $success = $_this->engine[$engine]->clear($check); - $_this->engine[$engine]->init($settings); + + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$config['engine']]; + $success = $engine->clear($check); + $engine->init($config['settings']); return $success; } /** * Check if Cache has initialized a working storage engine * - * @param string $engine Name of the engine - * @param string $config Name of the configuration setting + * @static + * @param string $engine * @return bool - * @access public */ static function isInitialized($engine = null) { @@ -362,8 +368,10 @@ if (!$engine && isset($_this->configs[$_this->name]['engine'])) { $engine = $_this->configs[$_this->name]['engine']; } - if (isset($_this->engine[$engine]) && ! is_null($_this->engine[$engine])) { - return $_this->engine[$engine]->settings(); + if (isset($_this->engine[$engine]) && !is_null($_this->engine[$engine])) { + /* @var $engine XoopsCacheEngine */ + $engine = $_this->engine[$engine]; + return $engine->settings(); } return array(); } @@ -396,25 +404,24 @@ /** * settings of current engine instance * - * @var int + * @var array * @access public */ - var $settings; + public $settings; /** - * Iitialize the cache engine + * Initialize the cache engine * * Called automatically by the cache frontend * - * @param array $params Associative array of parameters for the engine - * @return boolean True if the engine has been succesfully initialized, false if not - * @access public + * @param array $settings Associative array of parameters for the engine + * @return bool True if the engine has been succesfully initialized, false if not */ - function init($settings = array()) + public function init($settings = array()) { $this->settings = array_merge(array( - 'duration' => 31556926 , - 'probability' => 100), $settings); + 'duration' => 31556926, 'probability' => 100 + ), $settings); return true; } @@ -425,7 +432,7 @@ * * @access public */ - function gc() + public function gc() { } @@ -438,9 +445,9 @@ * @return boolean True if the data was succesfully cached, false on failure * @access public */ - function write($key, &$value, $duration) + public function write($key, &$value, $duration) { - trigger_error(sprintf(__('Method write() not implemented in %s', true), get_class($this)), E_USER_ERROR); + trigger_error(sprintf('Method write() not implemented in %s', get_class($this)), E_USER_ERROR); } /** @@ -450,9 +457,9 @@ * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @access public */ - function read($key) + public function read($key) { - trigger_error(sprintf(__('Method read() not implemented in %s', true), get_class($this)), E_USER_ERROR); + trigger_error(sprintf('Method read() not implemented in %s', get_class($this)), E_USER_ERROR); } /** @@ -462,7 +469,7 @@ * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed * @access public */ - function delete($key) + public function delete($key) { } @@ -473,7 +480,7 @@ * @return boolean True if the cache was succesfully cleared, false otherwise * @access public */ - function clear($check) + public function clear($check) { } @@ -483,7 +490,7 @@ * @return array settings * @access public */ - function settings() + public function settings() { return $this->settings; } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/file/file.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/file/file.php 2011-10-15 15:40:10 UTC (rev 7888) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/file/file.php 2011-10-15 18:33:14 UTC (rev 7889) @@ -55,7 +55,7 @@ ... [truncated message content] |