tiki-user_information.php 8.38 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
6
// 
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
changi67's avatar
changi67 committed
9 10
// $Id$

11 12
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
13
include_once ('lib/userprefs/scrambleEmail.php');
14

15 16
if ($prefs['feature_unified_user_details'] == 'y'){
	include "tiki-user_unified_details.php";
17 18 19
	die;
}

20
$registrationlib = TikiLib::lib('registration');
lphuberdeau's avatar
lphuberdeau committed
21
$trklib = TikiLib::lib('trk');
22 23
if (isset($_REQUEST['userId'])) {
	$userwatch = $tikilib->get_user_login($_REQUEST['userId']);
24
	if ($userwatch === false) {
25
		$smarty->assign('errortype', 'no_redirect_login');
26 27 28 29
		$smarty->assign('msg', tra("Unknown user"));
		$smarty->display("error.tpl");
		die;
	}
30
} elseif (isset($_REQUEST['view_user'])) {
31
	$userwatch = $_REQUEST['view_user'];
32
	if (!$userlib->user_exists($userwatch)) {
33
		$smarty->assign('errortype', 'no_redirect_login');
34 35 36 37
		$smarty->assign('msg', tra("Unknown user"));
		$smarty->display("error.tpl");
		die;
	}
38
} else {
39 40
	$access->check_user($user);
	$userwatch = $user;
lrargerich's avatar
lrargerich committed
41
}
42

43
$smarty->assign('userwatch', $userwatch);
44 45
// Custom fields
$customfields = array();
michael_davey's avatar
 
michael_davey committed
46
$customfields = $registrationlib->get_customfields($userwatch);
47
$smarty->assign_by_ref('customfields', $customfields);
48
$smarty->assign('infoPublic', 'y');
49 50
if ($tiki_p_admin != 'y') {
	$user_information = $tikilib->get_user_preference($userwatch, 'user_information', 'public');
51 52
	// If the user is trying to pull info on themselves, allow it.
	if ($user_information == 'private' && $userwatch != $user) {
53
		$smarty->assign('infoPublic', 'n');
54
	}
55
}
56 57 58
if ($user) {
	$smarty->assign('sent', 0);
	if (isset($_REQUEST['send'])) {
59
		check_ticket('user-information');
60 61 62 63
		$smarty->assign('sent', 1);
		$message = '';
		if (empty($_REQUEST['subject']) && empty($_REQUEST['body'])) {
			$smarty->assign('message', tra('ERROR: Either the subject or body must be non-empty'));
64
			$smarty->display("tiki.tpl");
65 66
			die;
		}
67
		$sent = $messulib->post_message($userwatch, $user, $_REQUEST['to'], '', $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority'], '', isset($_REQUEST['replytome']) ? 'y' : '', isset($_REQUEST['bccme']) ? 'y' : '');
68
		if ($sent) {
69
			$message = tra('Message sent to') . ':' . $userlib->clean_user($userwatch) . '<br />';
70 71 72
		} else {
			$message = tra('An error occurred, please check your mail settings and try again');
		}
73 74
		$smarty->assign('message', $message);
	}
75
}
76
if ($prefs['feature_score'] == 'y' and isset($user) and $user != $userwatch) {
77 78 79
	$tikilib->score_event($user, 'profile_see');
	$tikilib->score_event($userwatch, 'profile_is_seen');
}
changi67's avatar
changi67 committed
80
$smarty->assign('priority', 3);
81
if ($prefs['allowmsg_is_optional'] == 'y') {
changi67's avatar
changi67 committed
82
	$allowMsgs = $tikilib->get_user_preference($userwatch, 'allowMsgs', 'y');
83 84 85
} else {
	$allowMsgs = 'y';
}
changi67's avatar
changi67 committed
86
$smarty->assign('allowMsgs', $allowMsgs);
87
$smarty->assign_by_ref('user_prefs', $user_preferences[$userwatch]);
changi67's avatar
changi67 committed
88 89
$user_style = $tikilib->get_user_preference($userwatch, 'theme', $prefs['site_style']);
$smarty->assign_by_ref('user_style', $user_style);
90
$user_language = $tikilib->get_language($userwatch);
91 92
$user_language_text = $tikilib->format_language_list(array($user_language));
$smarty->assign_by_ref('user_language', $user_language_text[0]['name']);
changi67's avatar
changi67 committed
93 94 95 96 97 98 99 100 101 102 103
$realName = $tikilib->get_user_preference($userwatch, 'realName', '');
$gender = $tikilib->get_user_preference($userwatch, 'gender', '');
$country = $tikilib->get_user_preference($userwatch, 'country', 'Other');
$smarty->assign('country', $country);
$anonpref = $tikilib->get_preference('userbreadCrumb', 4);
$userbreadCrumb = $tikilib->get_user_preference($userwatch, 'userbreadCrumb', $anonpref);
$smarty->assign_by_ref('realName', $realName);
$smarty->assign_by_ref('gender', $gender);
$smarty->assign_by_ref('userbreadCrumb', $userbreadCrumb);
$homePage = $tikilib->get_user_preference($userwatch, 'homePage', '');
$smarty->assign_by_ref('homePage', $homePage);
lrargerich's avatar
lrargerich committed
104
$avatar = $tikilib->get_user_avatar($userwatch);
105 106 107
$smarty->assign('avatar', $avatar);
$user_information = $tikilib->get_user_preference($userwatch, 'user_information', 'public');
$smarty->assign('user_information', $user_information);
lrargerich's avatar
lrargerich committed
108
$userinfo = $userlib->get_user_info($userwatch);
109
$email_isPublic = $tikilib->get_user_preference($userwatch, 'email is public', 'n');
110
if ($email_isPublic != 'n') {
111
	$smarty->assign('scrambledEmail', scrambleEmail($userinfo['email'], $email_isPublic));
112
}
113
$smarty->assign_by_ref('userinfo', $userinfo);
changi67's avatar
changi67 committed
114 115
$smarty->assign_by_ref('email_isPublic', $email_isPublic);
$userPage = $prefs['feature_wiki_userpage_prefix'] . $userinfo['login'];
116 117
$exist = $tikilib->page_exists($userPage);
$smarty->assign("userPage_exists", $exist);
118
if ($prefs['feature_display_my_to_others'] == 'y') {
119
	if ($prefs['feature_wiki'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
120
		$wikilib = TikiLib::lib('wiki');
121 122 123 124
		$user_pages = $wikilib->get_user_all_pages($userwatch, 'pageName_asc');
		$smarty->assign_by_ref('user_pages', $user_pages);
	}
	if ($prefs['feature_blogs'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
125
		$bloglib = TikiLib::lib('blog');
126
		$user_blogs = $bloglib->list_user_blogs($userwatch, false);
127
		$smarty->assign_by_ref('user_blogs', $user_blogs);
128 129
		$user_blog_posts = $bloglib->list_posts(0, -1, 'created_desc', '', -1, $userwatch);
		$smarty->assign_by_ref('user_blog_posts', $user_blog_posts['data']);
130 131 132 133 134 135
	}
	if ($prefs['feature_galleries'] == 'y') {
		$user_galleries = $tikilib->get_user_galleries($userwatch, -1);
		$smarty->assign_by_ref('user_galleries', $user_galleries);
	}
	if ($prefs['feature_trackers'] == 'y') {
136 137
		$trklib = TikiLib::lib('trk');
		$user_items = $trklib->get_user_items($userwatch);
138 139 140
		$smarty->assign_by_ref('user_items', $user_items);
	}
	if ($prefs['feature_articles'] == 'y') {
141
		$artlib = TikiLib::lib('art');
142 143 144 145
		$user_articles = $artlib->get_user_articles($userwatch, -1);
		$smarty->assign_by_ref('user_articles', $user_articles);
	}
	if ($prefs['feature_forums'] == 'y') {
146
		$commentslib = TikiLib::lib('comments');
147 148 149 150 151
		$user_forum_comments = $commentslib->get_user_forum_comments($userwatch, -1);
		$smarty->assign_by_ref('user_forum_comments', $user_forum_comments);
		$user_forum_topics = $commentslib->get_user_forum_comments($userwatch, -1, 'topics');
		$smarty->assign_by_ref('user_forum_topics', $user_forum_topics);
	}
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
	if ($prefs['user_who_viewed_my_stuff'] == 'y') {
		$mystuff = array();
		if (isset($user_pages)) {
			$stuffType = 'wiki page';
			foreach ($user_pages as $obj) {
				$mystuff[] = array( 'object' => $obj["pageName"], 'objectType' => $stuffType, 'comment' => '' );
			}
		}
		if (isset($user_blogs)) {
			$stuffType = 'blog';
			foreach ($user_blogs as $obj) {
				$mystuff[] = array( 'object' => $obj["blogId"], 'objectType' => $stuffType, 'comment' => '' );
			}
		}
		if (isset($user_articles)) {
			$stuffType = 'article';
			foreach ($user_articles as $obj) {
				$mystuff[] = array( 'object' => $obj["articleId"], 'objectType' => $stuffType, 'comment' => '' );
			}
		}
		if (isset($user_forum_topics)) {
			$stuffType = 'forum';
			foreach ($user_forum_topics as $obj) {
				$forum_comment = 'comments_parentId=' . $obj["threadId"];
				$mystuff[] = array( 'object' => $obj["object"], 'objectType' => $stuffType, 'comment' => $forum_comment );
			}
		}
179
		$logslib = TikiLib::lib('logs');
180 181 182
		$whoviewed = $logslib->get_who_viewed($mystuff, false);
		$smarty->assign('whoviewed', $whoviewed);
	}
183
}
changi67's avatar
changi67 committed
184
if ($prefs['user_tracker_infos']) {
185
	// arg passed 11,56,58,68=trackerId,fieldId...
changi67's avatar
changi67 committed
186 187 188 189
	$trackerinfo = explode(',', $prefs['user_tracker_infos']);
	$userTrackerId = $trackerinfo[0];
	array_shift($trackerinfo);
	$fields = $trklib->list_tracker_fields($userTrackerId, 0, -1, 'position_asc', '', true, array('fieldId' => $trackerinfo));
190
	foreach ($fields['data'] as $field) {
191 192
		$lll[$field['fieldId']] = $field;
	}
193 194
	$definition = Tracker_Definition::get($userTrackerId);
	$items = $trklib->list_items($userTrackerId, 0, 1, '', $lll, $definition->getUserField(), '', '', '', $userwatch);
changi67's avatar
changi67 committed
195
	$smarty->assign_by_ref('userItem', $items['data'][0]);
196
}
197
ask_ticket('user-information');
198 199
// Get full user picture if it is set
if ($prefs["user_store_file_gallery_picture"] == 'y') {
200
	$userprefslib = TikiLib::lib('userprefs');
201 202 203 204
	if ($user_picture_id = $userprefslib->get_user_picture_id($userwatch)) {	
		$smarty->assign('user_picture_id', $user_picture_id);
	}	
}
205 206
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
207
$smarty->assign('mid', 'tiki-user_information.tpl');
208
$smarty->display("tiki.tpl");