예제 #1
0
function plugin_init_appliances()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['appliances'] = true;
    // Params : plugin name - string type - number - attributes
    Plugin::registerClass('PluginAppliancesAppliance', array('linkuser_types' => true, 'linkuser_tech_types' => true, 'linkgroup_types' => true, 'linkgroup_tech_types' => true, 'infocom_types' => true, 'document_types' => true, 'contract_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true));
    Plugin::registerClass('PluginAppliancesProfile', array('addtabon' => 'Profile'));
    Plugin::registerClass('PluginAppliancesEnvironment');
    Plugin::registerClass('PluginAppliancesApplianceType');
    Plugin::registerClass('PluginAppliancesAppliance_Item');
    Plugin::registerClass('PluginAppliancesOptvalue');
    Plugin::registerClass('PluginAppliancesOptvalue_Item');
    Plugin::registerClass('PluginAppliancesRelation');
    if (class_exists('PluginAccountsAccount')) {
        PluginAccountsAccount::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginCertificatesCertificate')) {
        PluginCertificatesCertificate::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginDatabasesDatabase')) {
        PluginDatabasesDatabase::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginDomainsDomain')) {
        PluginDomainsDomain::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginWebapplicationsWebapplication')) {
        PluginWebapplicationsWebapplication::registerType('PluginAppliancesAppliance');
    }
    // Define the type for which we know how to generate PDF, need :
    $PLUGIN_HOOKS['plugin_pdf']['PluginAppliancesAppliance'] = 'PluginAppliancesAppliancePDF';
    $PLUGIN_HOOKS['migratetypes']['appliances'] = 'plugin_datainjection_migratetypes_appliances';
    $PLUGIN_HOOKS['change_profile']['appliances'] = array('PluginAppliancesProfile', 'select');
    $PLUGIN_HOOKS['assign_to_ticket']['appliances'] = true;
    if (class_exists('PluginAppliancesAppliance')) {
        // only if plugin activated
        $PLUGIN_HOOKS['pre_item_purge']['appliances'] = array('Profile' => array('PluginAppliancesProfile', 'cleanProfile'));
        $PLUGIN_HOOKS['item_clone']['appliances'] = array('Profile' => array('PluginAppliancesProfile', 'cloneProfile'));
        $PLUGIN_HOOKS['plugin_datainjection_populate']['appliances'] = 'plugin_datainjection_populate_appliances';
    }
    if (isset($_SESSION["glpiID"])) {
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_appliances"] = 1;
            // Display a menu entry ?
            if (plugin_appliances_haveRight("appliance", "r")) {
                $PLUGIN_HOOKS['menu_entry']['appliances'] = false;
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['title'] = _n('Appliance', 'Appliances', 2, 'appliances');
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['page'] = '/plugins/appliances/front/appliance.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['links']['search'] = '/plugins/appliances/front/appliance.php';
            }
            if (plugin_appliances_haveRight("appliance", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['links']['add'] = '/plugins/appliances/front/appliance.form.php';
                $PLUGIN_HOOKS['use_massive_action']['appliances'] = 1;
            }
        } else {
            // Display a menu entry ?
            if (plugin_appliances_haveRight("appliance", "r")) {
                $PLUGIN_HOOKS['menu_entry']['appliances'] = 'front/appliance.php';
                $PLUGIN_HOOKS['submenu_entry']['appliances']['search'] = 'front/appliance.php';
            }
            if (plugin_appliances_haveRight("appliance", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['appliances']['add'] = 'front/appliance.form.php?new=1';
                $PLUGIN_HOOKS['use_massive_action']['appliances'] = 1;
            }
        }
    }
    // Import from Data_Injection plugin
    $PLUGIN_HOOKS['data_injection']['appliances'] = "plugin_appliances_data_injection_variables";
    // Import webservice
    $PLUGIN_HOOKS['webservices']['appliances'] = 'plugin_appliances_registerMethods';
    // End init, when all types are registered
    $PLUGIN_HOOKS['post_init']['appliances'] = 'plugin_appliances_postinit';
}