|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of 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
|
|
|
* Renderer. |
|
19
|
|
|
* |
|
20
|
|
|
* @package mod_bigbluebuttonbn |
|
21
|
|
|
* @copyright 2010 onwards, Blindside Networks Inc |
|
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
23
|
|
|
* @author Darko Miletic (darko.miletic [at] gmail [dt] com) |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace mod_bigbluebuttonbn\output; |
|
27
|
|
|
|
|
28
|
|
|
use renderable; |
|
29
|
|
|
use renderer_base; |
|
30
|
|
|
use templatable; |
|
31
|
|
|
use html_table; |
|
32
|
|
|
use html_writer; |
|
33
|
|
|
use stdClass; |
|
34
|
|
|
use coding_exception; |
|
35
|
|
|
use mod_bigbluebuttonbn\plugin; |
|
36
|
|
|
|
|
37
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
38
|
|
|
|
|
39
|
|
|
require_once($CFG->dirroot.'/mod/bigbluebuttonbn/locallib.php'); |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Class import_view |
|
43
|
|
|
* @package mod_bigbluebuttonbn |
|
44
|
|
|
* @copyright 2010 onwards, Blindside Networks Inc |
|
45
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
46
|
|
|
* @author Darko Miletic (darko.miletic [at] gmail [dt] com) |
|
47
|
|
|
*/ |
|
48
|
|
|
class import_view implements renderable, templatable { |
|
49
|
|
|
|
|
50
|
|
|
/** @var array */ |
|
51
|
|
|
private $context = []; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* import_view constructor. |
|
55
|
|
|
* @param stdClass $course |
|
56
|
|
|
* @param stdClass $bigbluebuttonbn |
|
57
|
|
|
* @param int $tc |
|
58
|
|
|
*/ |
|
59
|
|
|
public function __construct($course, $bigbluebuttonbn, $tc) { |
|
60
|
|
|
global $SESSION, $PAGE; |
|
61
|
|
|
$bbbsession = $SESSION->bigbluebuttonbn_bbbsession; |
|
62
|
|
|
$options = bigbluebuttonbn_import_get_courses_for_select($bbbsession); |
|
63
|
|
|
$selected = isset($options[$tc]) ? $tc : ''; |
|
64
|
|
|
$this->context['backactionurl'] = plugin::necurl('/mod/bigbluebuttonbn/view.php'); |
|
65
|
|
|
$this->context['cmid'] = $PAGE->cm->id; |
|
66
|
|
|
if (!empty($options)) { |
|
67
|
|
|
$selectoptions = []; |
|
68
|
|
|
$toadd = ['value' => '', 'label' => get_string('choosedots')]; |
|
69
|
|
|
if ('' == $tc) { |
|
70
|
|
|
$toadd['selected'] = true; |
|
71
|
|
|
} |
|
72
|
|
|
$selectoptions[] = $toadd; |
|
73
|
|
|
foreach ($options as $key => $option) { |
|
74
|
|
|
$toadd = ['value' => $key, 'label' => $option]; |
|
75
|
|
|
if ($key == $tc) { |
|
76
|
|
|
$toadd['selected'] = true; |
|
77
|
|
|
} |
|
78
|
|
|
$selectoptions[] = $toadd; |
|
79
|
|
|
} |
|
80
|
|
|
$this->context['hascontent'] = true; |
|
81
|
|
|
$this->context['selectoptions'] = $selectoptions; |
|
82
|
|
|
// Get course recordings. |
|
83
|
|
|
$bigbluebuttonbnid = null; |
|
84
|
|
|
if ($course->id == $selected) { |
|
85
|
|
|
$bigbluebuttonbnid = $bigbluebuttonbn->id; |
|
86
|
|
|
} |
|
87
|
|
|
$recordings = bigbluebuttonbn_get_allrecordings( |
|
88
|
|
|
$selected, $bigbluebuttonbnid, false, |
|
89
|
|
|
(boolean)\mod_bigbluebuttonbn\locallib\config::get('importrecordings_from_deleted_enabled') |
|
90
|
|
|
); |
|
91
|
|
|
// Exclude the ones that are already imported. |
|
92
|
|
|
if (!empty($recordings)) { |
|
93
|
|
|
$recordings = bigbluebuttonbn_unset_existent_recordings_already_imported( |
|
94
|
|
|
$recordings, $course->id, $bigbluebuttonbn->id |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
// Store recordings (indexed) in a session variable. |
|
98
|
|
|
$SESSION->bigbluebuttonbn_importrecordings = $recordings; |
|
99
|
|
|
// Proceed with rendering. |
|
100
|
|
|
if (!empty($recordings)) { |
|
101
|
|
|
$this->context['recordings'] = true; |
|
102
|
|
|
$this->context['recordingtable'] = bigbluebuttonbn_output_recording_table($bbbsession, $recordings, ['import']); |
|
103
|
|
|
} |
|
104
|
|
|
// JavaScript for locales. |
|
105
|
|
|
$PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn'); |
|
106
|
|
|
// Require JavaScript modules. |
|
107
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-imports', 'M.mod_bigbluebuttonbn.imports.init', |
|
108
|
|
|
array(array('bn' => $bigbluebuttonbn->id, 'tc' => $selected))); |
|
109
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-broker', 'M.mod_bigbluebuttonbn.broker.init', |
|
110
|
|
|
array()); |
|
111
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-recordings', 'M.mod_bigbluebuttonbn.recordings.init', |
|
112
|
|
|
array('recordings_html' => true)); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param renderer_base $output |
|
118
|
|
|
* @return array |
|
119
|
|
|
*/ |
|
120
|
|
|
public function export_for_template(renderer_base $output) { |
|
121
|
|
|
return $this->context; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
} |