MDL-75316 core_moodlenet: Share to MoodleNet modal and activity menu

Originally implemented as MDL-75785
This commit is contained in:
Huong Nguyen
2023-04-18 17:05:07 +08:00
committed by Michael Hawkins
parent 6a877d438b
commit 58ced4add0
36 changed files with 1594 additions and 4 deletions
+18 -1
View File
@@ -23,6 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core\moodlenet\utilities;
use core_contentbank\contentbank;
defined('MOODLE_INTERNAL') || die();
@@ -4799,7 +4800,7 @@ class settings_navigation extends navigation_node {
* @return navigation_node|false
*/
protected function load_module_settings() {
global $CFG;
global $CFG, $USER;
if (!$this->page->cm && $this->context->contextlevel == CONTEXT_MODULE && $this->context->instanceid) {
$cm = get_coursemodule_from_id(false, $this->context->instanceid, 0, false, MUST_EXIST);
@@ -4880,6 +4881,22 @@ class settings_navigation extends navigation_node {
$function($this, $modulenode);
}
// Send to MoodleNet.
$usercanshare = utilities::can_user_share($this->context->get_course_context(), $USER->id);
$issuerid = get_config('moodlenet', 'oauthservice');
$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' => 'activity',
'data-sharetype' => 'resource',
]);
$modulenode->add(get_string('moodlenet:sharetomoodlenet', 'moodle'),
$action, self::TYPE_SETTING, null, 'exportmoodlenet')->set_force_into_more_menu(true);
}
// Remove the module node if there are no children.
if ($modulenode->children->count() <= 0) {
$modulenode->remove();