Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marxjohnson/3225777 to your computer and use it in GitHub Desktop.
Save marxjohnson/3225777 to your computer and use it in GitHub Desktop.
Patch for Moodle 2 to enable subplugins in Local plugins. Copyright Richard Taunton Sixth Form College, UK. Licenced under GNU GPL.
From 6c6ed071f4891a877323fc503a56ee42d66b929c Mon Sep 17 00:00:00 2001
From: Mark Johnson <mark.johnson@tauntons.ac.uk>
Date: Wed, 23 Mar 2011 12:16:25 +0000
Subject: [PATCH 20/78] MDL-26943 Added submodule support for local plugins
---
lib/moodlelib.php | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index a285ea1..2405a6d 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -7610,6 +7610,19 @@ function get_plugin_types($fullpaths=true) {
// local is always last!
$info['local'] = 'local';
+ $locals = get_plugin_list('local');
+ if(!empty($locals)) {
+ foreach($locals as $local => $localdir) {
+ if (file_exists("$localdir/db/subplugins.php")) {
+ $subplugins = array();
+ include("$localdir/db/subplugins.php");
+ foreach ($subplugins as $subtype=>$dir) {
+ $info[$subtype] = $dir;
+ }
+ }
+
+ }
+ }
$fullinfo = array();
foreach ($info as $type => $dir) {
@@ -7647,6 +7660,9 @@ function get_plugin_list($plugintype) {
// mod is an exception because we have to call this function from get_plugin_types()
$fulldirs[] = $CFG->dirroot.'/mod';
+ } else if ($plugintype === 'local') {
+ // Same with local
+ $fulldirs[] = $CFG->dirroot.'/local';
} else if ($plugintype === 'theme') {
$fulldirs[] = $CFG->dirroot.'/theme';
// themes are special because they may be stored also in separate directory
--
1.7.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment