forked from elan-ev/studip-live-streaming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiveStreaming.php
151 lines (131 loc) · 5.08 KB
/
LiveStreaming.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
142
143
144
145
146
147
148
149
150
151
<?php
/**
* LiveStreaming plugin class for Stud.IP
*
* @author Viktoria Wiebe <vwiebe@uni-osnabrueck.de>
*
* This program 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 2 of
* the License, or (at your option) any later version.
*/
require_once 'lib/locallib.inc.php';
class LiveStreaming extends StudIPPlugin implements StandardPlugin, SystemPlugin
{
const GETTEXT_DOMAIN = 'LiveStreaming';
public function __construct()
{
global $perm;
parent::__construct();
// set up translation domain
bindtextdomain(static::GETTEXT_DOMAIN, $this->getPluginPath() . '/locale');
bind_textdomain_codeset(static::GETTEXT_DOMAIN, 'UTF-8');
StudipAutoloader::addClassLookups([
'LiveStream' => __DIR__ . '/lib/LiveStream.php',
]);
if ($perm->have_perm('admin')) {
$item = new Navigation($this->_('LiveStreaming konfigurieren'), PluginEngine::getLink($this, array(), 'admin/admin'));
if (Navigation::hasItem('/admin/config') && !Navigation::hasItem('/admin/config/livestreaming')) {
Navigation::addItem('/admin/config/livestreaming', $item);
}
}
}
/**
* Returns the plugin name
*/
public function getPluginName()
{
return 'LiveStreaming';
}
/**
* Returns the tab navigation for the OSKA plugin in the given course.
*
* @param $course_id the given course ID
*/
public function getTabNavigation($course_id)
{
global $perm;
if ($perm->have_studip_perm('admin', $course_id)) {
$navigation = new Navigation($this->getPluginName(), PluginEngine::getURL('LiveStreaming/player/teacher'));
$navigation->addSubNavigation('teacher', new Navigation($this->_('Konfiguration'), PluginEngine::getURL('LiveStreaming/player/teacher')));
$navigation->addSubNavigation('student', new Navigation($this->_('Studentenansicht'), PluginEngine::getURL('LiveStreaming/player/student')));
} elseif ($perm->have_studip_perm('tutor', $course_id)) {
$navigation = new Navigation($this->getPluginName(), PluginEngine::getURL('LiveStreaming/player/teacher'));
$navigation->addSubNavigation('teacher', new Navigation($this->_('Konfiguration'), PluginEngine::getURL('LiveStreaming/player/teacher')));
$navigation->addSubNavigation('student', new Navigation($this->_('Studentenansicht'), PluginEngine::getURL('LiveStreaming/player/student')));
} else {
$navigation = new Navigation($this->getPluginName(), PluginEngine::getURL('LiveStreaming/player/student'));
$navigation->addSubNavigation('student', new Navigation($this->_('Live-Stream'), PluginEngine::getURL('LiveStreaming/player/student')));
}
return ['livestreaming' => $navigation];
}
public function perform($unconsumed_path)
{
PageLayout::addStylesheet($this->getPluginURL() . '/assets/css/livestream.css');
PageLayout::addScript($this->getPluginURL() . '/assets/javascripts/livestream.js');
parent::perform($unconsumed_path);
}
/**
* Returns the course summary page template.
*
* @param $course_id the given course ID
*/
public function getInfoTemplate($course_id)
{
return NULL;
}
/**
* Returns the icon navigation object.
*
* @param $course_id the given course ID
* @param $last_visit point in time of the user's last visit
* @param $user_id the ID of the given user
*/
public function getIconNavigation($course_id, $last_visit, $user_id)
{
return NULL;
}
/**
* Plugin localization for a single string.
* This method supports sprintf()-like execution if you pass additional
* parameters.
*
* @param String $string String to translate
* @return translated string
*/
public function _($string)
{
$result = static::GETTEXT_DOMAIN === null
? $string
: dcgettext(static::GETTEXT_DOMAIN, $string, LC_MESSAGES);
if ($result === $string) {
$result = _($string);
}
if (func_num_args() > 1) {
$arguments = array_slice(func_get_args(), 1);
$result = vsprintf($result, $arguments);
}
return $result;
}
/**
* Checks if opencast is loaded, and if course id is passed,
* returns the series id of the course if opencast has been set for the course
*
* @param string $cid course ID with default null
* @return bool | array | string
*/
function checkOpenCast($cid = null) {
$opencast_plugin = PluginEngine::getPlugin("OpenCast");
if ($opencast_plugin) {
if ($cid) {
if ($opencast_plugin->isActivated($cid)) {
return true;
} else {
return false;
}
}
return true;
}
return false;
}
}