XOOPS  2.6.0
userinfo.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
23 include __DIR__ . '/mainfile.php';
24 
27 $xoops->preload()->triggerEvent('core.userinfo.start');
28 
29 $xoops->loadLanguage('user');
30 include_once $xoops->path('modules/system/constants.php');
31 
32 $uid = intval($_GET['uid']);
33 if ($uid <= 0) {
34  $xoops->redirect('index.php', 3, XoopsLocale::E_NO_USER_SELECTED);
35 }
36 $gperm_handler = $xoops->getHandlerGroupperm();
37 $groups = $xoops->getUserGroups();
38 
39 $isAdmin = $gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_USER, $groups);
40 if ($xoops->isUser()) {
41  if ($uid == $xoops->user->getVar('uid')) {
42  $xoopsConfigUser = $xoops->getConfigs();
43  $xoops->header('module:system/system_userinfo.tpl');
44  $xoops->tpl()->assign('user_ownpage', true);
45  $xoops->tpl()->assign('lang_editprofile', XoopsLocale::EDIT_PROFILE);
46  $xoops->tpl()->assign('lang_avatar', XoopsLocale::AVATAR);
47  $xoops->tpl()->assign('lang_inbox', XoopsLocale::INBOX);
48  $xoops->tpl()->assign('lang_logout', XoopsLocale::A_LOGOUT);
49  if ($xoopsConfigUser['self_delete'] == 1) {
50  $xoops->tpl()->assign('user_candelete', true);
51  $xoops->tpl()->assign('lang_deleteaccount', XoopsLocale::DELETE_ACCOUNT);
52  } else {
53  $xoops->tpl()->assign('user_candelete', false);
54  }
55  $thisUser = $xoops->user;
56  } else {
57  $member_handler = $xoops->getHandlerMember();
58  $thisUser = $member_handler->getUser($uid);
59  if (!is_object($thisUser) || !$thisUser->isActive()) {
60  $xoops->redirect("index.php", 3, XoopsLocale::E_NO_USER_SELECTED);
61  }
62  $xoops->header('module:system/system_userinfo.tpl');
63  $xoops->tpl()->assign('user_ownpage', false);
64  }
65 } else {
66  $member_handler = $xoops->getHandlerMember();
68  if (!is_object($thisUser) || !$thisUser->isActive()) {
69  $xoops->redirect("index.php", 3, XoopsLocale::E_NO_USER_SELECTED);
70  }
71  $xoops->header('module:system/system_userinfo.tpl');
72  $xoops->tpl()->assign('user_ownpage', false);
73 }
75 if ($xoops->isUser() && $isAdmin) {
76  $xoops->tpl()->assign('lang_editprofile', XoopsLocale::EDIT_PROFILE);
77  $xoops->tpl()->assign('lang_deleteaccount', XoopsLocale::DELETE_ACCOUNT);
78  $xoops->tpl()->assign('user_uid', $thisUser->getVar('uid'));
79 }
80 
81 // Let extensions add navigation button(s)
82 //$xoops->events()->triggerEvent('core.userinfo.button', array($thisUser, &$btn));
83 $response = $xoops->service("Avatar")->getAvatarEditUrl($thisUser);
84 $link=$response->getValue();
85 if (!empty($link)) {
86  $btn[] = array( 'link' => $link, 'title' => XoopsLocale::AVATAR, 'icon' => 'icon-user');
87  $xoops->tpl()->assign('btn', $btn);
88 }
89 
90 $xoops->tpl()->assign('xoops_pagetitle', sprintf(XoopsLocale::F_ALL_ABOUT, $thisUser->getVar('uname')));
91 $xoops->tpl()->assign('lang_allaboutuser', sprintf(XoopsLocale::F_ALL_ABOUT, $thisUser->getVar('uname')));
92 
93 $response = $xoops->service("Avatar")->getAvatarUrl($thisUser);
94 $avatar = $response->getValue();
95 
96 $xoops->tpl()->assign('user_avatarurl', empty($avatar) ? '' : $avatar);
97 $xoops->tpl()->assign('lang_realname', XoopsLocale::REAL_NAME);
98 $xoops->tpl()->assign('user_realname', $thisUser->getVar('name'));
99 $xoops->tpl()->assign('lang_website', XoopsLocale::WEBSITE);
100 if ($thisUser->getVar('url', 'E') == '') {
101  $xoops->tpl()->assign('user_websiteurl', '');
102 } else {
103  $xoops->tpl()->assign(
104  'user_websiteurl',
105  '<a href="' . $thisUser->getVar('url', 'E') . '" rel="external">' . $thisUser->getVar('url') . '</a>'
106  );
107 }
108 $xoops->tpl()->assign('lang_email', XoopsLocale::EMAIL);
109 $xoops->tpl()->assign('lang_privmsg', XoopsLocale::PM);
110 $xoops->tpl()->assign('lang_icq', XoopsLocale::ICQ);
111 $xoops->tpl()->assign('user_icq', $thisUser->getVar('user_icq'));
112 $xoops->tpl()->assign('lang_aim', XoopsLocale::AIM);
113 $xoops->tpl()->assign('user_aim', $thisUser->getVar('user_aim'));
114 $xoops->tpl()->assign('lang_yim', XoopsLocale::YIM);
115 $xoops->tpl()->assign('user_yim', $thisUser->getVar('user_yim'));
116 $xoops->tpl()->assign('lang_msnm', XoopsLocale::MSNM);
117 $xoops->tpl()->assign('user_msnm', $thisUser->getVar('user_msnm'));
118 $xoops->tpl()->assign('lang_location', XoopsLocale::LOCATION);
119 $xoops->tpl()->assign('user_location', $thisUser->getVar('user_from'));
120 $xoops->tpl()->assign('lang_occupation', XoopsLocale::OCCUPATION);
121 $xoops->tpl()->assign('user_occupation', $thisUser->getVar('user_occ'));
122 $xoops->tpl()->assign('lang_interest', XoopsLocale::INTEREST);
123 $xoops->tpl()->assign('user_interest', $thisUser->getVar('user_intrest'));
124 $xoops->tpl()->assign('lang_extrainfo', XoopsLocale::EXTRA_INFO);
125 $var = $thisUser->getVar('bio', 'N');
126 $xoops->tpl()->assign('user_extrainfo', $myts->displayTarea($var, 0, 1, 1));
127 $xoops->tpl()->assign('lang_statistics', XoopsLocale::STATISTICS);
128 $xoops->tpl()->assign('lang_membersince', XoopsLocale::MEMBER_SINCE);
129 $var = $thisUser->getVar('user_regdate');
130 $xoops->tpl()->assign('user_joindate', XoopsLocale::formatTimestamp($var, 's'));
131 $xoops->tpl()->assign('lang_rank', XoopsLocale::RANK);
132 $xoops->tpl()->assign('lang_posts', XoopsLocale::POSTS);
133 $xoops->tpl()->assign('lang_basicInfo', XoopsLocale::BASIC_INFORMATION);
134 $xoops->tpl()->assign('lang_more', XoopsLocale::MORE_ABOUT_ME);
135 $xoops->tpl()->assign('lang_myinfo', XoopsLocale::MY_INFORMATION);
136 $xoops->tpl()->assign('user_posts', $thisUser->getVar('posts'));
137 $xoops->tpl()->assign('lang_lastlogin', XoopsLocale::LAST_LOGIN);
138 $xoops->tpl()->assign('lang_signature', XoopsLocale::SIGNATURE);
139 $xoops->tpl()->assign('lang_posts', XoopsLocale::POSTS);
140 $var = $thisUser->getVar('user_sig', 'N');
141 $xoops->tpl()->assign('user_signature', $myts->displayTarea($var, 0, 1, 1));
142 if ($thisUser->getVar('user_viewemail') == 1) {
143  $xoops->tpl()->assign('user_email', $thisUser->getVar('email', 'E'));
144 } else {
145  if ($xoops->isUser()) {
146  // All admins will be allowed to see emails, even those that are not allowed
147  // to edit users (I think it's ok like this)
148  if ($xoops->userIsAdmin || ($xoops->user->getVar("uid") == $thisUser->getVar("uid"))) {
149  $xoops->tpl()->assign('user_email', $thisUser->getVar('email', 'E'));
150  } else {
151  $xoops->tpl()->assign('user_email', '&nbsp;');
152  }
153  }
154 }
155 if ($xoops->isUser()) {
156  $xoops->tpl()->assign(
157  'user_pmlink',
158  "<a href=\"javascript:openWithSelfMain('" . $xoops_url . "/pmlite.php?send2=1&amp;to_userid="
159  . $thisUser->getVar('uid') . "', 'pmlite', 450, 380);\"><img src=\"" . $xoops_url
160  . "/images/icons/pm.gif\" alt=\""
161  . sprintf(XoopsLocale::F_SEND_PRIVATE_MESSAGE_TO, $thisUser->getVar('uname')) . "\" /></a>"
162  );
163 } else {
164  $xoops->tpl()->assign('user_pmlink', '');
165 }
166 if ($xoops->isActiveModule('userrank')) {
167  $userrank = $thisUser->rank();
168  if (isset($userrank['image']) && $userrank['image']) {
169  $xoops->tpl()->assign(
170  'user_rankimage',
171  '<img src="' . \XoopsBaseConfig::get('uploads-url') . '/' . $userrank['image'] . '" alt="" />'
172  );
173  }
174  $xoops->tpl()->assign('user_ranktitle', $userrank['title']);
175 }
176 $date = $thisUser->getVar("last_login");
177 if (!empty($date)) {
178  $xoops->tpl()->assign('user_lastlogin', XoopsLocale::formatTimestamp($date, "m"));
179 }
180 
181 $module_handler = $xoops->getHandlerModule();
182 $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
183 $criteria->add(new Criteria('isactive', 1));
184 $criteria->add(new Criteria('weight', 0, '>'));
185 $modules = $module_handler->getObjectsArray($criteria, true);
186 $moduleperm_handler = $xoops->getHandlerGroupperm();
187 $groups = $xoops->getUserGroups();
188 $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
189 
190 foreach (array_keys($modules) as $i) {
191  if (in_array($i, $read_allowed)) {
192  /* @var $plugin SearchPluginInterface */
193  $plugin = \Xoops\Module\Plugin::getPlugin($modules[$i]->getVar('dirname'), 'search');
194  if (method_exists($plugin, 'search')) {
195  $results = $plugin->search('', '', 5, 0, $thisUser->getVar('uid'));
196 
197  if (is_array($results) && count($results) > 0) {
198  $count = count($results);
199 
200  foreach ($results as $k => $result) {
201  if (isset($result['image']) && $result['image'] != '') {
202  $results[$k]['image']
203  = $xoops->url('modules/' . $modules[$i]->getVar('dirname') . '/' . $result['image']);
204  } else {
205  $results[$k]['image'] = $xoops->url('images/icons/posticon2.gif');
206  }
207 
208  if (!preg_match("/^http[s]*:\/\//i", $result['link'])) {
209  $results[$k]['link']
210  = $xoops->url("modules/" . $modules[$i]->getVar('dirname') . "/" . $result['link']);
211  }
212 
213  $results[$k]['title'] = $myts->htmlspecialchars($result['title']);
214  $results[$k]['title_highligh'] = $myts->htmlspecialchars($result['title']);
215  if (!empty($result['time'])) {
216  $results[$k]['time'] = $result['time'] ? XoopsLocale::formatTimestamp($result['time']) : '';
217  }
218  if (!empty($results[$k]['uid'])) {
219  $results[$k]['uid'] = @intval($results[$k]['uid']);
220  $results[$k]['uname'] = XoopsUser::getUnameFromId($results[$k]['uid'], true);
221  }
222  }
223  if ($count == 5) {
224  $showall_link = '<a href="search.php?action=showallbyuser&amp;mid='
225  . $modules[$i]->getVar('mid') . '&amp;uid=' . $thisUser->getVar('uid')
226  . '">' . XoopsLocale::SHOW_ALL . '</a>';
227  } else {
228  $showall_link = '';
229  }
230  $xoops->tpl()->append(
231  'modules',
232  array(
233  'name' => $modules[$i]->getVar('name'),
234  'image' => $xoops->url('modules/' . $modules[$i]->getVar('dirname') . '/icons/logo_large.png'),
235  'result' => $results,
236  'showall_link' => $showall_link
237  )
238  );
239 
240  }
241  }
242  }
243 }
244 $xoops->footer();
static formatTimestamp($time, $format= 'l', $timeoffset=null)
Definition: Abstract.php:289
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
const MEMBER_SINCE
Definition: en_US.php:834
$xoops
Definition: userinfo.php:26
$i
Definition: dialog.php:68
const F_SEND_PRIVATE_MESSAGE_TO
Definition: en_US.php:439
$xoopsConfigUser
Definition: register.php:33
$criteria
Definition: userinfo.php:182
if($uid<=0) $gperm_handler
Definition: userinfo.php:36
static getInstance()
Definition: Xoops.php:160
$xoops_url
Definition: userinfo.php:25
$read_allowed
Definition: userinfo.php:188
$result
Definition: pda.php:33
$myts
Definition: userinfo.php:74
const STATISTICS
Definition: en_US.php:1017
$link
Definition: userinfo.php:84
const DELETE_ACCOUNT
Definition: en_US.php:203
$uid
Definition: userinfo.php:32
const MY_INFORMATION
Definition: en_US.php:848
$thisUser
Definition: userinfo.php:67
const INTEREST
Definition: en_US.php:484
const LAST_LOGIN
Definition: en_US.php:497
const OCCUPATION
Definition: en_US.php:872
const SHOW_ALL
Definition: en_US.php:1002
const AVATAR
Definition: en_US.php:76
static getUnameFromId($userid, $usereal=0)
Definition: user.php:124
static get($name)
const EDIT_PROFILE
Definition: en_US.php:228
const REAL_NAME
Definition: en_US.php:942
const XOOPS_SYSTEM_USER
Definition: constants.php:23
const BASIC_INFORMATION
Definition: en_US.php:136
const E_NO_USER_SELECTED
Definition: en_US.php:357
const F_ALL_ABOUT
Definition: en_US.php:400
const SIGNATURE
Definition: en_US.php:1005
$modules
Definition: userinfo.php:185
$moduleperm_handler
Definition: userinfo.php:186
$avatar
Definition: userinfo.php:94
$isAdmin
Definition: userinfo.php:39
if($xoops->isUser()&&$isAdmin) $response
Definition: userinfo.php:83
const EXTRA_INFO
Definition: en_US.php:309
$var
Definition: userinfo.php:125
$groups
Definition: userinfo.php:37
const LOCATION
Definition: en_US.php:515
const A_LOGOUT
Definition: en_US.php:103
const MORE_ABOUT_ME
Definition: en_US.php:843
if(!empty($date)) $module_handler
Definition: userinfo.php:181