XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
UserInfoAction.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_MODULE_PATH . '/user/class/ActionFrame.class.php';
13define('USER_USERINFO_MAXHIT', 5);
14
15/***
16 * @internal
17 * This action shows a information of the target user which is specified by
18 * $uid. And display posts of the user with the global search service.
19 *
20 * [Warning]
21 * Now, the global search service can't work because the design of XCube is
22 * changed.
23 *
24 * @todo The global search service can't work.
25 */
26class User_UserInfoAction extends User_Action
27{
28 public $mObject = null;
29 public $mRankObject = null;
30 public $mSearchResults = null;
31
32 public $mSelfDelete = false;
33
34 public $mPmliteURL = null;
35
43 protected function _getPagetitle()
44 {
46 }
47
48 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
49 {
50 $this->mSelfDelete = $moduleConfig['self_delete'];
51 }
52
53 public function isSecure()
54 {
55 return false;
56 }
57
58 public function getDefaultView(&$controller, &$xoopsUser)
59 {
60 $uid = isset($_GET['uid']) ? (int)xoops_getrequest('uid') : 0;
61
62 $handler =& xoops_gethandler('user');
63 $this->mObject =& $handler->get($uid);
64
65 if (!is_object($this->mObject)) {
66 return USER_FRAME_VIEW_ERROR;
67 }
68
69 $t_rank = xoops_getrank($this->mObject->get('rank'), $this->mObject->get('posts'));
70
71 $rankHandler =& xoops_getmodulehandler('ranks', 'user');
72 $this->mRankObject =& $rankHandler->get($t_rank['id']);
73
74 $root =& $controller->mRoot;
75
76 $service =& $root->mServiceManager->getService('privateMessage');
77 if ($service != null) {
78 $client =& $root->mServiceManager->createClient($service);
79 $this->mPmliteURL = $client->call('getPmliteUrl', ['fromUid' => is_object($xoopsUser) ? $xoopsUser->get('uid') : 0, 'toUid' => $uid]);
80 }
81 unset($service);
82
83 $service =& $root->mServiceManager->getService('LegacySearch');
84 if (null != $service) {
85 $this->mSearchResults = [];
86
87 $client =& $root->mServiceManager->createClient($service);
88
89 $moduleArr = $client->call('getActiveModules', []);
90 $uid = $this->mObject->get('uid');
91
92 foreach ($moduleArr as $t_module) {
93 $params = [
94 'mid' => $t_module['mid'],
95 'uid' => $uid,
96 'maxhit' => USER_USERINFO_MAXHIT,
97 'start' => 0
98 ];
99
100 $module = [
101 'name' => $t_module['name'],
102 'mid' => $t_module['mid'],
103 'results' => $client->call('searchItemsOfUser', $params)
104 ];
105
106 $nresult = is_countable($module['results']) ? count($module['results']) : 0;
107 if ($nresult) {
108 $module['has_more'] = $nresult >= USER_USERINFO_MAXHIT;
109 $this->mSearchResults[] = &$module;
110 unset($module);
111 }
112 }
113 }
114
115 return USER_FRAME_VIEW_SUCCESS;
116 }
117
118 /***
119 * [Notice]
120 * Because XCube_Service class group are changed now, this member function
121 * can't get the result of user posts.
122 * @param $controller
123 * @param $xoopsUser
124 * @param $render
125 */
126 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
127 {
128 $render->setTemplateName('user_userinfo.html');
129 $render->setAttribute('thisUser', $this->mObject);
130 $render->setAttribute('rank', $this->mRankObject);
131
132 $render->setAttribute('pmliteUrl', $this->mPmliteURL);
133
134 $userSignature = $this->mObject->getShow('user_sig');
135
136 $render->setAttribute('user_signature', $userSignature);
137
138 $render->setAttribute('searchResults', $this->mSearchResults);
139
140 //
141 // set flags.
142 //
143 $user_ownpage = (is_object($xoopsUser) && $xoopsUser->get('uid') == $this->mObject->get('uid'));
144 $render->setAttribute('user_ownpage', $user_ownpage);
145
146 //
147 // About 'SELF DELETE'
148 //
149 $render->setAttribute('self_delete', $this->mSelfDelete);
150 if ($user_ownpage && $this->mSelfDelete) {
151 $render->setAttribute('enableSelfDelete', true);
152 } else {
153 $render->setAttribute('enableSelfDelete', false);
154 }
155 }
156
157 public function executeViewError(&$controller, &$xoopsUser, &$render)
158 {
159 $controller->executeForward(XOOPS_URL . '/user.php');
160 }
161}
static getUserName( $uid)