Escolar Documentos
Profissional Documentos
Cultura Documentos
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/>.
/**
* Readme file for local customisations
*
* @package local
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Directory structure
-------------------
This directory has standard plugin structure. All standard plugin features
are supported. There may be some extra files with special meaning in /local/.
Local plugins
=============
Local plugins are used in cases when no standard plugin fits, examples are:
* event consumers communicating with external systems
* custom definitions of web services and external functions
* applications that extend moodle at the system level (hub server, amos server,
etc.)
* new database tables used in core hacks (discouraged)
* new capability definitions used in core hacks
* custom admin settings
Standard plugin features:
* /local/pluginname/version.php - version of script (must be incremented after
changes)
* /local/pluginname/db/install.xml - executed during install (new version.php
found)
* /local/pluginname/db/install.php - executed right after install.xml
* /local/pluginname/db/uninstall.php - executed during uninstallation
* /local/pluginname/db/upgrade.php - executed after version.php change
* /local/pluginname/db/access.php - definition of capabilities
* /local/pluginname/db/events.php - event handlers and subscripts
* /local/pluginname/db/messages.php - messaging registration
* /local/pluginname/db/services.php - definition of web services and web service
functions
* /local/pluginname/db/subplugins.php - list of subplugins types supported by this
local plugin
* /local/pluginname/lang/en/local_pluginname.php - language file
* /local/pluginname/settings.php - admin settings
Example:
/local/nicehack/version.php
<?php
$plugin->version = 2010022400; // The (date) version of this plugin
$plugin->requires = 2010021900; // Requires this Moodle version
/local/nicehack/access.php content
<?php
$local_nicehack_capabilities = array(
'local/nicehack:nicecapability' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
),
);
For example if you want to add new external page use following
/local/nicehack/settings.php
<?php
$ADMIN->add('root', new admin_category('tweaks', 'Custom tweaks'));
$ADMIN->add('tweaks', new admin_externalpage('nicehackery', 'Tweak something',
$CFG->wwwroot.'/local/nicehack/setuppage.php'));
Or if you want a new standard settings page for the plugin, inside the local
plugins category:
<?php
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtext('local_thisplugin/option',
'Option', 'Information about this option', 100, PARAM_INT));
}
sample files
/local/nicehack/db/events.php
$handlers = array (
'user_deleted' => array (
'handlerfile' => '/local/nicehack/lib.php',
'handlerfunction' => 'nicehack_userdeleted_handler',
'schedule' => 'instant'
),
);
NOTE: events are not yet fully implemented in current Moodle 2.0dev.
If you really really really need to modify core tables you might want to do
that in install.php and later upgrade.php
sample files
/local/nicehack/db/services.php
$$functions = array (
'nicehack_hello_world' => array(
'classname' => 'local_nicehack_external',
'methodname' => 'hello_world',
'classpath' => 'local/nicehack/externallib.php',
'description' => 'Get hello world string',
'type' => 'read',
),
);
$services = array(
'Nice hack service 1' => array(
'functions' => array ('nicehack_hello_world'),
'enabled'=>1,
),
);
sample code
<?php
function local_nicehack_extends_navigation(global_navigation $nav) {
// $nav is the global navigation instance.
// Here you can add to and manipulate the navigation structure as you like.
// This callback was introduced in 2.0 as
nicehack_extends_navigation(global_navigation $nav)
// In 2.3 support was added for the now preferred
local_nicehack_extends_navigation(global_navigation $nav).
}
function local_nicehack_extends_settings_navigation(settings_navigation $nav,
context $context) {
// $nav is the settings navigation instance.
// $context is the context the settings have been loaded for (settings is
context specific)
// Here you can add to and manipulate the settings structure as you like.
// This callback was introduced in 2.3
}
These customised defaults are useful especially when using CLI tools
for installation and upgrade.
The values usually correspond to the raw string in config table, with the exception
of comma separated lists that are usually entered as real arrays.
This file is just included directly, there does not need to be any
function inside. If the execution stops the script is executed again
during the next upgrade. The first execution of lib/db/upgrade.php
increments the version number and the pre upgrade script is not
executed any more.
Examples:
* disable one specific moodle page without code modification
* alter page parameters on the fly