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:
remicollet 2009-12-08 06:13:41 +00:00
parent d9c913419d
commit 2636ea6042

View File

@ -502,11 +502,11 @@ function plugin_display_planning_example($parm){
} }
// Define headings added by the plugin // Define headings added by the plugin
function plugin_get_headings_example($type,$ID,$withtemplate){ function plugin_get_headings_example($item, $withtemplate){
switch ($type){ switch (get_class($item)){
case PROFILE_TYPE: case 'Profile':
$prof = new Profile(); $prof = new Profile();
if ($ID>0 && $prof->getFromDB($ID) && $prof->fields['interface']=='central') { if ($item->fields['interface']=='central') {
return array( return array(
1 => "Test PLugin", 1 => "Test PLugin",
); );
@ -514,7 +514,7 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
return array(); return array();
} }
break; break;
case COMPUTER_TYPE : case 'Computer' :
// new object / template case // new object / template case
if ($withtemplate) { if ($withtemplate) {
return array(); return array();
@ -525,26 +525,26 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
); );
} }
break; break;
case COMPUTERDISK_TYPE : case 'ComputerDisk' :
case ENTERPRISE_TYPE : case 'Supplier' :
if ($ID>0) { // Not in create mode if ($item->getField('id')) { // Not in create mode
return array( return array(
1 => "Test PLugin", 1 => "Test PLugin",
2 => "Test PLugin 2", 2 => "Test PLugin 2",
); );
} }
break; break;
case "central": case 'Central':
return array( return array(
1 => "Test PLugin", 1 => "Test PLugin",
); );
break; break;
case "prefs": case 'Preference':
return array( return array(
1 => "Test PLugin", 1 => "Test PLugin",
); );
break; break;
case "mailing": case 'Notification':
return array( return array(
1 => "Test PLugin", 1 => "Test PLugin",
); );
@ -555,35 +555,35 @@ function plugin_get_headings_example($type,$ID,$withtemplate){
} }
// Define headings actions added by the plugin // Define headings actions added by the plugin
function plugin_headings_actions_example($type){ function plugin_headings_actions_example($item){
switch ($type){ switch (get_class($item)){
case PROFILE_TYPE : case 'Profile' :
case COMPUTER_TYPE : case 'Computer' :
return array( return array(
1 => "plugin_headings_example", 1 => "plugin_headings_example",
); );
break; break;
case COMPUTERDISK_TYPE : case 'ComputerDisk' :
case ENTERPRISE_TYPE : case 'Supplier' :
return array( return array(
1 => "plugin_headings_example", 1 => "plugin_headings_example",
2 => "plugin_headings_example", 2 => "plugin_headings_example",
); );
break; break;
case "central" : case 'Central' :
return array( return array(
1 => "plugin_headings_example", 1 => "plugin_headings_example",
); );
break; break;
case "prefs" : case 'Preference' :
return array( return array(
1 => "plugin_headings_example", 1 => "plugin_headings_example",
); );
break; break;
case "mailing" : case 'Notification' :
return array( return array(
1 => "plugin_headings_example", 1 => "plugin_headings_example",
); );
@ -594,17 +594,17 @@ function plugin_headings_actions_example($type){
} }
// Example of an action heading // Example of an action heading
function plugin_headings_example($type,$ID,$withtemplate=0){ function plugin_headings_example($item, $withtemplate=0){
global $LANG; global $LANG;
if (!$withtemplate){ if (!$withtemplate){
echo "<div align='center'>"; echo "<div align='center'>";
switch ($type){ switch (get_class($item)){
case "central": case 'Central':
echo "Plugin central action ".$LANG['plugin_example']["test"]; echo "Plugin central action ".$LANG['plugin_example']["test"];
break; break;
case "prefs":
// Complete form display
case 'Preference':
// Complete form display
$data=plugin_version_example(); $data=plugin_version_example();
echo "<form action='Where to post form'>"; echo "<form action='Where to post form'>";
@ -622,11 +622,13 @@ function plugin_headings_example($type,$ID,$withtemplate=0){
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
break; break;
case "mailing":
case 'Notification':
echo "Plugin mailing action ".$LANG['plugin_example']["test"]; echo "Plugin mailing action ".$LANG['plugin_example']["test"];
break; break;
default : default :
echo "Plugin function with headings TYPE=".$type." ID=".$ID; echo "Plugin function with headings CLASS=".get_class($item)." ID=".$item->getField('id');
break; break;
} }
echo "</div>"; echo "</div>";