Skip to content

Commit

Permalink
Possible fix for #7
Browse files Browse the repository at this point in the history
  • Loading branch information
ndunand committed Jun 7, 2019
1 parent aad590f commit d2dd01b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ function definition() {
foreach ($userchannels as $userchannel) {
$channels[(string)$userchannel->identifier] = (string)$userchannel->title;
}
if (!empty($this->_instance) && !isset($channels[$this->current->ext_id])) {
// Instance exists but $USER has not access to it (yet)
// from $sysaccount, which MUST exist because we already checked.
// We have to freeze the channel selector further down.
$sysuserchannels = $sysaccount->getChannels();
$syschannels = [];
foreach ($sysuserchannels as $sysuserchannel) {
$syschannels[(string)$sysuserchannel->identifier] = (string)$sysuserchannel->title;
}
}
$mform->addElement('select', 'ext_id', get_string('channelchoose', 'opencast'), $channels);
$mform->disabledIf('ext_id', 'channelnew', 'eq', OPENCAST_CHANNEL_NEW);

Expand Down Expand Up @@ -209,8 +219,19 @@ function definition() {
$mform->removeElement('channelnew');
$mform->removeElement('userupload');
$mform->removeElement('userupload_maxfilesize');
$mform->addElement('html',
html_writer::tag('p', get_string('channel_not_found', 'opencast'), ['class' => 'notify']));
if (isset($syschannels[$this->current->ext_id])) {
// channel is not in user's list but exists, so display correct error message
$mform->addElement('html',
html_writer::tag('p', 'Wiating for access rights to be set... please try again.', ['class' => 'notify'])); // TODO localize string
// destroy ACL cache for this series
mod_opencast_apicall::clear_cache($CFG->dataroot . '/cache/mod_opencast', 'PUT', '/series/' . $this->current->ext_id . '/acl');
// TODO cachedir should be property of mod_opencast_apicall class
}
else {
// channel acually does not exist at all
$mform->addElement('html',
html_writer::tag('p', get_string('channel_not_found', 'opencast'), ['class' => 'notify']));
}
}

$this->standard_coursemodule_elements();
Expand Down

0 comments on commit d2dd01b

Please sign in to comment.