Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Glpi/ContentTemplates/Parameters/TicketParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
use Glpi\ContentTemplates\Parameters\ParametersTypes\ArrayParameter;
use Glpi\ContentTemplates\Parameters\ParametersTypes\AttributeParameter;
use Glpi\ContentTemplates\Parameters\ParametersTypes\ObjectParameter;
use Glpi\Plugin\Hooks;
use Item_Ticket;
use KnowbaseItem;
use KnowbaseItem_Item;
use Location;
use OLA;
use Plugin;
use RequestType;
use Session;
use SLA;
Expand Down Expand Up @@ -74,7 +76,7 @@ protected function getTargetClasses(): array

public function getAvailableParameters(): array
{
return array_merge(parent::getAvailableParameters(), [
$availableParameters = array_merge(parent::getAvailableParameters(), [
new AttributeParameter("type", _n('Type', 'Types', 1)),
new AttributeParameter("global_validation", _n('Approval', 'Approvals', 1)),
new AttributeParameter("tto", __('Time to own'), 'date("d/m/y H:i")'),
Expand All @@ -88,6 +90,8 @@ public function getAvailableParameters(): array
new ArrayParameter("knowbaseitems", new KnowbaseItemParameters(), KnowbaseItem_Item::getTypeName(Session::getPluralNumber())),
new ArrayParameter("assets", new AssetParameters(), Item_Ticket::getTypeName(Session::getPluralNumber())),
]);

return Plugin::doHookFunction(Hooks::SHOW_ITEM_RESP_PARAM, $availableParameters);
}

protected function defineValues(CommonDBTM $ticket): array
Expand Down Expand Up @@ -161,6 +165,6 @@ protected function defineValues(CommonDBTM $ticket): array
}
}

return $values;
return Plugin::doHookFunction(Hooks::SHOW_ITEM_RESP_VALUE, $values);
}
}
16 changes: 16 additions & 0 deletions src/Glpi/Plugin/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,20 @@ class Hooks
*/
public const SHOW_ITEM_STATS = 'show_item_stats';

/**
* Register a function to display new variables in reply messages.
* The function is called with the array of available variables as a parameter.
* The function is expected to return new array of available variables.
*/
public const SHOW_ITEM_RESP_PARAM = 'show_item_resp_param';

/**
* Register a function to display new variables in reply messages.
* The function is called with the array of available variables as a parameter.
* The function is expected to return new array of available variables.
*/
public const SHOW_ITEM_RESP_VALUE = 'show_item_resp_value';

/**
* Register a function to add additional permission restrictions for the item.
* The function is called with the item as a parameter.
Expand Down Expand Up @@ -1408,6 +1422,8 @@ public static function getItemHooks(): array
self::POST_SHOW_TAB,
self::POST_PREPAREADD,
self::SHOW_ITEM_STATS,
self::SHOW_ITEM_RESP_PARAM,
self::SHOW_ITEM_RESP_VALUE,
self::TIMELINE_ACTIONS,
];
}
Expand Down