Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden duplicated videos end up having empty ACLs #372

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions classes/local/apibridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1573,12 +1573,13 @@ private function get_non_permanent_acl_rules_for_status($courseid, $visibility,
* @param int $courseid id of the course the event belongs to.
* @param int $visibility visibility of the event.
* @param array|null $groups array of group ids used for replacing the placeholders
* @param bool $forceonhidden flag to force return the acls when hidden.
* @return array of objects representing acl rules, each with the fields 'allow', 'action' and 'role'.
* @throws dml_exception
* @throws coding_exception In case of an invalid visibility status. Only [0,1,2] are allowed.
*/
private function get_permanent_acl_rules_for_status($courseid, $visibility, $groups = null) {
return $this->get_acl_rules_for_status($courseid, $visibility, true, $groups);
private function get_permanent_acl_rules_for_status($courseid, $visibility, $groups = null, $forceonhidden = false) {
return $this->get_acl_rules_for_status($courseid, $visibility, true, $groups, $forceonhidden);
}

/**
Expand All @@ -1588,11 +1589,12 @@ private function get_permanent_acl_rules_for_status($courseid, $visibility, $gro
* @param int $visibility visibility of the event.
* @param bool $permanent whether to get permanent or non-permanent acl rules.
* @param array|null $groups array of group ids used for replacing the placeholders
* @param bool $forceonhidden flag to force return the acls when hidden.
* @return array of objects representing acl rules, each with the fields 'allow', 'action' and 'role'.
* @throws dml_exception
* @throws coding_exception In case of an invalid visibility status. Only [0,1,2] are allowed.
*/
private function get_acl_rules_for_status($courseid, $visibility, $permanent, $groups = null) {
private function get_acl_rules_for_status($courseid, $visibility, $permanent, $groups = null, $forceonhidden = false) {
$roles = $this->getroles($permanent ? 1 : 0);

$result = [];
Expand All @@ -1614,6 +1616,21 @@ private function get_acl_rules_for_status($courseid, $visibility, $permanent, $g
}
break;
case block_opencast_renderer::HIDDEN:
if ($permanent && $forceonhidden) {
justusdieckmann marked this conversation as resolved.
Show resolved Hide resolved
foreach ($roles as $role) {
foreach ($role->actions as $action) {
$rolenameformatted = self::replace_placeholders($role->rolename, $courseid)[0];
// Might return null if USERNAME cannot be replaced.
if ($rolenameformatted) {
$result[] = (object)[
'allow' => true,
'action' => $action,
'role' => $rolenameformatted,
];
}
}
}
}
break;
case block_opencast_renderer::GROUP:
foreach ($roles as $role) {
Expand Down Expand Up @@ -2881,7 +2898,7 @@ public function set_duplicated_event_visibility($duplicatedeventid, $sourceevent
$event = new event();
// Gathering acls for the duplicated event.
$newacls = $this->get_non_permanent_acl_rules_for_status($courseid, $targetvisibiltiy, $groups);
$newacls = array_merge($newacls, $this->get_permanent_acl_rules_for_status($courseid, $targetvisibiltiy, $groups));
$newacls = array_merge($newacls, $this->get_permanent_acl_rules_for_status($courseid, $targetvisibiltiy, $groups, true));
foreach ($newacls as $acl) {
$event->add_acl($acl->allow, $acl->action, $acl->role);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function execute() {
$event = $apibridge->get_already_existing_event([$data->duplicatedeventid]);
if (!$event || !in_array($event->status, ['EVENTS.EVENTS.STATUS.PROCESSED', 'EVENTS.EVENTS.STATUS.PROCESSING_FAILURE'])
|| count($event->publication_status) == 0
|| count($event->publication_status) == 1 && $event->publication_status[0] === 'internal') {
|| (count($event->publication_status) == 1 && $event->publication_status[0] === 'internal')) {
justusdieckmann marked this conversation as resolved.
Show resolved Hide resolved
throw new moodle_exception('error_duplicated_event_id_not_ready', 'block_opencast', '', $a);
}

Expand Down
Loading