mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-06-28 06:58:43 +02:00
[example] Improve for new plugin management
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@54 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
20
hook.php
20
hook.php
@ -41,18 +41,6 @@ class pluginExample extends CommonDBTM {
|
||||
};
|
||||
|
||||
|
||||
// Define rights for the plugin types
|
||||
function plugin_example_haveTypeRight($type,$right){
|
||||
switch ($type){
|
||||
case PLUGIN_EXAMPLE_TYPE :
|
||||
// 1 - All rights for all users
|
||||
// return true;
|
||||
// 2 - Similarity right : same right of computer
|
||||
return haveRight("computer",$right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Define dropdown relations
|
||||
function plugin_example_getDatabaseRelations(){
|
||||
//
|
||||
@ -70,7 +58,7 @@ function plugin_example_getDropdown(){
|
||||
|
||||
// Define search option for types of the plugins
|
||||
function plugin_example_getSearchOption(){
|
||||
global $LANGEXAMPLE,$LANG;
|
||||
global $LANG;
|
||||
$sopt=array();
|
||||
|
||||
// Part header
|
||||
@ -79,7 +67,7 @@ function plugin_example_getSearchOption(){
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][1]['table']='glpi_plugin_example';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][1]['field']='name';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][1]['linkfield']='name';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][1]['name']=$LANGEXAMPLE["name"];
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][1]['name']=$LANG['plugin_example']["name"];
|
||||
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][2]['table']='glpi_dropdown_plugin_example';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][2]['field']='name';
|
||||
@ -547,12 +535,12 @@ function plugin_headings_actions_example($type){
|
||||
|
||||
// Example of an action heading
|
||||
function plugin_headings_example($type,$ID,$withtemplate=0){
|
||||
global $LANGEXAMPLE;
|
||||
global $LANG;
|
||||
if (!$withtemplate){
|
||||
echo "<div align='center'>";
|
||||
switch ($type){
|
||||
case "central":
|
||||
echo "Plugin central action ".$LANGEXAMPLE["test"];
|
||||
echo "Plugin central action ".$LANG['plugin_example']["test"];
|
||||
break;
|
||||
case "prefs":
|
||||
// Complete form display
|
||||
|
@ -33,6 +33,6 @@
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
$LANGEXAMPLE["test"]="test english";
|
||||
$LANGEXAMPLE["name"]="Name";
|
||||
$LANG['plugin_example']["test"]="test english";
|
||||
$LANG['plugin_example']["name"]="Name";
|
||||
?>
|
||||
|
@ -34,6 +34,6 @@
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
$LANGEXAMPLE["test"]="test french";
|
||||
$LANGEXAMPLE["name"]="Nom";
|
||||
$LANG['plugin_example']["test"]="test french";
|
||||
$LANG['plugin_example']["name"]="Nom";
|
||||
?>
|
||||
|
17
setup.php
17
setup.php
@ -34,13 +34,13 @@
|
||||
|
||||
// Init the hooks of the plugins -Needed
|
||||
function plugin_init_example() {
|
||||
global $PLUGIN_HOOKS,$LANGEXAMPLE,$LANG,$CFG_GLPI;
|
||||
global $PLUGIN_HOOKS,$LANG,$CFG_GLPI;
|
||||
|
||||
// Display a menu entry ?
|
||||
$PLUGIN_HOOKS['menu_entry']['example'] = true;
|
||||
$PLUGIN_HOOKS['submenu_entry']['example']['add'] = 'example.form.php';
|
||||
$PLUGIN_HOOKS['submenu_entry']['example']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".$LANGEXAMPLE["test"]."' alt='".$LANGEXAMPLE["test"]."'>"] = 'index.php';
|
||||
$PLUGIN_HOOKS['submenu_entry']['example'][$LANGEXAMPLE["test"]] = 'index.php';
|
||||
$PLUGIN_HOOKS['submenu_entry']['example']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".$LANG['plugin_example']["test"]."' alt='".$LANG['plugin_example']["test"]."'>"] = 'index.php';
|
||||
$PLUGIN_HOOKS['submenu_entry']['example'][$LANG['plugin_example']["test"]] = 'index.php';
|
||||
$PLUGIN_HOOKS['submenu_entry']['example']['config'] = 'index.php';
|
||||
|
||||
$PLUGIN_HOOKS["helpdesk_menu_entry"]['example'] = true;
|
||||
@ -194,6 +194,17 @@ function plugin_example_check_config(){
|
||||
return true;
|
||||
}
|
||||
|
||||
// Define rights for the plugin types
|
||||
function plugin_example_haveTypeRight($type,$right){
|
||||
switch ($type){
|
||||
case PLUGIN_EXAMPLE_TYPE :
|
||||
// 1 - All rights for all users
|
||||
// return true;
|
||||
// 2 - Similarity right : same right of computer
|
||||
return haveRight("computer",$right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user