Solving:
"admin tool" - one of possible moodle extension plugins.
All plugin types - http://codingtrabla.blogspot.com/2015/02/moodle-all-plugin-extention-modules.html
Let's create admin tool "mytool".
When done plugin folder should be copied to folder
.../moodle/admin/tool/ folder e.g.
.../moodle/admin/tool/mytool/
1. Create Plugin Folder structure and files
/mytool/
/mytool/version.php
/mytool/settings.php
/mytool/index.php
/mytool/lang/en/tool_mytool.php
2. /mytool/version.php
<?php
/**
* Version details.
*
* @package tool_mytool
* @copyright 2015 Samurai Kit
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015010100;
$plugin->requires = 2011120500; // Moodle 2.2.0+
$plugin->cron = 0; // No cron jobs to run here
$plugin->component = 'tool_mytool';
$plugin->release = '1.0 (Build: 2015010100) Trololo :) ';
$plugin->dependencies = array(); // No dependencies
3. /mytool/settings.php
<?php
/**
* Add the admin menu link under Site Admin > Server > My Tool
*
* @package tool_mytool
* @copyright 2015 Samurai Kit
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) { // needs this condition or there is error on login page
$ADMIN->add('server',
new admin_externalpage('toolmytool',
get_string('pluginname', 'tool_mytool'),
"$CFG->wwwroot/$CFG->admin/tool/mytool/index.php"
)
);
}
4. /mytool/index.php
<?php
/**
* @package tool_mytool
* @copyright 2015 Samurai Kit
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Include required libary files
require_once(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
// Include what we need
require_once($CFG->dirroot.'/vendor/autoload.php');
// Setup admin page; authorizing, etc.
admin_externalpage_setup('toolmytool');
// Put here what to display
echo 'Trololo';
?>
5. /mytool/lang/en/tool_mytool.php
<?php
/**
* Strings for the MyTool tool
*
* @package tool_mytool
* @copyright 2015 Samurai Kit
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'My Tool';
$string['trololo'] = 'Tro-Lo-Lo';
to your moodle installation
.../moodle/admin/tool/
No comments:
Post a Comment