Skip to content

Commit

Permalink
MDL-75318 core: Add navigation for sharing course to MoodleNet
Browse files Browse the repository at this point in the history
  • Loading branch information
safatshahin committed Aug 22, 2023
1 parent 4b94384 commit 37266f1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4627,6 +4627,26 @@ protected function load_course_settings($forceopen = false) {
$coursenode->force_open();
}

// Share course to moodlenet.
$usercanshare = utilities::can_user_share($coursecontext, $USER->id, 'course');
$issuerid = get_config('moodlenet', 'oauthservice');
try {
$issuer = \core\oauth2\api::get_issuer($issuerid);
$isvalidinstance = utilities::is_valid_instance($issuer);
if ($usercanshare && $isvalidinstance) {
$this->page->requires->js_call_amd('core/moodlenet/send_resource', 'init');
$action = new action_link(new moodle_url(''), '', null, [
'data-action' => 'sendtomoodlenet',
'data-type' => 'course',
'data-sharetype' => 'resource',
]);
$coursenode->add(get_string('moodlenet:sharetomoodlenet', 'moodle'),
$action, self::TYPE_SETTING, null, 'exportcoursetomoodlenet')->set_force_into_more_menu(true);
}
} catch (dml_missing_record_exception $e) {
debugging("Invalid MoodleNet OAuth 2 service set in site administration: 'moodlenet | oauthservice'. " .
"This must be a valid issuer.");
}

if ($adminoptions->update) {
// Add the course settings link
Expand Down Expand Up @@ -4894,7 +4914,7 @@ protected function load_module_settings() {
$function($this, $modulenode);
}

// Send to MoodleNet.
// Send activity to MoodleNet.
$usercanshare = utilities::can_user_share($this->context->get_course_context(), $USER->id);
$issuerid = get_config('moodlenet', 'oauthservice');
try {
Expand Down

0 comments on commit 37266f1

Please sign in to comment.