mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
neww hook for headings
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@110 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
d9c913419d
commit
2636ea6042
56
hook.php
56
hook.php
@ -502,11 +502,11 @@ function plugin_display_planning_example($parm){
|
||||
}
|
||||
|
||||
// Define headings added by the plugin
|
||||
function plugin_get_headings_example($type,$ID,$withtemplate){
|
||||
switch ($type){
|
||||
case PROFILE_TYPE:
|
||||
function plugin_get_headings_example($item, $withtemplate){
|
||||
switch (get_class($item)){
|
||||
case 'Profile':
|
||||
$prof = new Profile();
|
||||
if ($ID>0 && $prof->getFromDB($ID) && $prof->fields['interface']=='central') {
|
||||
if ($item->fields['interface']=='central') {
|
||||
return array(
|
||||
1 => "Test PLugin",
|
||||
);
|
||||
@ -514,7 +514,7 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
|
||||
return array();
|
||||
}
|
||||
break;
|
||||
case COMPUTER_TYPE :
|
||||
case 'Computer' :
|
||||
// new object / template case
|
||||
if ($withtemplate) {
|
||||
return array();
|
||||
@ -525,26 +525,26 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
|
||||
);
|
||||
}
|
||||
break;
|
||||
case COMPUTERDISK_TYPE :
|
||||
case ENTERPRISE_TYPE :
|
||||
if ($ID>0) { // Not in create mode
|
||||
case 'ComputerDisk' :
|
||||
case 'Supplier' :
|
||||
if ($item->getField('id')) { // Not in create mode
|
||||
return array(
|
||||
1 => "Test PLugin",
|
||||
2 => "Test PLugin 2",
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "central":
|
||||
case 'Central':
|
||||
return array(
|
||||
1 => "Test PLugin",
|
||||
);
|
||||
break;
|
||||
case "prefs":
|
||||
case 'Preference':
|
||||
return array(
|
||||
1 => "Test PLugin",
|
||||
);
|
||||
break;
|
||||
case "mailing":
|
||||
case 'Notification':
|
||||
return array(
|
||||
1 => "Test PLugin",
|
||||
);
|
||||
@ -555,35 +555,35 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
|
||||
}
|
||||
|
||||
// Define headings actions added by the plugin
|
||||
function plugin_headings_actions_example($type){
|
||||
function plugin_headings_actions_example($item){
|
||||
|
||||
switch ($type){
|
||||
case PROFILE_TYPE :
|
||||
case COMPUTER_TYPE :
|
||||
switch (get_class($item)){
|
||||
case 'Profile' :
|
||||
case 'Computer' :
|
||||
return array(
|
||||
1 => "plugin_headings_example",
|
||||
);
|
||||
|
||||
break;
|
||||
case COMPUTERDISK_TYPE :
|
||||
case ENTERPRISE_TYPE :
|
||||
case 'ComputerDisk' :
|
||||
case 'Supplier' :
|
||||
return array(
|
||||
1 => "plugin_headings_example",
|
||||
2 => "plugin_headings_example",
|
||||
);
|
||||
|
||||
break;
|
||||
case "central" :
|
||||
case 'Central' :
|
||||
return array(
|
||||
1 => "plugin_headings_example",
|
||||
);
|
||||
break;
|
||||
case "prefs" :
|
||||
case 'Preference' :
|
||||
return array(
|
||||
1 => "plugin_headings_example",
|
||||
);
|
||||
break;
|
||||
case "mailing" :
|
||||
case 'Notification' :
|
||||
return array(
|
||||
1 => "plugin_headings_example",
|
||||
);
|
||||
@ -594,17 +594,17 @@ function plugin_headings_actions_example($type){
|
||||
}
|
||||
|
||||
// Example of an action heading
|
||||
function plugin_headings_example($type,$ID,$withtemplate=0){
|
||||
function plugin_headings_example($item, $withtemplate=0){
|
||||
global $LANG;
|
||||
if (!$withtemplate){
|
||||
echo "<div align='center'>";
|
||||
switch ($type){
|
||||
case "central":
|
||||
switch (get_class($item)){
|
||||
case 'Central':
|
||||
echo "Plugin central action ".$LANG['plugin_example']["test"];
|
||||
break;
|
||||
case "prefs":
|
||||
// Complete form display
|
||||
|
||||
case 'Preference':
|
||||
// Complete form display
|
||||
$data=plugin_version_example();
|
||||
|
||||
echo "<form action='Where to post form'>";
|
||||
@ -622,11 +622,13 @@ function plugin_headings_example($type,$ID,$withtemplate=0){
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
break;
|
||||
case "mailing":
|
||||
|
||||
case 'Notification':
|
||||
echo "Plugin mailing action ".$LANG['plugin_example']["test"];
|
||||
break;
|
||||
|
||||
default :
|
||||
echo "Plugin function with headings TYPE=".$type." ID=".$ID;
|
||||
echo "Plugin function with headings CLASS=".get_class($item)." ID=".$item->getField('id');
|
||||
break;
|
||||
}
|
||||
echo "</div>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user