1: <?php
2:
3: if (!defined('XOOPS_ROOT_PATH')) exit();
4:
5: require_once XOOPS_MODULE_PATH . "/user/class/AbstractViewAction.class.php";
6: require_once XOOPS_MODULE_PATH . "/user/admin/forms/UserRecountForm.class.php";
7:
8: class User_UserViewAction extends User_AbstractViewAction
9: {
10: var $mActionForm = null;
11:
12: 13: 14:
15: var $mGetUserPosts = null;
16:
17: function User_UserViewAction()
18: {
19: parent::User_AbstractViewAction();
20: $this->mGetUserPosts =new XCube_Delegate();
21: $this->mGetUserPosts->register('User_UserViewAction.GetUserPosts');
22: }
23:
24: function prepare(&$controller, &$xoopsUser, $moduleConfig)
25: {
26: parent::prepare($controller, $xoopsUser, $moduleConfig);
27: $this->mActionForm =new User_RecountForm();
28: $this->mActionForm->prepare();
29: }
30:
31: function _getId()
32: {
33: return xoops_getrequest('uid');
34: }
35:
36: function &_getHandler()
37: {
38: $handler =& xoops_getmodulehandler('users');
39: return $handler;
40: }
41:
42: function getDefaultView(&$controller, &$xoopsUser)
43: {
44: if (is_object($this->mObject)) {
45: $this->mActionForm->load($this->mObject);
46: }
47:
48: $ret = parent::getDefaultView($controller, $xoopsUser);
49:
50:
51:
52:
53: if ($ret == USER_FRAME_VIEW_SUCCESS) {
54: return USER_FRAME_VIEW_INDEX;
55: }
56: else {
57: return $ret;
58: }
59: }
60:
61: function execute(&$controller, &$xoopsUser)
62: {
63: if ($this->mObject == null) {
64: return USER_FRAME_VIEW_ERROR;
65: }
66:
67: $this->mActionForm->load($this->mObject);
68:
69: $this->mActionForm->fetch();
70: $this->mActionForm->validate();
71:
72: if ($this->mActionForm->hasError()) {
73: return $this->getDefaultView($controller, $xoopsUser);
74: }
75:
76:
77:
78:
79: $posts = 0;
80: $this->mGetUserPosts->call(new XCube_Ref($posts), $this->mObject);
81:
82: $handler =& xoops_getmodulehandler('users');
83: return $handler->insert($this->mObject) ? USER_FRAME_VIEW_SUCCESS
84: : USER_FRAME_VIEW_ERROR;
85: }
86:
87: function executeViewIndex(&$controller, &$xoopsUser, &$render)
88: {
89: $render->setTemplateName("user_view.html");
90: $render->setAttribute('actionForm', $this->mActionForm);
91: $render->setAttribute('object', $this->mObject);
92:
93: $render->setAttribute('rank', $this->mObject->getRank());
94:
95: $handler =& xoops_gethandler('timezone');
96: $timezone =& $handler->get($this->mObject->get('timezone_offset'));
97: $render->setAttribute('timezone', $timezone);
98:
99:
100:
101:
102: $umodeOptions = array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED);
103: $render->setAttribute('umode', $umodeOptions[$this->mObject->get('umode')]);
104:
105: $uorderOptions = array(0 => _OLDESTFIRST, 1 => _NEWESTFIRST);
106: $render->setAttribute('uorder', $uorderOptions[$this->mObject->get('uorder')]);
107:
108:
109:
110:
111: $controller->mRoot->mLanguageManager->loadPageTypeMessageCatalog('notification');
112: require_once XOOPS_ROOT_PATH . "/include/notification_constants.php";
113:
114: $methodOptions = array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE,
115: XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM,
116: XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL
117: );
118: $render->setAttribute('notify_method', $methodOptions[$this->mObject->get('notify_method')]);
119:
120: $modeOptions = array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS,
121: XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
122: XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN
123: );
124: $render->setAttribute('notify_mode', $modeOptions[$this->mObject->get('notify_mode')]);
125:
126: $definitions = array();
127: $profile = null;
128: XCube_DelegateUtils::call('Legacy_Profile.GetDefinition', new XCube_Ref($definitions), 'view');
129: XCube_DelegateUtils::call('Legacy_Profile.GetProfile', new XCube_Ref($profile), $this->mObject->get('uid'));
130: $render->setAttribute('definitions', $definitions);
131: $render->setAttribute('data', $profile);
132: }
133:
134: function executeViewSuccess(&$controller, &$xoopsUser, &$render)
135: {
136: $controller->executeRedirect("./index.php?action=UserView&uid=" . $this->mObject->get('uid'), 1, _AD_USER_MESSAGE_RECOUNT_SUCCESS);
137: }
138:
139: function executeViewError(&$controller, &$xoopsUser, &$render)
140: {
141: $controller->executeRedirect("./index.php?action=UserList", 1, _AD_USER_ERROR_CONTENT_IS_NOT_FOUND);
142: }
143: }
144:
145: ?>
146: