PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/html/modules/user/kernel/LegacypageFunctions.class.php

http://xoopscube-modules.googlecode.com/
PHP | 329 lines | 195 code | 79 blank | 55 comment | 25 complexity | 548a1c3425216bc06d11e58ae3321576 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * @package user
  4. * @version $Id: LegacypageFunctions.class.php,v 1.6 2007/12/15 15:18:11 minahito Exp $
  5. */
  6. if (!defined('XOOPS_ROOT_PATH')) exit();
  7. /***
  8. * @internal
  9. * This is static functions collection class for legacy pages access.
  10. */
  11. class User_LegacypageFunctions
  12. {
  13. /***
  14. * @internal
  15. * The process for userinfo.php. This process doesn't execute anything
  16. * directly. Forward to the controller of the user module.
  17. */
  18. function userinfo()
  19. {
  20. //
  21. // Boot the action frame of the user module directly.
  22. //
  23. $root =& XCube_Root::getSingleton();
  24. $root->mController->executeHeader();
  25. $root->mController->setupModuleContext('user');
  26. $root->mLanguageManager->loadModuleMessageCatalog('user');
  27. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  28. $moduleRunner = new User_ActionFrame(false);
  29. $moduleRunner->setActionName("UserInfo");
  30. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  31. $root->mController->execute();
  32. $root->mController->executeView();
  33. }
  34. /***
  35. * @internal
  36. * The process for edituser.php. This process doesn't execute anything
  37. * directly. Forward to the controller of the user module.
  38. */
  39. function edituser()
  40. {
  41. $actionName = "EditUser";
  42. switch (xoops_getrequest('op')) {
  43. case 'avatarform':
  44. case 'avatarupload':
  45. $actionName = "AvatarEdit";
  46. break;
  47. case 'avatarchoose':
  48. $actionName = "AvatarSelect";
  49. break;
  50. }
  51. //
  52. // Boot the action frame of the user module directly.
  53. //
  54. $root =& XCube_Root::getSingleton();
  55. $root->mController->executeHeader();
  56. $root->mController->setupModuleContext('user');
  57. $root->mLanguageManager->loadModuleMessageCatalog('user');
  58. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  59. $moduleRunner = new User_ActionFrame(false);
  60. $moduleRunner->setActionName($actionName);
  61. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  62. $root->mController->execute();
  63. $root->mController->executeView();
  64. }
  65. /***
  66. * @internal
  67. * The process for register.php. This process doesn't execute anything
  68. * directly. Forward to the controller of the user module.
  69. */
  70. function register()
  71. {
  72. $root =& XCube_Root::getSingleton();
  73. $xoopsUser =& $root->mContext->mXoopsUser;
  74. if (is_object($xoopsUser)) {
  75. $root->mController->executeForward(XOOPS_URL);
  76. }
  77. //
  78. // Boot the action frame of the user module directly.
  79. //
  80. $root->mController->executeHeader();
  81. $root->mController->setupModuleContext('user');
  82. $root->mLanguageManager->loadModuleMessageCatalog('user');
  83. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  84. $actionName = "";
  85. $action = $root->mContext->mRequest->getRequest('action');
  86. if ($action != null && $action =="UserRegister") {
  87. $actionName = "UserRegister";
  88. }
  89. else {
  90. $actionName = $action != null ? "UserRegister_confirm" : "UserRegister";
  91. }
  92. $moduleRunner = new User_ActionFrame(false);
  93. $moduleRunner->setActionName($actionName);
  94. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  95. $root->mController->execute();
  96. $root->mController->executeView();
  97. }
  98. /***
  99. * @internal
  100. * The process for lostpass.php. This process doesn't execute anything
  101. * directly. If the current user is registered user, kick out to the top
  102. * page. Else, forward to the lost-pass page.
  103. */
  104. function lostpass()
  105. {
  106. $root =& XCube_Root::getSingleton();
  107. $xoopsUser =& $root->mContext->mXoopsUser;
  108. if (is_object($xoopsUser)) {
  109. $root->mController->executeForward(XOOPS_URL);
  110. }
  111. //
  112. // Boot the action frame of the user module directly.
  113. //
  114. $root->mController->executeHeader();
  115. $root->mController->setupModuleContext('user');
  116. $root->mLanguageManager->loadModuleMessageCatalog('user');
  117. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  118. $root =& XCube_Root::getSingleton();
  119. $moduleRunner = new User_ActionFrame(false);
  120. $moduleRunner->setActionName("LostPass");
  121. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  122. $root->mController->execute();
  123. $root->mController->executeView();
  124. }
  125. /***
  126. * @internal
  127. * The process for user.php. This process doesn't execute anything directly.
  128. * Forward to the controller of the user module.
  129. */
  130. function user()
  131. {
  132. $root =& XCube_Root::getSingleton();
  133. $op = isset($_REQUEST['op']) ? trim(xoops_getrequest('op')) : "main";
  134. $xoopsUser =& $root->mContext->mXoopsUser;
  135. $actionName = "default";
  136. switch($op) {
  137. case "login":
  138. $root->mController->checkLogin();
  139. return;
  140. case "logout":
  141. $root->mController->logout();
  142. return;
  143. case "main":
  144. if (is_object($xoopsUser)) {
  145. $root->mController->executeForward(XOOPS_URL . "/userinfo.php?uid=" . $xoopsUser->get('uid'));
  146. }
  147. break;
  148. case "actv":
  149. $actionName = "UserActivate";
  150. break;
  151. case "delete":
  152. $actionName = "UserDelete";
  153. break;
  154. }
  155. //
  156. // Boot the action frame of the user module directly.
  157. //
  158. $root =& XCube_Root::getSingleton();
  159. $root->mController->executeHeader();
  160. $root->mController->setupModuleContext('user');
  161. $root->mLanguageManager->loadModuleMessageCatalog('user');
  162. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  163. $moduleRunner = new User_ActionFrame(false);
  164. $moduleRunner->setActionName($actionName);
  165. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  166. $root->mController->execute();
  167. $root->mController->executeView();
  168. }
  169. function checkLogin(&$xoopsUser)
  170. {
  171. if (is_object($xoopsUser)) {
  172. return;
  173. }
  174. $root =& XCube_Root::getSingleton();
  175. $root->mLanguageManager->loadModuleMessageCatalog('user');
  176. $userHandler =& xoops_getmodulehandler('users', 'user');
  177. $criteria =new CriteriaCompo();
  178. $criteria->add(new Criteria('uname', xoops_getrequest('uname')));
  179. $criteria->add(new Criteria('pass', md5(xoops_getrequest('pass'))));
  180. $userArr =& $userHandler->getObjects($criteria);
  181. if (count($userArr) != 1) {
  182. return;
  183. }
  184. if ($userArr[0]->get('level') == 0) {
  185. // TODO We should use message "_MD_USER_LANG_NOACTTPADM"
  186. return;
  187. }
  188. $handler =& xoops_gethandler('user');
  189. $user =& $handler->get($userArr[0]->get('uid'));
  190. if (is_callable(array($user, "getNumGroups"))) { // Compatible for replaced handler.
  191. if ($user->getNumGroups() == 0) {
  192. return;
  193. }
  194. }
  195. else {
  196. $groups = $user->getGroups();
  197. if (count($groups) == 0) {
  198. return;
  199. }
  200. }
  201. $xoopsUser = $user;
  202. //
  203. // Regist to session
  204. //
  205. $root->mSession->regenerate();
  206. $_SESSION = array();
  207. $_SESSION['xoopsUserId'] = $xoopsUser->get('uid');
  208. $_SESSION['xoopsUserGroups'] = $xoopsUser->getGroups();
  209. }
  210. function checkLoginSuccess(&$xoopsUser)
  211. {
  212. if (is_object($xoopsUser)) {
  213. $handler =& xoops_gethandler('user');
  214. $xoopsUser->set('last_login', time());
  215. $handler->insert($xoopsUser);
  216. }
  217. }
  218. function logout(&$successFlag, $xoopsUser)
  219. {
  220. $root =& XCube_Root::getSingleton();
  221. $xoopsConfig = $root->mContext->mXoopsConfig;
  222. $root->mLanguageManager->loadModuleMessageCatalog('user');
  223. // Reset session
  224. $_SESSION = array();
  225. $root->mSession->destroy(true);
  226. // clear entry from online users table
  227. if (is_object($xoopsUser)) {
  228. $onlineHandler =& xoops_gethandler('online');
  229. $onlineHandler->destroy($xoopsUser->get('uid'));
  230. }
  231. $successFlag = true;
  232. }
  233. function misc()
  234. {
  235. if (xoops_getrequest('type') != 'online') {
  236. return;
  237. }
  238. require_once XOOPS_MODULE_PATH . "/user/class/ActionFrame.class.php";
  239. $root =& XCube_Root::getSingleton();
  240. $root->mController->setupModuleContext('user');
  241. $actionName = "MiscOnline";
  242. $moduleRunner = new User_ActionFrame(false);
  243. $moduleRunner->setActionName($actionName);
  244. $root->mController->mExecute->add(array(&$moduleRunner, 'execute'));
  245. $root->mController->setDialogMode(true);
  246. $root->mController->execute();
  247. $root->mController->executeView();
  248. }
  249. }
  250. ?>