-
Notifications
You must be signed in to change notification settings - Fork 2
/
ossn_com.php
86 lines (81 loc) · 2.72 KB
/
ossn_com.php
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
<?php
/**
* Open Source Social Network
*
* @packageOpen Source Social Network
* @author Open Social Website Core Team <info@informatikon.com>
* @copyright 2014 iNFORMATIKON TECHNOLOGIES
* @license General Public Licence http://www.opensource-socialnetwork.org/licence
* @link http://www.opensource-socialnetwork.org/licence
*/
define('__who_view_profile_type__', 'profile:viewed');
function who_viewed_my_profile_init() {
ossn_extend_view('css/ossn.default', 'profileviews/css');
if(ossn_isLoggedin()) {
ossn_register_callback('page', 'load:profile', 'who_viewed_my_profile');
ossn_register_page('profileviews', 'profileviews');
ossn_register_sections_menu('newsfeed', array(
'name' => 'profileviews',
'text' => ossn_print('profileviews'),
'url' => ossn_site_url('profileviews'),
'parent' => 'links',
'icon' => true,
));
}
}
function profileviews() {
//fix bug https://www.opensource-socialnetwork.org/component/view/2813/profile-views
$looks = ossn_get_relationships(array(
'from' => ossn_loggedin_user()->guid,
'type' => __who_view_profile_type__,
'order_by' => 'relation_id DESC',
));
$count = ossn_get_relationships(array(
'from' => ossn_loggedin_user()->guid,
'type' => __who_view_profile_type__,
'count' => true,
));
$users = false;
if($looks) {
foreach($looks as $item) {
$user = ossn_user_by_guid($item->relation_to);
if($user) {
$users[] = $user;
}
}
}
$vars['users'] = $users;
$vars['icon_size'] = 'small';
$lists = "<div class='ossn-page-contents'>";
$lists .= '<p><strong>' . ossn_print('profileviews') . '</strong></p>';
if($users){
$lists .= ossn_plugin_view('output/users_list', $vars);
$lists .= ossn_view_pagination($count);
}
$lists .= '</div>';
$contents = array(
'content' => $lists,
);
$title = ossn_print('profileviews');
$content = ossn_set_page_layout('newsfeed', $contents);
echo ossn_view_page($title, $content);
}
function who_viewed_my_profile() {
$profile = ossn_user_by_guid(ossn_get_page_owner_guid());
$user = ossn_loggedin_user();
if(!$profile || !$user) {
return false;
}
/*
if($profile->guid == $user->guid){
return false; // causing events tab to disappear from profile page
}
if(!ossn_relation_exists($profile->guid, $user->guid, __who_view_profile_type__)) {
ossn_add_relation($profile->guid, $user->guid, __who_view_profile_type__);
}
*/
if($profile->guid != $user->guid && !ossn_relation_exists($profile->guid, $user->guid, __who_view_profile_type__)){
ossn_add_relation($profile->guid, $user->guid, __who_view_profile_type__);
}
}
ossn_register_callback('ossn', 'init', 'who_viewed_my_profile_init');