// current USER is channel producer in Moodle (i.e. Teacher) if ($sc_obj->getIvt()) { $mod_opencast_clip->editdetails_page = '#some-page'; } if ($sc_obj->isProducer($sc_user->getExternalAccount())) { // current user is actual SwitchCast producer $mod_opencast_clip->deleteclip_page = '#some-page'; } } if ($mod_opencast_clip->getOwnerUserId() == $USER->id) { // current USER is clip owner if ($sc_obj->getIvt() && $sc_obj->getInvitingPossible()) { $mod_opencast_clip->clipmembers_page = '#some-page'; } } $owner = $mod_opencast_clip->getOwner(); unset($mod_opencast_clip->owner); // we don't want SWITCHaai uniqueID to appear in the JSON output if ($owner == '') { $mod_opencast_clip->owner_name = ''; } else { $mod_opencast_clip->owner_name = 'SOME_NAME'; } $allclips[$clip['identifier']] = $mod_opencast_clip; } else { $mod_opencast_clip = $allclips[$clip['identifier']]; } $all_clip_objs[] = $mod_opencast_clip; } } usort($clip_objs, 'opencast_clip_sort');
/** * Displays a clip outline in a table row * * @param mod_opencast_event $sc_clip a SWITCHcast clip object * @param bool $with_actions display action buttons * @param bool $is_template use row as template * @param string $allowed_actions comma separated list of allowed actions, used if $with_actions is true * @param bool $with_owner display owner column * @param bool $with_uploader display uploader column * @param bool $with_recordingstation * @param bool $with_playbuttons */ function display_clip_outline(mod_opencast_event $sc_clip, $with_actions = true, $is_template = false, $allowed_actions = 'all', $with_owner = false, $with_uploader = false, $with_recordingstation = true, $with_playbuttons = true) { global $CFG, $DB, $cm; $title = $sc_clip->getTitle(); if ($title == '') { $title = get_string('untitled_clip', 'opencast'); } $subtitle = $sc_clip->getSubtitle(); $title = html_writer::tag('span', $title, ['class' => 'title']); $title .= html_writer::tag('div', $subtitle, ['class' => 'subtitle']); $owner = $sc_clip->getOwner(); if ($owner == '') { $owner = get_string('no_owner', 'opencast'); } else { $owner_moodle_id = mod_opencast_user::getMoodleUserIdFromExtId($owner); if ($owner_moodle_user = $DB->get_record('user', ['id' => $owner_moodle_id])) { $owner = $owner_moodle_user->lastname . ', ' . $owner_moodle_user->firstname; } else { $owner = get_string('owner_not_in_moodle', 'opencast'); } } $uploader = ''; if ($with_uploader) { $uploaded_clip = $DB->get_record('opencast_uploadedclip', ['ext_id' => $sc_clip->getExtId()]); if ($uploaded_clip) { if ($uploader_moodle_user = $DB->get_record('user', ['id' => $uploaded_clip->userid])) { $uploader = $uploader_moodle_user->lastname . ', ' . $uploader_moodle_user->firstname; } } } if ($is_template) { $extraclass = $this->series->getIvt() ? 'with-owner' : 'without-owner'; echo html_writer::start_tag('tr', ['class' => 'opencast-clip-template-row ' . $extraclass]); } else { echo html_writer::start_tag('tr'); } echo html_writer::start_tag('td'); echo html_writer::start_tag('div', ['class' => 'cliplabel', 'title' => $subtitle]); echo html_writer::empty_tag('img', ['src' => $sc_clip->getCover()]); echo html_writer::tag('h3', $title); if ($with_playbuttons) { echo html_writer::start_tag('div', ['class' => 'linkbar']); // echo html_writer::tag('span', $sc_clip->getLinkBox()); if ($is_template) { echo html_writer::tag('a', '', ['href' => '#opencast-inactive', 'title' => get_string('annotations', 'opencast'), 'class' => 'annotate', 'target' => '_blank']); } else { if ($this->series->getAllowAnnotations()) { echo html_writer::tag('a', '', ['href' => $sc_clip->getAnnotationLink(), 'title' => get_string('annotations', 'opencast'), 'class' => 'annotate', 'target' => '_blank']); } } echo html_writer::tag('a', '', ['href' => $sc_clip->getLinkFlash(), 'title' => get_string('flash', 'opencast'), 'class' => 'flash', 'target' => '_blank']); // echo html_writer::tag('span', $sc_clip->getLinkMp4()); echo html_writer::tag('a', '', ['href' => $sc_clip->getLinkMov(), 'title' => get_string('mov', 'opencast'), 'class' => 'mov', 'target' => '_blank']); // echo html_writer::tag('a', '', [ // 'href' => $sc_clip->getLinkM4v(), 'title' => get_string('m4v', 'opencast'), // 'class' => 'm4v', 'target' => '_blank' // ]); // echo html_writer::tag('span', $sc_clip->getSubtitle()); echo html_writer::end_tag('div'); } echo html_writer::end_tag('div'); echo html_writer::end_tag('td'); echo html_writer::start_tag('td', ['class' => 'opencast-presenter']); echo html_writer::tag('span', $sc_clip->getPresenter()); echo html_writer::end_tag('td'); echo html_writer::start_tag('td', ['class' => 'opencast-location']); echo html_writer::tag('span', $sc_clip->getLocation()); echo html_writer::end_tag('td'); if ($with_recordingstation) { echo html_writer::start_tag('td', ['class' => 'opencast-recordingstation']); echo html_writer::tag('span', $sc_clip->getRecordingStation()); echo html_writer::end_tag('td'); } echo html_writer::start_tag('td', ['class' => 'opencast-recordingdate']); echo html_writer::tag('span', $sc_clip->getRecordingDate()); echo html_writer::end_tag('td'); if ($is_template || $with_owner) { echo html_writer::start_tag('td', ['class' => 'opencast-owner']); echo html_writer::tag('span', $owner); echo html_writer::end_tag('td'); } if ($with_uploader) { echo html_writer::start_tag('td', ['class' => 'opencast-uploader']); echo html_writer::tag('span', $uploader); echo html_writer::end_tag('td'); } $allowed_actions = explode(',', $allowed_actions); if ($with_actions && count($allowed_actions)) { echo html_writer::start_tag('td', ['class' => 'opencast-actions']); echo html_writer::start_tag('div', ['class' => 'opencast-hidden-actions']); if (in_array('editdetails', $allowed_actions) || in_array('all', $allowed_actions)) { echo html_writer::tag('a', get_string('editdetails', 'opencast'), ['href' => $CFG->wwwroot . '/mod/opencast/event_editdetails.php?id=' . $cm->id . '&clip_ext_id=' . $sc_clip->getExtId(), 'class' => 'button opencast-editdetails']); } if (in_array('invite', $allowed_actions) || in_array('all', $allowed_actions)) { echo html_writer::tag('a', get_string('editmembers', 'opencast'), ['href' => $CFG->wwwroot . '/mod/opencast/event_members.php?id=' . $cm->id . '&clip_identifier=' . $sc_clip->getExtId(), 'class' => 'button opencast-clipmembers']); } if (in_array('delete', $allowed_actions) || in_array('all', $allowed_actions)) { echo html_writer::tag('a', get_string('delete_clip', 'opencast'), ['href' => $CFG->wwwroot . '/mod/opencast/event_delete.php?id=' . $cm->id . '&clip_ext_id=' . $sc_clip->getExtId(), 'class' => 'button opencast-deleteclip']); } echo html_writer::end_tag('div'); echo html_writer::end_tag('td'); } echo html_writer::end_tag('tr'); }
/** * get Clips * * @param array $filters * * @return bool|stdClass * @throws moodle_exception */ public function getEvents($filters = []) { $url = '/events'; $url .= '?limit=1000'; $url .= '&withpublications=true'; $url .= '&filter=series:' . $this->getExtId(); $events = mod_opencast_apicall::sendRequest($url, 'GET', null, false, true, null, false, true); // dont run-as, we want all events, we'll be filtering later $count_events = count($events); for ($i = 0; $i < $count_events; $i++) { if ($events[$i]->processing_state != OPENCAST_PROCESSING_SUCCEEDED) { // do not dislay unprocessed events as part of the series unset($events[$i]); continue; } // then process filters foreach ($filters as $filter_key => $value) { if (!$value) { // skip empty filters continue; } if (in_array($filter_key, ['title', 'location'])) { // TODO WAIT FOR SWITCH : check if works when "presenter" bug is resolved, cf. https://dokuwiki.toolbox.switch.ch/opencast-api/api_known_issues // direct attributes: easy! if (strpos($events[$i]->{$filter_key}, $value) === false) { unset($events[$i]); continue 2; } } else { if ($filter_key == 'ivt_owner') { // we have to check this event's full ACLs $event = new mod_opencast_event($this, $events[$i]->identifier); $event->fetch(); if ($event->getOwner() != $value) { unset($events[$i]); continue 2; } } else { if ($filter_key == 'withoutowner' && $value == 'true') { $event = new mod_opencast_event($this, $events[$i]->identifier); $event->fetch(); if ($event->getOwner() != '') { unset($events[$i]); continue 2; } } else { if ($filter_key == 'presenter') { $event = new mod_opencast_event($this, $events[$i]->identifier); $event->fetch(); if (strpos($event->getPresenter(), $value) === false) { unset($events[$i]); continue 2; } } } } } } } return $events; }