[xoops-cvslog 3620] CVS update: xoops2jp/html/modules/user/kernel

アーカイブの一覧に戻る

Minahito minah****@users*****
2006年 7月 19日 (水) 19:22:25 JST


Index: xoops2jp/html/modules/user/kernel/LegacypageFunctions.class.php
diff -u /dev/null xoops2jp/html/modules/user/kernel/LegacypageFunctions.class.php:1.1.2.1
--- /dev/null	Wed Jul 19 19:22:25 2006
+++ xoops2jp/html/modules/user/kernel/LegacypageFunctions.class.php	Wed Jul 19 19:22:25 2006
@@ -0,0 +1,184 @@
+<?php
+/**
+ * @package user
+ * @version $Id: LegacypageFunctions.class.php,v 1.1.2.1 2006/07/19 10:22:25 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+ 
+/**
+ * This is static functions collection class for legacy pages access.
+ */
+class User_LegacypageFunctions
+{
+	/**
+	 * The process for userinfo.php. This process doesn't execute anything
+	 * directly. Forward to the controller of the user module.
+	 */
+	function userinfo()
+	{
+		$root =& XCube_Root::getSingleton();
+		
+		$uid = isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : 0;
+		
+		$url = XOOPS_URL;
+		if ($uid > 0) {
+			$url = XOOPS_MODULE_URL . "/user/index.php?action=UserInfo&uid=" . $uid;
+		}
+		else {
+			$xoopsUser =& $root->mController->getXoopsUser();
+			if (is_object($xoopsUser)) {
+				$url = XOOPS_MODULE_URL . "/user/index.php?action=UserInfo&uid=" . $xoopsUser->get('uid');
+			}
+		}
+		
+		$root->mController->executeForward($url);
+	}
+	
+	/**
+	 * The process for edituser.php. This process doesn't execute anything
+	 * directly. Forward to the controller of the user module.
+	 */
+	function edituser()
+	{
+		$root =& XCube_Root::getSingleton();
+		$uid = isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : 0;
+
+		$url = XOOPS_URL;
+		if ($uid > 0) {
+			$url = XOOPS_MODULE_URL . "/user/index.php?action=EditUser&uid=" . $uid;
+		}
+		else {
+			$xoopsUser =& $root->mController->getXoopsUser();
+			if (is_object($xoopsUser)) {
+				$url = XOOPS_MODULE_URL . "/user/index.php?action=EditUser&uid=" . $xoopsUser->get('uid');
+			}
+		}
+
+		$root->mController->executeForward($url);
+	}
+	
+	/**
+	 * The process for register.php. This process doesn't execute anything
+	 * directly. Forward to the controller of the user module.
+	 */
+	function register()
+	{
+		$root =& XCube_Root::getSingleton();
+		$xoopsUser =& $root->mController->getXoopsUser();
+		
+		if (is_object($xoopsUser)) {
+			$root->mController->executeForward(XOOPS_URL);
+		}
+		else {
+			$root->mController->executeForward(XOOPS_MODULE_URL . "/user/index.php?action=UserRegister");
+		}
+	}
+	
+	/**
+	 * The process for lostpass.php. This process doesn't execute anything
+	 * directly. If the current user is registered user, kick out to the top
+	 * page. Else, forward to the lost-pass page.
+	 */
+	function AccessToLostpass()
+	{
+		$root =& XCube_Root::getSingleton();
+		$xoopsUser =& $root->mController->getXoopsUser();
+
+		if (is_object($xoopsUser)) {
+			$controller->executeForward(XOOPS_URL);
+		}
+		else {
+			$controller->executeForward(XOOPS_MODULE_URL . "/user/index.php?action=LostPass");
+		}
+	}
+
+	/**
+	 * The process for user.php. This process doesn't execute anything directly.
+	 * Forward to the controller of the user module.
+	 */
+	function user()
+	{
+		$root =& XCube_Root::getSingleton();
+		$op = isset($_REQUEST['op']) ? trim(xoops_getrequest('op')) : "main";
+		$xoopsUser =& $root->mController->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"; 
+				$root->mController->executeForward($url);
+				break;
+				
+			case "login":
+				$root->mController->checkLogin();
+				break;
+			
+			case "logout":
+				$root->mController->logout();
+				break;
+		}
+	}
+	
+	function checkLogin(&$xoopsUser)
+	{
+		if (is_object($xoopsUser)) {
+			return;
+		}
+
+		$root =& XCube_Root::getSingleton();
+		$root->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) {
+			return;
+		}
+		
+		$xoopsUser = $userArr[0];
+			
+		if ($xoopsUser->get('level') == 0) {
+			// TODO We should use message "_US_NOACTTPADM"
+			return;
+		}
+	
+		//
+		// Regist to session
+		//
+		$_SESSION = array();
+		$_SESSION['xoopsUserId'] = $xoopsUser->get('uid');
+		$_SESSION['xoopsUserGroups'] = $xoopsUser->getGroups();
+	}
+
+	function logout(&$successFlag, $xoopsUser)
+	{
+		$root =& XCube_Root::getSingleton();
+		$xoopsConfig = $root->mController->getConfig();
+		
+		$root->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'));
+		}
+		
+		$successFlag = true;
+    }
+}
+
+?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
アーカイブの一覧に戻る