Example #1
0
 /**
  * Deletes the clip at SWITCHcast server
  *
  * @return boolean true if succesful
  */
 public function delete()
 {
     global $DB;
     $url = '/events/' . $this->getExtId();
     mod_opencast_apicall::sendRequest($url, "DELETE");
     $DB->delete_records('opencast_cmember', ['clip_ext_id' => $this->getExtId()]);
     return true;
 }
Example #2
0
    print_error('invalidcoursemodule', null, $return_course);
}
if (!($context = context_module::instance($cm->id))) {
    print_error('badcontext', null, $return_course);
}
require_login($course);
require_capability('mod/opencast:use', $context);
$url = base64_decode($url_b64);
$salt = base64_decode($salt_b64);
$token = base64_decode($token_b64);
if ($token == sha1(mod_opencast_series::getValueForKey('default_sysaccount') . $salt . $opencast->id . $url)) {
    $eventparams = ['context' => $context, 'objectid' => $opencast->id];
    $event = \mod_opencast\event\clip_viewed::create($eventparams);
    $event->add_record_snapshot('course_modules', $cm);
    $event->add_record_snapshot('course', $course);
    $event->add_record_snapshot('opencast', $opencast);
    $event->trigger();
    // 1.- request signing of the URL
    $time = time();
    $validity_time_seconds = 60;
    $valid_until = $time + $validity_time_seconds;
    $signing_request_params = ['url' => $url, 'valid-until' => date('Y-m-d', $valid_until) . 'T' . gmdate('H:i:s', $valid_until) . 'Z'];
    if (mod_opencast_series::getValueForKey('use_ipaddr_restriction')) {
        $signing_request_params['valid-source'] = getremoteaddr();
    }
    $signed_url = mod_opencast_apicall::sendRequest('/security/sign', 'POST', $signing_request_params);
    // 2.- redirect to signed URL
    header("Location: " . $signed_url->url);
    exit;
}
print_error('redirfailed', 'opencast');
Example #3
0
 /**
  *
  * @param int|string $id
  * @param bool       $inmoodle
  * @param bool       $returninfo
  * @param bool       $haltonerror
  *
  * @return type
  * @throws moodle_exception
  */
 function fetch($id, $inmoodle = true, $returninfo = false, $haltonerror = true)
 {
     global $DB;
     if ($inmoodle) {
         // there must be a DB record
         if (is_number($id)) {
             $rec = $DB->get_record('opencast', ['id' => $id]);
         } else {
             $rec = $DB->get_record('opencast', ['ext_id' => $id]);
         }
         $this->setExtId($rec->ext_id);
         $this->setIvt($rec->is_ivt);
         $this->setInvitingPossible($rec->inviting);
         // TODO remove as we're now only using local org (i.e. unil.ch for us)
         //            $this->setSysAccount($this->getSysAccountByOrganization($rec->organization_domain));
         $this->setOrganizationDomain($rec->organization_domain);
     } else {
         if (!is_number($id)) {
             // channel not in Moodle
             $this->setExtId($id);
         } else {
             print_error('');
         }
     }
     $url = '/series';
     $url .= '/' . $this->getExtId();
     $ch = mod_opencast_apicall::sendRequest($url, 'GET', null, false, true, null, false, $haltonerror);
     if (!$ch && !$haltonerror) {
         // no need to go further
         return false;
     }
     $ch_metadata = mod_opencast_apicall::sendRequest($url . '/metadata', 'GET', null, false, true, null, false);
     $ch_acls = mod_opencast_apicall::sendRequest($url . '/acl', 'GET', null, false, true, null, false);
     foreach ($ch_acls as $acl) {
         if ($acl->allow == true && $acl->action == 'write' && preg_match('/^ROLE\\_([^\\_]+)\\_USER$/', $acl->role, $matches)) {
             $this->setProducer($matches[1]);
         }
     }
     $this->setChannelName((string) $ch->title);
     // $metadata_fields = self::search_collection($ch_metadata, 'flavor', 'dublincore/series', 'fields');
     // $this->setLicense(self::search_collection($metadata_fields, 'id', 'license', 'value'));
     //		$this->setAllowAnnotations(trim((string)$ch->allow_annotations) == 'yes');
     //        $this->setOrganizationDomain((string)$ch->organization_name);
     //		$this->setUploadForm($ch->urls->url[1]);
     //		$this->setEditLink($ch->urls->url[4]);
     if (!$inmoodle || $returninfo) {
         // we just want the channel info
         $ch->meadata = $ch_metadata;
         $ch->acl = $ch_acls;
         return $ch;
     }
 }
Example #4
0
 /**
  * getChannels from the current $USER
  *
  */
 public function getChannels()
 {
     $aaiUniqueId = $this->getExternalAccount();
     if (!$aaiUniqueId) {
         // prevent getting an error if we're trying to get a non-AAI user's
         // channels by mistake
         return [];
     }
     // new implementation:
     $url = '/series/';
     $results = mod_opencast_apicall::sendRequest($url, 'GET');
     $filtered_result = [];
     foreach ($results as $result) {
         $ch_acls = mod_opencast_apicall::sendRequest('/series/' . $result->identifier . '/acl', 'GET', null, false, true, null, true, false);
         for ($i = 0; $i < count($ch_acls); $i++) {
             $acl = $ch_acls[$i];
             if ($acl->allow == true && $acl->action == 'write' && $acl->role == 'ROLE_AAI_USER_' . $aaiUniqueId) {
                 // is a producer
                 $filtered_result[] = $result;
             }
         }
     }
     return $filtered_result;
 }