diff --git a/inc/showtabitem.class.php b/inc/showtabitem.class.php
new file mode 100644
index 0000000..ac88975
--- /dev/null
+++ b/inc/showtabitem.class.php
@@ -0,0 +1,186 @@
+.
+--------------------------------------------------------------------------
+ */
+
+/**
+ * Summary of PluginExampleShowtabitem
+ * Example of pre_show_xxx and post_show_xxx implementation
+ *
+ *
+ * pre_show_item will be fired before an item is shown
+ * ex: when viewing a ticket, change, computer,...
+ *
+ * will be fired at each sub-item
+ * ex: for each TicketTask, TicketFollowup, ...
+ *
+ * post_show_item will be fired after the item show
+ *
+ *
+ * pre_show_tab will be fired before a tab is shown
+ * when tabs are loaded,
+ * ex: when viewing the Followup tab
+ *
+ * post_show_tab will be fired after the tab show
+ *
+ * */
+class PluginExampleShowtabitem {
+
+ /**
+ * Summary of pre_show_tab
+ * @param array $params is an array like following
+ * array( 'item', 'options')
+ * where 'item' is the parent object (like 'Ticket'),
+ * and 'options' are options like following
+ * array( 'tabnum', 'itemtype')
+ * 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)
+ * Note: you may pass datas to post_show_tab using the $param['options'] array (see example below)
+ */
+ static function pre_show_tab($params) {
+ switch( $params['item']->getType() ) {
+ case 'Ticket':
+ if( $params['options']['itemtype']=='Ticket' && $params['options']['tabnum']==2) {
+ // if tasks are not all done
+ // then prevent solution div to show
+ // this is an example to prevent solving of ticket
+ if( true ) { // here you should test if some tasks are in todo status.
+ $params['options']['prevent_solution'] = true ; // this will be passed to the post_show hook
+ echo "
" ; // in order to hide the default solution div
+ }
+ }
+ }
+ }
+
+ /**
+ * Summary of post_show_tab
+ * @param array $params is identical to pre_show_tab parameter
+ * Note: you may get datas from pre_show_tab in $param['options'] array (see example below)
+ */
+ static function post_show_tab($params) {
+ switch( $params['item']->getType() ) {
+ case 'Ticket':
+ if( isset($params['options']['prevent_solution'])) {
+ echo "
";
+ echo "
+
+
+
+
+
+ "."Can't solve ticket"."
+
+
+
+
+ "."Tasks are waiting to be done"."
+
+
+
+
+
+
+
";
+ }
+ break ;
+
+ case 'Computer':
+ break;
+ }
+ }
+
+ /**
+ * Summary of pre_show_item
+ * @param array $params is an array like following
+ * array( 'item', 'options')
+ * where 'item' is the object to show (like 'Ticket', 'TicketTask', ...),
+ * and 'options' are options like following
+ * if item is a main object like a ticket, change, problem, ... then it contains
+ * array( '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
+ * 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)
+ * and 'rand' contains the random number that will be used to render the item
+ * and 'showprivate' is the right to show private items
+ * Note: you may pass datas to post_show_item using the $param['options'] array
+ */
+ static function pre_show_item($params) {
+ switch( $params['item']->getType() ) {
+ case 'Ticket':
+ //echo 'test' ;
+ break;
+ case 'TicketTask' :
+ //echo 'test' ;
+ break;
+ case 'TicketFollowup' :
+ //echo 'test' ;
+ break;
+ }
+ }
+
+ /**
+ * Summary of post_show_item
+ * @param array $params is an array like following
+ * array( 'item', 'options')
+ * where 'item' is the object to show (like 'Ticket', 'TicketTask', ...),
+ * and 'options' are options like following
+ * if item is a main object like a ticket, change, problem, ... then it contains
+ * array( '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
+ * 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)
+ * and 'rand' contains the random number that will be used to render the item
+ * and 'showprivate' is the right to show private items
+ * Note: you may get datas from pre_show_item using the $param['options'] array
+ */
+ static function post_show_item($params) {
+ switch( $params['item']->getType() ) {
+ case 'Ticket':
+ //echo 'test' ;
+ break;
+ case 'TicketTask' :
+ //echo 'test' ;
+ break;
+ case 'TicketFollowup' :
+ //echo 'test' ;
+ break;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/setup.php b/setup.php
index d552a5e..3037f9f 100755
--- a/setup.php
+++ b/setup.php
@@ -59,7 +59,7 @@ function plugin_init_example() {
Plugin::registerClass('PluginExampleDeviceCamera',
array('device_types' => true));
-
+
if (class_exists('PluginExampleExample')) {
Link::registerTag(PluginExampleExample::$tags);
}
@@ -68,10 +68,10 @@ function plugin_init_example() {
if (isset($_SESSION["glpi_plugin_example_profile"])) { // Right set in change_profile hook
$PLUGIN_HOOKS['menu_toadd']['example'] = array('plugins' => 'PluginExampleExample',
'tools' => 'PluginExampleExample');
-
+
// Old menu style
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
-//
+//
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
@@ -171,12 +171,20 @@ function plugin_init_example() {
$PLUGIN_HOOKS['post_init']['example'] = 'plugin_example_postinit';
$PLUGIN_HOOKS['status']['example'] = 'plugin_example_Status';
-
+
// CSRF compliance : All actions must be done via POST and forms closed by Html::closeForm();
$PLUGIN_HOOKS['csrf_compliant']['example'] = true;
$PLUGIN_HOOKS['display_central']['example'] = "plugin_example_display_central";
$PLUGIN_HOOKS['display_login']['example'] = "plugin_example_display_login";
+
+ // pre_show and post_show for tabs and items,
+ // see PluginExampleShowtabitem class for implementation explanations
+ $PLUGIN_HOOKS['pre_show_tab']['example'] = array( 'PluginExampleShowtabitem', 'pre_show_tab' );
+ $PLUGIN_HOOKS['post_show_tab']['example'] = array( 'PluginExampleShowtabitem', 'post_show_tab' );
+ $PLUGIN_HOOKS['pre_show_item']['example'] = array( 'PluginExampleShowtabitem', 'pre_show_item' );
+ $PLUGIN_HOOKS['post_show_item']['example'] = array( 'PluginExampleShowtabitem', 'post_show_item' );
+
}
@@ -184,7 +192,7 @@ function plugin_init_example() {
function plugin_version_example() {
return array('name' => 'Plugin Example',
- 'version' => '7.0',
+ 'version' => '7.1',
'author' => 'GLPI developer team',
'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/example',