forked from jfruitet/graph_stats-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails.php
executable file
·114 lines (101 loc) · 3.97 KB
/
details.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file is used to setting the block allover the site
*
* @package block
* @subpackage graph_stats
* @copyright 2011 Éric Bugnet with help of Jean Fruitet
* @copyright 2014 Wesley Ellis, Code Improvements.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
global $CFG, $USER, $SESSION, $COURSE, $DB;
/*
* Today's date
* @var timestamp
*/
$today = mktime(0, 0, 0, date("m") , date("d") , date("Y"));
$url = new moodle_url('/block/graph_stats/details.php');
/*
* course id to show in graph
* @var integer
*/
$courseid = optional_param('course_id', 1, PARAM_INT);
require_course_login($courseid);
$context = context_course::instance($courseid);
$PAGE->set_pagelayout('standard');
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_title(get_string('connectedtoday', 'block_graph_stats'));
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();
if (has_capability('report/log:view', $context)) {
echo html_writer::start_tag('h2', array('class' => 'main'));
echo get_string('connectedtoday', 'block_graph_stats');
echo html_writer::end_tag('h2');
echo html_writer::link(new moodle_url('/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course=1%2F'
. $courseid . '&user=&date=' . $today . '&modid=&modaction=&logformat=showashtml'),
get_string('moredetails', 'block_graph_stats') ,
array('title' => get_string('moredetails', 'block_graph_stats')));
if (!empty($SESSION->fullnamedisplay)) {
$CFG->fullnamedisplay = $SESSION->fullnamedisplay;
}
echo html_writer::start_tag('ul');
$params = array(
'time1' => mktime(0, 0, 0, date('m') , date('d'), date('Y')),
'time2' => mktime(23, 59, 59, date('m') , date('d'), date('Y')) );
$query = "
SELECT DISTINCT
l.userid, u.firstname, u.lastname
FROM
{log} l, {user} u
WHERE
l.userid = u.id AND
time > :time1 AND
time < :time2 AND
action = 'login'
";
if ($CFG->fullnamedisplay == 'lastname firstname') {
$query = $query."
ORDER BY
u.lastname, u.firstname ASC
";
} else {
$query = $query."
ORDER BY
u.firstname, u.lastname ASC
";
}
if ($connections = $DB->get_records_sql($query, $params)) {
foreach ($connections as $connection) {
if ($CFG->fullnamedisplay == 'firstname lastname') {
$fullname = $connection->firstname.' '. $connection->lastname;
} else if ($CFG->fullnamedisplay == 'lastname firstname') {
$fullname = $connection->lastname.' '. $connection->firstname;
} else if ($CFG->fullnamedisplay == 'firstname') {
$fullname = $connection->firstname;
} else {
$fullname = $connection->lastname.' '. $connection->firstname;
}
echo html_writer::start_tag('li');
echo $fullname;
echo html_writer::end_tag('li');
}
}
echo html_writer::end_tag('ul');
}
echo $OUTPUT->footer();