forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report2.json.php
50 lines (43 loc) · 1.43 KB
/
report2.json.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
<?php
header('Content-Type: application/json');
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/comment.php';
session_write_close();
$from = date("Y-m-d 00:00:00", strtotime($_POST['dateFrom']));
$to = date('Y-m-d 23:59:59', strtotime($_POST['dateTo']));
// list all channels
if($config->getAuthCanViewChart() == 0){
if(User::isAdmin()){
$users = User::getAllUsers();
}else if(User::isLogged()){
$users = array(array('id'=> User::getId()));
}else{
$users = array();
}
} else if($config->getAuthCanViewChart() == 1){
if((!empty($_SESSION['user']['canViewChart']))||(User::isAdmin())) {
$users = User::getAllUsers(true);
}
}
$rows = array();
foreach ($users as $key => $value) {
// list all videos on that channel
$identification = User::getNameIdentificationById($value['id']);
$thumbs = Comment::getTotalCommentsThumbsUpFromUser($value['id'], $from, $to);
if(empty($thumbs['thumbsUp']) && empty($thumbs['thumbsDown'])){
continue;
}
$item = array(
'thumbsUp'=>$thumbs['thumbsUp'],
'thumbsDown'=>$thumbs['thumbsDown'],
'user'=>"<a href='".User::getChannelLink($value['id'])."'>{$identification}</a>"
);
$rows[] = $item;
}
$obj = new stdClass();
$obj->data = $rows;
echo json_encode($obj);