Add version constant, update phpdoc

This commit is contained in:
Johan Cwiklinski 2017-02-08 15:21:59 +01:00 committed by Johan Cwiklinski
parent b270e19e91
commit aaab0d8415
2 changed files with 58 additions and 29 deletions

View File

@ -1,29 +1,28 @@
<?php <?php
/* /*
* @version $Id: hook.php 219 2013-11-25 19:01:42Z webmyster $
------------------------------------------------------------------------- -------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique Example plugin for GLPI
Copyright (C) 2003-2011 by the INDEPNET Development Team. Copyright (C) 2001-2017 by the Example Development Team.
http://indepnet.net/ http://glpi-project.org https://github.com/pluginsGLPI/example
------------------------------------------------------------------------- -------------------------------------------------------------------------
LICENSE LICENSE
This file is part of GLPI. This file is part of Example.
GLPI is free software; you can redistribute it and/or modify Example is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
GLPI is distributed in the hope that it will be useful, Example is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>. along with Example. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
*/ */
@ -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() { function plugin_example_install() {
global $DB; 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() { function plugin_example_uninstall() {
global $DB; global $DB;
@ -664,5 +671,3 @@ function plugin_example_infocom_hook($params) {
echo __("Plugin example displays on central page", "example"); echo __("Plugin example displays on central page", "example");
echo "</th></tr>"; echo "</th></tr>";
} }
?>

View File

@ -1,29 +1,28 @@
<?php <?php
/* /*
* @version $Id: HEADER 15930 2011-10-25 10:47:55Z jmd $
------------------------------------------------------------------------- -------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique Example plugin for GLPI
Copyright (C) 2003-2011 by the INDEPNET Development Team. Copyright (C) {YEAR} by the {NAME} Development Team.
http://indepnet.net/ http://glpi-project.org https://github.com/pluginsGLPI/example
------------------------------------------------------------------------- -------------------------------------------------------------------------
LICENSE LICENSE
This file is part of GLPI. This file is part of Example.
GLPI is free software; you can redistribute it and/or modify Example is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
GLPI is distributed in the hope that it will be useful, Example is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>. along with Example. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
*/ */
@ -32,7 +31,14 @@
// Purpose of file: // 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() { function plugin_init_example() {
global $PLUGIN_HOOKS,$CFG_GLPI; 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() { function plugin_version_example() {
return array('name' => 'Plugin Example', return array('name' => 'Plugin Example',
'version' => '7.1', 'version' => PLUGIN_EXAMPLE_VERSION,
'author' => 'GLPI developer team', 'author' => 'GLPI developer team',
'license' => 'GPLv2+', 'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/example', '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() { function plugin_example_check_prerequisites() {
// Strict version check (could be less strict, or could allow various version) // 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')*/) { if (version_compare(GLPI_VERSION,'0.85','lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) {
if (method_exists('Plugin', 'messageIncompatible')) {
echo Plugin::messageIncompatible('core', '0.85');
} else {
echo "This plugin requires GLPI >= 0.85"; echo "This plugin requires GLPI >= 0.85";
}
return false; return false;
} }
return true; return true;
} }
/**
// Check configuration process for plugin : need to return true if succeeded * Check configuration process
// Can display a message only if failure and $verbose is true *
function plugin_example_check_config($verbose=false) { * @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 if (true) { // Your configuration check
return true; return true;
} }