Skip to content

Commit

Permalink
Added pre_show_tab, post_show_tab (#777)
Browse files Browse the repository at this point in the history
Added pre_show_item, post_show_item
  • Loading branch information
tomolimo authored and orthagh committed Jul 6, 2016
1 parent e565fb6 commit 94c8fad
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
20 changes: 16 additions & 4 deletions inc/commonglpi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ static function displayStandardTab(CommonGLPI $item, $tab, $withtemplate=0, $opt
foreach ($ong as $key => $val) {
if ($key != 'empty') {
echo "<div class='alltab'>$val</div>";
self::displayStandardTab($item, $key, $withtemplate);
self::displayStandardTab($item, $key, $withtemplate, $options);
}
}
}
Expand All @@ -459,14 +459,24 @@ static function displayStandardTab(CommonGLPI $item, $tab, $withtemplate=0, $opt
if (isset($data[1])) {
$tabnum = $data[1];
}

$options['withtemplate'] = $withtemplate;

if ($tabnum == 'main') {
$options['withtemplate'] = $withtemplate;
return $item->showForm($item->getID(), $options);
Plugin::doHook('pre_show_item', array('item' => $item, 'options' => &$options));
$ret = $item->showForm($item->getID(), $options);
Plugin::doHook('post_show_item', array('item' => $item, 'options' => $options));
return $ret;
}

if (!is_integer($itemtype) && ($itemtype != 'empty')
&& ($obj = getItemForItemtype($itemtype))) {
return $obj->displayTabContentForItem($item, $tabnum, $withtemplate);
$options['tabnum'] = $tabnum;
$options['itemtype'] = $itemtype;
Plugin::doHook('pre_show_tab', array( 'item' => $item, 'options' => &$options));
$ret = $obj->displayTabContentForItem($item, $tabnum, $withtemplate);
Plugin::doHook('post_show_tab', array('item' => $item, 'options' => $options));
return $ret;
}
break;
}
Expand Down Expand Up @@ -612,7 +622,9 @@ function showPrimaryForm($options=array()) {
}
echo "<div class='form_content'>";
echo "<div class='$class'>";
Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
$this->showForm($options['id'], $options);
Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
echo "</div>";
echo "</div>";
}
Expand Down
5 changes: 5 additions & 0 deletions inc/commonitiltask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,12 @@ function showSummary(CommonITILObject $item) {

while ($data = $DB->fetch_assoc($result)) {
if ($this->getFromDB($data['id'])) {
$options = array( 'parent' => $item,
'rand' => $rand,
'showprivate' => $showprivate ) ;
Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
$this->showInObjectSumnary($item, $rand, $showprivate);
Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
}
}
echo $header;
Expand Down
12 changes: 11 additions & 1 deletion inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6281,7 +6281,14 @@ function showTimeline($rand) {

$timeline_index = 0;
foreach ($timeline as $item) {
$item_i = $item['item'];
$options = array( 'parent' => $this,
'rand' => $rand
) ;
$obj = new $item['type'] ;
$obj->fields = $item['item'] ;
Plugin::doHook('pre_show_item', array('item' => $obj, 'options' => &$options));

$item_i = $obj->fields;

$date = "";
if (isset($item_i['date'])) {
Expand Down Expand Up @@ -6480,6 +6487,9 @@ function showTimeline($rand) {
echo "</div>"; //end h_info

$timeline_index++;

Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options));

} // end foreach timeline

echo "<div class='break'></div>";
Expand Down
7 changes: 7 additions & 0 deletions inc/ticketfollowup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,12 @@ function showSummary($ticket) {

while ($data = $DB->fetch_assoc($result)) {
$this->getFromDB($data['id']);
$options = array( 'parent' => $ticket,
'rand' => $rand
);
Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
$data = array_merge( $data, $this->fields );

$candelete = $this->canPurge() && $this->canPurgeItem();
$canedit = $this->canUpdate() && $this->canUpdateItem();

Expand Down Expand Up @@ -1004,6 +1010,7 @@ function showSummary($ticket) {
echo "};";
echo "</script>\n";
}
Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
}
}
}
Expand Down

0 comments on commit 94c8fad

Please sign in to comment.