From e882210574e2d9400f91835332b1fe232e9038f4 Mon Sep 17 00:00:00 2001 From: TamaroWalter Date: Mon, 15 Apr 2024 18:13:13 +0200 Subject: [PATCH] init plugin structure --- classes/townsquaresupportinterface.php | 50 ++++++++++++++++++++++++++ db/access.php | 24 +++++++++++++ db/subplugins.json | 5 +++ db/subplugins.php | 27 ++++++++++++++ lang/en/local_townsquaresupport.php | 30 ++++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 classes/townsquaresupportinterface.php create mode 100644 db/access.php create mode 100644 db/subplugins.json create mode 100644 db/subplugins.php create mode 100644 lang/en/local_townsquaresupport.php diff --git a/classes/townsquaresupportinterface.php b/classes/townsquaresupportinterface.php new file mode 100644 index 0000000..bbe39c8 --- /dev/null +++ b/classes/townsquaresupportinterface.php @@ -0,0 +1,50 @@ +. + +/** + * Interface for all subplugins that improve the townsquare block content. + * + * The Plugins of the type townsquaresupport are used to increase the content of the townsquare block. + * Every module that wants to show content on townsquare can implement this interface. + * Every module must: + * - gather "events" for a user that can be transformed into letters. + * - provide php_unit test to ensure the correct behaviour. + * local_townsquaresupport will call this function of each subplugin. The townsquare block will then gather all events from local_townsquaresupport + * + * @package local_townsquaresupport + * @copyright 2024 Tamaro Walter + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace local_townsquaresupport; + +interface townsquaresupportinterface { + + /** + * Function to gather the events + * Every event must gain sufficient data so that townsquare can build a letter from it. + * The array should contain following information: + * [courseid] => int Course ID from where the content comes from. + * [modulename] => string Name of the activity module. + * [instancename] => string Name of the instance that shows the notification. + * [content] => string The content that will be showed in the letter. + * [timestart] => int Timestamp that represents the deadline/creation of a notification. Is important to sort events. + * [coursemoduleid] => int Course module id of the content module. + * [eventtype] => string Type of the event. + * + * @return array of events that can be transformed into letters + */ + public function get_events(): array; +} diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..cc13aef --- /dev/null +++ b/db/access.php @@ -0,0 +1,24 @@ +. + +/** + * Plugin capabilities for the block_townsquare plugin. + * + * @package block_townsquare + * @copyright 2023 Tamaro Walter + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); diff --git a/db/subplugins.json b/db/subplugins.json new file mode 100644 index 0000000..a38f543 --- /dev/null +++ b/db/subplugins.json @@ -0,0 +1,5 @@ +{ + "plugintypes": { + "supportedmodules": "local/townsquaresupport/supportedmodules" + } +} diff --git a/db/subplugins.php b/db/subplugins.php new file mode 100644 index 0000000..8dfe460 --- /dev/null +++ b/db/subplugins.php @@ -0,0 +1,27 @@ +. + +/** + * This file defines the sub-plugins for the townsquare block. + * + * @package blocks_townsquare + * @copyright 2023 Tamaro Walter + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$subplugins = ['supportedmodules' => 'local/townsquaresupport/supportedmodules']; diff --git a/lang/en/local_townsquaresupport.php b/lang/en/local_townsquaresupport.php new file mode 100644 index 0000000..93efb1a --- /dev/null +++ b/lang/en/local_townsquaresupport.php @@ -0,0 +1,30 @@ +. + +/** + * Plugin strings are defined here. + * + * @package local_townsquaresupport + * @category string + * @copyright 2024 Tamaro Walter + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +// Subplugin strings +$string['subplugintype_townsquaresupport'] = 'Supported module'; +$string['subplugintype_townsquaresupport_plural'] = 'Supported modules'; \ No newline at end of file