From aaab0d84159d1179404aed06add989c8eb7dd76f Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 8 Feb 2017 15:21:59 +0100 Subject: [PATCH] Add version constant, update phpdoc --- hook.php | 29 ++++++++++++++++------------ setup.php | 58 +++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/hook.php b/hook.php index 95e45d2..39b17da 100644 --- a/hook.php +++ b/hook.php @@ -1,29 +1,28 @@ . + along with Example. If not, see . -------------------------------------------------------------------------- */ @@ -442,7 +441,11 @@ function plugin_example_addParamFordynamicReport($itemtype) { } -// Install process for plugin : need to return true if succeeded +/** + * Plugin install process + * + * @return boolean + */ function plugin_example_install() { global $DB; @@ -533,7 +536,11 @@ function plugin_example_install() { } -// Uninstall process for plugin : need to return true if succeeded +/** + * Plugin uninstall process + * + * @return boolean + */ function plugin_example_uninstall() { global $DB; @@ -664,5 +671,3 @@ function plugin_example_infocom_hook($params) { echo __("Plugin example displays on central page", "example"); echo ""; } - -?> diff --git a/setup.php b/setup.php index 133663c..c2e98a7 100755 --- a/setup.php +++ b/setup.php @@ -1,29 +1,28 @@ . + along with Example. If not, see . -------------------------------------------------------------------------- */ @@ -32,7 +31,14 @@ // Purpose of file: // ---------------------------------------------------------------------- -// Init the hooks of the plugins -Needed +define ('PLUGIN_EXAMPLE_VERSION', '7.1'); + +/** + * Init hooks of the plugin. + * REQUIRED + * + * @return void + */ function plugin_init_example() { global $PLUGIN_HOOKS,$CFG_GLPI; @@ -205,11 +211,16 @@ function plugin_init_example() { } -// Get the name and the version of the plugin - Needed +/** + * Get the name and the version of the plugin + * REQUIRED + * + * @return array + */ function plugin_version_example() { return array('name' => 'Plugin Example', - 'version' => '7.1', + 'version' => PLUGIN_EXAMPLE_VERSION, 'author' => 'GLPI developer team', 'license' => 'GPLv2+', 'homepage' => 'https://github.com/pluginsGLPI/example', @@ -217,21 +228,34 @@ function plugin_version_example() { } -// Optional : check prerequisites before install : may print errors or add to message after redirect +/** + * Check pre-requisites before install + * OPTIONNAL, but recommanded + * + * @return boolean + */ function plugin_example_check_prerequisites() { // Strict version check (could be less strict, or could allow various version) if (version_compare(GLPI_VERSION,'0.85','lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) { - echo "This plugin requires GLPI >= 0.85"; + if (method_exists('Plugin', 'messageIncompatible')) { + echo Plugin::messageIncompatible('core', '0.85'); + } else { + echo "This plugin requires GLPI >= 0.85"; + } return false; } return true; } - -// Check configuration process for plugin : need to return true if succeeded -// Can display a message only if failure and $verbose is true -function plugin_example_check_config($verbose=false) { +/** + * Check configuration process + * + * @param boolean $verbose Whether to display message on failure. Defaults to false + * + * @return boolean + */ +function plugin_example_check_config($verbose = false) { if (true) { // Your configuration check return true; }