$sc_clip = new mod_opencast_event($sc_obj, $clip_ext_id, false, $opencast->id); if ($sc_clip->getOwnerUserId() != $USER->id) { print_error('invalidaction', null, $return_channel); } // Perform action ? if ($action !== '' && $userid !== 0 && confirm_sesskey() && has_capability('mod/opencast:use', $context) && $opencast->inviting && ($USER->id == $sc_clip->getOwnerUserId() || has_capability('mod/opencast:isproducer', $context))) { /* * $action AND $userid are defined * and channel allows clip inviting * and $USER has rights and is clip owner */ if ($action == 'add') { $sc_clip->addMember($userid, $course->id, $opencast->id); } else { if ($action == 'remove') { $sc_clip->removeMember($userid, $course->id, $opencast->id); } } $eventparams = ['context' => $context, 'objectid' => $opencast->id, 'relateduserid' => $userid]; if ($action == 'add') { $event = \mod_opencast\event\member_invited::create($eventparams); } else { if ($action == 'remove') { $event = \mod_opencast\event\member_revoked::create($eventparams); } } $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('opencast', $opencast); $event->trigger(); redirect($url);