@@ -48,7 +48,7 @@ public function __invoke(Request $request, Response $response, $args)
4848 if (!empty ($ share_uuid )) {
4949 $ video_share = VideosShares::findByUuid ($ share_uuid );
5050 if (!empty ($ video_share )) {
51- $ roles [] = ' STUDIP_ ' . $ video_share ->video ->episode . '_read ' ;
51+ $ roles [] = $ video_share ->video ->episode . '_read ' ;
5252 } else {
5353 throw new Error ('Share not found ' , 404 );
5454 }
@@ -63,12 +63,28 @@ public function __invoke(Request $request, Response $response, $args)
6363 $ email = $ user ->email ;
6464 $ fullname = $ user ->getFullName ();
6565
66- // Add user permission to access user-bound series and own playlists
67- $ roles [] = 'STUDIP_ ' . $ user_id ;
68-
6966 // Stud.IP-root has access to all videos and playlists
7067 if ($ GLOBALS ['perm ' ]->have_perm ('root ' , $ user_id )) {
7168 $ roles [] = 'ROLE_ADMIN ' ;
69+ }
70+
71+ // Admin users have permissions on videos of all administrated courses
72+ else if ($ GLOBALS ['perm ' ]->have_perm ('admin ' , $ user_id )) {
73+
74+ $ sem_user = new \Seminar_User ($ user_id );
75+
76+ $ nobody = $ GLOBALS ['user ' ];
77+ $ GLOBALS ['user ' ] = $ sem_user ;
78+
79+ $ filter = \AdminCourseFilter::get ();
80+ $ courses = array_column ($ filter ->getCourses (), 'seminar_id ' );
81+
82+ $ GLOBALS ['user ' ] = $ nobody ;
83+
84+ foreach ($ courses as $ course_id ) {
85+ $ roles [$ course_id . '_Instructor ' ] = $ course_id . '_Instructor ' ;
86+ }
87+
7288 } else {
7389 // Handle video roles
7490
@@ -77,9 +93,9 @@ public function __invoke(Request $request, Response $response, $args)
7793 if (!$ vperm ->video ->episode ) continue ;
7894
7995 if ($ vperm ->perm == 'owner ' || $ vperm ->perm == 'write ' ) {
80- $ roles [$ vperm ->video ->episode . '_write ' ] = ' STUDIP_ ' . $ vperm ->video ->episode . '_write ' ;
96+ $ roles [$ vperm ->video ->episode . '_write ' ] = $ vperm ->video ->episode . '_write ' ;
8197 } else {
82- $ roles [$ vperm ->video ->episode . '_read ' ] = ' STUDIP_ ' . $ vperm ->video ->episode . '_read ' ;
98+ $ roles [$ vperm ->video ->episode . '_read ' ] = $ vperm ->video ->episode . '_read ' ;
8399 }
84100 }
85101
@@ -89,9 +105,15 @@ public function __invoke(Request $request, Response $response, $args)
89105 $ stmt ->execute ([$ user_id ]);
90106 $ courses_write = $ stmt ->fetchAll (\PDO ::FETCH_COLUMN );
91107
108+ // Handle deputies ("Dozentenvertretung") as well
109+ $ courses_write = array_merge (
110+ $ courses_write ,
111+ array_column (\Deputy::findDeputyCourses ($ user_id )->toArray (), 'range_id ' )
112+ );
113+
92114 // add instructor roles
93115 foreach ($ courses_write as $ course_id ) {
94- $ roles [$ course_id . '_Instructor ' ] = ' STUDIP_ ' . $ course_id . '_Instructor ' ;
116+ $ roles [$ course_id . '_Instructor ' ] = $ course_id . '_Instructor ' ;
95117 }
96118
97119 // Get courses with read access ('autor', 'user')
@@ -102,17 +124,17 @@ public function __invoke(Request $request, Response $response, $args)
102124
103125 // add learner roles
104126 foreach ($ courses_read as $ course_id ) {
105- $ roles [$ course_id . '_Learner ' ] = ' STUDIP_ ' . $ course_id . '_Learner ' ;
127+ $ roles [$ course_id . '_Learner ' ] = $ course_id . '_Learner ' ;
106128 }
107129
108130 // Handle playlist roles
109131
110132 // get all playlists the user has permissions on
111133 foreach (PlaylistsUserPerms::findByUser_id ($ user_id ) as $ pperm ) {
112134 if ($ pperm ->perm == 'owner ' || $ pperm ->perm == 'write ' ) {
113- $ roles [$ pperm ->playlist ->service_playlist_id . '_write ' ] = 'STUDIP_PLAYLIST_ ' . $ pperm ->playlist ->service_playlist_id . '_write ' ;
135+ $ roles [$ pperm ->playlist ->service_playlist_id . '_write ' ] = 'PLAYLIST_ ' . $ pperm ->playlist ->service_playlist_id . '_write ' ;
114136 } else {
115- $ roles [$ pperm ->playlist ->service_playlist_id . '_read ' ] = 'STUDIP_PLAYLIST_ ' . $ pperm ->playlist ->service_playlist_id . '_read ' ;
137+ $ roles [$ pperm ->playlist ->service_playlist_id . '_read ' ] = 'PLAYLIST_ ' . $ pperm ->playlist ->service_playlist_id . '_read ' ;
116138 }
117139 }
118140
@@ -125,7 +147,7 @@ public function __invoke(Request $request, Response $response, $args)
125147 $ stmt ->execute ();
126148
127149 foreach ($ stmt ->fetchAll (\PDO ::FETCH_COLUMN ) as $ service_playlist_id ) {
128- $ roles [$ service_playlist_id . '_write ' ] = 'STUDIP_PLAYLIST_ ' . $ service_playlist_id . '_write ' ;
150+ $ roles [$ service_playlist_id . '_write ' ] = 'PLAYLIST_ ' . $ service_playlist_id . '_write ' ;
129151 }
130152
131153 // find playlists with read access
@@ -139,7 +161,7 @@ public function __invoke(Request $request, Response $response, $args)
139161
140162 foreach ($ stmt ->fetchAll (\PDO ::FETCH_COLUMN ) as $ service_playlist_id ) {
141163 // All seminar members have read permission on visible playlists
142- $ roles [$ service_playlist_id . '_read ' ] = 'STUDIP_PLAYLIST_ ' . $ service_playlist_id . '_read ' ;
164+ $ roles [$ service_playlist_id . '_read ' ] = 'PLAYLIST_ ' . $ service_playlist_id . '_read ' ;
143165 }
144166 }
145167 } else {
0 commit comments