Merge branch 'MDL-73592-master' of git://github.com/rezaies/moodle
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Install script for tool_moodlenet.
|
||||
*
|
||||
* @package tool_moodlenet
|
||||
* @copyright 2022 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Perform the post-install procedures.
|
||||
*/
|
||||
function xmldb_tool_moodlenet_install() {
|
||||
// Set the active activity chooser footer plugin to tool_moodlenet.
|
||||
// We couldn't do this in admin/settings/courses.php for 2 reasons:
|
||||
// First, because it would be a breach of component communications principles to do so there.
|
||||
// Second, because we can't call get_plugins_with_function() during install and upgrade (or it will return []).
|
||||
set_config('activitychooseractivefooter', 'tool_moodlenet');
|
||||
}
|
||||
@@ -123,5 +123,41 @@ function xmldb_tool_moodlenet_upgrade(int $oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2021052501, 'tool', 'moodlenet');
|
||||
}
|
||||
|
||||
if ($oldversion < 2022021600) {
|
||||
// This is a special case for if MoodleNet integration has never been enabled,
|
||||
// or if defaultmoodlenet is not set for whatever reason.
|
||||
if (!get_config('tool_moodlenet', 'defaultmoodlenet')) {
|
||||
set_config('defaultmoodlenet', 'https://moodle.net', 'tool_moodlenet');
|
||||
set_config('defaultmoodlenetname', get_string('defaultmoodlenetnamevalue', 'tool_moodlenet'), 'tool_moodlenet');
|
||||
}
|
||||
|
||||
// Enable MoodleNet and set it to display on activity chooser footer.
|
||||
// But only do this if we know for sure that the default MoodleNet is a working one.
|
||||
if (get_config('tool_moodlenet', 'defaultmoodlenet') == 'https://moodle.net') {
|
||||
set_config('enablemoodlenet', '1', 'tool_moodlenet');
|
||||
set_config('activitychooseractivefooter', 'tool_moodlenet');
|
||||
|
||||
// Send notification.
|
||||
$message = new \core\message\message();
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'notices';
|
||||
$message->userfrom = \core_user::get_noreply_user();
|
||||
$message->userto = get_admin();
|
||||
$message->notification = 1;
|
||||
$message->contexturl = (new moodle_url('/admin/settings.php',
|
||||
['section' => 'optionalsubsystems'], 'admin-enablemoodlenet'))->out(false);
|
||||
$message->contexturlname = get_string('advancedfeatures', 'admin');
|
||||
$message->subject = get_string('autoenablenotification_subject', 'tool_moodlenet');
|
||||
$message->fullmessageformat = FORMAT_HTML;
|
||||
$message->fullmessagehtml = get_string('autoenablenotification', 'tool_moodlenet', (object) [
|
||||
'settingslink' => (new moodle_url('/admin/settings.php', ['section' => 'tool_moodlenet']))->out(false),
|
||||
]);
|
||||
$message->smallmessage = strip_tags($message->fullmessagehtml);
|
||||
message_send($message);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2022021600, 'tool', 'moodlenet');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['autoenablenotification'] = '<p>In Moodle 4.0 onwards, the <a href="https://moodle.net/">MoodleNet</a> integration is enabled by default in Advanced features. Users with the capability to create and manage activities can browse MoodleNet via the activity chooser and import MoodleNet resources into their courses.</p><p>If desired, an alternative MoodleNet instance may be specified in the <a href="{$a->settingslink}">MoodleNet settings</a>.</p>';
|
||||
$string['autoenablenotification_subject'] = 'Default MoodleNet setting changed.';
|
||||
$string['addingaresource'] = 'Adding content from MoodleNet';
|
||||
$string['aria:enterprofile'] = "Enter your MoodleNet profile URL";
|
||||
$string['aria:footermessage'] = "Browse for content on MoodleNet";
|
||||
|
||||
@@ -30,7 +30,7 @@ if ($hassiteconfig) {
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('tool_moodlenet/enablemoodlenet',
|
||||
new lang_string('enablemoodlenet', 'tool_moodlenet'),
|
||||
new lang_string('enablemoodlenet_desc', 'tool_moodlenet'),
|
||||
0, 1, 0)
|
||||
1, 1, 0)
|
||||
);
|
||||
|
||||
// Create a MoodleNet category.
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'tool_moodlenet';
|
||||
$plugin->version = 2021052501;
|
||||
$plugin->version = 2022021600;
|
||||
$plugin->requires = 2021052500;
|
||||
$plugin->maturity = MATURITY_ALPHA;
|
||||
|
||||
Reference in New Issue
Block a user