コード例 #1
0
 /**
  * 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');
 }
コード例 #2
0
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record('course', ['id' => $cm->course]))) {
    print_error('coursemisconf');
}
$return_course = new moodle_url('/course/view.php', ['id' => $course->id]);
require_course_login($course, false, $cm);
if (!($opencast = opencast_get_opencast($cm->instance))) {
    print_error('invalidcoursemodule', null, $return_course);
}
if (!($context = context_module::instance($cm->id))) {
    print_error('badcontext', null, $return_course);
}
$sc_obj = new mod_opencast_series();
$sc_obj->fetch($opencast->id);
$sc_clip = new mod_opencast_event($sc_obj, $clip_identifier, false, $opencast->id);
// Perform action ?
if (in_array($action, ['edit']) && confirm_sesskey() && has_capability('mod/opencast:isproducer', $context)) {
    /*
     * $confirm
     * AND sesskey() ok
     * AND has producer rights
     */
    if ($action === 'edit') {
        $sc_clip->setTitle(optional_param('title', $sc_clip->getTitle(), PARAM_RAW_TRIMMED));
        $sc_clip->setSubtitle(optional_param('subtitle', $sc_clip->getSubtitle(), PARAM_RAW_TRIMMED));
        $sc_clip->setPresenter(optional_param('presenter', $sc_clip->getPresenter(), PARAM_RAW_TRIMMED));
        $sc_clip->setLocation(optional_param('location', $sc_clip->getLocation(), PARAM_RAW_TRIMMED));
        if ($userid !== 0) {
            if ($userid == -1) {
                $sc_clip->setOwner('');
コード例 #3
0
            $mod_opencast_clip->owner_name = $owner_moodle_user->lastname . ', ' . $owner_moodle_user->firstname;
        } else {
            $mod_opencast_clip->owner_name = get_string('owner_not_in_moodle', 'opencast');
        }
    }
    //    if (!$mod_opencast_clip->AnnotationLink) {
    //        // hack because if present it will fill our template
    //        unset($mod_opencast_clip->AnnotationLink);
    //    }
    $clip_objs[] = $mod_opencast_clip;
}
if (mod_opencast_series::getValueForKey('display_select_columns')) {
    $all_clip_objs = [];
    foreach ($all_clips as $clip) {
        if (!isset($allclips[$clip['identifier']])) {
            $mod_opencast_clip = new mod_opencast_event($sc_obj, $clip['identifier'], false, $opencast->id);
            $mod_opencast_clip->editdetails_page = '#opencast-inactive';
            $mod_opencast_clip->deleteclip_page = '#opencast-inactive';
            $mod_opencast_clip->clipmembers_page = '#opencast-inactive';
            if (has_capability('mod/opencast:isproducer', $context)) {
                // 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
コード例 #4
0
    print_error('coursemisconf');
}
$return_course = new moodle_url('/course/view.php', ['id' => $course->id]);
if ($userid !== 0 && !($user = $DB->get_record('user', ['id' => $userid]))) {
    print_error('invaliduser', null, $return_channel);
}
if ($action !== '' && !in_array($action, ['add', 'remove'])) {
    print_error('invalidaction', null, $return_channel);
}
require_course_login($course, false, $cm);
if (!($opencast = opencast_get_opencast($cm->instance))) {
    print_error('invalidcoursemodule', null, $return_course);
}
$sc_obj = new mod_opencast_series();
$sc_obj->fetch($opencast->id);
$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);
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
if (!($course = $DB->get_record('course', ['id' => $cm->course]))) {
    print_error('coursemisconf');
}
require_course_login($course, false, $cm);
if (!($opencast = opencast_get_opencast($cm->instance))) {
    print_error('invalidcoursemodule');
}
if (!($context = context_module::instance($cm->id))) {
    print_error('badcontext');
}
if (!has_capability('mod/opencast:isproducer', $context)) {
    print_error('feature_forbidden', 'opencast', $return_channel);
}
$sc_obj = new mod_opencast_series();
$sc_obj->fetch($opencast->id);
$sc_clip = new mod_opencast_event($sc_obj, $event_identifier, false, $opencast->id);
// Perform action ?
if ($confirm === 1 && confirm_sesskey() && has_capability('mod/opencast:isproducer', $context)) {
    /*
     * $confirm
     * AND sesskey() ok
     * AND $USER has producer rights
     */
    $sc_clip->delete();
    $eventparams = ['context' => $context, 'objectid' => $opencast->id];
    $event = \mod_opencast\event\clip_deleted::create($eventparams);
    $event->add_record_snapshot('course_modules', $cm);
    $event->add_record_snapshot('course', $course);
    $event->add_record_snapshot('opencast', $opencast);
    $event->trigger();
    redirect($return_channel);