|
1
|
|
|
<?php namespace XoopsModules\Smallworld; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* You may not change or alter any portion of this comment or credits |
|
5
|
|
|
* of supporting developers from this source code or any supporting source code |
|
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
* |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* SmallWorld |
|
15
|
|
|
* |
|
16
|
|
|
* @copyright The XOOPS Project (https://xoops.org) |
|
17
|
|
|
* @copyright 2011 Culex |
|
18
|
|
|
* @license GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/) |
|
19
|
|
|
* @package SmallWorld |
|
20
|
|
|
* @since 1.0 |
|
21
|
|
|
* @author Michael Albertsen (http://culex.dk) <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class Profile |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @Show user |
|
27
|
|
|
* @param int $id |
|
28
|
|
|
* @return void |
|
29
|
|
|
*/ |
|
30
|
|
|
public function ShowUser($id) |
|
31
|
|
|
{ |
|
32
|
|
|
global $xoopsUser, $xoTheme, $xoopsTpl, $arr04, $arr05, $xoopsDB; |
|
33
|
|
|
if ($xoopsUser) { |
|
34
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
35
|
|
|
$module = $moduleHandler->getByDirname('smallworld'); |
|
36
|
|
|
$configHandler = xoops_getHandler('config'); |
|
37
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
$user = new \XoopsUser($id); |
|
40
|
|
|
$myName = $xoopsUser->getUnameFromId($xoopsUser->getVar('uid')); // My name |
|
41
|
|
|
$db = new SwDatabase(); |
|
42
|
|
|
$check = new User(); |
|
43
|
|
|
$Wall = new WallUpdates(); |
|
44
|
|
|
|
|
45
|
|
|
$cdb = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE userid = '" . $id . "'"; |
|
46
|
|
|
$result = $xoopsDB->queryF($cdb); |
|
47
|
|
|
$cnt = $xoopsDB->getRowsNum($result); |
|
|
|
|
|
|
48
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
49
|
|
|
$uname = $r['username']; |
|
50
|
|
|
$realname = $r['realname']; |
|
51
|
|
|
$membersince = date('d-m-Y', $user->user_regdate()); |
|
|
|
|
|
|
52
|
|
|
$birthday = Smallworld_UsToEuroDate($r['birthday']); |
|
53
|
|
|
$cnt_bday = smallworldNextBdaySecs($r['birthday']); |
|
54
|
|
|
$birthcity = $r['birthplace']; |
|
55
|
|
|
$email = $user->email(); |
|
|
|
|
|
|
56
|
|
|
$country = $user->user_from(); |
|
|
|
|
|
|
57
|
|
|
$signature = $user->user_sig(); |
|
58
|
|
|
$messenger = $user->user_msnm(); |
|
59
|
|
|
$totalposts = $Wall->CountMsges($id); |
|
60
|
|
|
$membersince = date('m-d-Y', $user->user_regdate()); |
|
61
|
|
|
$usersratedplus = $db->CountUsersRates($id, 'up'); |
|
62
|
|
|
$usersratedminus = $db->CountUsersRates($id, 'down'); |
|
63
|
|
|
$workfull = $db->getJobsToDiv($id); |
|
64
|
|
|
$workArray = unserialize($r['employer']); |
|
65
|
|
|
$work = "<a href='javascript:void(0)' id='_smallworld_workmore'>" . $workArray[0] . ' (' . _SMALLWORLD_MORE . ')</a>'; |
|
66
|
|
|
$educationfull = $db->getSchoolToDiv($id); |
|
67
|
|
|
$educationArray = unserialize($r['school_type']); |
|
68
|
|
|
$education = "<a href='javascript:void(0)' id='_smallworld_educationmore'>" . $educationArray[0] . ' (' . _SMALLWORLD_MORE . ')</a>'; |
|
69
|
|
|
$lng = $r['birthplace_lng']; |
|
70
|
|
|
$latt = $r['birthplace_lat']; |
|
71
|
|
|
$country = $r['birthplace_country']; |
|
72
|
|
|
$rank = $user->rank(); |
|
73
|
|
|
$rank_title = $rank['title']; |
|
74
|
|
|
if (isset($rank['image'])) { |
|
75
|
|
|
$rank_image = "<img align='center' src='" . XOOPS_UPLOAD_URL . '/' . $rank['image'] . "'>"; |
|
76
|
|
|
} else { |
|
77
|
|
|
$rank_image = ''; |
|
78
|
|
|
} |
|
79
|
|
|
$commentsrating = "<img src='" . XOOPS_URL . "/modules/smallworld/assets/images/like.png' height='10px' width='10px'" . '> ' . $usersratedplus; |
|
80
|
|
|
$commentsrating .= " <img src='" . XOOPS_URL . "/modules/smallworld/assets/images/dislike.png' height='10px' width='10px'" . '> ' . $usersratedminus; |
|
81
|
|
|
$lastlogin = $user->getVar('last_login'); |
|
82
|
|
|
|
|
83
|
|
|
$gender = $r['gender']; |
|
84
|
|
|
if (2 == $gender) { |
|
85
|
|
|
$heorshe = _SMALLWORLD_HE; |
|
86
|
|
|
$hisorher = _SMALLWORLD_HIS; |
|
87
|
|
|
} |
|
88
|
|
|
if (1 == $gender) { |
|
89
|
|
|
$heorshe = _SMALLWORLD_SHE; |
|
90
|
|
|
$hisorher = _SMALLWORLD_HER; |
|
91
|
|
|
} |
|
92
|
|
|
if ('' == $gender || 0 == $gender) { |
|
93
|
|
|
$heorshe = _SMALLWORLD_HEORSHE; |
|
94
|
|
|
$hisorher = _SMALLWORLD_HISHER; |
|
95
|
|
|
} |
|
96
|
|
|
$avatar = $Wall->Gravatar($id); |
|
97
|
|
|
$avatar_size = smallworld_getImageSize(80, 100, smallworld_getAvatarLink($id, $avatar)); |
|
|
|
|
|
|
98
|
|
|
$avatar_highwide = smallworld_imageResize($avatar_size[0], $avatar_size[1], 100); |
|
99
|
|
|
$user_img = "<img src='" . smallworld_getAvatarLink($id, $avatar) . "' id='smallworld_user_img' " . $avatar_highwide . '>'; |
|
100
|
|
|
|
|
101
|
|
|
$currentcity = $r['present_city']; |
|
102
|
|
|
$currlng = $r['present_lng']; |
|
103
|
|
|
$currlatt = $r['present_lat']; |
|
104
|
|
|
$currcountry = $r['present_country']; |
|
105
|
|
|
|
|
106
|
|
|
// experimental. Set javascript var using php getVar() |
|
107
|
|
|
$js = "<script type='text/javascript'>"; |
|
108
|
|
|
$js .= 'var smallworld_currlng = ' . $currlng . "\n"; |
|
109
|
|
|
$js .= 'var smallworld_currlatt = ' . $currlatt . "\n"; |
|
110
|
|
|
$js .= 'var smallworld_birthlng = ' . $lng . "\n"; |
|
111
|
|
|
$js .= 'var smallworld_birthlatt = ' . $latt . "\n"; |
|
112
|
|
|
$js .= '</script>'; |
|
113
|
|
|
echo $js; |
|
114
|
|
|
|
|
115
|
|
|
$relationship = $r['relationship']; |
|
116
|
|
|
$spouseExists = $check->spousexist($r['partner']); |
|
117
|
|
|
|
|
118
|
|
|
if (2 == $relationship) { |
|
119
|
|
|
$status = _SMALLWORLD_ISSINGLE; |
|
120
|
|
|
$spouse = ''; |
|
121
|
|
|
} |
|
122
|
|
View Code Duplication |
if (3 == $relationship) { |
|
|
|
|
|
|
123
|
|
|
$status = _SMALLWORLD_INRELATIONSHIP; |
|
124
|
|
|
if ($spouseExists > 0) { |
|
125
|
|
|
$spouse = "<a href='" . XOOPS_URL . '/modules/smallworld/userprofile.php?username=' . $r['partner'] . "' target='_self'>" . $r['partner'] . '</a>'; |
|
126
|
|
|
} else { |
|
127
|
|
|
$spouse = $r['partner']; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
View Code Duplication |
if (0 == $relationship) { |
|
|
|
|
|
|
131
|
|
|
$status = _SMALLWORLD_ISMARRIED; |
|
132
|
|
|
if ($spouseExists > 0) { |
|
133
|
|
|
$spouse = "<a href='" . XOOPS_URL . '/modules/smallworld/userprofile.php?username=' . $r['partner'] . "' target='_self'>" . $r['partner'] . '</a>'; |
|
134
|
|
|
} else { |
|
135
|
|
|
$spouse = $r['partner']; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
View Code Duplication |
if (1 == $relationship) { |
|
|
|
|
|
|
139
|
|
|
$status = _SMALLWORLD_ISENGAGED; |
|
140
|
|
|
if ($spouseExists > 0) { |
|
141
|
|
|
$spouse = "<a href='" . XOOPS_URL . '/modules/smallworld/userprofile.php?username=' . $r['partner'] . "' target='_self'>" . $r['partner'] . '</a>'; |
|
142
|
|
|
} else { |
|
143
|
|
|
$spouse = $r['partner']; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
View Code Duplication |
if (5 == $relationship) { |
|
|
|
|
|
|
147
|
|
|
$status = _SMALLWORLD_ISCOMPLICATED; |
|
148
|
|
|
if ($spouseExists > 0) { |
|
149
|
|
|
$spouse = "<a href='" . XOOPS_URL . '/modules/smallworld/userprofile.php?username=' . $r['partner'] . "' target='_self'>" . $r['partner'] . '</a>'; |
|
150
|
|
|
} else { |
|
151
|
|
|
$spouse = $r['partner']; |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
View Code Duplication |
if (4 == $relationship) { |
|
|
|
|
|
|
155
|
|
|
$status = _SMALLWORLD_OPENRELATIONSHIP; |
|
156
|
|
|
if ($spouseExists > 0) { |
|
157
|
|
|
$spouse = "<a href='" . XOOPS_URL . '/modules/smallworld/userprofile.php?username=' . $r['partner'] . "' target='_self'>" . $r['partner'] . '</a>'; |
|
158
|
|
|
} else { |
|
159
|
|
|
$spouse = $r['partner']; |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
//Personal info |
|
164
|
|
|
$aboutme = $r['aboutme']; |
|
165
|
|
|
$religion = $arr05[$r['religion']]; |
|
166
|
|
|
$politic = $arr04[$r['politic']]; |
|
167
|
|
|
|
|
168
|
|
|
//Interests |
|
169
|
|
|
$favbook = $r['books']; |
|
170
|
|
|
$favmusic = $r['music']; |
|
171
|
|
|
$favmovie = $r['movie']; |
|
172
|
|
|
$favtvshow = $r['tvshow']; |
|
173
|
|
|
$favinterests = $r['interests']; |
|
174
|
|
|
|
|
175
|
|
|
// Contact and adresses |
|
176
|
|
|
$email = unserialize($r['emailtype']); |
|
177
|
|
|
$screenname = $db->getScreennamesToDiv($id); |
|
178
|
|
View Code Duplication |
if ('' == $r['phone'] || 0 == $r['phone']) { |
|
|
|
|
|
|
179
|
|
|
$phone = 'xxx-xxx-xxxx'; |
|
180
|
|
|
} else { |
|
181
|
|
|
$phone = $r['phone']; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
View Code Duplication |
if ('' == $r['mobile'] || 0 == $r['mobile']) { |
|
|
|
|
|
|
185
|
|
|
$gsm = 'xxx-xxx-xxxx'; |
|
186
|
|
|
} else { |
|
187
|
|
|
$gsm = $r['mobile']; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
$adress = $r['adress']; |
|
191
|
|
|
$website = $r['website']; |
|
192
|
|
|
$age = Smallworld_Birthday($r['birthday']); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
//SW_CheckIfUser ($userid); |
|
196
|
|
|
$xoopsTpl->assign('userid', $id); |
|
197
|
|
|
|
|
198
|
|
|
// ----- LANG DEFINES ------ |
|
199
|
|
|
$xoopsTpl->assign('username', $uname); |
|
|
|
|
|
|
200
|
|
|
$xoopsTpl->assign('MyUserName', $myName); |
|
201
|
|
|
$xoopsTpl->assign('avatar', $user_img); |
|
|
|
|
|
|
202
|
|
|
$xoopsTpl->assign('realname', $realname); |
|
|
|
|
|
|
203
|
|
|
$xoopsTpl->assign('birthday', $birthday); |
|
|
|
|
|
|
204
|
|
|
$xoopsTpl->assign('nextBDay', $cnt_bday); |
|
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
$xoopsTpl->assign('usersratinf', $commentsrating); |
|
|
|
|
|
|
207
|
|
|
|
|
208
|
|
|
$xoopsTpl->assign('age', $age); |
|
|
|
|
|
|
209
|
|
|
$xoopsTpl->assign('birthcity', $birthcity); |
|
|
|
|
|
|
210
|
|
|
$xoopsTpl->assign('country', $country); |
|
|
|
|
|
|
211
|
|
|
$xoopsTpl->assign('heorshe', $heorshe); |
|
|
|
|
|
|
212
|
|
|
$xoopsTpl->assign('hisorher', $hisorher); |
|
|
|
|
|
|
213
|
|
|
|
|
214
|
|
|
$xoopsTpl->assign('membersince', $membersince); |
|
|
|
|
|
|
215
|
|
|
$xoopsTpl->assign('msn', $messenger); |
|
|
|
|
|
|
216
|
|
|
$xoopsTpl->assign('website', $website); |
|
|
|
|
|
|
217
|
|
|
$xoopsTpl->assign('totalposts', $totalposts); |
|
|
|
|
|
|
218
|
|
|
$xoopsTpl->assign('ranktitle', $rank_title); |
|
|
|
|
|
|
219
|
|
|
$xoopsTpl->assign('rankimage', $rank_image); |
|
|
|
|
|
|
220
|
|
|
$xoopsTpl->assign('lastlogin', date('d-m-Y', $lastlogin)); |
|
|
|
|
|
|
221
|
|
|
$xoopsTpl->assign('signature', $signature); |
|
|
|
|
|
|
222
|
|
|
$xoopsTpl->assign('currentcity', $currentcity); |
|
|
|
|
|
|
223
|
|
|
$xoopsTpl->assign('currcity', $currentcity); |
|
224
|
|
|
$xoopsTpl->assign('currcountry', $currcountry); |
|
|
|
|
|
|
225
|
|
|
|
|
226
|
|
|
$xoopsTpl->assign('education', $education); |
|
|
|
|
|
|
227
|
|
|
$xoopsTpl->assign('educationfull', $educationfull); |
|
|
|
|
|
|
228
|
|
|
|
|
229
|
|
|
$xoopsTpl->assign('work', $work); |
|
|
|
|
|
|
230
|
|
|
$xoopsTpl->assign('workfull', $workfull); |
|
|
|
|
|
|
231
|
|
|
|
|
232
|
|
|
$xoopsTpl->assign('relationship', $status); |
|
|
|
|
|
|
233
|
|
|
$xoopsTpl->assign('status', $status); |
|
234
|
|
|
$xoopsTpl->assign('spouse', $spouse); |
|
|
|
|
|
|
235
|
|
|
$xoopsTpl->assign('aboutme', $aboutme); |
|
|
|
|
|
|
236
|
|
|
$xoopsTpl->assign('lang.avatar', _SMALLWORLD_AVATAR); |
|
237
|
|
|
|
|
238
|
|
|
// Pers info language define |
|
239
|
|
|
$xoopsTpl->assign('politic', $politic); |
|
|
|
|
|
|
240
|
|
|
$xoopsTpl->assign('religion', $religion); |
|
|
|
|
|
|
241
|
|
|
|
|
242
|
|
|
$xoopsTpl->assign('favbook', $favbook); |
|
|
|
|
|
|
243
|
|
|
$xoopsTpl->assign('favmusic', $favmusic); |
|
|
|
|
|
|
244
|
|
|
$xoopsTpl->assign('favmovie', $favmovie); |
|
|
|
|
|
|
245
|
|
|
$xoopsTpl->assign('favtvshow', $favtvshow); |
|
|
|
|
|
|
246
|
|
|
$xoopsTpl->assign('favinterests', $favinterests); |
|
|
|
|
|
|
247
|
|
|
|
|
248
|
|
|
$xoopsTpl->assign('email', $email); |
|
|
|
|
|
|
249
|
|
|
$xoopsTpl->assign('screenname', $screenname); |
|
|
|
|
|
|
250
|
|
|
$xoopsTpl->assign('phone', $phone); |
|
|
|
|
|
|
251
|
|
|
$xoopsTpl->assign('mobile', $gsm); |
|
|
|
|
|
|
252
|
|
|
$xoopsTpl->assign('adress', $adress); |
|
|
|
|
|
|
253
|
|
|
|
|
254
|
|
|
$xoopsTpl->assign('website', $website); |
|
255
|
|
|
$xoopsTpl->assign('addsomeinfo', _SMALLWORLD_ADDSOMEINFO); |
|
256
|
|
|
$xoopsTpl->assign('pagename', 'profile'); |
|
257
|
|
|
} |
|
258
|
|
|
} |
|
259
|
|
|
} |
|
260
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.