Skip to content

Commit

Permalink
fix hidden visibility change for duplicated videos, fixes Opencast-Mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Mar 26, 2024
1 parent a2416a1 commit b3deb42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
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) {
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')) {
throw new moodle_exception('error_duplicated_event_id_not_ready', 'block_opencast', '', $a);
}

Expand Down

0 comments on commit b3deb42

Please sign in to comment.