mirror of
				https://github.com/pluginsGLPI/example.git
				synced 2025-10-31 11:53:30 +01:00 
			
		
		
		
	Use new methods for search options
This commit is contained in:
		| @@ -111,28 +111,46 @@ class PluginExampleExample extends CommonDBTM { | ||||
|       return true; | ||||
|    } | ||||
|  | ||||
|    function getSearchOptions() { | ||||
|    function rawSearchOptions() { | ||||
|  | ||||
|       $tab = array(); | ||||
|       $tab['common'] = "Header Needed"; | ||||
|       $tab = []; | ||||
|  | ||||
|       $tab[1]['table']     = 'glpi_plugin_example_examples'; | ||||
|       $tab[1]['field']     = 'name'; | ||||
|       $tab[1]['name']      = __('Name'); | ||||
|       $tab[] = [ | ||||
|          'id'                 => 'common', | ||||
|          'name'               => __('Header Needed') | ||||
|       ]; | ||||
|  | ||||
|       $tab[2]['table']     = 'glpi_plugin_example_dropdowns'; | ||||
|       $tab[2]['field']     = 'name'; | ||||
|       $tab[2]['name']      = __('Dropdown'); | ||||
|       $tab[] = [ | ||||
|          'id'                 => '1', | ||||
|          'table'              => 'glpi_plugin_example_examples', | ||||
|          'field'              => 'name', | ||||
|          'name'               => __('Name'), | ||||
|       ]; | ||||
|  | ||||
|       $tab[3]['table']     = 'glpi_plugin_example_examples'; | ||||
|       $tab[3]['field']     = 'serial'; | ||||
|       $tab[3]['name']      = __('Serial number'); | ||||
|       $tab[3]['usehaving'] = true; | ||||
|       $tab[3]['searchtype'] = 'equals'; | ||||
|       $tab[] = [ | ||||
|          'id'                 => '2', | ||||
|          'table'              => 'glpi_plugin_example_dropdowns', | ||||
|          'field'              => 'name', | ||||
|          'name'               => __('Dropdown'), | ||||
|       ]; | ||||
|  | ||||
|       $tab[30]['table']     = 'glpi_plugin_example_examples'; | ||||
|       $tab[30]['field']     = 'id'; | ||||
|       $tab[30]['name']      = __('ID'); | ||||
|       $tab[] = [ | ||||
|          'id'                 => '3', | ||||
|          'table'              => 'glpi_plugin_example_examples', | ||||
|          'field'              => 'serial', | ||||
|          'name'               => __('Serial number'), | ||||
|          'usehaving'          => true, | ||||
|          'searchtype'         => 'equals', | ||||
|       ]; | ||||
|  | ||||
|       $tab[] = [ | ||||
|          'id'                 => '30', | ||||
|          'table'              => 'glpi_plugin_example_examples', | ||||
|          'field'              => 'id', | ||||
|          'name'               => __('ID'), | ||||
|          'usehaving'          => true, | ||||
|          'searchtype'         => 'equals', | ||||
|       ]; | ||||
|  | ||||
|       return $tab; | ||||
|    } | ||||
|   | ||||
							
								
								
									
										31
									
								
								setup.php
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								setup.php
									
									
									
									
									
								
							| @@ -219,13 +219,19 @@ function plugin_init_example() { | ||||
|  * @return array | ||||
|  */ | ||||
| function plugin_version_example() { | ||||
|  | ||||
|    return array('name'           => 'Plugin Example', | ||||
|                 'version'        => PLUGIN_EXAMPLE_VERSION, | ||||
|                 'author'         => 'GLPI developer team', | ||||
|                 'license'        => 'GPLv2+', | ||||
|                 'homepage'       => 'https://github.com/pluginsGLPI/example', | ||||
|                 'minGlpiVersion' => '0.85');// For compatibility / no install in version < 0.80 | ||||
|    return [ | ||||
|       'name'           => 'Plugin Example', | ||||
|       'version'        => PLUGIN_EXAMPLE_VERSION, | ||||
|       'author'         => 'GLPI developer team', | ||||
|       'license'        => 'GPLv2+', | ||||
|       'homepage'       => 'https://github.com/pluginsGLPI/example', | ||||
|       'requirements'   => [ | ||||
|          'glpi' => [ | ||||
|             'min' => '9.3', | ||||
|             'dev' => true | ||||
|          ] | ||||
|       ] | ||||
|    ]; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -237,15 +243,12 @@ function plugin_version_example() { | ||||
|  */ | ||||
| function plugin_example_check_prerequisites() { | ||||
|  | ||||
|    // Strict version check (could be less strict, or could allow various version) | ||||
|    if (version_compare(GLPI_VERSION, '0.85', 'lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) { | ||||
|       if (method_exists('Plugin', 'messageIncompatible')) { | ||||
|          echo Plugin::messageIncompatible('core', '0.85'); | ||||
|       } else { | ||||
|          echo "This plugin requires GLPI >= 0.85"; | ||||
|       } | ||||
|    $version = rtrim(GLPI_VERSION, '-dev'); | ||||
|    if (version_compare($version, '9.3', 'lt')) { | ||||
|       echo "This plugin requires GLPI 9.3"; | ||||
|       return false; | ||||
|    } | ||||
|  | ||||
|    return true; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user