Minahito
minah****@users*****
2006年 7月 19日 (水) 19:30:32 JST
Index: xoops2jp/html/modules/user/kernel/UserEventProxyRegister.class.php diff -u xoops2jp/html/modules/user/kernel/UserEventProxyRegister.class.php:1.1.2.8 xoops2jp/html/modules/user/kernel/UserEventProxyRegister.class.php:removed --- xoops2jp/html/modules/user/kernel/UserEventProxyRegister.class.php:1.1.2.8 Thu Jun 22 14:38:46 2006 +++ xoops2jp/html/modules/user/kernel/UserEventProxyRegister.class.php Wed Jul 19 19:30:32 2006 @@ -1,123 +0,0 @@ -<?php - -if (!defined('XOOPS_ROOT_PATH')) exit(); - -require_once XOOPS_ROOT_PATH."/class/XCube_EventManager.class.php"; - -class UserEventProxyRegister extends XCube_EventProxyRegister -{ - var $_mList=array("Legacypage.Userinfo.Access","Legacypage.Edituser.Access", - "Legacypage.User.Access", "Site.CheckLogin", "Site.Logout", - "Legacypage.Register.Access","Site.CheckLogin.Success", - "Legacypage.Lostpass.Access"); - - function getEventNameList() - { - return $this->_mList; - } - - function &createLegacypage_Userinfo_AccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","AccessToUserinfo"); - return $delegate; - } - - function &createLegacypage_Edituser_AccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","AccessToEdituser"); - return $delegate; - } - - function &createLegacypage_User_AccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","AccessToUser"); - return $delegate; - } - - function &createLegacypage_Register_AccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","AccessToRegister"); - return $delegate; - } - - function &createSite_CheckLoginDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","CheckLogin"); - return $delegate; - } - - function &createSite_LogoutDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","Logout"); - return $delegate; - } - - function &createSite_CheckLogin_SuccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","CheckLoginSuccess"); - return $delegate; - } - - function &createLegacypage_Lostpass_AccessDelegate() - { - require_once XOOPS_MODULE_PATH."/user/kernel/UserEventFunction.class.php"; - $delegate=new XCube_Delegate("UserEventFunction","AccessToLostpass"); - return $delegate; - } -} - -class UserCommonEventFunction -{ - function &Login(&$controller,&$loginEventArgs) - { - if (!empty($_SESSION['xoopsUserId'])) { - $memberHandler=xoops_gethandler('member'); - $xoopsUser=&$memberHandler->getUser($_SESSION['xoopsUserId']); - if(!is_object($xoopsUser)) { - $xoopsUser = null; - $_SESSION=array(); - } - else { - $xoopsUser->setGroups($_SESSION['xoopsUserGroups']); - } - $loginEventArgs->setXoopsUser($xoopsUser); - $controller->mXoopsUser=&$xoopsUser; - } - - return $loginEventArgs; - } - - /** - * [Notice] - * New function for new delegate. Of course, we'll change the name before - * released. - */ - function NewLogin(&$xoopsUser) - { - if (is_object($xoopsUser)) { - return; - } - - if (!empty($_SESSION['xoopsUserId'])) { - $memberHandler=xoops_gethandler('member'); - $user =& $memberHandler->getUser($_SESSION['xoopsUserId']); - $xoopsUser = $user; - if(!is_object($xoopsUser)) { - $xoopsUser = null; - $_SESSION = array(); - } - else { - $xoopsUser->setGroups($_SESSION['xoopsUserGroups']); - } - } - } -} - -?> \ No newline at end of file Index: xoops2jp/html/modules/user/kernel/UserEventFunction.class.php diff -u xoops2jp/html/modules/user/kernel/UserEventFunction.class.php:1.1.2.11 xoops2jp/html/modules/user/kernel/UserEventFunction.class.php:removed --- xoops2jp/html/modules/user/kernel/UserEventFunction.class.php:1.1.2.11 Fri Apr 21 12:03:57 2006 +++ xoops2jp/html/modules/user/kernel/UserEventFunction.class.php Wed Jul 19 19:30:32 2006 @@ -1,200 +0,0 @@ -<?php - -if (!defined('XOOPS_ROOT_PATH')) exit(); - -/** - * Static methods' collection for delegates. - */ -class UserEventFunction -{ - /** - * @param $sender Base_Controller - */ - function AccessToUserinfo(&$controller,&$eventArgs) - { - // $controller=(Base_Controller)$sender; - $uid=isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0; - if($uid>0) { - $url=XOOPS_MODULE_URL."/user/index.php?action=UserInfo&uid=".$uid; - } - else { - $xoopsUser=&$controller->getXoopsUser(); - if(is_object($xoopsUser)) - $url=XOOPS_MODULE_URL."/user/index.php?action=UserInfo&uid=".$xoopsUser->get('uid'); - } - - $controller->executeForward($url); - } - - /** - * @param $sender Base_Controller - */ - function AccessToEdituser(&$controller,&$eventArgs) - { - // $controller=(Base_Controller)$sender; - $uid=isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0; - - $url=XOOPS_URL; - if($uid>0) { - $url=XOOPS_MODULE_URL."/user/index.php?action=EditUser&uid=".$uid; - } - else { - $xoopsUser=&$controller->getXoopsUser(); - if(is_object($xoopsUser)) - $url=XOOPS_MODULE_URL."/user/index.php?action=EditUser&uid=".$xoopsUser->get('uid'); - } - - $controller->executeForward($url); - } - - /** - * @param $sender Base_Controller - */ - function AccessToUser(&$controller,&$eventArgs) - { - // $controller=(Base_Controller)$sender; - $op=isset($_REQUEST['op']) ? trim($_REQUEST['op']) : "main"; - $xoopsUser=&$controller->getXoopsUser(); - - switch($op) { - case "main": - $url=is_object($xoopsUser) ? XOOPS_MODULE_URL."/user/index.php?action=UserInfo&uid=".$xoopsUser->get('uid') - : XOOPS_MODULE_URL."/user/index.php"; - $controller->executeForward($url); - break; - - case "login": - $checkLoginEventArgs = new CheckLoginEventArgs(); - $controller->mRoot->mEventManager->raiseEvent("Site.CheckLogin",$controller,$checkLoginEventArgs); - break; - - case "logout": - $args=array(); - $args['successFlag']=false; - $controller->mRoot->mEventManager->raiseEvent("Site.Logout",$controller,$args); - break; - } - } - - /** - * @param $sender Base_Controller - */ - function AccessToRegister(&$controller,&$eventArgs) - { - $xoopsUser =& $controller->getXoopsUser(); - if (is_object($xoopsUser)) { - $controller->executeForward(XOOPS_URL); - } - else { - $controller->executeForward(XOOPS_MODULE_URL . "/user/index.php?action=UserRegister"); - } - } - - function CheckLogin(&$controller,&$eventArgs) - { - if($eventArgs->isSuccess()) - return; - - $controller->mRoot->mLanguageManager->loadModuleLanguage('user'); - - $userHandler =& xoops_gethandler('user'); - - $criteria =& new CriteriaCompo(); - $criteria->add(new Criteria('uname', xoops_getrequest('uname'))); - $criteria->add(new Criteria('pass', md5(xoops_getrequest('pass')))); - - $userArr =& $userHandler->getObjects($criteria); - - if (count($userArr) != 1) { - $eventArgs->setRedirectUrl(XOOPS_URL."/user.php"); - $eventArgs->setRedirectMessage(_US_INCORRECTLOGIN); - return; - } - - $user =& $userArr[0]; - - if($user->get('level')==0) { - $eventArgs->setRedirectUrl(XOOPS_URL); - $eventArgs->setRedirectMessage(_US_NOACTTPADM); - return; - } - - // Regist to session - $_SESSION = array(); - $_SESSION['xoopsUserId'] = $user->get('uid'); - $_SESSION['xoopsUserGroups'] = $user->getGroups(); - - if (!empty($_POST['xoops_redirect']) && !strpos($_POST['xoops_redirect'], 'register')) { - $parsed = parse_url(XOOPS_URL); - $url = isset($parsed['scheme']) ? $parsed['scheme'].'://' : 'http://'; - if (isset($parsed['host'])) { - $url .= isset($parsed['port']) ?$parsed['host'].':'.$parsed['port'].trim($_POST['xoops_redirect']): $parsed['host'].trim($_POST['xoops_redirect']); - } else { - $url .= xoops_getenv('HTTP_HOST').trim($_POST['xoops_redirect']); - } - } else { - $url = XOOPS_URL.'/index.php'; - } - - $eventArgs->setXoopsUser($user); - - $eventArgs->setRedirectUrl($url); - $eventArgs->setSuccessFlag(true); - } - - function Logout(&$controller,&$eventArgs) - { - // @Todo: this function depends global variable - global $xoopsConfig; - global $xoopsUser; - - $controller->mRoot->mLanguageManager->loadModuleLanguage('user'); - - // Reset session - $_SESSION = array(); - session_destroy(); - - if ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '') { - setcookie($xoopsConfig['session_name'], '', time()- 3600, '/', '', 0); - } - - // clear entry from online users table - if (is_object($xoopsUser)) { - $onlineHandler =& xoops_gethandler('online'); - $onlineHandler->destroy($xoopsUser->get('uid')); - } - - $eventArgs['successFlag']=true; - } - - /** - * Update last login time - */ - function CheckLoginSuccess(&$sender,&$eventArgs) - { - if(is_object($eventArgs['xoopsUser'])) { - $userHandler=&xoops_gethandler('user'); - $eventArgs['xoopsUser']->setVar('last_login', time()); - $userHandler->insert($eventArgs['xoopsUser']); - } - } - - /** - * If the current user is registered user, kick out to the top page. - * Else, forward to the lost-pass page. - */ - function AccessToLostpass(&$controller, &$eventArgs) - { - $xoopsUser =& $controller->getXoopsUser(); - if (is_object($xoopsUser)) { - $controller->executeForward(XOOPS_URL); - } - else { - $controller->executeForward(XOOPS_MODULE_URL . "/user/index.php?action=LostPass"); - } - } - -} - - -?> \ No newline at end of file