mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
addHaving for plugin example
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@58 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
62854932c0
commit
b1646a78a7
26
hook.php
26
hook.php
@ -78,6 +78,7 @@ function plugin_example_getSearchOption(){
|
|||||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['field']='serial';
|
$sopt[PLUGIN_EXAMPLE_TYPE][3]['field']='serial';
|
||||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['linkfield']='serial';
|
$sopt[PLUGIN_EXAMPLE_TYPE][3]['linkfield']='serial';
|
||||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['name']='Serial';
|
$sopt[PLUGIN_EXAMPLE_TYPE][3]['name']='Serial';
|
||||||
|
$sopt[PLUGIN_EXAMPLE_TYPE][3]['usehaving']=true;
|
||||||
|
|
||||||
$sopt[PLUGIN_EXAMPLE_TYPE][30]['table']='glpi_plugin_example';
|
$sopt[PLUGIN_EXAMPLE_TYPE][30]['table']='glpi_plugin_example';
|
||||||
$sopt[PLUGIN_EXAMPLE_TYPE][30]['field']='ID';
|
$sopt[PLUGIN_EXAMPLE_TYPE][30]['field']='ID';
|
||||||
@ -148,6 +149,31 @@ function plugin_example_addWhere($link,$nott,$type,$ID,$val){
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function plugin_example_addHaving($link,$nott,$type,$ID,$val,$num){
|
||||||
|
global $SEARCH_OPTION;
|
||||||
|
|
||||||
|
$table=$SEARCH_OPTION[$type][$ID]["table"];
|
||||||
|
$field=$SEARCH_OPTION[$type][$ID]["field"];
|
||||||
|
|
||||||
|
$SEARCH=makeTextSearch($val,$nott);
|
||||||
|
|
||||||
|
// Example of standard Having clause but use it ONLY for specific Having
|
||||||
|
// No need of the function if you do not have specific cases
|
||||||
|
switch ($table.".".$field){
|
||||||
|
case "glpi_plugin_example.serial" :
|
||||||
|
$ADD="";
|
||||||
|
if (($nott&&$val!="NULL")||$val=='^$') {
|
||||||
|
$ADD=" OR ITEM_$num IS NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
return " $LINK ( ITEM_".$num.$SEARCH." $ADD ) ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function plugin_example_addSelect($type,$ID,$num){
|
function plugin_example_addSelect($type,$ID,$num){
|
||||||
global $SEARCH_OPTION;
|
global $SEARCH_OPTION;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user