/
ossn_com.php
65 lines (63 loc) · 2.2 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
<?php
/**
* Open Source Social Network
*
* @package Open Source Social Network
* @author Core Team
* @copyright (C) OpenTeknik LLC
* @license Open Source Social Network License (OSSN LICENSE) http://www.opensource-socialnetwork.org/licence
* @link https://www.opensource-socialnetwork.org/
*/
ossn_register_callback('ossn', 'init', function (): void {
ossn_extend_view('css/ossn.default', 'friendsonline/css');
if(ossn_isLoggedin()) {
ossn_register_menu_item('newsfeed', array(
'name' => 'friendsonline',
'text' => ossn_print('friendsonline'),
'href' => ossn_site_url('friendsonline'),
'parent' => 'links',
));
ossn_register_page('friendsonline', 'friendsonline_page_handler');
ossn_add_hook('newsfeed', 'sidebar:right', function ($hook, $type, $return) {
$widget = ossn_plugin_view('widget/view', array(
'title' => ossn_print('friendsonline'),
'class' => 'friendsonline-widget',
'contents' => ossn_plugin_view('friendsonline/widget'),
));
$return[] = $widget;
return $return;
});
ossn_add_hook('newsfeed', "center:top", function ($hook, $type, $return) {
$widget = ossn_plugin_view('widget/view', array(
'title' => ossn_print('friendsonline'),
'class' => 'friendsonline-widget',
'contents' => ossn_plugin_view('friendsonline/widget'),
));
$return[] = $widget;
return $return;
});
}
});
function friendsonline(array $params = array()): int | array | bool {
$time = time();
$intervals = 60;
$users = new OssnUser();
$notself = '';
if(ossn_isLoggedin()) {
$user = ossn_loggedin_user();
$notself = "AND u.guid != {$user->guid}";
}
$default = array(
'offset' => input('online_users_page', '', 1),
'wheres' => "(u.last_activity > {$time} - {$intervals} {$notself})",
);
$args = array_merge($default, $params);
return $users->searchUsers($args);
}
function friendsonline_page_handler($pages): void {
$title = ossn_print('friendsonline');
$content = ossn_set_page_layout('newsfeed', array(
'content' => ossn_plugin_view('friendsonline/view', $params),
));
echo ossn_view_page($title, $content);
}