From c7e421e1fdda821b935e65c524872b7db9f9625f Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 25 Feb 2014 12:51:07 +0000 Subject: [PATCH 1/2] First full commit of plugin system --- doc/Plugin_System.md | 61 +++++++++++++++++++++ html/includes/plugins.inc.php | 68 +++++++++++++++++++++++ html/includes/print-menubar.php | 18 ++++--- html/index.php | 2 + html/pages/plugin.inc.php | 20 +++++++ html/pages/plugin/admin.inc.php | 95 +++++++++++++++++++++++++++++++++ html/plugins/.gitignore | 2 + includes/definitions.inc.php | 1 + includes/functions.php | 36 +++++++++++++ sql-schema/030.sql | 1 + 10 files changed, 297 insertions(+), 7 deletions(-) create mode 100644 doc/Plugin_System.md create mode 100644 html/includes/plugins.inc.php create mode 100644 html/pages/plugin.inc.php create mode 100644 html/pages/plugin/admin.inc.php create mode 100644 html/plugins/.gitignore create mode 100644 sql-schema/030.sql diff --git a/doc/Plugin_System.md b/doc/Plugin_System.md new file mode 100644 index 0000000000..3d0c41ce91 --- /dev/null +++ b/doc/Plugin_System.md @@ -0,0 +1,61 @@ +# Developing for the Plugin System + +This documentation will hopefully give you a basis for how to write a plugin for LibreNMS. + +A test plugin is available on GitHib: https://github.com/laf/Test + +Plugins need to be installed into html/plugins + +The structure of a plugin is follows: + +``` +html/plugins + /PluginName + /PluginName.php + /PluginName.inc.php +``` + +The above structure is checked before a plugin can be installed. + +All files / folder names are case sensitive and must match. + +PluginName - This is a directory and needs to be named as per the plugin you are creating. + +PluginName.php - This file is used to process calls into the plugin from the main LibreNMS install. + Here only functions within the class for your plugin that LibreNMS calls will be executed. + For a list of currently enabled system hooks, please see further down. + The minimum code required in this file is (replace Test with the name of your plugin): +``` + +``` + +PluginName.inc.php - This file is the main included file when browsing to the plugin itself. + You can use this to display / edit / remove whatever you like. + The minimum code required in this file is: +``` + +``` + +### System Hooks ### + +System hooks are called as functions within your plugin class, so for example to create a menu entry within the PLugin dropdown you would do: + +``` + public function menu() { + echo('
  • '.get_class().'
  • '); + } +``` + +This would then add the name and a link to your plugin. + +The following system hooks are currently available: + +menu() +* This is called to build the plugin menu system and you can use this to link to your plugin (you don't have to). diff --git a/html/includes/plugins.inc.php b/html/includes/plugins.inc.php new file mode 100644 index 0000000000..5ca6ca718e --- /dev/null +++ b/html/includes/plugins.inc.php @@ -0,0 +1,68 @@ + diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 460625eb89..001d80728f 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -484,15 +484,19 @@ if(is_file("includes/print-menubar-custom.inc.php")) + + + -