|
46 | 46 | $systemcontext = context_system::instance(); |
47 | 47 |
|
48 | 48 | if ($courseid == $SITE->id) { |
49 | | - course_require_view_participants($systemcontext); |
| 49 | + require_capability('block/opencast:viewusers', $systemcontext); |
| 50 | + $viewfullnames = has_capability('moodle/site:viewfullnames', $systemcontext); |
50 | 51 | } else { |
51 | 52 | course_require_view_participants($coursecontext); |
| 53 | + $viewfullnames = has_capability('moodle/site:viewfullnames', $coursecontext); |
52 | 54 | } |
53 | 55 |
|
54 | | -if (empty(get_config('aclownerrole_' . $ocinstanceid, 'block_opencast'))) { |
| 56 | +if (empty(get_config('block_opencast', 'aclownerrole_' . $ocinstanceid))) { |
55 | 57 | redirect($redirecturl, get_string('functionalitydisabled', 'block_opencast'), null, |
56 | 58 | \core\output\notification::NOTIFY_ERROR); |
57 | 59 | } |
|
66 | 68 | } |
67 | 69 | $title = $series->title; |
68 | 70 | $acls = $series->acl; |
| 71 | + $noowner = !$apibridge->has_owner($series->acl); |
69 | 72 |
|
70 | 73 | } else { |
71 | 74 | $video = $apibridge->get_opencast_video($identifier, false, true); |
|
77 | 80 | $title = $video->video->title; |
78 | 81 | $acls = $video->video->acl; |
79 | 82 | } |
| 83 | + $noowner = !$apibridge->has_owner($acls); |
| 84 | + if ($noowner) { |
| 85 | + // Check if user owns series. |
| 86 | + $series = $apibridge->get_series_by_identifier($video->video->is_part_of, true); |
| 87 | + if (!$series || (!$apibridge->is_owner($acls, $USER->id, $courseid) && $apibridge->has_owner($series->acl))) { |
| 88 | + $noowner = false; |
| 89 | + } |
| 90 | + } |
80 | 91 | } |
81 | 92 |
|
82 | 93 | // Verify that current user is the owner or is admin. |
83 | | -if (!$apibridge->is_owner($acls, $USER->id, $courseid) && |
| 94 | +$isowner = $apibridge->is_owner($acls, $USER->id, $courseid); |
| 95 | +if (!$isowner && |
| 96 | + !$noowner && |
84 | 97 | !has_capability('block/opencast:canchangeownerforallvideos', $systemcontext)) { |
85 | 98 | throw new moodle_exception(get_string('userisntowner', 'block_opencast')); |
86 | 99 | } else { |
|
90 | 103 | $PAGE->navbar->add(get_string('pluginname', 'block_opencast'), $redirecturl); |
91 | 104 | $PAGE->navbar->add(get_string('changeowner', 'block_opencast'), $baseurl); |
92 | 105 |
|
| 106 | + $excludeusers = array(); |
| 107 | + if ($isowner) { |
| 108 | + $excludeusers = [$USER->id]; |
| 109 | + } |
| 110 | + |
93 | 111 | $userselector = new block_opencast_enrolled_user_selector('ownerselect', |
94 | | - array('context' => $coursecontext, 'multiselect' => false)); |
| 112 | + array('context' => $coursecontext, 'multiselect' => false, 'exclude' => $excludeusers)); |
| 113 | + $userselector->viewfullnames = $viewfullnames; |
95 | 114 |
|
96 | 115 | $changeownerform = new \block_opencast\local\changeowner_form(null, |
97 | 116 | array('courseid' => $courseid, 'title' => $title, 'identifier' => $identifier, |
98 | | - 'ocinstanceid' => $ocinstanceid, 'userselector' => $userselector, 'isseries' => $isseries)); |
| 117 | + 'ocinstanceid' => $ocinstanceid, 'userselector' => $userselector, 'isseries' => $isseries, 'noowner' => $noowner)); |
99 | 118 |
|
100 | 119 | if ($changeownerform->is_cancelled()) { |
101 | 120 | redirect($redirecturl); |
|
0 commit comments