1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of the Zoom plugin for Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* CLI script to manually get the meeting report.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2020 UC Regents
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
define('CLI_SCRIPT', true);
|
|
|
26 |
|
|
|
27 |
require(__DIR__ . '/../../../config.php');
|
|
|
28 |
require_once($CFG->libdir . '/clilib.php');
|
|
|
29 |
|
|
|
30 |
// Now get cli options.
|
|
|
31 |
[$options, $unrecognized] = cli_get_params(
|
|
|
32 |
[
|
|
|
33 |
'help' => false,
|
|
|
34 |
'start' => false,
|
|
|
35 |
'end' => false,
|
|
|
36 |
'hostuuid' => false,
|
|
|
37 |
'courseid' => false,
|
|
|
38 |
],
|
|
|
39 |
[
|
|
|
40 |
'h' => 'help',
|
|
|
41 |
]
|
|
|
42 |
);
|
|
|
43 |
|
|
|
44 |
if ($unrecognized) {
|
|
|
45 |
$unrecognized = implode("\n ", $unrecognized);
|
|
|
46 |
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
if ($options['help'] || empty($options['start'] || empty($options['end']))) {
|
|
|
50 |
$help = "CLI script to manually get the meeting report for a given start and end date.
|
|
|
51 |
|
|
|
52 |
Options:
|
|
|
53 |
-h, --help Print out this help
|
|
|
54 |
--start Required. In YYYY-MM-DD format
|
|
|
55 |
--end Required. In YYYY-MM-DD format
|
|
|
56 |
--hostuuid Optional. Specific host we want to get meetings for.
|
|
|
57 |
--courseid Optional. If given, will find all hosts for course and get meeting reports.
|
|
|
58 |
|
|
|
59 |
Example:
|
|
|
60 |
\$sudo -u www-data /usr/bin/php mod/zoom/cli/get_meeting_report.php --start=2020-03-31 --end=2020-04-01
|
|
|
61 |
";
|
|
|
62 |
cli_error($help);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
$hostuuids = null;
|
|
|
66 |
if (!empty($options['hostuuid'])) {
|
|
|
67 |
$hostuuids = [$options['hostuuid']];
|
|
|
68 |
} else if (!empty($options['courseid'])) {
|
|
|
69 |
// Find all hosts for course.
|
|
|
70 |
$hostuuids = $DB->get_fieldset_select('zoom', 'DISTINCT host_id', 'course=:courseid', ['courseid' => $options['courseid']]);
|
|
|
71 |
if (empty($hostuuids)) {
|
|
|
72 |
cli_writeln(get_string('nozoomsfound', 'mod_zoom'));
|
|
|
73 |
cli_error('No hosts found for course');
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
// Turn on debugging so we can see the detailed progress.
|
|
|
78 |
set_debugging(DEBUG_DEVELOPER, true);
|
|
|
79 |
|
|
|
80 |
$meetingtask = new mod_zoom\task\get_meeting_reports();
|
|
|
81 |
$meetingtask->execute($options['start'], $options['end'], $hostuuids);
|
|
|
82 |
|
|
|
83 |
cli_writeln('DONE!');
|