示例#1
0
文件: setup.php 项目: korial29/tag
function plugin_init_tag()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['tag'] = true;
    Plugin::registerClass('PluginTagTagItem', array('addtabon' => array('PluginTagTag')));
    $plugin = new Plugin();
    if ($plugin->isInstalled("tag") && $plugin->isActivated("tag")) {
        // add link on plugin name in Configuration > Plugin
        $PLUGIN_HOOKS['config_page']['tag'] = "front/tag.php";
        $PLUGIN_HOOKS['add_javascript']['tag'][] = 'js/scripts.js';
    }
    // only on itemtype form
    if (preg_match_all("/.*\\/(.*)\\.form\\.php/", $_SERVER['REQUEST_URI'], $matches) !== false) {
        if (strpos($_SERVER['REQUEST_URI'], "/front/dropdown.php") === false && strpos($_SERVER['REQUEST_URI'], ".form.php?") !== false && strpos($_SERVER['REQUEST_URI'], "id=-1") === false && strpos($_SERVER['REQUEST_URI'], "withtemplate=") === false && strpos($_SERVER['REQUEST_URI'], "?new=1") === false && strpos($_SERVER['REQUEST_URI'], "popup=1&rand=") === false && strpos($_SERVER['REQUEST_URI'], "/front/queuedmail") === false && strpos($_SERVER['REQUEST_URI'], "plugins/tag/front/tag.form.php") === false && strpos($_SERVER['REQUEST_URI'], "plugins/tag/front/tagtype") === false && strpos($_SERVER['REQUEST_URI'], "plugins/datainjection/front/model.form.php") === false && strpos($_SERVER['REQUEST_URI'], "plugins/webservices/front/client.form.php?new=1") === false && strpos($_SERVER['REQUEST_URI'], "plugins/printercounters/") === false && isset($_SESSION["glpiroot"]) && strpos($_SERVER['REQUEST_URI'], $_SESSION["glpiroot"] . "/front/reservation.form.php") === false && strpos($_SERVER['REQUEST_URI'], $_SESSION["glpiroot"] . "/front/config.form.php") === false) {
            //for ?forcetab=PluginBehaviorsConfig%241
            if (Session::haveRight("itilcategory", READ)) {
                $PLUGIN_HOOKS['add_javascript']['tag'][] = 'js/show_tags.js';
            }
        }
        if (isset($matches[1][0])) {
            $itemtype = $matches[1][0];
            if (preg_match_all("/plugins\\/(.*)\\//U", $_SERVER['REQUEST_URI'], $matches_plugin) !== false) {
                if (isset($matches_plugin[1][0])) {
                    $itemtype = "Plugin" . ucfirst($matches_plugin[1][0]) . ucfirst($itemtype);
                }
            }
            // stop on blaclisted itemtype
            if (in_array($itemtype, array_map('strtolower', getBlacklistItemtype()))) {
                return '';
            }
            if (class_exists($itemtype)) {
                //normalize classname case
                $obj = new $itemtype();
                $itemtype = get_class($obj);
                // Tag have no tag associated
                if ($itemtype != 'PluginTagTag') {
                    $PLUGIN_HOOKS['pre_item_update']['tag'][$itemtype] = 'plugin_pre_item_update_tag';
                    $PLUGIN_HOOKS['pre_item_purge']['tag'][$itemtype] = 'plugin_pre_item_purge_tag';
                }
            }
        }
    }
}
<?php

include '../../../inc/includes.php';
// check if itemtype can display tag control
if (in_array(strtolower($_REQUEST['itemtype']), array_map('strtolower', getBlacklistItemtype()))) {
    return '';
}
$class = $_REQUEST['itemtype'] == 'ticket' ? "tab_bg_1" : '';
echo "<tr class='{$class}'>";
echo "<th>" . _n('Tag', 'Tags', 2, 'tag') . "</th>";
echo "<td colspan='3'>";
PluginTagTag::tagDropdownMultiple();
echo "</td>";
echo "</tr>";