diff --git a/hook.php b/hook.php index 7d14c30..3cbd899 100644 --- a/hook.php +++ b/hook.php @@ -500,28 +500,6 @@ function plugin_item_transfer_example($parm) { return false; } - -// Parm contains begin, end and who -// Create data to be displayed in the planning of $parm["who"] or $parm["who_group"] between $parm["begin"] and $parm["end"] - -function plugin_planning_populate_example($parm) { - - // Add items in the items fields of the parm array - // Items need to have an unique index beginning by the begin date of the item to display - // needed to be correcly displayed - - $parm["items"][$parm["begin"]."$$$"."plugin_example1"]["plugin"] = "example"; - $parm["items"][$parm["begin"]."$$$"."plugin_example1"]["begin"] = date("Y-m-d 17:00:00"); - $parm["items"][$parm["begin"]."$$$"."plugin_example1"]["end"] = date("Y-m-d 18:00:00"); - $parm["items"][$parm["begin"]."$$$"."plugin_example1"]["name"] = __("test planning example 1"); - // Set the ID using the ID of the item in the database to have unique ID - $ID = date("Ymd"); // Current date for example - $parm["items"][$parm["begin"]."$$$"."plugin_example1"]["planningID"] = "plugin_example".$ID; - - return $parm; -} - - // Display the planning item function plugin_display_planning_example($parm) { diff --git a/inc/example.class.php b/inc/example.class.php index eda54d6..8148b78 100644 --- a/inc/example.class.php +++ b/inc/example.class.php @@ -169,7 +169,7 @@ class PluginExampleExample extends CommonDBTM { return true; } - static function getSpecificValueToDisplay($field, $values, $options=array()) { + static function getSpecificValueToDisplay($field, $values, array $options=array()) { if (!is_array($values)) { $values = array($field => $values); @@ -180,6 +180,24 @@ class PluginExampleExample extends CommonDBTM { } return ''; } + + // Parm contains begin, end and who + // Create data to be displayed in the planning of $parm["who"] or $parm["who_group"] between $parm["begin"] and $parm["end"] + static function populatePlanning($parm) { + + // Add items in the output array + // Items need to have an unique index beginning by the begin date of the item to display + // needed to be correcly displayed + $output = array(); + $output[$parm["begin"]."$$$"."plugin_example1"]["plugin"] = "example"; + $output[$parm["begin"]."$$$"."plugin_example1"]["begin"] = date("Y-m-d 17:00:00"); + $output[$parm["begin"]."$$$"."plugin_example1"]["end"] = date("Y-m-d 18:00:00"); + $output[$parm["begin"]."$$$"."plugin_example1"]["name"] = __("test planning example 1"); + // Set the ID using the ID of the item in the database to have unique ID + $ID = date("Ymd"); // Current date for example + $output[$parm["begin"]."$$$"."plugin_example1"]["planningID"] = "plugin_example".$ID; + return $output; + } } ?> diff --git a/setup.php b/setup.php index f798faf..7e3fd15 100755 --- a/setup.php +++ b/setup.php @@ -131,8 +131,11 @@ function plugin_init_example() { $PLUGIN_HOOKS['redirect_page']['example']['one'] = 'example.form.php'; $PLUGIN_HOOKS['redirect_page']['example']['two'] = 'example2.form.php'; - //function to populate planning - $PLUGIN_HOOKS['planning_populate']['example'] = 'plugin_planning_populate_example'; + // function to populate planning + // No more used since GLPI 0.84 + // $PLUGIN_HOOKS['planning_populate']['example'] = 'plugin_planning_populate_example'; + // Use instead : add class to planning types and define populatePlanning in class + $CFG_GLPI['planning_types'][] = 'PluginExampleExample'; //function to display planning items $PLUGIN_HOOKS['display_planning']['example'] = 'plugin_display_planning_example';