// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Version information
 *
 * @package    mod
 * @subpackage opencast
 * @copyright  2013-2015 Université de Lausanne
 * @author     Nicolas.Dunand@unil.ch
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/mod/opencast/lib.php';
$seriesExtId = required_param('ext_id', PARAM_RAW_TRIMMED);
$sc_user = new mod_opencast_user();
$url = '/series/' . $seriesExtId;
if ($sc_user->getExternalAccount() != '') {
    $runas = true;
} else {
    $runas = false;
}
$series = new mod_opencast_series();
$series->fetch($seriesExtId, false);
//$series = mod_opencast_apicall::sendRequest($url, 'GET', null, null, null, null, $runas);
$channel_details = ['title' => $series->title];
echo json_encode($channel_details);
Ejemplo 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;
 }
 /*
  * $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('');
         } else {
             $sc_user = new mod_opencast_user(null, $userid);
             $newowner_aaiUniqueId = $sc_user->getExternalAccount();
             if ($newowner_aaiUniqueId) {
                 $newowner = new mod_opencast_user($newowner_aaiUniqueId);
                 $sc_clip->setOwner($newowner_aaiUniqueId);
                 $sc_clip->update();
             } else {
                 print_error('owner_no_switch_account', 'opencast', $url, $setuser->lastname . ', ' . $setuser->firstname);
             }
         }
     }
     $sc_clip->update();
     $eventparams = ['context' => $context, 'objectid' => $opencast->id];
     $event = \mod_opencast\event\clip_editdetails::create($eventparams);
     $event->add_record_snapshot('course_modules', $cm);
     $event->add_record_snapshot('course', $course);
     $event->add_record_snapshot('opencast', $opencast);
Ejemplo n.º 4
0
    $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
                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 = '';
Ejemplo n.º 5
0
 /**
  * To create a channel we need an aai account that is allowed to register a new channel.
  * Thus the first choice is the aai account of the current user, if he doesn't have an
  * account we use the system account.
  */
 function doCreate()
 {
     global $USER;
     $scuser = new mod_opencast_user();
     // if the current USER has no switchaai account, prevent channel creation
     if ($scuser->getExternalAccount() == '') {
         print_error('user_notaai', 'opencast');
     }
     if ($this->getExtId() == '') {
         // No ext_id: that's a new channel to be created at SWITCHcast server
         $url = '/series';
         $data = ['metadata' => json_encode([['label' => 'Opencast Series DublinCore', 'flavor' => 'dublincore/series', 'fields' => [['id' => 'title', 'value' => $this->title]]]], JSON_UNESCAPED_SLASHES), 'acl' => json_encode([['allow' => true, 'action' => 'read', 'role' => 'ROLE_ORG_PRODUCER'], ['allow' => true, 'action' => 'write', 'role' => 'ROLE_ORG_PRODUCER'], ['allow' => true, 'action' => 'read', 'role' => 'ROLE_EXTERNAL_APPLICATION'], ['allow' => true, 'action' => 'write', 'role' => 'ROLE_EXTERNAL_APPLICATION'], ['allow' => true, 'action' => 'read', 'role' => 'ROLE_AAI_USER_' . $scuser->getExternalAccount()], ['allow' => true, 'action' => 'write', 'role' => 'ROLE_AAI_USER_' . $scuser->getExternalAccount()]], JSON_UNESCAPED_SLASHES)];
         $new_series = mod_opencast_apicall::sendRequest($url, 'POST', $data);
         // Check ext_id
         if ($new_series->identifier) {
             $this->setExtId($new_series->identifier);
         } else {
             print_error('errorchannelcreation', 'opencast');
         }
     } else {
         // existing channel at SWITCHcast server, to be updated
         // basically, we only add our sysAccount as producer at the SWITCHcast server
         $this->update();
     }
 }
Ejemplo n.º 6
0
 function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $scuser = new mod_opencast_user();
     if ($data['channelnew'] == OPENCAST_CHANNEL_NEW) {
         if ($scuser->getExternalAccount() == '') {
             $errors['channelnew'] = get_string('user_notaai', 'opencast');
         }
         if (!$data['newchannelname']) {
             $errors['newchannelname'] = get_string('required');
         }
     }
     if ($data['channelnew'] == OPENCAST_CHANNEL_EXISTING) {
         // make sure we can be external_authority for this channel
         $scobj = new mod_opencast_series();
         $ext_id = isset($data['ext_id']) ? $data['ext_id'] : $this->current->ext_id;
         $scobj->setExtId($ext_id);
         $sysaccount_extid = mod_opencast_series::getSysAccountOfUser();
         // we must explicitly set $USER as a producer in $scobj or we won't be allowed to add his system_user
         $scobj->setOrganizationDomain(mod_opencast_series::getOrganizationByEmail($sysaccount_extid));
         $scobj->setProducer($scuser->getExternalAccount());
         // first, add SysAccount as producer (using $USER account), so we can use SysAccount later to make API calls
         //            $scobj->addProducer($sysaccount_extid, false);
         $channelid = empty($this->_instance) ? $ext_id : $this->current->id;
         // if there already is one instance we must refer to it by its Moodle ID otherwise there could
         // be several records!
         $thechannel = $scobj->fetch($channelid, !empty($this->_instance), true);
     } else {
         if ($data['groupmode'] != NOGROUPS && !$data['is_ivt']) {
             $errors['groupmode'] = get_string('nogroups_withoutivt', 'opencast');
         }
     }
     return $errors;
 }