Esempio n. 1
0
 /**
  * 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);
         }
     }
 }
Esempio n. 2
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;
 }