new hook 'post_init', see #2610

git-svn-id: https://forge.glpi-project.org/svn/example/trunk@153 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
remicollet 2011-01-24 08:54:44 +00:00
parent e28ae857b1
commit e9366fba35
2 changed files with 18 additions and 7 deletions

View File

@ -119,7 +119,7 @@ function plugin_example_displayConfigItem($type, $ID, $data, $num) {
function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables) { function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables) {
// Example of default JOIN clause // Example of default JOIN clause
// No need of the function if you do not have specific cases // No need of the function if you do not have specific cases
switch ($type) { switch ($type) {
// case "PluginExampleExample" : // case "PluginExampleExample" :
@ -291,7 +291,7 @@ function plugin_example_MassiveActionsDisplay($options=array()) {
case 'Computer' : case 'Computer' :
switch ($options['action']) { switch ($options['action']) {
case "plugin_example_DoIt" : case "plugin_example_DoIt" :
echo "&nbsp;<input type='hidden' name='toto' value='1'><input type='submit' name='massiveaction' class='submit' value='". echo "&nbsp;<input type='hidden' name='toto' value='1'><input type='submit' name='massiveaction' class='submit' value='".
$LANG["buttons"][2]."'>&nbsp;but do nothing :)"; $LANG["buttons"][2]."'>&nbsp;but do nothing :)";
break; break;
@ -388,13 +388,13 @@ function plugin_example_MassiveActionsFieldsDisplay($options=array()) {
// MUST Use a specific AddWhere & $tab[X]['searchtype'] = 'equals'; declaration // MUST Use a specific AddWhere & $tab[X]['searchtype'] = 'equals'; declaration
function plugin_example_searchOptionsValues($options=array()) { function plugin_example_searchOptionsValues($options=array()) {
global $LANG; global $LANG;
$table = $options['searchoption']['table']; $table = $options['searchoption']['table'];
$field = $options['searchoption']['field']; $field = $options['searchoption']['field'];
// Table fields // Table fields
switch ($table.".".$field) { switch ($table.".".$field) {
case "glpi_plugin_example_examples.serial" : case "glpi_plugin_example_examples.serial" :
echo "Not really specific - Use your own dropdown - Just for example&nbsp;"; echo "Not really specific - Use your own dropdown - Just for example&nbsp;";
Dropdown::show(getItemTypeForTable($options['searchoption']['table']), Dropdown::show(getItemTypeForTable($options['searchoption']['table']),
@ -788,4 +788,13 @@ function plugin_example_get_events(NotificationTargetTicket $target) {
function plugin_example_get_datas(NotificationTargetTicket $target) { function plugin_example_get_datas(NotificationTargetTicket $target) {
$target->datas['##ticket.example##'] = "Example datas"; $target->datas['##ticket.example##'] = "Example datas";
} }
function plugin_example_postinit() {
global $CFG_GLPI;
// All plugins are initialized, so all types are registered
foreach ($CFG_GLPI["infocom_types"] as $type) {
// do something
}
}
?> ?>

View File

@ -48,8 +48,8 @@ function plugin_init_example() {
Plugin::registerClass('PluginExampleExample', Plugin::registerClass('PluginExampleExample',
array('notificationtemplates_types' => true)); array('notificationtemplates_types' => true));
Plugin::registerClass('PluginExampleRuleTestCollection', Plugin::registerClass('PluginExampleRuleTestCollection',
array('rulecollections_types' => true)); array('rulecollections_types' => true));
// Display a menu entry ? // Display a menu entry ?
@ -146,6 +146,8 @@ function plugin_init_example() {
// Stats // Stats
$PLUGIN_HOOKS['stats']['example'] = array('stat.php' => 'New stat', $PLUGIN_HOOKS['stats']['example'] = array('stat.php' => 'New stat',
'stat.php?other' => 'New stats 2',); 'stat.php?other' => 'New stats 2',);
$PLUGIN_HOOKS['post_init']['example'] = 'plugin_example_postinit';
} }