mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-06-29 23:38:42 +02:00
Feature GLP11
This commit is contained in:
452
setup.php
452
setup.php
@ -42,9 +42,9 @@ use GlpiPlugin\Example\Showtabitem;
|
||||
define('PLUGIN_EXAMPLE_VERSION', '0.0.1');
|
||||
|
||||
// Minimal GLPI version, inclusive
|
||||
define('PLUGIN_EXAMPLE_MIN_GLPI', '10.0.0');
|
||||
define('PLUGIN_EXAMPLE_MIN_GLPI', '11.0.0');
|
||||
// Maximum GLPI version, exclusive
|
||||
define('PLUGIN_EXAMPLE_MAX_GLPI', '10.0.99');
|
||||
define('PLUGIN_EXAMPLE_MAX_GLPI', '11.0.99');
|
||||
|
||||
/**
|
||||
* Init hooks of the plugin.
|
||||
@ -52,249 +52,250 @@ define('PLUGIN_EXAMPLE_MAX_GLPI', '10.0.99');
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function plugin_init_example() {
|
||||
global $PLUGIN_HOOKS,$CFG_GLPI;
|
||||
function plugin_init_example()
|
||||
{
|
||||
|
||||
// Params : plugin name - string type - ID - Array of attributes
|
||||
// No specific information passed so not needed
|
||||
//Plugin::registerClass(Example::getType(),
|
||||
// array('classname' => Example::class,
|
||||
// ));
|
||||
/** @var array $CFG_GLPI */
|
||||
/** @var array $PLUGIN_HOOKS */
|
||||
global $CFG_GLPI, $PLUGIN_HOOKS;
|
||||
|
||||
Plugin::registerClass(Config::class, ['addtabon' => 'Config']);
|
||||
// Params : plugin name - string type - ID - Array of attributes
|
||||
// No specific information passed so not needed
|
||||
//Plugin::registerClass(Example::getType(),
|
||||
// array('classname' => Example::class,
|
||||
// ));
|
||||
|
||||
// Params : plugin name - string type - ID - Array of attributes
|
||||
Plugin::registerClass(Dropdown::class);
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$types = ['Central', 'Computer', 'ComputerDisk', 'Notification', 'Phone',
|
||||
'Preference', 'Profile', 'Supplier'];
|
||||
Plugin::registerClass(Example::class,
|
||||
['notificationtemplates_types' => true,
|
||||
'addtabon' => $types,
|
||||
'link_types' => true]);
|
||||
Plugin::registerClass(Config::class, ['addtabon' => 'Config']);
|
||||
|
||||
Plugin::registerClass(RuleTestCollection::class,
|
||||
['rulecollections_types' => true]);
|
||||
// Params : plugin name - string type - ID - Array of attributes
|
||||
Plugin::registerClass(Dropdown::class);
|
||||
|
||||
Plugin::registerClass(DeviceCamera::class,
|
||||
['device_types' => true]);
|
||||
$types = ['Central', 'Computer', 'ComputerDisk', 'Notification', 'Phone',
|
||||
'Preference', 'Profile', 'Supplier'];
|
||||
Plugin::registerClass(
|
||||
Example::class,
|
||||
['notificationtemplates_types' => true,
|
||||
'addtabon' => $types,
|
||||
'link_types' => true],
|
||||
);
|
||||
|
||||
if (version_compare(GLPI_VERSION, '9.1', 'ge')) {
|
||||
if (class_exists(Example::class)) {
|
||||
Link::registerTag(Example::$tags);
|
||||
}
|
||||
}
|
||||
// Display a menu entry ?
|
||||
Plugin::registerClass(\GlpiPlugin\Example\Profile::class, ['addtabon' => ['Profile']]);
|
||||
if (Example::canView()) { // Right set in change_profile hook
|
||||
$PLUGIN_HOOKS['menu_toadd']['example'] = ['plugins' => Example::class,
|
||||
'tools' => Example::class];
|
||||
Plugin::registerClass(
|
||||
RuleTestCollection::class,
|
||||
['rulecollections_types' => true],
|
||||
);
|
||||
|
||||
// Old menu style
|
||||
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
|
||||
//
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
|
||||
Plugin::registerClass(
|
||||
DeviceCamera::class,
|
||||
['device_types' => true],
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY]['example'] = true;
|
||||
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY_ICON]['example'] = 'fas fa-puzzle-piece';
|
||||
}
|
||||
if (class_exists(Example::class)) {
|
||||
Link::registerTag(Example::$tags);
|
||||
}
|
||||
|
||||
// Config page
|
||||
if (Session::haveRight('config', UPDATE)) {
|
||||
$PLUGIN_HOOKS['config_page']['example'] = 'front/config.php';
|
||||
}
|
||||
// Display a menu entry ?
|
||||
Plugin::registerClass(\GlpiPlugin\Example\Profile::class, ['addtabon' => ['Profile']]);
|
||||
if (Example::canView()) { // Right set in change_profile hook
|
||||
$PLUGIN_HOOKS['menu_toadd']['example'] = ['plugins' => Example::class,
|
||||
'tools' => Example::class];
|
||||
|
||||
// Init session
|
||||
//$PLUGIN_HOOKS['init_session']['example'] = 'plugin_init_session_example';
|
||||
// Change profile
|
||||
$PLUGIN_HOOKS['change_profile']['example'] = 'plugin_change_profile_example';
|
||||
// Change entity
|
||||
//$PLUGIN_HOOKS['change_entity']['example'] = 'plugin_change_entity_example';
|
||||
// Old menu style
|
||||
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
|
||||
//
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
|
||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
|
||||
|
||||
// Item action event // See define.php for defined ITEM_TYPE
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['example'] = [Computer::class => 'plugin_pre_item_update_example'];
|
||||
$PLUGIN_HOOKS[hooks::ITEM_UPDATE]['example'] = [Computer::class => 'plugin_item_update_example'];
|
||||
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY]['example'] = true;
|
||||
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY_ICON]['example'] = 'fas fa-puzzle-piece';
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_EMPTY]['example'] = [Computer::class => 'plugin_item_empty_example'];
|
||||
// Config page
|
||||
if (Session::haveRight('config', UPDATE)) {
|
||||
$PLUGIN_HOOKS['config_page']['example'] = 'front/config.php';
|
||||
}
|
||||
|
||||
// Restrict right
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_CAN]['example'] = [Computer::class => [Example::class, 'item_can']];
|
||||
$PLUGIN_HOOKS['add_default_where']['example'] = [Computer::class => [Example::class, 'add_default_where']];
|
||||
// Init session
|
||||
//$PLUGIN_HOOKS['init_session']['example'] = 'plugin_init_session_example';
|
||||
// Change profile
|
||||
$PLUGIN_HOOKS['change_profile']['example'] = 'plugin_change_profile_example';
|
||||
// Change entity
|
||||
//$PLUGIN_HOOKS['change_entity']['example'] = 'plugin_change_entity_example';
|
||||
|
||||
// Example using a method in class
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_ADD]['example'] = [Computer::class => [Example::class,
|
||||
'pre_item_add_computer']];
|
||||
$PLUGIN_HOOKS[Hooks::POST_PREPAREADD]['example'] = [Computer::class => [Example::class,
|
||||
'post_prepareadd_computer']];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['example'] = [Computer::class => [Example::class,
|
||||
'item_add_computer']];
|
||||
// Item action event // See define.php for defined ITEM_TYPE
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['example'] = [Computer::class => 'plugin_pre_item_update_example'];
|
||||
$PLUGIN_HOOKS[hooks::ITEM_UPDATE]['example'] = [Computer::class => 'plugin_item_update_example'];
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_DELETE]['example'] = [Computer::class => 'plugin_pre_item_delete_example'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_DELETE]['example'] = [Computer::class => 'plugin_item_delete_example'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_EMPTY]['example'] = [Computer::class => 'plugin_item_empty_example'];
|
||||
|
||||
// Example using the same function
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_PURGE]['example'] = [Computer::class => 'plugin_pre_item_purge_example',
|
||||
'Phone' => 'plugin_pre_item_purge_example'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_PURGE]['example'] = [Computer::class => 'plugin_item_purge_example',
|
||||
'Phone' => 'plugin_item_purge_example'];
|
||||
// Restrict right
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_CAN]['example'] = [Computer::class => [Example::class, 'item_can']];
|
||||
$PLUGIN_HOOKS['add_default_where']['example'] = [Computer::class => [Example::class, 'add_default_where']];
|
||||
|
||||
// Example with 2 different functions
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_RESTORE]['example'] = [Computer::class => 'plugin_pre_item_restore_example',
|
||||
'Phone' => 'plugin_pre_item_restore_example2'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_RESTORE]['example'] = [Computer::class => 'plugin_item_restore_example'];
|
||||
// Example using a method in class
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_ADD]['example'] = [Computer::class => [Example::class,
|
||||
'pre_item_add_computer']];
|
||||
$PLUGIN_HOOKS[Hooks::POST_PREPAREADD]['example'] = [Computer::class => [Example::class,
|
||||
'post_prepareadd_computer']];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['example'] = [Computer::class => [Example::class,
|
||||
'item_add_computer']];
|
||||
|
||||
// Add event to GLPI core itemtype, event will be raised by the plugin.
|
||||
// See plugin_example_uninstall for cleanup of notification
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_GET_EVENTS]['example']
|
||||
= ['NotificationTargetTicket' => 'plugin_example_get_events'];
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_DELETE]['example'] = [Computer::class => 'plugin_pre_item_delete_example'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_DELETE]['example'] = [Computer::class => 'plugin_item_delete_example'];
|
||||
|
||||
// Add datas to GLPI core itemtype for notifications template.
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_GET_DATA]['example']
|
||||
= ['NotificationTargetTicket' => 'plugin_example_get_datas'];
|
||||
// Example using the same function
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_PURGE]['example'] = [Computer::class => 'plugin_pre_item_purge_example',
|
||||
'Phone' => 'plugin_pre_item_purge_example'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_PURGE]['example'] = [Computer::class => 'plugin_item_purge_example',
|
||||
'Phone' => 'plugin_item_purge_example'];
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_TRANSFER]['example'] = 'plugin_item_transfer_example';
|
||||
// Example with 2 different functions
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_RESTORE]['example'] = [Computer::class => 'plugin_pre_item_restore_example',
|
||||
'Phone' => 'plugin_pre_item_restore_example2'];
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_RESTORE]['example'] = [Computer::class => 'plugin_item_restore_example'];
|
||||
|
||||
// function to populate planning
|
||||
// No more used since GLPI 0.84
|
||||
// $PLUGIN_HOOKS['planning_populate']['example'] = 'plugin_planning_populate_example';
|
||||
// Use instead : add class to planning types and define populatePlanning in class
|
||||
$CFG_GLPI['planning_types'][] = Example::class;
|
||||
// Add event to GLPI core itemtype, event will be raised by the plugin.
|
||||
// See plugin_example_uninstall for cleanup of notification
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_GET_EVENTS]['example']
|
||||
= ['NotificationTargetTicket' => 'plugin_example_get_events'];
|
||||
|
||||
//function to display planning items
|
||||
// No more used sinc GLPi 0.84
|
||||
// $PLUGIN_HOOKS['display_planning']['example'] = 'plugin_display_planning_example';
|
||||
// Use instead : displayPlanningItem of the specific itemtype
|
||||
// Add datas to GLPI core itemtype for notifications template.
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_GET_DATA]['example']
|
||||
= ['NotificationTargetTicket' => 'plugin_example_get_datas'];
|
||||
|
||||
// Massive Action definition
|
||||
$PLUGIN_HOOKS['use_massive_action']['example'] = 1;
|
||||
$PLUGIN_HOOKS[Hooks::ITEM_TRANSFER]['example'] = 'plugin_item_transfer_example';
|
||||
|
||||
$PLUGIN_HOOKS['assign_to_ticket']['example'] = 1;
|
||||
// function to populate planning
|
||||
// No more used since GLPI 0.84
|
||||
// $PLUGIN_HOOKS['planning_populate']['example'] = 'plugin_planning_populate_example';
|
||||
// Use instead : add class to planning types and define populatePlanning in class
|
||||
$CFG_GLPI['planning_types'][] = Example::class;
|
||||
|
||||
// Add specific files to add to the header : javascript or css
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['example'] = 'example.js';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_CSS]['example'] = 'example.css';
|
||||
//function to display planning items
|
||||
// No more used sinc GLPi 0.84
|
||||
// $PLUGIN_HOOKS['display_planning']['example'] = 'plugin_display_planning_example';
|
||||
// Use instead : displayPlanningItem of the specific itemtype
|
||||
|
||||
// Add specific tags to the header
|
||||
$PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG]['example'] = [
|
||||
[
|
||||
'tag' => 'meta',
|
||||
'properties' => [
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex, nofollow',
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag' => 'link',
|
||||
'properties' => [
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => 'The company RSS feed',
|
||||
'href' => 'https://example.org/feed.xml',
|
||||
]
|
||||
],
|
||||
];
|
||||
// Massive Action definition
|
||||
$PLUGIN_HOOKS['use_massive_action']['example'] = 1;
|
||||
|
||||
// Add specific files to add to the header into anonymous page : javascript or css
|
||||
$PLUGIN_HOOKS[Hooks::ADD_CSS_ANONYMOUS_PAGE]['example'] = 'example_anonymous.css';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE]['example'] = 'mymodule_anonymous.js';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE]['example'] = 'example_anonymous.js';
|
||||
$PLUGIN_HOOKS['assign_to_ticket']['example'] = 1;
|
||||
|
||||
// Add specific tags to the header into anonymous page
|
||||
$PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE]['example'] = [
|
||||
[
|
||||
'tag' => 'meta',
|
||||
'properties' => [
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex, nofollow',
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag' => 'link',
|
||||
'properties' => [
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => 'The company RSS feed',
|
||||
'href' => 'https://example.org/feed.xml',
|
||||
]
|
||||
],
|
||||
];
|
||||
// Add specific files to add to the header : javascript or css
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['example'] = 'example.js';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_CSS]['example'] = 'example.css';
|
||||
|
||||
// request more attributes from ldap
|
||||
//$PLUGIN_HOOKS['retrieve_more_field_from_ldap']['example']="plugin_retrieve_more_field_from_ldap_example";
|
||||
// Add specific tags to the header
|
||||
$PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG]['example'] = [
|
||||
[
|
||||
'tag' => 'meta',
|
||||
'properties' => [
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex, nofollow',
|
||||
],
|
||||
],
|
||||
[
|
||||
'tag' => 'link',
|
||||
'properties' => [
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => 'The company RSS feed',
|
||||
'href' => 'https://example.org/feed.xml',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Retrieve others datas from LDAP
|
||||
//$PLUGIN_HOOKS['retrieve_more_data_from_ldap']['example']="plugin_retrieve_more_data_from_ldap_example";
|
||||
// Add specific files to add to the header into anonymous page : javascript or css
|
||||
$PLUGIN_HOOKS[Hooks::ADD_CSS_ANONYMOUS_PAGE]['example'] = 'example_anonymous.css';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE]['example'] = 'mymodule_anonymous.js';
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE]['example'] = 'example_anonymous.js';
|
||||
|
||||
// Reports
|
||||
$PLUGIN_HOOKS['reports']['example'] = ['report.php' => 'New Report',
|
||||
'report.php?other' => 'New Report 2'];
|
||||
// Add specific tags to the header into anonymous page
|
||||
$PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE]['example'] = [
|
||||
[
|
||||
'tag' => 'meta',
|
||||
'properties' => [
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex, nofollow',
|
||||
],
|
||||
],
|
||||
[
|
||||
'tag' => 'link',
|
||||
'properties' => [
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => 'The company RSS feed',
|
||||
'href' => 'https://example.org/feed.xml',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Stats
|
||||
$PLUGIN_HOOKS['stats']['example'] = ['stat.php' => 'New stat',
|
||||
'stat.php?other' => 'New stats 2',];
|
||||
// request more attributes from ldap
|
||||
//$PLUGIN_HOOKS['retrieve_more_field_from_ldap']['example']="plugin_retrieve_more_field_from_ldap_example";
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::POST_INIT]['example'] = 'plugin_example_postinit';
|
||||
// Retrieve others datas from LDAP
|
||||
//$PLUGIN_HOOKS['retrieve_more_data_from_ldap']['example']="plugin_retrieve_more_data_from_ldap_example";
|
||||
|
||||
$PLUGIN_HOOKS['status']['example'] = 'plugin_example_Status';
|
||||
// Reports
|
||||
$PLUGIN_HOOKS['reports']['example'] = ['report.php' => 'New Report',
|
||||
'report.php?other' => 'New Report 2'];
|
||||
|
||||
// CSRF compliance : All actions must be done via POST and forms closed by Html::closeForm();
|
||||
$PLUGIN_HOOKS[Hooks::CSRF_COMPLIANT]['example'] = true;
|
||||
// Stats
|
||||
$PLUGIN_HOOKS['stats']['example'] = ['stat.php' => 'New stat',
|
||||
'stat.php?other' => 'New stats 2',];
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::DISPLAY_CENTRAL]['example'] = "plugin_example_display_central";
|
||||
$PLUGIN_HOOKS[Hooks::DISPLAY_LOGIN]['example'] = "plugin_example_display_login";
|
||||
$PLUGIN_HOOKS[Hooks::INFOCOM]['example'] = "plugin_example_infocom_hook";
|
||||
$PLUGIN_HOOKS[Hooks::POST_INIT]['example'] = 'plugin_example_postinit';
|
||||
|
||||
// pre_show and post_show for tabs and items,
|
||||
// see GlpiPlugin\Example\Showtabitem class for implementation explanations
|
||||
$PLUGIN_HOOKS[Hooks::PRE_SHOW_TAB]['example'] = [Showtabitem::class, 'pre_show_tab'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_SHOW_TAB]['example'] = [Showtabitem::class, 'post_show_tab'];
|
||||
$PLUGIN_HOOKS[Hooks::PRE_SHOW_ITEM]['example'] = [Showtabitem::class, 'pre_show_item'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_SHOW_ITEM]['example'] = [Showtabitem::class, 'post_show_item'];
|
||||
$PLUGIN_HOOKS['status']['example'] = 'plugin_example_Status';
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_FORM]['example'] = [ItemForm::class, 'preItemForm'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['example'] = [ItemForm::class, 'postItemForm'];
|
||||
$PLUGIN_HOOKS[Hooks::DISPLAY_CENTRAL]['example'] = "plugin_example_display_central";
|
||||
$PLUGIN_HOOKS[Hooks::DISPLAY_LOGIN]['example'] = "plugin_example_display_login";
|
||||
$PLUGIN_HOOKS[Hooks::INFOCOM]['example'] = "plugin_example_infocom_hook";
|
||||
|
||||
//TODO: remove check when GLPI 11.0.0 is released
|
||||
if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) {
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection'];
|
||||
}
|
||||
// pre_show and post_show for tabs and items,
|
||||
// see GlpiPlugin\Example\Showtabitem class for implementation explanations
|
||||
$PLUGIN_HOOKS[Hooks::PRE_SHOW_TAB]['example'] = [Showtabitem::class, 'pre_show_tab'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_SHOW_TAB]['example'] = [Showtabitem::class, 'post_show_tab'];
|
||||
$PLUGIN_HOOKS[Hooks::PRE_SHOW_ITEM]['example'] = [Showtabitem::class, 'pre_show_item'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_SHOW_ITEM]['example'] = [Showtabitem::class, 'post_show_item'];
|
||||
|
||||
// Add new actions to timeline
|
||||
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['example'] = [
|
||||
ItemForm::class, 'timelineActions'
|
||||
];
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITEM_FORM]['example'] = [ItemForm::class, 'preItemForm'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['example'] = [ItemForm::class, 'postItemForm'];
|
||||
|
||||
// declare this plugin as an import plugin for Computer itemtype
|
||||
$PLUGIN_HOOKS['import_item']['example'] = [Computer::class => ['Plugin']];
|
||||
$PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection'];
|
||||
$PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection'];
|
||||
|
||||
// add additional informations on Computer::showForm
|
||||
$PLUGIN_HOOKS[Hooks::AUTOINVENTORY_INFORMATION]['example'] = [
|
||||
Computer::class => [Computer::class, 'showInfo']
|
||||
];
|
||||
// Add new actions to timeline
|
||||
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['example'] = [
|
||||
ItemForm::class, 'timelineActions',
|
||||
];
|
||||
|
||||
// declare this plugin as an import plugin for Computer itemtype
|
||||
$PLUGIN_HOOKS['import_item']['example'] = [Computer::class => ['Plugin']];
|
||||
|
||||
// add additional informations on Computer::showForm
|
||||
$PLUGIN_HOOKS[Hooks::AUTOINVENTORY_INFORMATION]['example'] = [
|
||||
Computer::class => [Computer::class, 'showInfo'],
|
||||
];
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::FILTER_ACTORS]['example'] = "plugin_example_filter_actors";
|
||||
|
||||
// add new cards to dashboard grid
|
||||
$PLUGIN_HOOKS['dashboard_types']['example'] = [Example::class, 'dashboardTypes'];
|
||||
$PLUGIN_HOOKS['dashboard_cards']['example'] = [Example::class, 'dashboardCards'];
|
||||
// add new cards to dashboard grid
|
||||
$PLUGIN_HOOKS['dashboard_types']['example'] = [Example::class, 'dashboardTypes'];
|
||||
$PLUGIN_HOOKS['dashboard_cards']['example'] = [Example::class, 'dashboardCards'];
|
||||
|
||||
// Dashboard filter
|
||||
$PLUGIN_HOOKS[Hooks::DASHBOARD_FILTERS]['example'] = [
|
||||
ComputerModelFilter::class
|
||||
];
|
||||
// Dashboard filter
|
||||
$PLUGIN_HOOKS[Hooks::DASHBOARD_FILTERS]['example'] = [
|
||||
ComputerModelFilter::class,
|
||||
];
|
||||
|
||||
//TODO: remove check when GLPI 11.0.0 is released
|
||||
if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) {
|
||||
// Icon in the impact analysis
|
||||
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
|
||||
}
|
||||
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
|
||||
}
|
||||
|
||||
|
||||
@ -304,20 +305,21 @@ function plugin_init_example() {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function plugin_version_example() {
|
||||
return [
|
||||
'name' => 'Plugin Example',
|
||||
'version' => PLUGIN_EXAMPLE_VERSION,
|
||||
'author' => 'Example plugin team',
|
||||
'license' => 'GPLv2+',
|
||||
'homepage' => 'https://github.com/pluginsGLPI/example',
|
||||
'requirements' => [
|
||||
'glpi' => [
|
||||
'min' => PLUGIN_EXAMPLE_MIN_GLPI,
|
||||
'max' => PLUGIN_EXAMPLE_MAX_GLPI,
|
||||
]
|
||||
]
|
||||
];
|
||||
function plugin_version_example()
|
||||
{
|
||||
return [
|
||||
'name' => 'Plugin Example',
|
||||
'version' => PLUGIN_EXAMPLE_VERSION,
|
||||
'author' => 'Example plugin team',
|
||||
'license' => 'GPLv2+',
|
||||
'homepage' => 'https://github.com/pluginsGLPI/example',
|
||||
'requirements' => [
|
||||
'glpi' => [
|
||||
'min' => PLUGIN_EXAMPLE_MIN_GLPI,
|
||||
'max' => PLUGIN_EXAMPLE_MAX_GLPI,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -327,11 +329,12 @@ function plugin_version_example() {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_example_check_prerequisites() {
|
||||
if (false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
function plugin_example_check_prerequisites()
|
||||
{
|
||||
if (false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -341,13 +344,14 @@ function plugin_example_check_prerequisites() {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_example_check_config($verbose = false) {
|
||||
if (true) { // Your configuration check
|
||||
return true;
|
||||
}
|
||||
function plugin_example_check_config($verbose = false)
|
||||
{
|
||||
if (true) { // Your configuration check
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo __('Installed / not configured', 'example');
|
||||
}
|
||||
return false;
|
||||
if ($verbose) {
|
||||
echo __('Installed / not configured', 'example');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user