Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 * List all zoom meetings.
19
 *
20
 * @package    mod_zoom
21
 * @copyright  2015 UC Regents
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require(__DIR__ . '/../../config.php');
26
require_once(__DIR__ . '/lib.php');
27
require_once(__DIR__ . '/locallib.php');
28
require_once($CFG->libdir . '/moodlelib.php');
29
 
30
$id = required_param('id', PARAM_INT); // Course.
31
 
32
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
33
 
34
require_course_login($course);
35
 
36
$context = context_course::instance($course->id);
37
require_capability('mod/zoom:view', $context);
38
$iszoommanager = has_capability('mod/zoom:addinstance', $context);
39
 
40
$params = [
41
    'context' => $context,
42
];
43
$event = \mod_zoom\event\course_module_instance_list_viewed::create($params);
44
$event->add_record_snapshot('course', $course);
45
$event->trigger();
46
 
47
$strname = get_string('modulenameplural', 'mod_zoom');
48
$strnew = get_string('newmeetings', 'mod_zoom');
49
$strold = get_string('oldmeetings', 'mod_zoom');
50
 
51
$strtitle = get_string('title', 'mod_zoom');
52
$strwebinar = get_string('webinar', 'mod_zoom');
53
$strtime = get_string('meeting_time', 'mod_zoom');
54
$strduration = get_string('duration', 'mod_zoom');
55
$stractions = get_string('actions', 'mod_zoom');
56
$strsessions = get_string('sessions', 'mod_zoom');
57
 
58
$strmeetingstarted = get_string('meeting_started', 'mod_zoom');
59
$strjoin = get_string('join', 'mod_zoom');
60
 
61
$PAGE->set_url('/mod/zoom/index.php', ['id' => $id]);
62
$PAGE->navbar->add($strname);
63
$PAGE->set_title("$course->shortname: $strname");
64
$PAGE->set_heading($course->fullname);
65
$PAGE->set_pagelayout('incourse');
66
 
67
echo $OUTPUT->header();
68
 
69
if ($CFG->branch < '400') {
70
    echo $OUTPUT->heading($strname);
71
}
72
 
73
if (! $zooms = get_all_instances_in_course('zoom', $course)) {
74
    notice(get_string('nozooms', 'mod_zoom'), new moodle_url('/course/view.php', ['id' => $course->id]));
75
}
76
 
77
$usesections = course_format_uses_sections($course->format);
78
 
79
$zoomuserid = zoom_get_user_id(false);
80
 
81
$newtable = new html_table();
82
$newtable->attributes['class'] = 'generaltable mod_index';
83
$newhead = [$strtitle, $strtime, $strduration, $stractions];
84
$newalign = ['left', 'left', 'left', 'left'];
85
 
86
$oldtable = new html_table();
87
$oldhead = [$strtitle, $strtime];
88
$oldalign = ['left', 'left'];
89
 
90
// Show section column if there are sections.
91
if ($usesections) {
92
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
93
    array_unshift($newhead, $strsectionname);
94
    array_unshift($newalign, 'center');
95
    array_unshift($oldhead, $strsectionname);
96
    array_unshift($oldalign, 'center');
97
}
98
 
99
// Show sessions column only if user can edit Zoom meetings.
100
if ($iszoommanager) {
101
    $newhead[] = $strsessions;
102
    $newalign[] = 'left';
103
    $oldhead[] = $strsessions;
104
    $oldalign[] = 'left';
105
}
106
 
107
$newtable->head = $newhead;
108
$newtable->align = $newalign;
109
$oldtable->head = $oldhead;
110
$oldtable->align = $oldalign;
111
 
112
$now = time();
113
$modinfo = get_fast_modinfo($course);
985 ariadna 114
 
1 efrain 115
$cms = $modinfo->instances['zoom'];
116
foreach ($zooms as $z) {
117
    $row = [];
118
    [$inprogress, $available, $finished] = zoom_get_state($z);
119
 
120
    $cm = $cms[$z->id];
121
    if ($usesections && isset($cm->sectionnum)) {
122
        $row[0] = get_section_name($course, $cm->sectionnum);
123
    }
124
 
125
    $url = new moodle_url('view.php', ['id' => $cm->id]);
126
    $row[1] = html_writer::link($url, $cm->get_formatted_name());
127
    if ($z->webinar) {
128
        $row[1] .= " ($strwebinar)";
129
    }
130
 
131
    // Get start time column information.
132
    if ($z->recurring && $z->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME) {
133
        $displaytime = get_string('recurringmeeting', 'mod_zoom');
134
        $displaytime .= html_writer::empty_tag('br');
135
        $displaytime .= get_string('recurringmeetingexplanation', 'mod_zoom');
136
    } else if ($z->recurring && $z->recurrence_type != ZOOM_RECURRINGTYPE_NOTIME) {
137
        $displaytime = get_string('recurringmeeting', 'mod_zoom');
138
        $displaytime .= html_writer::empty_tag('br');
139
        if (($nextoccurrence = zoom_get_next_occurrence($z)) > 0) {
140
            $displaytime .= get_string('nextoccurrence', 'mod_zoom') . ': ' . userdate($nextoccurrence);
141
        } else {
142
            $displaytime .= get_string('nooccurrenceleft', 'mod_zoom');
143
        }
144
    } else {
145
        $displaytime = userdate($z->start_time);
146
    }
147
 
148
    $report = new moodle_url('report.php', ['id' => $cm->id]);
149
    $sessions = html_writer::link($report, $strsessions);
150
 
151
    if ($finished) {
152
        $row[2] = $displaytime;
153
        if ($iszoommanager) {
154
            $row[3] = $sessions;
155
        }
156
 
157
        $oldtable->data[] = $row;
158
    } else {
159
        if ($inprogress) {
160
            $label = html_writer::tag('span', $strmeetingstarted, ['class' => 'label label-info zoom-info']);
161
            $row[2] = html_writer::tag('div', $label);
162
        } else {
163
            $row[2] = $displaytime;
164
        }
165
 
166
        $row[3] = ($z->recurring && $z->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME) ? '--' : format_time($z->duration);
167
 
168
        if ($available) {
169
            $buttonhtml = html_writer::tag('button', $strjoin, ['type' => 'submit', 'class' => 'btn btn-primary']);
170
            $aurl = new moodle_url('/mod/zoom/loadmeeting.php', ['id' => $cm->id]);
171
            $buttonhtml .= html_writer::input_hidden_params($aurl);
172
            $row[4] = html_writer::tag('form', $buttonhtml, ['action' => $aurl->out_omit_querystring(), 'target' => '_blank']);
173
        } else {
174
            $row[4] = '--';
175
        }
176
 
177
        if ($iszoommanager) {
178
            $row[] = $sessions;
179
        }
180
 
181
        $newtable->data[] = $row;
182
    }
183
}
184
 
185
echo $OUTPUT->heading($strnew, 4);
186
echo html_writer::table($newtable);
187
echo $OUTPUT->heading($strold, 4, null, 'mod-zoom-old-meetings-header');
188
// Show refresh meeting sessions link only if user can run the 'refresh session reports' console command.
189
if (has_capability('mod/zoom:refreshsessions', $context)) {
190
    $linkarguments = [
191
        'courseid' => $id,
192
        'start' => date('Y-m-d', strtotime('-3 days')),
193
        'end' => date('Y-m-d'),
194
    ];
195
    $url = new moodle_url($CFG->wwwroot . '/mod/zoom/console/get_meeting_report.php', $linkarguments);
196
    echo html_writer::link($url, get_string('refreshreports', 'mod_zoom'), ['target' => '_blank', 'class' => 'pl-4']);
197
}
198
 
199
echo html_writer::table($oldtable);
200
 
201
echo $OUTPUT->footer();