.
--------------------------------------------------------------------------
*/
/**
* 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', ...),
* BEWARE that sometimes it can be an array of data and not an object (ex: for solution item)
* 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) {
if(!is_array($params['item'])) {
switch( $params['item']->getType() ) {
case 'Ticket':
//echo 'test' ;
break;
case 'TicketTask' :
//echo 'test' ;
break;
case 'TicketFollowup' :
//echo 'test' ;
break;
}
} else {
// here we are going to view a Solution
}
}
/**
* 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) {
if(!is_array($params['item'])) {
switch( $params['item']->getType() ) {
case 'Ticket':
//echo 'test' ;
break;
case 'TicketTask' :
//echo 'test' ;
break;
case 'TicketFollowup' :
//echo 'test' ;
break;
}
} else {
// here we are going to view a Solution
}
}
}