diff --git a/hook.php b/hook.php index 995bffd..1f9a686 100644 --- a/hook.php +++ b/hook.php @@ -191,14 +191,16 @@ function plugin_example_addWhere($link,$nott,$type,$ID,$val) { // 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." ) "; - // } + 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." ) ";*/ + case "glpi_plugin_example_examples.serial" : + return $link." `$table`.`$field` = '$val' "; + } return ""; } @@ -360,9 +362,9 @@ function plugin_example_MassiveActionsFieldsDisplay($options=array()) { // Table fields switch ($table.".".$field) { - case 'glpi_plugin_example.serial' : - echo "Not really specific - Just for example "; - autocompletionTextField($linkfield,$table,$field); + case 'glpi_plugin_example_examples.serial' : + echo "Not really specific - Just for example "; + //autocompletionTextField($linkfield,$table,$field); // Dropdown::showYesNo($linkfield); // Need to return true if specific display return true; @@ -373,8 +375,6 @@ function plugin_example_MassiveActionsFieldsDisplay($options=array()) { switch ($table.".".$field) { case "glpi_plugin_example_dropdowns.name" : echo "Not really specific - Just for example "; - dropdown($table,$linkfield,1,$_SESSION["glpiactive_entity"]); - //dropdownUsers($linkfield,0,"own_ticket",0,1,$_SESSION["glpiactive_entity"]); // Need to return true if specific display return true; } @@ -383,6 +383,30 @@ function plugin_example_MassiveActionsFieldsDisplay($options=array()) { return false; } +// How to display specific search fields or dropdown ? +// options must contain at least itemtype and options array +// MUST Use a specific AddWhere & $tab[X]['searchtype'] = 'equals'; declaration +function plugin_example_searchOptionsValues($options=array()) { + global $LANG; + + $table = $options['searchoption']['table']; + $field = $options['searchoption']['field']; + + // Table fields + switch ($table.".".$field) { + + case "glpi_plugin_example_examples.serial" : + echo "Not really specific - Use your own dropdown - Just for example "; + Dropdown::show(getItemTypeForTable($options['searchoption']['table']), + array('value' => $options['value'], + 'name' => $options['name'], + 'comments' => 0)); + // Need to return true if specific display + return true; + } + return false; +} + ////////////////////////////// diff --git a/inc/example.class.php b/inc/example.class.php index d149bd7..da686be 100644 --- a/inc/example.class.php +++ b/inc/example.class.php @@ -68,23 +68,20 @@ class PluginExampleExample extends CommonDBTM { $tab[1]['table'] = 'glpi_plugin_example_examples'; $tab[1]['field'] = 'name'; - $tab[1]['linkfield'] = 'name'; $tab[1]['name'] = $LANG['plugin_example']["name"]; $tab[2]['table'] = 'glpi_plugin_example_dropdowns'; $tab[2]['field'] = 'name'; - $tab[2]['linkfield'] = 'plugin_example_dropdowns_id'; $tab[2]['name'] = 'Dropdown'; $tab[3]['table'] = 'glpi_plugin_example_examples'; $tab[3]['field'] = 'serial'; - $tab[3]['linkfield'] = 'serial'; $tab[3]['name'] = 'Serial'; $tab[3]['usehaving'] = true; + $tab[3]['searchtype'] = 'equals'; $tab[30]['table'] = 'glpi_plugin_example_examples'; $tab[30]['field'] = 'id'; - $tab[30]['linkfield'] = ''; $tab[30]['name'] = $LANG["common"][2]; return $tab;