Esempio n. 1
0
function plugin_init_webapplications()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['webapplications'] = true;
    //load changeprofile function
    $PLUGIN_HOOKS['change_profile']['webapplications'] = array('PluginWebapplicationsProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['webapplications'] = true;
    if (class_exists('PluginWebapplicationsWebapplication_Item')) {
        // only if plugin activated
        $PLUGIN_HOOKS['pre_item_purge']['webapplications'] = array('Profile' => array('PluginWebapplicationsProfile', 'purgeProfiles'));
        $PLUGIN_HOOKS['plugin_datainjection_populate']['webapplications'] = 'plugin_datainjection_populate_webapplications';
    }
    // Params : plugin name - string type - number - class - table - form page
    Plugin::registerClass('PluginWebapplicationsWebapplication', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'contract_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'addtabon' => 'Supplier'));
    Plugin::registerClass('PluginWebapplicationsProfile', array('addtabon' => array('Profile')));
    if (class_exists('PluginAccountsAccount')) {
        PluginAccountsAccount::registerType('PluginWebapplicationsWebapplication');
    }
    if (class_exists('PluginCertificatesCertificate')) {
        PluginCertificatesCertificate::registerType('PluginWebapplicationsWebapplication');
    }
    //if glpi is loaded
    if (Session::getLoginUserID()) {
        //if environment plugin is installed
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            //init $_SESSION for environment using
            $_SESSION["glpi_plugin_environment_webapplications"] = 1;
            if (plugin_webapplications_haveRight("webapplications", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['webapplications']['title'] = PluginWebapplicationsWebapplication::getTypeName(2);
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['webapplications']['page'] = '/plugins/webapplications/front/webapplication.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['webapplications']['links']['search'] = '/plugins/webapplications/front/webapplication.php';
            }
            if (plugin_webapplications_haveRight("webapplications", "w")) {
                //redirect link to add webapplications
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['webapplications']['links']['add'] = '/plugins/webapplications/front/webapplication.form.php';
                //use massiveaction in the plugin
                $PLUGIN_HOOKS['use_massive_action']['webapplications'] = 1;
            }
            //if environment plugin isn't installed
        } else {
            // Display a menu entry ?
            if (plugin_webapplications_haveRight("webapplications", "r")) {
                //menu entry
                $PLUGIN_HOOKS['menu_entry']['webapplications'] = 'front/webapplication.php';
                //search link
                $PLUGIN_HOOKS['submenu_entry']['webapplications']['search'] = 'front/webapplication.php';
            }
            if (plugin_webapplications_haveRight("webapplications", "w")) {
                //add link
                $PLUGIN_HOOKS['submenu_entry']['webapplications']['add'] = 'front/webapplication.form.php';
                //use massiveaction in the plugin
                $PLUGIN_HOOKS['use_massive_action']['webapplications'] = 1;
            }
        }
        if (plugin_webapplications_haveRight("webapplications", "r") || Session::haveRight("config", "w")) {
        }
        // Import from Data_Injection plugin
        //      $PLUGIN_HOOKS['migratetypes']['webapplications']
        //                                   = 'plugin_datainjection_migratetypes_webapplications';
        $PLUGIN_HOOKS['plugin_pdf']['PluginWebapplicationsWebapplication'] = 'PluginWebapplicationsWebapplicationPDF';
    }
    // End init, when all types are registered
    $PLUGIN_HOOKS['post_init']['webapplications'] = 'plugin_webapplications_postinit';
}
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         if ($item->getType() == 'PluginWebapplicationsWebapplication' && count(PluginWebapplicationsWebapplication::getTypes(false))) {
             if ($_SESSION['glpishow_count_on_tabs']) {
                 return self::createTabEntry(_n('Associated item', 'Associated items', 2), self::countForWebapplication($item));
             }
             return _n('Associated item', 'Associated items', 2);
         } else {
             if (in_array($item->getType(), PluginWebapplicationsWebapplication::getTypes(true)) && plugin_webapplications_haveRight('webapplications', 'r')) {
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     return self::createTabEntry(PluginWebapplicationsWebapplication::getTypeName(2), self::countForItem($item));
                 }
                 return PluginWebapplicationsWebapplication::getTypeName(2);
             }
         }
     }
     return '';
 }
 static function canView()
 {
     return plugin_webapplications_haveRight('webapplications', 'r');
 }
Esempio n. 4
0
function plugin_webapplications_AssignToTicket($types)
{
    if (plugin_webapplications_haveRight("open_ticket", "1")) {
        $types['PluginWebapplicationsWebapplication'] = PluginWebapplicationsWebapplication::getTypeName(2);
    }
    return $types;
}