Skip to content

Commit

Permalink
Merge pull request #262 from ferishili/v2.6_corrections
Browse files Browse the repository at this point in the history
V2.6 corrections
  • Loading branch information
ferishili authored Apr 30, 2021
2 parents 489238a + 5edaeb0 commit 8415c02
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Driver/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private function buildQueryString($params)
{
$segments = array();
foreach ($params as $key => $value) {
if (filter_var($value, FILTER_VALIDATE_BOOLEAN)) {
if (filter_var($value, FILTER_VALIDATE_BOOLEAN) && $key != 'duration') {
$encoded_value = $value == true ? 'true' : 'false';
} else {
$encoded_value = rawurlencode($value);
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public function index_action()
if ($err == 'course-type') {
PageLayout::postError(_('Der ausgewählte Server ist in diesem Veranstaltungstyp nicht verfügbar.'));
}
if ($err == 'accessdenied') {
throw new AccessDeniedException();
}
}
}

Expand Down
1 change: 0 additions & 1 deletion app/controllers/room.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public function join_meeting_action($link_hex, $cid)
if (!$name) {
$name = $invitations_link->default_name;
}
$name = $this->sonderzeichen($name);
$meeting = $invitations_link->meeting;

// Checking Course Type
Expand Down
39 changes: 39 additions & 0 deletions lib/MeetingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,43 @@ public function checkRecordingCapability($driver, $cid) {
"seriesid" => $seriesid
];
}

/**
* Checks if a group assigned to a meeting still exists, otherwise remove the group_id
* from the MeetingCourse model
*
* @param MeetingCourse $meetingCourse the meeting course object
*/
public function checkAssignedGroup(MeetingCourse $meetingCourse) {
if ($meetingCourse->group_id) {
try {
$group = \Statusgruppen::find($meetingCourse->group_id);
if (!$group) {
$meetingCourse->group_id = null;
$meetingCourse->store();
}
} catch (Throwable $e) {
throw new Error(_('Unable to check Assigned Group'), 404);
}
}
return $meetingCourse;
}

/**
* This method check the permission (global and if he is in the group) for a given user
*
* @param $group_id The Group-ID
* @param $cid The Course-ID
* @return bool True if user have permission, False otherwise
*/
public function checkGroupPermission($group_id, $cid)
{
global $perm, $user;
$group = new \Statusgruppen($group_id);

return $group->isMember($user->id)
|| ($user && is_object($perm)
&& $perm->have_studip_perm('tutor', $cid, $user->id)
);
}
}
9 changes: 9 additions & 0 deletions lib/Routes/Rooms/RoomAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ public function __invoke(Request $request, Response $response, $args)
}
}
}

// Check Group
if (isset($json['group_id']) && !empty($json['group_id'])) {
$group = \Statusgruppen::find($json['group_id']);
if (!$group) {
$has_error = true;
$error_text = I18N::_('Die ausgewählte Gruppe ist nicht mehr verfügbar');
}
}

if (!$has_error) {
//putting mandatory logoutURL into features
Expand Down
18 changes: 16 additions & 2 deletions lib/Routes/Rooms/RoomEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ public function __invoke(Request $request, Response $response, $args)
//Checking Server Active
$active_server = $servers[$json['server_index']]['active'];

// Check group
$allow_group = true;
if (isset($json['group_id']) && !empty($json['group_id'])) {
$group = \Statusgruppen::find($json['group_id']);
if (!$group) {
$allow_group = false;
}
}

$message = [];
if (!$meetingCourse->isNew() && $name && $allow_change_driver && $allow_change_server_index && $allow_course_type && $active_server) {
if (!$meetingCourse->isNew() && $name && $allow_change_driver && $allow_change_server_index && $allow_course_type && $active_server && $allow_group) {
$change_date = new \DateTime();
if (isset($json['active'])) {
$meetingCourse->active = $json['active'];
Expand Down Expand Up @@ -147,7 +156,12 @@ public function __invoke(Request $request, Response $response, $args)
'type' => 'success'
];
} else {
$message = ($allow_course_type ? 'Raumeinstellung kann nicht bearbeitet werden!' : 'Der ausgewählte Server ist in diesem Veranstaltungstyp nicht verfügbar');
$message = 'Raumeinstellung kann nicht bearbeitet werden!';
if (!$allow_group) {
$message = 'Die ausgewählte Gruppe ist nicht mehr verfügbar.';
} else if (!$allow_course_type) {
$message = 'Der ausgewählte Server ist in diesem Veranstaltungstyp nicht verfügbar.';
}
$message = [
'text' => I18N::_($message),
'type' => 'error'
Expand Down
24 changes: 17 additions & 7 deletions lib/Routes/Rooms/RoomJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ public function __invoke(Request $request, Response $response, $args)
$room_id = $args['room_id'];
$cid = $args['cid'];

if (!$perm->have_studip_perm('user', $cid)) {
throw new \AccessDeniedException();
$meetingCourse = new MeetingCourse([$room_id, $cid ]);
// Check Assigned Group
$meetingCourse = $this->checkAssignedGroup($meetingCourse);

// Check group access permission
if (!$perm->have_studip_perm('user', $cid) || ($meetingCourse->group_id && !$this->checkGroupPermission($meetingCourse->group_id, $cid))) {
header('Location:' .
\URLHelper::getURL(
'plugins.php/meetingplugin/index',
['cid' => $cid, 'err' => 'accessdenied']
)
);
exit;
}

$meeting = Meeting::find($room_id);
$meeting = $meetingCourse->meeting;

// Checking folder existence
$this->checkAssignedFolder($meeting);
Expand All @@ -71,8 +82,8 @@ public function __invoke(Request $request, Response $response, $args)
exit;
}

//putting mandatory logoutURL into features
if ($features = json_decode($meeting->features, true)) {
//putting mandatory logoutURL into features
if (!isset($features['logoutURL'])) {
$hostUrl = $request->getUri()->getScheme() . '://' . $request->getUri()->getHost()
.($request->getUri()->getPort() ? ':' . $request->getUri()->getPort() : '');
Expand All @@ -89,9 +100,9 @@ public function __invoke(Request $request, Response $response, $args)
} else if (isset($features['meta_opencast-dc-isPartOf'])) {
unset($features['meta_opencast-dc-isPartOf']);
}
$meeting->features = json_encode($features);
$meeting->store();
}
$meeting->features = json_encode($features);
$meeting->store();
}

$driver = $driver_factory->getDriver($meeting->driver, $meeting->server_index);
Expand All @@ -100,7 +111,6 @@ public function __invoke(Request $request, Response $response, $args)
&& $features['room_anyone_can_start'] === 'false'
&& !$perm->have_studip_perm('tutor', $cid)
) {
$meetingCourse = new MeetingCourse([$room_id, $cid ]);
$status = $driver->isMeetingRunning($meetingCourse->meeting->getMeetingParameters()) === 'true' ? true : false;

if (!$status) {
Expand Down
28 changes: 7 additions & 21 deletions lib/Routes/Rooms/RoomsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public function __invoke(Request $request, Response $response, $args)
foreach ($meeting_course_list_raw as $meetingCourse) {
try {

if ($meetingCourse->group_id && !$this->checkPermission($meetingCourse->group_id, $cid)) {
// Check Assigned Group
$meetingCourse = $this->checkAssignedGroup($meetingCourse);

// Check group access permission
if ($meetingCourse->group_id && !$this->checkGroupPermission($meetingCourse->group_id, $cid)) {
continue;
}

Expand All @@ -77,13 +81,13 @@ public function __invoke(Request $request, Response $response, $args)
}
}

$meeting = $meetingCourse->meeting->toArray();
$meeting = array_merge($meetingCourse->toArray(), $meeting);
// Checking folder existence
$this->checkAssignedFolder($meetingCourse->meeting);
if (!filter_var(Driver::getConfigValueByDriver($meetingCourse->meeting->driver, 'preupload'), FILTER_VALIDATE_BOOLEAN)) {
$meeting['preupload_not_allowed'] = _('Das automatische Hochladen von Folien ist derzeit nicht möglich');
}
$meeting = $meetingCourse->meeting->toArray();
$meeting = array_merge($meetingCourse->toArray(), $meeting);

$meeting['has_recordings'] = false;

Expand Down Expand Up @@ -180,22 +184,4 @@ private function getFeatures($str_features, $key = null)
return $features;
}
}

/**
* This method check the permission (global and if he is in the group) for a given user
*
* @param $group_id The Group-ID
* @param $cid The Course-ID
* @return bool True if user have permission, False otherwise
*/
public function checkPermission($group_id, $cid)
{
global $perm, $user;
$group = new \Statusgruppen($group_id);

return $group->isMember($user->id)
|| ($user && is_object($perm)
&& $perm->have_studip_perm('tutor', $cid, $user->id)
);
}
}
2 changes: 1 addition & 1 deletion vueapp/components/MeetingComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
role="status-yellow" size="24"></StudipIcon>
<span v-translate>
Das Meeting gehört der Gruppe
{{ group_name }}
</span>
<span v-if="group_name" v-text="group_name"></span>
</div>

<div v-if="course_config.display.editRoom && room.folder_id !== null && room.details && room.details.folder">
Expand Down
2 changes: 1 addition & 1 deletion vueapp/components/MeetingGuest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
}
if (this.room && this.guest_name) {
this.room.guest_name = this.sonderzeichen(this.guest_name);
this.room.guest_name = this.guest_name;
this.$store.dispatch(ROOM_JOIN_GUEST, this.room)
.then(({ data }) => {
if (data.join_url != '') {
Expand Down

0 comments on commit 8415c02

Please sign in to comment.