From 3b5913f295af212e1f58ee2a2c64cda2d177166e Mon Sep 17 00:00:00 2001 From: remicollet Date: Mon, 7 Dec 2009 09:46:56 +0000 Subject: [PATCH] remove XXX_TYPE and switch to Plugin::registerClass() git-svn-id: https://forge.glpi-project.org/svn/example/trunk@108 349b9182-4a13-0410-896f-e5e9767dd1b3 --- hook.php | 14 +++++++------- index.php | 12 ++++++------ setup.php | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hook.php b/hook.php index 1888035..4285b4b 100644 --- a/hook.php +++ b/hook.php @@ -122,7 +122,7 @@ function plugin_example_addLeftJoin($type,$ref_table,$new_table,$linkfield){ function plugin_example_forceGroupBy($type){ switch ($type){ - case PLUGIN_EXAMPLE_TYPE : + case 'PluginExampleExample' : // Force add GROUP BY IN REQUEST return true; break; @@ -224,7 +224,7 @@ function plugin_example_MassiveActions($type){ break; // Actions for types provided by the plugin - case PLUGIN_EXAMPLE_TYPE : + case 'PluginExampleExample' : return array( // GLPI core one "add_document"=>$LANG["document"][16], @@ -247,7 +247,7 @@ function plugin_example_MassiveActionsDisplay($type,$action){ break; } break; - case PLUGIN_EXAMPLE_TYPE: + case 'PluginExampleExample': switch ($action){ // No case for add_document : use GLPI core one case "do_nothing": @@ -280,7 +280,7 @@ function plugin_example_MassiveActionsProcess($data){ } break; case 'do_nothing': - if ($data['device_type']==PLUGIN_EXAMPLE_TYPE){ + if ($data['device_type']=='PluginExampleExample'){ $ci =new CommonItem(); addMessageAfterRedirect("Right it is the type I want..."); addMessageAfterRedirect("But... I say I will do nothing for :"); @@ -673,7 +673,7 @@ function plugin_example_cron_info($name) { // Do special actions for dynamic report function plugin_example_dynamicReport($parm){ - if ($parm["item_type"]==PLUGIN_EXAMPLE_TYPE){ + if ($parm["item_type"]=='PluginExampleExample'){ // Do all what you want for export depending on $parm echo "Personalized export for type ".$parm["display_type"]; echo 'with additional datas :
'; @@ -690,7 +690,7 @@ function plugin_example_dynamicReport($parm){ // Add parameters to printPager in search system function plugin_example_addParamFordynamicReport($device_type){ - if ($device_type==PLUGIN_EXAMPLE_TYPE){ + if ($device_type=='PluginExampleExample'){ // Return array data containing all params to add : may be single data or array data // Search config are available from session variable return array( @@ -779,7 +779,7 @@ function plugin_example_uninstall(){ function plugin_example_AssignToTicket($types) { - $types[PLUGIN_EXAMPLE_TYPE] = "Example"; + $types['PluginExampleExample'] = "Example"; return $types; } diff --git a/index.php b/index.php index ed42a00..c38f8b7 100755 --- a/index.php +++ b/index.php @@ -35,8 +35,8 @@ $NEEDED_ITEMS=array("search"); -define('GLPI_ROOT', '../..'); -include (GLPI_ROOT . "/inc/includes.php"); +define('GLPI_ROOT', '../..'); +include (GLPI_ROOT . "/inc/includes.php"); if ($_SESSION["glpiactiveprofile"]["interface"] == "central"){ commonHeader("TITRE", $_SERVER['PHP_SELF'],"plugins","example","optionname"); @@ -44,13 +44,13 @@ if ($_SESSION["glpiactiveprofile"]["interface"] == "central"){ helpHeader("TITRE", $_SERVER['PHP_SELF']); } -checkTypeRight(PLUGIN_EXAMPLE_TYPE,"r"); +checkTypeRight('PluginExampleExample',"r"); -manageGetValuesInSearch(PLUGIN_EXAMPLE_TYPE); +manageGetValuesInSearch('PluginExampleExample'); -searchForm(PLUGIN_EXAMPLE_TYPE,$_GET); +searchForm('PluginExampleExample',$_GET); -showList(PLUGIN_EXAMPLE_TYPE,$_GET); +showList('PluginExampleExample',$_GET); commonFooter(); ?> diff --git a/setup.php b/setup.php index 9a32fd9..5f1d93c 100755 --- a/setup.php +++ b/setup.php @@ -38,7 +38,7 @@ function plugin_init_example() { global $PLUGIN_HOOKS,$LANG,$CFG_GLPI; // Params : plugin name - string type - ID - Array of attributes - registerPluginType('example', 'PLUGIN_EXAMPLE_TYPE', 'PluginExampleExample', array( + Plugin::registerClass('PluginExampleExample', array( 'classname' => 'PluginExampleExample', 'tablename' => 'glpi_plugin_example_example', 'formpage' => 'front/example.form.php', @@ -53,7 +53,7 @@ function plugin_init_example() { )); // Params : plugin name - string type - ID - Array of attributes - registerPluginType('example', 'PLUGIN_EXAMPLEDROPDOWN_TYPE', 'PluginExampleDropdown', array( + Plugin::registerClass('PluginExampleDropdown', array( 'classname' => 'PluginExampleDropdown', 'tablename' => 'glpi_plugin_example_dropdown', 'typename' => 'Example Dropdown Type', @@ -61,7 +61,7 @@ function plugin_init_example() { 'searchpage' => 'front/dropdown.php')); // Display a menu entry ? - if (plugin_example_haveTypeRight(PLUGIN_EXAMPLE_TYPE,'r')) { // Right set in change_profile hook + if (plugin_example_haveTypeRight('PluginExampleExample','r')) { // Right set in change_profile hook $PLUGIN_HOOKS['menu_entry']['example'] = true; $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title']="Search"; @@ -184,7 +184,7 @@ function plugin_example_haveTypeRight($type,$right){ return false; } switch ($type){ - case PLUGIN_EXAMPLE_TYPE : + case 'PluginExampleExample' : // Evaluate the right from data saved in session by change_profile hook return ($right=='r' || $_SESSION["glpi_plugin_example_profile"]=='w'); }