-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathview_table.php
141 lines (133 loc) · 8.21 KB
/
view_table.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?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/>.
/**
* Defines the accept event.
*
* @package mod_jitsi
* @copyright 2023 Sergio Comerón Sánchez-Paniagua <sergiocomeron@icloud.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/tablelib.php');
require_once($CFG->libdir.'/adminlib.php');
/**
* Extend the standard table class for jitsi.
*/
class mod_view_table extends table_sql {
/**
* Constructor
* @param int $uniqueid all tables have to have a unique id, this is used
* as a key when storing table properties like sort order in the session.
*/
public function __construct($uniqueid) {
parent::__construct($uniqueid);
// Define the list of columns to show.
$columns = ['id'];
$this->define_columns($columns);
// Define the titles of columns to show in header.
$headers = ['Video'];
$this->define_headers($headers);
}
/**
* This function is called for each data row to allow processing of the
* username value.
*
* @param object $values Contains object with all the values of record.
* @return $string Return username with link to profile or username only
* when downloading.
*/
protected function col_id($values) {
global $DB, $OUTPUT;
$jitsi = $DB->get_record('jitsi', ['id' => $values->jitsi]);
$module = $DB->get_record('modules', ['name' => 'jitsi']);
$cm = $DB->get_record('course_modules', ['instance' => $values->jitsi, 'module' => $module->id]);
$context = context_module::instance($cm->id);
$record = $DB->get_record('jitsi_record', ['id' => $values->id]);
$sourcerecord = $DB->get_record('jitsi_source_record', ['id' => $record->source]);
if ($sourcerecord->id && $sourcerecord->link != null) {
$deleteurl = new moodle_url('/mod/jitsi/view.php?id='.$cm->id.'&deletejitsirecordid=' .
$record->id . '&sesskey=' . sesskey() . '#record');
$deleteicon = new pix_icon('t/delete', get_string('delete'));
$deleteaction = $OUTPUT->action_icon($deleteurl, $deleteicon,
new confirm_action(get_string('confirmdeleterecordinactivity', 'jitsi')));
$hideurl = new moodle_url('/mod/jitsi/view.php?id='.$cm->id.'&hidejitsirecordid=' .
$record->id . '&sesskey=' . sesskey(). '#record');
$showurl = new moodle_url('/mod/jitsi/view.php?id='.$cm->id.'&showjitsirecordid=' .
$record->id . '&sesskey=' . sesskey(). '#record');
$hideicon = new pix_icon('t/hide', get_string('hide'));
$showicon = new pix_icon('t/show', get_string('show'));
$hideaction = $OUTPUT->action_icon($hideurl, $hideicon, new confirm_action('Hide?'));
$showaction = $OUTPUT->action_icon($showurl, $showicon, new confirm_action('Show?'));
$tmpl = new \core\output\inplace_editable('mod_jitsi', 'recordname', $values->id,
has_capability('mod/jitsi:editrecordname', $context),
format_string($values->name), $values->name, get_string('editrecordname', 'jitsi'),
get_string('newvaluefor', 'jitsi') . format_string($values->name));
if ($jitsi->sessionwithtoken == 0) {
if (has_capability('mod/jitsi:deleterecord', $context) && !has_capability('mod/jitsi:hide', $context)) {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><span class=\"align-middle text-right\"><p>".$deleteaction.
"</p></span><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div><br>";
}
if (has_capability('mod/jitsi:hide', $context) && !has_capability('mod/jitsi:deleterecord', $context)) {
if ($record->visible != 0) {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><span class=\"align-middle text-right\"><p>".$hideaction.
"</p></span><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div><br>";
} else {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><span class=\"align-middle text-right\"><p>".$showaction.
"</p></span><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div><br>";
}
}
if (has_capability('mod/jitsi:hide', $context) && has_capability('mod/jitsi:deleterecord', $context)) {
if ($record->visible != 0) {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><span class=\"align-middle text-right\"><p>".$deleteaction.
"".$hideaction."</p></span><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div><br>";
} else {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><span class=\"align-middle text-right\"><p>".$deleteaction.
"".$showaction."</p></span><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div><br>";
}
}
if (!has_capability('mod/jitsi:hide', $context) && !has_capability('mod/jitsi:deleterecord', $context)) {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><br><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div>";
}
} else {
return "<h5>".$OUTPUT->render($tmpl)."</h5><h6 class=\"card-subtitle mb-2 text-muted\">".
userdate($values->timecreated)."</h6><br><div class=\"embed-responsive embed-responsive-16by9\">
<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/".$values->link."\"
allowfullscreen></iframe></div>";
}
} else {
return "<iframe class=\"embed-responsive-item\" src=\"https://youtube.com/embed/\"
allowfullscreen></iframe></div>";
}
}
}