Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for single Activity format #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,25 +463,28 @@ function moodleoverflow_pluginfile($course, $cm, $context, $filearea, $args, $fo
* Extends the settings navigation with the moodleoverflow settings.
*
* This function is called when the context for the page is a moodleoverflow module. This is not called by AJAX
* so it is safe to rely on the $PAGE.
* so it is safe to rely on the page variable.
*
* @param settings_navigation $settingsnav complete settings navigation tree
* @param navigation_node $moodleoverflownode moodleoverflow administration node
*/
function moodleoverflow_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $moodleoverflownode = null) {
global $CFG, $DB, $PAGE, $USER;
global $DB, $USER;

// Retrieve the current moodle record.
$moodleoverflow = $DB->get_record('moodleoverflow', ['id' => $PAGE->cm->instance]);
$moodleoverflow = $DB->get_record('moodleoverflow', ['id' => $settingsnav->get_page()->cm->instance]);

// Check if the user can subscribe to the instance.
$enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
$activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
$canmanage = has_capability('mod/moodleoverflow:managesubscriptions', $PAGE->cm->context);
if (!$context = context_module::instance($settingsnav->get_page()->cm->id)) {
throw new \moodle_exception('badcontext');
}
$enrolled = is_enrolled($context, $USER, '', false);
$activeenrolled = is_enrolled($context, $USER, '', true);
$canmanage = has_capability('mod/moodleoverflow:managesubscriptions', $context);
$forcesubscribed = \mod_moodleoverflow\subscriptions::is_forcesubscribed($moodleoverflow);
$subscdisabled = \mod_moodleoverflow\subscriptions::subscription_disabled($moodleoverflow);
$cansubscribe = $activeenrolled && (!$subscdisabled || $canmanage) &&
!($forcesubscribed && has_capability('mod/moodleoverflow:allowforcesubscribe', $PAGE->cm->context));
!($forcesubscribed && has_capability('mod/moodleoverflow:allowforcesubscribe', $context));
$cantrack = \mod_moodleoverflow\readtracking::moodleoverflow_can_track_moodleoverflows($moodleoverflow);

// Display a link to the index.
Expand All @@ -503,7 +506,7 @@ function moodleoverflow_extend_settings_navigation(settings_navigation $settings
if ($cansubscribe) {

// Choose the linktext depending on the current state of subscription.
$issubscribed = \mod_moodleoverflow\subscriptions::is_subscribed($USER->id, $moodleoverflow, $PAGE->cm->context);
$issubscribed = \mod_moodleoverflow\subscriptions::is_subscribed($USER->id, $moodleoverflow, $context);
if ($issubscribed) {
$linktext = get_string('unsubscribe', 'moodleoverflow');
} else {
Expand Down
Loading