-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdetails.php
107 lines (93 loc) · 3.33 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
<?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 print users connected today
*
* @package block
* @subpackage graph_stats
* @copyright 2011 Éric Bugnet with help of Jean Fruitet
* @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
*/
$course_id = optional_param('course_id', 1, PARAM_INT);
require_course_login($course_id);
$context = get_context_instance(CONTEXT_COURSE, $course_id);
$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('coursereport/log:view', $context)) {
echo '<h2 class="main">'.get_string('connectedtoday','block_graph_stats').'</h2>';
echo '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course=1%2F'.$course_id.'&user=&date='.$today.'&modid=&modaction=&logformat=showashtml" alt="'.get_string('moredetails','block_graph_stats').'">'.get_string('moredetails', 'block_graph_stats').'</a>';
if (!empty($SESSION->fullnamedisplay)) {
$CFG->fullnamedisplay = $SESSION->fullnamedisplay;
}
echo "<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 '<li>'.$fullname.'</li>';
}
}
echo "</ul>";
}
echo $OUTPUT->footer();