From e2b9e280e7e7bcab925f86d9992f6b73c8e93922 Mon Sep 17 00:00:00 2001 From: moyooo Date: Fri, 18 May 2007 22:13:36 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://forge.glpi-project.org/svn/example/trunk@26 349b9182-4a13-0410-896f-e5e9767dd1b3 --- setup.php | 72 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/setup.php b/setup.php index 32388c9..773c3a9 100755 --- a/setup.php +++ b/setup.php @@ -122,17 +122,6 @@ function plugin_example_getSearchOption(){ return $sopt; } - -function plugin_example_addLeftJoin($type,$ref_table,$new_table,$linkfield){ - switch ($new_table){ - case "glpi_dropdown_plugin_example" : - // Standard LEFT JOIN for the example but use it for specific jointures - return " LEFT JOIN $new_table ON ($ref_table.$linkfield = $new_table.ID) "; - break; - } - return ""; -} - function plugin_example_giveItem($type,$field,$data,$num,$linkfield=""){ global $CFG_GLPI, $INFOFORM_PAGES; @@ -148,6 +137,19 @@ function plugin_example_giveItem($type,$field,$data,$num,$linkfield=""){ return ""; } +function plugin_example_addLeftJoin($type,$ref_table,$new_table,$linkfield){ + + // Example of standard LEFT JOIN clause but use it ONLY for specific LEFT JOIN + // No need of the function if you do not have specific cases + switch ($new_table){ + case "glpi_dropdown_plugin_example" : + return " LEFT JOIN $new_table ON ($ref_table.$linkfield = $new_table.ID) "; + break; + } + return ""; +} + + function plugin_example_addWhere($link,$nott,$type,$ID,$val){ global $SEARCH_OPTION; @@ -156,17 +158,17 @@ function plugin_example_addWhere($link,$nott,$type,$ID,$val){ $SEARCH=makeTextSearch($val,$nott); - switch ($table.".".$field){ - case "glpi_plugin_example.name" : - // Standard Where clause for the example but use it for specific jointures - $ADD=""; - if ($nott&&$val!="NULL") { - $ADD=" OR $table.$field IS NULL"; - } - - return $link." ($table.$field $SEARCH ".$ADD." ) "; - break; - } + // Example of standard Where clause but use it ONLY for specific Where + // No need of the function if you do not have specific cases +// switch ($table.".".$field){ +// case "glpi_plugin_example.name" : +// $ADD=""; +// if ($nott&&$val!="NULL") { +// $ADD=" OR $table.$field IS NULL"; +// } +// return $link." ($table.$field $SEARCH ".$ADD." ) "; +// break; +// } return ""; } @@ -176,12 +178,13 @@ function plugin_example_addSelect($type,$ID,$num){ $table=$SEARCH_OPTION[$type][$ID]["table"]; $field=$SEARCH_OPTION[$type][$ID]["field"]; - switch ($table.".".$field){ - case "glpi_plugin_example.name" : - // Standard Select clause for the example but use it for specific selection - return $table.".".$field." AS ITEM_$num, "; - break; - } +// Example of standard Select clause but use it ONLY for specific Select +// No need of the function if you do not have specific cases +// switch ($table.".".$field){ +// case "glpi_plugin_example.name" : +// return $table.".".$field." AS ITEM_$num, "; +// break; +// } return ""; } @@ -191,12 +194,13 @@ function plugin_example_addOrderBy($type,$ID,$order,$key=0){ $table=$SEARCH_OPTION[$type][$ID]["table"]; $field=$SEARCH_OPTION[$type][$ID]["field"]; - switch ($table.".".$field){ - case "glpi_plugin_example.name" : - // Standard Order By clause for the example but use it for specific selection - return " ORDER BY $table.$field $order "; - break; - } +// Example of standard OrderBy clause but use it ONLY for specific order by +// No need of the function if you do not have specific cases +// switch ($table.".".$field){ +// case "glpi_plugin_example.name" : +// return " ORDER BY $table.$field $order "; +// break; +// } return ""; } //////////////////////////////