glpi / src / plugin.php @ ad6689da
History | View | Annotate | Download (4.24 KB)
1 | 077e4de7 | Francois POIROTTE | <?php
|
---|---|---|---|
2 | |||
3 | function plugin_init_vigilo() |
||
4 | { |
||
5 | global $PLUGIN_HOOKS; |
||
6 | global $DB; |
||
7 | $hooks =& $PLUGIN_HOOKS; |
||
8 | ad6689da | Francois POIROTTE | $p = "vigilo"; |
9 | $hookObj = new VigiloHooks(); |
||
10 | 077e4de7 | Francois POIROTTE | |
11 | ad6689da | Francois POIROTTE | $hooks['csrf_compliant'][$p] = true; |
12 | $hooks['item_add'][$p] = array("Computer" => array($hookObj, "addComputer"), |
||
13 | "NetworkEquipment" => array($hookObj, "addNetworkEquipment"), |
||
14 | "Printer" => array($hookObj, "addPrinter")); |
||
15 | $hooks['item_update'][$p] = array("Computer" => array($hookObj, "updateComputer"), |
||
16 | "NetworkEquipment" => array($hookObj, "updateNetworkEquipment"), |
||
17 | "Printer" => array($hookObj, "updatePrinter")); |
||
18 | $hooks['item_purge'][$p] = array("Computer" => array($hookObj, "delete"), |
||
19 | "NetworkEquipment" => array($hookObj, "delete"), |
||
20 | "Printer" => array($hookObj, "delete")); |
||
21 | $hooks['item_delete'][$p] = array("Computer" => array($hookObj, "delete"), |
||
22 | "NetworkEquipment" => array($hookObj, "delete"), |
||
23 | "Printer" => array($hookObj, "delete")); |
||
24 | $hooks['item_restore'][$p] = array("Computer" => array($hookObj, "addComputer"), |
||
25 | "NetworkEquipment" => array($hookObj, "addNetworkEquipment"), |
||
26 | "Printer" => array($hookObj, "addPrinter")); |
||
27 | 077e4de7 | Francois POIROTTE | |
28 | $events = array('item_add', 'item_update', 'item_purge', 'item_delete', 'item_restore'); |
||
29 | foreach ($events as $event) { |
||
30 | $hooks[$event][$p] += array( |
||
31 | "ComputerDisk" => array($hookObj,"manageDisks"), |
||
32 | "NetworkPort" => array($hookObj,"manageNetworks"), |
||
33 | "IPAddress" => array($hookObj,"manageAddresses"), |
||
34 | "DeviceProcessor" => array($hookObj,"manageNetworks"), |
||
35 | "DeviceMemory" => array($hookObj,"manageNetworks"), |
||
36 | "DeviceHardDrive" => array($hookObj,"manageNetworks"), |
||
37 | "DeviceControl" => array($hookObj,"manageNetworks"), |
||
38 | "DeviceSoundCard" => array($hookObj,"manageNetworks"), |
||
39 | "Software" => array($hookObj,"manageSoftwares"), |
||
40 | "Location" => array($hookObj,"updateGroups"), |
||
41 | "Computer_SoftwareVersion" => array($hookObj, "manageComputerSoftwareVersion"), |
||
42 | "Entity" => array($hookObj,"updateGroups"), |
||
43 | "Manufacturer" => array($hookObj,"updateGroups"), |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | $hooks["menu_toadd"][$p]['plugins'] = 'PluginVigiloMenu'; |
||
48 | $hooks['config_page'][$p] = 'front/menu.php?itemtype=vigilo'; |
||
49 | $hooks['autoinventory_information'][$p] = array( |
||
50 | ad6689da | Francois POIROTTE | 'Computer' => array('PluginVigiloComputer', 'showComputerInfo') |
51 | ); |
||
52 | 077e4de7 | Francois POIROTTE | |
53 | if (!FieldExists('glpi_computers', 'vigilo_template')) { |
||
54 | $query = "ALTER TABLE glpi_computers ADD vigilo_template VARCHAR(30)"; |
||
55 | $DB->queryOrDie($query, "Ajout d'une colonne vigilo_template dans la table glpi_computers"); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | function getSearchOptions() |
||
60 | { |
||
61 | $computer = new Computer(); |
||
62 | $options = $computer->getSearchOptions(); |
||
63 | |||
64 | $options['vigilo'] = 'Vigilo Template'; |
||
65 | |||
66 | $options['7007']['name'] = 'vigilo_template'; |
||
67 | $options['7007']['table'] = 'glpi_computers'; |
||
68 | $options['7007']['field'] = 'vigilo_template'; |
||
69 | $options['7007']['searchtype'] = 'equals'; |
||
70 | $options['7007']['datatype'] = 'dropdown'; |
||
71 | |||
72 | return $options; |
||
73 | } |
||
74 | |||
75 | function plugin_version_vigilo() |
||
76 | { |
||
77 | return array('name' => 'Vigilo monitoring', |
||
78 | 'version' => '0.1', |
||
79 | 'author' => 'CSSI', |
||
80 | 'license' => 'GPLv2+', |
||
81 | 'homepage' => 'http://vigilo-nms.org', |
||
82 | 'minGlpiVersion' => '9.1'); |
||
83 | } |
||
84 | |||
85 | function plugin_vigilo_check_config($verbose = false) |
||
86 | { |
||
87 | if (version_compare(GLPI_VERSION, '9.1', 'lt')) { |
||
88 | echo "This plugin requires GLPI >= 9.1"; |
||
89 | return false; |
||
90 | } |
||
91 | return true; |
||
92 | } |
||
93 | |||
94 | function plugin_vigilo_check_prerequisites() |
||
95 | { |
||
96 | return true; |
||
97 | } |
||
98 | |||
99 | function plugin_vigilo_install() |
||
100 | { |
||
101 | return true; |
||
102 | } |
||
103 | |||
104 | function plugin_vigilo_uninstall() |
||
105 | { |
||
106 | return true; |
||
107 | } |