1: <?php
2: 3: 4: 5:
6:
7: if (!defined('XOOPS_ROOT_PATH')) die();
8:
9: class User_PrimaryFilter extends XCube_ActionFilter
10: {
11: function preFilter()
12: {
13: $root =& XCube_Root::getSingleton();
14: $this->mController->mSetupUser->add("User_Utils::setupUser");
15: $this->mController->_mNotifyRedirectToUser->add("User_Utils::convertUrlToUser");
16:
17: $file = XOOPS_ROOT_PATH . "/modules/user/kernel/LegacypageFunctions.class.php";
18:
19: $root->mDelegateManager->add("Legacypage.Userinfo.Access", "User_LegacypageFunctions::userinfo", $file);
20: $root->mDelegateManager->add("Legacypage.Edituser.Access", "User_LegacypageFunctions::edituser", $file);
21: $root->mDelegateManager->add("Legacypage.Register.Access", "User_LegacypageFunctions::register", $file);
22: $root->mDelegateManager->add("Legacypage.User.Access", "User_LegacypageFunctions::user", $file);
23: $root->mDelegateManager->add("Legacypage.Lostpass.Access", "User_LegacypageFunctions::lostpass", $file);
24: $root->mDelegateManager->add("Site.CheckLogin", "User_LegacypageFunctions::checkLogin", $file);
25: $root->mDelegateManager->add("Site.CheckLogin.Success", "User_LegacypageFunctions::checkLoginSuccess", $file);
26: $root->mDelegateManager->add("Site.Logout", "User_LegacypageFunctions::logout", $file);
27:
28: $root->mDelegateManager->add("Legacypage.Misc.Access", "User_LegacypageFunctions::misc", XCUBE_DELEGATE_PRIORITY_NORMAL - 5, $file);
29: }
30: }
31:
32: 33: 34: 35: 36: 37: 38: 39: 40:
41: class User_Utils
42: {
43: function setupUser(&$principal, &$controller, &$context)
44: {
45: if (is_object($context->mXoopsUser)) {
46: return;
47: }
48:
49: if (!empty($_SESSION['xoopsUserId'])) {
50: $memberHandler = xoops_gethandler('member');
51: $user =& $memberHandler->getUser($_SESSION['xoopsUserId']);
52: $context->mXoopsUser =& $user;
53: if (is_object($context->mXoopsUser)) {
54: $context->mXoopsUser->setGroups($_SESSION['xoopsUserGroups']);
55:
56: $roles = array();
57: $roles[] = "Site.RegisteredUser";
58: if ($context->mXoopsUser->isAdmin(-1)) {
59: $roles[] = "Site.Administrator";
60: }
61: if (in_array(XOOPS_GROUP_ADMIN, $_SESSION['xoopsUserGroups'])) {
62: $roles[] = "Site.Owner";
63: }
64:
65: $identity =new Legacy_Identity($context->mXoopsUser);
66: $principal = new Legacy_GenericPrincipal($identity, $roles);
67: return;
68: } else {
69: $context->mXoopsUser = null;
70: $_SESSION = array();
71: }
72: }
73: $identity =new Legacy_AnonymousIdentity();
74: $principal = new Legacy_GenericPrincipal($identity, array("Site.GuestUser"));
75: }
76:
77: function convertUrlToUser(&$url)
78: {
79: global $xoopsRequestUri;
80: if (!strstr($url, '?')) {
81: $url .= "?xoops_redirect=" . urlencode($xoopsRequestUri);
82: }
83: else {
84: $url .= "&xoops_redirect=" . urlencode($xoopsRequestUri);
85: }
86: }
87: }
88:
89: ?>
90: