-
Notifications
You must be signed in to change notification settings - Fork 0
/
live.php
99 lines (88 loc) · 2.74 KB
/
live.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
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* live
*
*
*
*/
// fetch bootloader
require('bootloader.php');
// live enabled
if (!$system['live_enabled']) {
_error(404);
}
// live permission
if (!$user->_data['can_go_live']) {
_error('PERMISSION');
}
// check demo account
if ($user->_data['user_demo']) {
_error('PERMISSION');
}
// page header
page_header(__("Live") . ' | ' . __($system['system_title']));
//fix live feature
// get agora (uid|token|channel_name)
$agora = $user->agora_token_builder(true);
/* assign variables */
$smarty->assign('agora', $agora);
// check node (page|group|event|user)
if (isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
/* get page */
$page = $user->get_page($_GET['page_id']);
if (!$page) {
_error(404);
}
/* check if the viewer is page admin */
if (!$user->check_page_adminship($user->_data['user_id'], $page['page_id'])) {
_error(404);
}
/* get node_monetization_enabled */
$node_monetization_enabled = $page['page_monetization_enabled'];
//check
/* get node_author */
$node_author = $page['page_admin'];
/* get node_monetization_plans */
$node_monetization_plans = $page['page_monetization_plans'];
/* assign variables */
$smarty->assign('page_id', $_GET['page_id']);
} elseif (isset($_GET['group_id']) && is_numeric($_GET['group_id'])) {
/* get group */
$group = $user->get_group($_GET['group_id']);
if (!$group) {
_error(404);
}
/* check if the viewer joined the group */
if (!$user->check_group_membership($user->_data['user_id'], $group['group_id'])) {
_error(404);
}
/* get node_monetization_enabled */
$node_monetization_enabled = $group['group_monetization_enabled'];
/* get node_author */
$node_author = $group['group_admin'];
/* get node_monetization_plans */
$node_monetization_plans = $group['group_monetization_plans'];
/* assign variables */
$smarty->assign('group_id', $_GET['group_id']);
} elseif (isset($_GET['event_id']) && is_numeric($_GET['event_id'])) {
/* assign variables */
$smarty->assign('event_id', $_GET['event_id']);
} else {
/* get node_monetization_enabled */
$node_monetization_enabled = $user->_data['user_monetization_enabled'];
/* get node_author */
$node_author = $user->_data['user_id'];
/* get node_monetization_plans */
$node_monetization_plans = $user->_data['user_monetization_plans'];
}
// check if post can be shared with subscribers only
$can_be_for_subscriptions = false;
if ($system['monetization_enabled']) {
if ($node_monetization_enabled && $user->check_user_permission($node_author, 'monetization_permission') && $node_monetization_plans > 0) {
$can_be_for_subscriptions = true;
}
}
/* assign variables */
$smarty->assign('can_be_for_subscriptions', $can_be_for_subscriptions);
// page footer
page_footer('live');