Permalink
Newer
Older
100644 136 lines (104 sloc) 5.44 KB
1
<?php
2
3
////////////////////////////////////////////////////////////////////////////////
4
// //
5
// Copyright (C) 2007 Phorum Development Team //
6
// http://www.phorum.org //
7
// //
8
// This program is free software. You can redistribute it and/or modify //
9
// it under the terms of either the current Phorum License (viewable at //
10
// phorum.org) or the Phorum License that was distributed with this file //
11
// //
12
// This program is distributed in the hope that it will be useful, //
13
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
15
// //
16
// You should have received a copy of the Phorum License //
17
// along with this program. //
18
////////////////////////////////////////////////////////////////////////////////
19
define('phorum_page','profile');
20
21
include_once("./common.php");
22
include_once("./include/email_functions.php");
23
include_once("./include/format_functions.php");
24
25
// set all our URL's
26
phorum_build_common_urls();
27
28
$template = "profile";
29
$error = "";
30
31
// redirect if no profile id passed
32
if(!empty($PHORUM["args"][1])){
33
$profile_id = (int)$PHORUM["args"][1];
34
}
35
36
if(empty($PHORUM["args"][1]) || empty($profile_id)){
37
phorum_redirect_by_url(phorum_get_url(PHORUM_INDEX_URL));
38
exit();
39
}
40
41
include_once("./include/users.php");
42
43
$user = phorum_user_get($profile_id);
44
45
if(!is_array($user) || $user["active"]==0) {
46
$PHORUM["DATA"]["ERROR"]=$PHORUM["DATA"]["LANG"]["UnknownUser"];
47
$PHORUM['DATA']["URL"]["REDIRECT"]=phorum_get_url(PHORUM_LIST_URL);
48
$PHORUM['DATA']["BACKMSG"]=$PHORUM["DATA"]["LANG"]["BackToList"];
49
50
// have to include the header here for the Redirect
53
}
54
55
// security messures
56
unset($user["password"]);
57
unset($user["permissions"]);
58
59
// set any custom profile fields that are not present.
60
if (!empty($PHORUM["PROFILE_FIELDS"])) {
61
foreach($PHORUM["PROFILE_FIELDS"] as $id => $field) {
62
if ($id === 'num_fields' || !empty($field['deleted'])) continue;
63
if (!isset($user[$field['name']])) $user[$field['name']] = "";
64
}
65
}
66
67
// No need to show the real name in case it's the same
68
// as the display name.
69
if ($user["real_name"] == $user["display_name"]) {
70
unset($user["real_name"]);
71
}
72
73
$PHORUM["DATA"]["PROFILE"] = $user;
74
$PHORUM["DATA"]["PROFILE"]["forum_id"] = $PHORUM["forum_id"];
75
76
$PHORUM["DATA"]["PROFILE"]["raw_date_added"]=$PHORUM["DATA"]["PROFILE"]["date_added"];
77
$PHORUM["DATA"]["PROFILE"]["date_added"]=phorum_date( $PHORUM['short_date'], $PHORUM["DATA"]["PROFILE"]["date_added"]);
78
79
if( !empty($PHORUM["user"]["admin"]) ||
80
(phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_MESSAGES) && PHORUM_MOD_EMAIL_VIEW) ||
81
(phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_USERS) && PHORUM_MOD_EMAIL_VIEW) ||
82
!$user["hide_email"]){
83
84
$PHORUM["DATA"]["PROFILE"]["email"]=phorum_html_encode($user["email"]);
85
} else {
86
$PHORUM["DATA"]["PROFILE"]["email"] = $PHORUM["DATA"]["LANG"]["Hidden"];
87
}
88
89
if( $PHORUM["track_user_activity"] &&
90
(!empty($PHORUM["user"]["admin"]) ||
91
(phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_MESSAGES)) ||
92
(phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_USERS)) ||
93
!$user["hide_activity"])){
95
$PHORUM["DATA"]["PROFILE"]["raw_date_last_active"]=$PHORUM["DATA"]["PROFILE"]["date_last_active"];
96
$PHORUM["DATA"]["PROFILE"]["date_last_active"]=phorum_date( $PHORUM['short_date'], $PHORUM["DATA"]["PROFILE"]["date_last_active"]);
97
} else {
98
unset($PHORUM["DATA"]["PROFILE"]["date_last_active"]);
99
}
100
101
$PHORUM["DATA"]["PROFILE"]["posts"] = number_format($PHORUM["DATA"]["PROFILE"]["posts"], 0, "", $PHORUM["thous_sep"]);
103
$PHORUM["DATA"]["PROFILE"]["URL"]["PM"] = phorum_get_url(PHORUM_PM_URL, "page=send", "to_id=".urlencode($user["user_id"]));
104
$PHORUM["DATA"]["PROFILE"]["URL"]["ADD_BUDDY"] = phorum_get_url(PHORUM_PM_URL, "page=buddies", "action=addbuddy", "addbuddy_id=".urlencode($user["user_id"]));
105
$PHORUM["DATA"]["PROFILE"]["is_buddy"] = phorum_db_pm_is_buddy($user["user_id"]);
106
// unset($PHORUM["DATA"]["PROFILE"]["signature"]);
107
108
$PHORUM["DATA"]["PROFILE"]["URL"]["SEARCH"] = phorum_get_url(PHORUM_SEARCH_URL, "author=".urlencode($PHORUM["DATA"]["PROFILE"]["user_id"]), "match_type=USER_ID", "match_dates=0", "match_threads=0");
110
$PHORUM["DATA"]["PROFILE"]["username"] =
111
htmlspecialchars($PHORUM["DATA"]["PROFILE"]["username"]);
112
113
if (isset($PHORUM["DATA"]["PROFILE"]["real_name"])) {
114
$PHORUM["DATA"]["PROFILE"]["real_name"] =
115
htmlspecialchars($PHORUM["DATA"]["PROFILE"]["real_name"]);
116
}
117
118
if (empty($PHORUM["custom_display_name"])) {
119
$PHORUM["DATA"]["PROFILE"]["display_name"] =
120
htmlspecialchars($PHORUM["DATA"]["PROFILE"]["display_name"]);
123
if (isset($PHORUM["hooks"]["profile"]))
124
$PHORUM["DATA"]["PROFILE"] = phorum_hook("profile", $PHORUM["DATA"]["PROFILE"]);
126
$PHORUM["DATA"]["HEADING"] = $PHORUM["DATA"]["LANG"]["UserProfile"];
127
$PHORUM["DATA"]["DESCRIPTION"] = "";
128
129
130
// set all our URL's
131
phorum_build_common_urls();
# Fix for ticket #180: Forumlist and Messagelist incorrect in profile…
Nov 10, 2005
132
134
135
?>