mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
use CommonDropdown object
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@96 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
4f0bbf654f
commit
dd5e99eb1b
22
hook.php
22
hook.php
@ -35,11 +35,25 @@
|
||||
|
||||
// Class of the defined type
|
||||
class pluginExample extends CommonDBTM {
|
||||
function pluginExample () {
|
||||
function __construct () {
|
||||
$this->table="glpi_plugin_example";
|
||||
$this->type=PLUGIN_EXAMPLE_TYPE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Class for a Dropdown
|
||||
class pluginExampleDropdown extends CommonDropdown {
|
||||
function __construct () {
|
||||
$this->table="glpi_plugin_example_dropdown";
|
||||
$this->type=PLUGIN_EXAMPLEDROPDOWN_TYPE;
|
||||
}
|
||||
|
||||
static function getTypeName() {
|
||||
global $LANG;
|
||||
|
||||
return "Plugin Example Dropdown";
|
||||
}
|
||||
}
|
||||
|
||||
// Hook called on profile change
|
||||
// Good place to evaluate the user right on this plugin
|
||||
@ -69,7 +83,7 @@ function plugin_example_getDatabaseRelations(){
|
||||
// Define Dropdown tables to be manage in GLPI :
|
||||
function plugin_example_getDropdown(){
|
||||
// Table => Name
|
||||
return array("glpi_plugin_example_dropdown"=>"Plugin Example Dropdown");
|
||||
return array(PLUGIN_EXAMPLEDROPDOWN_TYPE => "Plugin Example Dropdown");
|
||||
}
|
||||
|
||||
////// SEARCH FUNCTIONS ///////(){
|
||||
@ -103,6 +117,8 @@ function plugin_example_getSearchOption(){
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][30]['linkfield']='';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][30]['name']=$LANG["common"][2];
|
||||
|
||||
$obj = new pluginExampleDropdown();
|
||||
$sopt[PLUGIN_EXAMPLEDROPDOWN_TYPE] = $obj->getSearchOptions();
|
||||
return $sopt;
|
||||
}
|
||||
|
||||
|
12
setup.php
12
setup.php
@ -52,6 +52,15 @@ function plugin_init_example() {
|
||||
//'linkgroup_types' => true
|
||||
));
|
||||
|
||||
// Params : plugin name - string type - ID - Array of attributes
|
||||
registerPluginType('example', 'PLUGIN_EXAMPLEDROPDOWN_TYPE', 1002, array(
|
||||
'classname' => 'pluginExampleDropdown',
|
||||
'tablename' => 'glpi_plugin_example_dropdown',
|
||||
'formpage' => 'example.form.php',
|
||||
'searchpage' => 'index.php',
|
||||
'typename' => 'Example Dropdown Type',
|
||||
'dropdown' => true));
|
||||
|
||||
// Display a menu entry ?
|
||||
if (plugin_example_haveTypeRight(PLUGIN_EXAMPLE_TYPE,'r')) { // Right set in change_profile hook
|
||||
$PLUGIN_HOOKS['menu_entry']['example'] = true;
|
||||
@ -176,6 +185,9 @@ function plugin_example_haveTypeRight($type,$right){
|
||||
// Evaluate the right from data saved in session by change_profile hook
|
||||
return ($right=='r' || $_SESSION["glpi_plugin_example_profile"]=='w');
|
||||
break;
|
||||
case PLUGIN_EXAMPLEDROPDOWN_TYPE :
|
||||
return haveRight("entity_dropdown",$right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user