Beispiel #1
0
 /**
  * Checks the current USER's permission on the event
  *
  * @param string $perm_type permission : 'read' or 'write'
  *
  * @return bool true if permission granted
  */
 public function isAllowed($perm_type)
 {
     global $DB, $USER, $context;
     if (!has_capability('mod/opencast:use', $context)) {
         return false;
     }
     $mod_opencast_user = new mod_opencast_user();
     $user_uploaded_events = $DB->get_records('opencast_uploadedclip', ['userid' => $USER->id]);
     $user_uploaded_events_extids = [];
     if (is_array($user_uploaded_events)) {
         foreach ($user_uploaded_events as $user_uploaded_event) {
             $user_uploaded_events_extids[] = $user_uploaded_event->ext_id;
         }
     }
     if ($perm_type == 'write') {
         if (has_capability('mod/opencast:isproducer', $context) || $mod_opencast_user->getExternalAccount() == $this->getOwner() && $this->getOwner() !== '' || in_array($this->getExtId(), $user_uploaded_events_extids)) {
             /*
              * the current $USER is channel producer
              * OR the current $USER is the clip owner
              * OR the current $USER is the user who uploaded the clip
              */
             return true;
         }
     } else {
         if ($perm_type == 'read') {
             if (has_capability('mod/opencast:isproducer', $context) || has_capability('mod/opencast:seeallclips', $context) || $this->series->getIvt() && $this->getOwner() !== '' && $mod_opencast_user->getExternalAccount() == $this->getOwner() || $this->series->getIvt() == false || $this->series->getIvt() == true && $this->series->getInvitingPossible() == true && is_numeric(array_search($USER->id, $this->getMembers())) || mod_opencast_user::checkSameGroup(mod_opencast_user::getMoodleUserIdFromExtId($this->getOwner()), $USER->id) || in_array($this->getExtId(), $user_uploaded_events_extids)) {
                 /*
                  * the current $USER is channel producer
                  * the current $USER has the mod/opencast:seeallclips capability
                  * OR activity is set in individual mode AND the current $USER is the clip owner
                  * OR there are no individual clip permissions set for this activity
                  * OR activity is set in individual mode AND $USER is an invited member of a clip
                  * OR is in the same user group as the clip owner
                  * OR the current $USER is the user who uploaded the clip
                  */
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * Displays user outlines of each group member (for the clip members table)
  *
  */
 function display_group_members()
 {
     global $sc_obj, $sc_clip, $cm, $context;
     if (groups_get_activity_groupmode($cm) == NOGROUPS || $sc_obj->getIvt() == false || $sc_clip->getOwner() == false) {
         return;
     }
     $users = get_users_by_capability($context, 'mod/opencast:use', 'u.id');
     foreach ($users as $userid => $user) {
         if (mod_opencast_user::checkSameGroup(mod_opencast_user::getMoodleUserIdFromExtId($sc_clip->getOwner()), $userid)) {
             $this->display_user_outline($userid, false, false, false, true);
         }
     }
 }
        $mod_opencast_clip->editdetails_page = $CFG->wwwroot . '/mod/opencast/event_editdetails.php?id=' . $cm->id . '&clip_identifier=' . $mod_opencast_clip->getExtId();
        $mod_opencast_clip->deleteclip_page = $CFG->wwwroot . '/mod/opencast/event_delete.php?id=' . $cm->id . '&clip_ext_id=' . $mod_opencast_clip->getExtId();
    }
    if ($mod_opencast_clip->getOwnerUserId() == $USER->id) {
        // current USER is clip owner
        if ($sc_obj->getIvt() && $sc_obj->getInvitingPossible()) {
            $mod_opencast_clip->clipmembers_page = $CFG->wwwroot . '/mod/opencast/event_members.php?id=' . $cm->id . '&clip_identifier=' . $mod_opencast_clip->getExtId();
        }
    }
    $owner = $mod_opencast_clip->getOwner();
    unset($mod_opencast_clip->owner);
    // we don't want SWITCHaai uniqueID to appear in the JSON
    if ($owner == '') {
        $mod_opencast_clip->owner_name = '';
    } else {
        $owner_moodle_id = mod_opencast_user::getMoodleUserIdFromExtId($owner);
        if ($owner_moodle_user = $DB->get_record('user', ['id' => $owner_moodle_id])) {
            $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) {