1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
User profile Sidebar |
5
|
|
|
*/ |
6
|
|
|
$owner = elgg_get_page_owner_entity(); |
7
|
|
|
|
8
|
|
|
$options = array( |
9
|
|
|
'type' => 'user', |
10
|
|
|
'pagination' => FALSE, |
11
|
|
|
'relationship' => 'friend', |
12
|
|
|
'relationship_guid' => $owner->getGUID(), |
13
|
|
|
'list_type' => 'gallery', |
14
|
|
|
'limit' => 14, |
15
|
|
|
'size' => 'small' |
16
|
|
|
); |
17
|
|
|
|
18
|
|
|
// add secondary clause for mutual relationships |
19
|
|
|
$options['wheres'][] = get_mutual_friendship_where_clause(); |
20
|
|
|
$list = elgg_list_entities_from_relationship($options); |
21
|
|
|
$count = count(elgg_get_entities_from_relationship($options)); |
22
|
|
|
|
23
|
|
|
$all_link = elgg_view('output/url', array( |
24
|
|
|
'href' => 'friends/' . $owner->username, |
25
|
|
|
'text' => elgg_echo('profile:viewall:coll'), |
26
|
|
|
'is_trusted' => true, |
27
|
|
|
'class' => 'text-center btn btn-default center-block', |
28
|
|
|
)); |
29
|
|
|
|
30
|
|
|
$footer = "<div class='text-right'>$all_link</div>"; |
31
|
|
|
|
32
|
|
|
if($count <= 0) { |
33
|
|
|
$friends = elgg_echo('gcprofile:nocoll', array($owner->getDisplayName())); |
34
|
|
|
$footer = ''; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
echo elgg_view_module('aside', elgg_echo('friends'), $list, array('footer' => $footer)); |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
// checks for reciprical friend relationship |
41
|
|
|
function get_mutual_friendship_where_clause() { |
42
|
|
|
$db_prefix = get_config('dbprefix'); |
43
|
|
|
return "EXISTS ( |
44
|
|
|
SELECT 1 FROM {$db_prefix}entity_relationships r2 |
45
|
|
|
WHERE r2.guid_one = r.guid_two |
46
|
|
|
AND r2.relationship = 'friend' |
47
|
|
|
AND r2.guid_two = r.guid_one)"; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/* |
51
|
|
|
User Profile Groups |
52
|
|
|
*/ |
53
|
|
|
|
54
|
|
|
$owner = elgg_get_page_owner_entity(); |
55
|
|
|
|
56
|
|
|
$groups = elgg_get_entities_from_relationship(array( |
57
|
|
|
'relationship'=> 'member', |
58
|
|
|
'relationship_guid'=> $owner->guid, |
59
|
|
|
'inverse_relationship'=> FALSE, |
60
|
|
|
'type'=> 'group', |
61
|
|
|
'limit'=> 3 |
62
|
|
|
)); |
63
|
|
|
|
64
|
|
|
$count = elgg_get_entities_from_relationship(array( |
65
|
|
|
'relationship'=> 'member', |
66
|
|
|
'relationship_guid'=> $owner->guid, |
67
|
|
|
'inverse_relationship'=> FALSE, |
68
|
|
|
'type'=> 'group', |
69
|
|
|
'limit'=> false, |
70
|
|
|
'count'=>true, |
71
|
|
|
)); |
72
|
|
|
|
73
|
|
|
$options = array( |
74
|
|
|
'full_view' => false, |
75
|
|
|
'list_type' => 'list', |
76
|
|
|
'pagination' => false, |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
$content = elgg_view_entity_list($groups, $options); |
80
|
|
|
|
81
|
|
|
$groupCount = '(' . $count . ')'; |
82
|
|
|
|
83
|
|
|
$all_link = elgg_view('output/url', array( |
84
|
|
|
'href' => 'groups/member/' . $owner->username, |
85
|
|
|
'text' => elgg_echo('profile:viewall:groups') . $groupCount, |
86
|
|
|
'is_trusted' => true, |
87
|
|
|
'class' => 'text-center btn btn-default center-block', |
88
|
|
|
)); |
89
|
|
|
|
90
|
|
|
$footer = "<div class='text-right'>$all_link</div>"; |
91
|
|
|
|
92
|
|
|
if(!($groups)) { |
93
|
|
|
|
94
|
|
|
$content = elgg_echo('gcprofile:nogroups', array($owner->getDisplayName())); |
95
|
|
|
$footer=''; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
echo elgg_view_module('aside', elgg_echo('groups'), $content, array('footer' => $footer)); |
99
|
|
|
|
100
|
|
|
//echo elgg_view('profile/sidebar/colleagues', $vars); |
101
|
|
|
//echo elgg_view('profile/sidebar/user_groups', $vars); |
102
|
|
|
|
103
|
|
|
?> |
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.