aboutsummaryrefslogtreecommitdiff
path: root/mod/profile/views/default/profile/profile_ownerblock.php
blob: a0c551b942551533fb1c59b5dcd1a76ce5c5b398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php

/**
 * A simple owner block which houses info about the user whose 'stuff' you are looking at
 */
 
//get the page owner
if($vars['entity']){
	if($vars['context'] == 'edit')
		$user = get_entity($vars['entity']->container_guid);
	else
		$user = get_entity($vars['entity']->guid);
}else{
	$user = page_owner_entity();
}
$more_info = '';
//set some variables
$location = elgg_view("output/tags",array('value' => $user->location));
$section = $vars['section'];
if($section == 'details'){
	$icon = elgg_view("profile/icon",array('entity' => $user, 'size' => 'large', 'override' => 'true'));
	$icon_class = "large";
}else{
	$icon = elgg_view("profile/icon",array('entity' => $user, 'size' => 'small'));
	$more_info = "<div class='owner_block_contents clearfloat'>";
	$more_info .= "<h3><a href='{$url}'>{$user->name}</a></h3>";
	$more_info .= "<p class='profile_info briefdescription'>{$user->briefdescription}</p>";
	$more_info .= "<p class='profile_info location'>{$location}</p>";
	$more_info .= "</div>";
}
$profile_actions = "";
if(isloggedin() && (get_loggedin_user()->getGuid() == page_owner())){
	$profile_actions = "<div class='clearfloat profile_actions'>";
	$profile_actions .= "<a href='{$vars['url']}pg/profile/{$user->username}/edit/details' class='action_button'>". elgg_echo('profile:edit') ."</a>";
	$profile_actions .= "<a href='{$vars['url']}pg/profile/{$user->username}/edit/icon' class='action_button'>". elgg_echo('profile:editicon') ."</a>";
	$profile_actions .= "</div>";
}else{
	$profile_actions = "<div class='profile_actions'>";
	if (isloggedin()) {
		if ($_SESSION['user']->getGUID() != $user->getGUID()) {
			$ts = time();
			$token = generate_action_token($ts);
					
			if ($user->isFriend()) {
				$profile_actions .= "<a href=\"{$vars['url']}action/friends/remove?friend={$user->getGUID()}&__elgg_token=$token&__elgg_ts=$ts\" class='action_button'>" . elgg_echo('friend:remove') . "</a>";
			} else {
				$profile_actions .= "<a href=\"{$vars['url']}action/friends/add?friend={$user->getGUID()}&__elgg_token=$token&__elgg_ts=$ts\" class='action_button'>" . elgg_echo('friend:add') . "</a>";
			}
		}
	}
	if(is_plugin_enabled('messages') && isloggedin()){
		$profile_actions .= "<a href=\"{$vars['url']}mod/messages/send.php?send_to={$user->guid}\" class='action_button'>". elgg_echo('messages:send') ."</a>";
	}
	$profile_actions .= "</div>";
}

$username = $user->username;
$email = $user->email;
$phone = $user->phone;
	
//get correct links
$url = $vars['url'];

//if admin display admin links
if(isadminloggedin()){
	$admin_links = elgg_view('profile/admin_menu');
}else{
	$admin_links = '';
}


//check tools are enabled - hard-coded for phase1
// @todo - provide a view to extend for profile pages ownerblock tool-links
if(is_plugin_enabled('blog')){
	$blog_link = "<li><a href=\"{$vars['url']}pg/blog/{$username}\">Blog</a></li>";
}else{
	$blog_link = "";
}
if(is_plugin_enabled('bookmarks')){
	$bookmark_link = "<li><a href=\"{$vars['url']}pg/bookmarks/{$username}\">Bookmarks</a></li>";
}else{
	$bookmark_link = "";
}
if(is_plugin_enabled('document')){
	$docs_link = "<li><a href=\"{$vars['url']}pg/document/{$username}\">Documents</a></li>";
}else{
	$docs_link = "";
}
if(is_plugin_enabled('feeds')){
	$feeds_link = "<li><a href=\"{$vars['url']}pg/feeds/{$username}\">Feeds</a></li>";
}else{
	$feeds_link = "";
}
if(is_plugin_enabled('tidypics')){
	$tidypics_link = "<li><a href=\"{$vars['url']}pg/photos/owned/{$username}\">Photos</a></li>";
}else{
	$tidypics_link = "";
}
if(is_plugin_enabled('videolist')){
	$video_link = "<li><a href=\"{$vars['url']}pg/videolist/{$username}\">Videos</a></li>";
}else{
	$video_link = "";
}

//contruct the display
$display = <<<EOT

<div id="owner_block">
	<div class="owner_block_icon {$icon_class}">
		{$icon}
	</div>
	{$more_info}
	{$profile_actions}
	<div class="owner_block_links">
		<ul>
		{$blog_link}
		{$bookmark_link}
		{$docs_link}
		{$feeds_link}
		{$tidypics_link}
		{$video_link}
		</ul>
	</div>
	<!-- if admin user -->
	{$admin_links}	
</div>
	
EOT;

echo $display;