Use new methods for search options

This commit is contained in:
Cédric Anne 2018-05-28 09:57:42 +02:00
parent bd27fb258c
commit 33484aae68
2 changed files with 52 additions and 31 deletions

View File

@ -111,28 +111,46 @@ class PluginExampleExample extends CommonDBTM {
return true; return true;
} }
function getSearchOptions() { function rawSearchOptions() {
$tab = array(); $tab = [];
$tab['common'] = "Header Needed";
$tab[1]['table'] = 'glpi_plugin_example_examples'; $tab[] = [
$tab[1]['field'] = 'name'; 'id' => 'common',
$tab[1]['name'] = __('Name'); 'name' => __('Header Needed')
];
$tab[2]['table'] = 'glpi_plugin_example_dropdowns'; $tab[] = [
$tab[2]['field'] = 'name'; 'id' => '1',
$tab[2]['name'] = __('Dropdown'); 'table' => 'glpi_plugin_example_examples',
'field' => 'name',
'name' => __('Name'),
];
$tab[3]['table'] = 'glpi_plugin_example_examples'; $tab[] = [
$tab[3]['field'] = 'serial'; 'id' => '2',
$tab[3]['name'] = __('Serial number'); 'table' => 'glpi_plugin_example_dropdowns',
$tab[3]['usehaving'] = true; 'field' => 'name',
$tab[3]['searchtype'] = 'equals'; 'name' => __('Dropdown'),
];
$tab[30]['table'] = 'glpi_plugin_example_examples'; $tab[] = [
$tab[30]['field'] = 'id'; 'id' => '3',
$tab[30]['name'] = __('ID'); '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; return $tab;
} }

View File

@ -219,13 +219,19 @@ function plugin_init_example() {
* @return array * @return array
*/ */
function plugin_version_example() { function plugin_version_example() {
return [
return array('name' => 'Plugin Example', 'name' => 'Plugin Example',
'version' => PLUGIN_EXAMPLE_VERSION, 'version' => PLUGIN_EXAMPLE_VERSION,
'author' => 'GLPI developer team', 'author' => 'GLPI developer team',
'license' => 'GPLv2+', 'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/example', 'homepage' => 'https://github.com/pluginsGLPI/example',
'minGlpiVersion' => '0.85');// For compatibility / no install in version < 0.80 'requirements' => [
'glpi' => [
'min' => '9.3',
'dev' => true
]
]
];
} }
@ -237,15 +243,12 @@ function plugin_version_example() {
*/ */
function plugin_example_check_prerequisites() { function plugin_example_check_prerequisites() {
// Strict version check (could be less strict, or could allow various version) $version = rtrim(GLPI_VERSION, '-dev');
if (version_compare(GLPI_VERSION, '0.85', 'lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) { if (version_compare($version, '9.3', 'lt')) {
if (method_exists('Plugin', 'messageIncompatible')) { echo "This plugin requires GLPI 9.3";
echo Plugin::messageIncompatible('core', '0.85');
} else {
echo "This plugin requires GLPI >= 0.85";
}
return false; return false;
} }
return true; return true;
} }