GLPI 9.4 compatibility

- Use ITILFollowup in replacement of TicketFollowup
This commit is contained in:
Cédric Anne 2018-11-27 10:01:19 +01:00
parent 6b3334ecfd
commit 511aba6951
3 changed files with 12 additions and 13 deletions

View File

@ -26,7 +26,7 @@
<versions> <versions>
<version> <version>
<num>0.0.1</num> <num>0.0.1</num>
<compatibility>0.85</compatibility> <compatibility>9.4</compatibility>
</version> </version>
</versions> </versions>
<langs> <langs>

View File

@ -36,7 +36,7 @@ along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ex: when viewing a ticket, change, computer,... * ex: when viewing a ticket, change, computer,...
* *
* will be fired at each sub-item * will be fired at each sub-item
* ex: for each TicketTask, TicketFollowup, ... * ex: for each TicketTask, ITILFollowup, ...
* *
* post_show_item will be fired after the item show * post_show_item will be fired after the item show
* *
@ -58,7 +58,7 @@ class PluginExampleShowtabitem {
* and 'options' are options like following * and 'options' are options like following
* array( 'tabnum', 'itemtype') * array( 'tabnum', 'itemtype')
* where 'tabnum' is the internal name of the tab that will be shown * where 'tabnum' is the internal name of the tab that will be shown
* and 'itemtype' is the type of the tab (ex: 'TicketFollowup' when showing followup tab in a ticket) * and 'itemtype' is the type of the tab (ex: 'ITILFollowup' when showing followup tab in a ticket)
* Note: you may pass datas to post_show_tab using the $param['options'] array (see example below) * Note: you may pass datas to post_show_tab using the $param['options'] array (see example below)
*/ */
static function pre_show_tab($params) { static function pre_show_tab($params) {
@ -135,7 +135,7 @@ class PluginExampleShowtabitem {
* where 'id' is the id of object that will be shown (same than $param['item']->fields['id']) * where 'id' is the id of object that will be shown (same than $param['item']->fields['id'])
* or if item contains a sub-object like followup, task, ... then it contains * or if item contains a sub-object like followup, task, ... then it contains
* array( 'parent', 'rand', 'showprivate') * array( 'parent', 'rand', 'showprivate')
* where 'parent' is the main object related to the current item (ex: if 'item' is TicketFollowup then it will be the related Ticket) * where 'parent' is the main object related to the current item (ex: if 'item' is ITILFollowup then it will be the related Ticket)
* and 'rand' contains the random number that will be used to render the item * and 'rand' contains the random number that will be used to render the item
* and 'showprivate' is the right to show private items * and 'showprivate' is the right to show private items
* Note: you may pass datas to post_show_item using the $param['options'] array * Note: you may pass datas to post_show_item using the $param['options'] array
@ -149,7 +149,7 @@ class PluginExampleShowtabitem {
case 'TicketTask' : case 'TicketTask' :
//echo 'test' ; //echo 'test' ;
break; break;
case 'TicketFollowup' : case 'ITILFollowup' :
//echo 'test' ; //echo 'test' ;
break; break;
} }
@ -170,7 +170,7 @@ class PluginExampleShowtabitem {
* where 'id' is the id of object that will be shown (same than $param['item']->fields['id']) * where 'id' is the id of object that will be shown (same than $param['item']->fields['id'])
* or if item contains a sub-object like followup, task, ... then it contains * or if item contains a sub-object like followup, task, ... then it contains
* array( 'parent', 'rand', 'showprivate') * array( 'parent', 'rand', 'showprivate')
* where 'parent' is the main object related to the current item (ex: if 'item' is TicketFollowup then it will be the related Ticket) * where 'parent' is the main object related to the current item (ex: if 'item' is ITILFollowup then it will be the related Ticket)
* and 'rand' contains the random number that will be used to render the item * and 'rand' contains the random number that will be used to render the item
* and 'showprivate' is the right to show private items * and 'showprivate' is the right to show private items
* Note: you may get datas from pre_show_item using the $param['options'] array * Note: you may get datas from pre_show_item using the $param['options'] array
@ -184,7 +184,7 @@ class PluginExampleShowtabitem {
case 'TicketTask' : case 'TicketTask' :
//echo 'test' ; //echo 'test' ;
break; break;
case 'TicketFollowup' : case 'ITILFollowup' :
//echo 'test' ; //echo 'test' ;
break; break;
} }

View File

@ -232,8 +232,7 @@ function plugin_version_example() {
'homepage' => 'https://github.com/pluginsGLPI/example', 'homepage' => 'https://github.com/pluginsGLPI/example',
'requirements' => [ 'requirements' => [
'glpi' => [ 'glpi' => [
'min' => '9.3', 'min' => '9.4',
'dev' => true
] ]
] ]
]; ];
@ -248,12 +247,12 @@ function plugin_version_example() {
*/ */
function plugin_example_check_prerequisites() { function plugin_example_check_prerequisites() {
$version = rtrim(GLPI_VERSION, '-dev'); //Version check is not done by core in GLPI < 9.2 but has to be delegated to core in GLPI >= 9.2.
if (version_compare($version, '9.3', 'lt')) { $version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
echo "This plugin requires GLPI 9.3"; if (version_compare($version, '9.2', '<')) {
echo "This plugin requires GLPI >= 9.4";
return false; return false;
} }
return true; return true;
} }