Skip to content
Snippets Groups Projects
Commit b8cb95a5 authored by Elmar Ludwig's avatar Elmar Ludwig Committed by Jan-Hendrik Willms
Browse files

don't offer OER actions when module is disabled, fixes #2769

Closes #2769

Merge request studip/studip!2027
parent f432e2ec
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ class Contents_CoursewareController extends CoursewareController ...@@ -23,6 +23,7 @@ class Contents_CoursewareController extends CoursewareController
$this->user = $GLOBALS['user']; $this->user = $GLOBALS['user'];
$this->licenses = $this->getLicenses(); $this->licenses = $this->getLicenses();
$this->oer_enabled = Config::get()->OERCAMPUS_ENABLED && $GLOBALS['perm']->have_perm(Config::get()->OER_PUBLIC_STATUS);
$this->unitsNotFound = Unit::countBySql('range_id = ?', [$this->user->id]) === 0; $this->unitsNotFound = Unit::countBySql('range_id = ?', [$this->user->id]) === 0;
} }
...@@ -61,7 +62,7 @@ class Contents_CoursewareController extends CoursewareController ...@@ -61,7 +62,7 @@ class Contents_CoursewareController extends CoursewareController
*/ */
public function courseware_action($unit_id = null): void public function courseware_action($unit_id = null): void
{ {
global $perm, $user; global $user;
Navigation::activateItem('/contents/courseware/courseware'); Navigation::activateItem('/contents/courseware/courseware');
if ($this->unitsNotFound) { if ($this->unitsNotFound) {
...@@ -297,7 +298,7 @@ class Contents_CoursewareController extends CoursewareController ...@@ -297,7 +298,7 @@ class Contents_CoursewareController extends CoursewareController
*/ */
public function shared_content_courseware_action($entry_element_id): void public function shared_content_courseware_action($entry_element_id): void
{ {
global $perm, $user; global $user;
$navigation = new Navigation(_('Geteiltes Lernmaterial'), 'dispatch.php/contents/courseware/shared_content_courseware/' . $entry_element_id); $navigation = new Navigation(_('Geteiltes Lernmaterial'), 'dispatch.php/contents/courseware/shared_content_courseware/' . $entry_element_id);
Navigation::addItem('/contents/courseware/shared_content_courseware', $navigation); Navigation::addItem('/contents/courseware/shared_content_courseware', $navigation);
...@@ -320,9 +321,6 @@ class Contents_CoursewareController extends CoursewareController ...@@ -320,9 +321,6 @@ class Contents_CoursewareController extends CoursewareController
$this->user_id = $struct->owner_id; $this->user_id = $struct->owner_id;
$this->oer_enabled = Config::get()->OERCAMPUS_ENABLED && $perm->have_perm(Config::get()->OER_PUBLIC_STATUS);
$this->setCoursewareSidebar(); $this->setCoursewareSidebar();
} }
} }
...@@ -31,6 +31,7 @@ class Course_CoursewareController extends CoursewareController ...@@ -31,6 +31,7 @@ class Course_CoursewareController extends CoursewareController
object_set_visit_module($this->studip_module->getPluginId()); object_set_visit_module($this->studip_module->getPluginId());
$this->last_visitdate = object_get_visit(Context::getId(), $this->studip_module->getPluginId()); $this->last_visitdate = object_get_visit(Context::getId(), $this->studip_module->getPluginId());
$this->licenses = $this->getLicenses(); $this->licenses = $this->getLicenses();
$this->oer_enabled = Config::get()->OERCAMPUS_ENABLED && $GLOBALS['perm']->have_perm(Config::get()->OER_PUBLIC_STATUS);
$this->unitsNotFound = Unit::countBySql('range_id = ?', [Context::getId()]) === 0; $this->unitsNotFound = Unit::countBySql('range_id = ?', [Context::getId()]) === 0;
} }
...@@ -42,7 +43,7 @@ class Course_CoursewareController extends CoursewareController ...@@ -42,7 +43,7 @@ class Course_CoursewareController extends CoursewareController
public function courseware_action($unit_id = null): void public function courseware_action($unit_id = null): void
{ {
global $perm, $user; global $user;
Navigation::activateItem('course/courseware/unit'); Navigation::activateItem('course/courseware/unit');
if ($this->unitsNotFound) { if ($this->unitsNotFound) {
PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.'))); PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.')));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
entry-type="users" entry-type="users"
entry-id="<?= htmlReady($user_id) ?>" entry-id="<?= htmlReady($user_id) ?>"
unit-id="<?= htmlReady($unit_id) ?>" unit-id="<?= htmlReady($unit_id) ?>"
oer-enabled='<?= htmlReady(Config::get()->OERCAMPUS_ENABLED) ?>' oer-enabled='<?= htmlReady($oer_enabled) ?>'
licenses='<?= htmlReady($licenses) ?>' licenses='<?= htmlReady($licenses) ?>'
> >
</div> </div>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
entry-type="courses" entry-type="courses"
entry-id="<?= htmlReady(Context::getId()) ?>" entry-id="<?= htmlReady(Context::getId()) ?>"
unit-id="<?= htmlReady($unit_id) ?>" unit-id="<?= htmlReady($unit_id) ?>"
oer-enabled="<?= htmlReady(Config::get()->OERCAMPUS_ENABLED) ?>" oer-enabled='<?= htmlReady($oer_enabled) ?>'
licenses='<?= htmlReady($licenses) ?>' licenses='<?= htmlReady($licenses) ?>'
> >
</div> </div>
......
...@@ -64,11 +64,15 @@ export default { ...@@ -64,11 +64,15 @@ export default {
return this.canVisit; return this.canVisit;
}, },
showOer() { showOer() {
if (!this.oerEnabled) {
return false;
}
if (this.context.type === 'users') { if (this.context.type === 'users') {
return true; return true;
} }
return this.oerEnabled && this.userIsTeacher && this.canVisit return this.userIsTeacher && this.canVisit;
} }
}, },
methods: { methods: {
......
...@@ -1030,9 +1030,14 @@ export default { ...@@ -1030,9 +1030,14 @@ export default {
let menu = [ let menu = [
{ id: 4, label: this.$gettext('Informationen anzeigen'), icon: 'info', emit: 'showInfo' }, { id: 4, label: this.$gettext('Informationen anzeigen'), icon: 'info', emit: 'showInfo' },
{ id: 5, label: this.$gettext('Lesezeichen setzen'), icon: 'star', emit: 'setBookmark' }, { id: 5, label: this.$gettext('Lesezeichen setzen'), icon: 'star', emit: 'setBookmark' },
];
if (this.oerEnabled) {
menu.push(
{ id: 6, label: this.$gettext('Lerninhalt für OER Campus vorschlagen'), icon: 'oer-campus', { id: 6, label: this.$gettext('Lerninhalt für OER Campus vorschlagen'), icon: 'oer-campus',
emit: 'showSuggest' } emit: 'showSuggest' }
]; );
}
if (!document.documentElement.classList.contains('responsive-display')) { if (!document.documentElement.classList.contains('responsive-display')) {
menu.push( menu.push(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment