FastActions » History » Version 5

tsmr, 12/23/2011 09:44 AM

1 1 tsmr
h1. FastActions
2 1 tsmr
3 1 tsmr
*Goal* : Add a system to display fast actions on GLPI header
4 1 tsmr
5 1 tsmr
*Concerned objects* : All objects which have an interest to be launch quickly
6 1 tsmr
7 5 tsmr
*Detail* :
8 1 tsmr
9 1 tsmr
Example : for a Call Center which need to generate tickets on the fly :
10 1 tsmr
11 1 tsmr
|Class|Action|Parameter|
12 1 tsmr
|Ticket|New Ticket|Specify requester|
13 1 tsmr
|Problem|New Problem|Specify requester|
14 2 tsmr
|Plugins|Action defined by plugin|Parameters defined by plugin|
15 3 tsmr
16 5 tsmr
*Setup* :
17 1 tsmr
18 5 tsmr
Add a system like fields unicity for select for each types which can use rapid actions the possibles actions (prefined dropdown)
19 5 tsmr
Goal : Define the classes & actions listed into the fast actions dropdown
20 1 tsmr
21 5 tsmr
*Initial Patch* : 
22 1 tsmr
23 5 tsmr
- 1 file ajax/dropdownHeaderActions.php calling Html::addDropdownActionsForHeader($_POST['action']);
24 1 tsmr
25 5 tsmr
- Add an array into define.php : $CFG_GLPI["header_types"] = array('Ticket'); (and modification of plugin.class.php for using with plugins)
26 1 tsmr
27 5 tsmr
- Add 3 functions into html.class.php :
28 3 tsmr
29 5 tsmr
addCriteriaForHeader which define each classes which can use fast actions (with a hook $PLUGIN_HOOKS["header_entry"])
30 3 tsmr
31 5 tsmr
showActionFromHeader which list each classes into a dropdown
32 5 tsmr
33 5 tsmr
addDropdownActionsForHeader which list actions for each classes.
34 5 tsmr
35 5 tsmr
For plugins :
36 3 tsmr
37 3 tsmr
Plugin::registerClass -> 'header_types' => true
38 3 tsmr
39 3 tsmr
$PLUGIN_HOOKS['header_entry']['example'] = array('My fast action' =>'/plugins/example/front/example.form.php');
40 3 tsmr
$PLUGIN_HOOKS['header_action']['example'] = 'plugin_example_header_action';
41 4 tsmr
<pre>
42 3 tsmr
43 3 tsmr
function plugin_example_header_action() {
44 3 tsmr
   global $LANG;
45 3 tsmr
   
46 3 tsmr
   echo "<div class='center'><input type=\"submit\" class=\"submit\" value=\"" . $LANG['buttons'][2] . "\" ></div>";
47 3 tsmr
}
48 4 tsmr
</pre>