Exemplo n.º 1
0
function plugin_genericobject_getDropdown()
{
    $dropdowns = array();
    $plugin = new Plugin();
    if ($plugin->isActivated("genericobject")) {
        foreach (getAllDatasFromTable(getTableForItemType('PluginGenericobjectType'), "`is_active`='1'") as $itemtype) {
            foreach (PluginGenericobjectType::getDropdownForItemtype($itemtype['itemtype']) as $table) {
                $dropdown_itemtype = getItemTypeForTable($table);
                $dropdowns[$dropdown_itemtype] = $dropdown_itemtype::getTypeName();
            }
        }
    }
    return $dropdowns;
}
Exemplo n.º 2
0
function plugin_genericobject_getDropdown()
{
    $dropdowns = array();
    $plugin = new Plugin();
    if ($plugin->isActivated("genericobject")) {
        foreach (PluginGenericobjectType::getTypes(true) as $idx => $type) {
            _log($idx, var_export($type, true));
            $itemtype = $type['itemtype'];
            foreach (PluginGenericobjectType::getDropdownForItemtype($itemtype) as $table) {
                $dropdown_itemtype = getItemTypeForTable($table);
                if (class_exists($dropdown_itemtype)) {
                    $dropdowns[$dropdown_itemtype] = $dropdown_itemtype::getTypeName();
                }
            }
        }
    }
    return $dropdowns;
}
Exemplo n.º 3
0
 static function registerType()
 {
     global $DB, $PLUGIN_HOOKS, $UNINSTALL_TYPES, $ORDER_TYPES, $CFG_GLPI, $GO_LINKED_TYPES;
     $class = get_called_class();
     $item = new $class();
     $fields = PluginGenericobjectSingletonObjectField::getInstance($class);
     PluginGenericobjectType::includeLocales($item->getObjectTypeName());
     PluginGenericobjectType::includeConstants($item->getObjectTypeName());
     $options = array("document_types" => $item->canUseDocuments(), "helpdesk_visible_types" => $item->canUseTickets(), "linkgroup_types" => $item->canUseTickets() && isset($fields["groups_id"]), "linkuser_types" => $item->canUseTickets() && isset($fields["users_id"]), "ticket_types" => $item->canUseTickets(), "infocom_types" => $item->canUseInfocoms(), "networkport_types" => $item->canUseNetworkPorts(), "reservation_types" => $item->canBeReserved(), "contract_types" => $item->canUseContracts(), "unicity_types" => $item->canUseUnicity());
     Plugin::registerClass($class, $options);
     if (Session::haveRight($class, "r")) {
         //Change url for adding a new object, depending on template management activation
         if ($item->canUseTemplate()) {
             //Template management is active
             $add_url = "/front/setup.templates.php?itemtype={$class}&add=1";
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['template'] = "/front/setup.templates.php?itemtype={$class}&add=0";
         } else {
             //Template management is not active
             $add_url = Toolbox::getItemTypeFormURL($class, false);
         }
         //Menu management
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['title'] = $class::getTypeName();
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['page'] = Toolbox::getItemTypeSearchURL($class, false);
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['search'] = Toolbox::getItemTypeSearchURL($class, false);
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = $add_url;
         //Add configuration icon, if user has right
         if (Session::haveRight('config', 'w')) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['config'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false) . "?itemtype={$class}";
         }
         //Item can be linked to tickets
         if ($item->canUseTickets()) {
             if (!in_array($class, $_SESSION['glpiactiveprofile']['helpdesk_item_type'])) {
                 $_SESSION['glpiactiveprofile']['helpdesk_item_type'][] = $class;
             }
         }
         if ($item->canUsePluginUninstall()) {
             if (!in_array($class, $UNINSTALL_TYPES)) {
                 array_push($UNINSTALL_TYPES, $class);
             }
         }
         if ($item->canUsePluginOrder()) {
             if (!in_array($class, $ORDER_TYPES)) {
                 array_push($ORDER_TYPES, $class);
             }
         }
         if ($item->canUseGlobalSearch()) {
             if (!in_array($class, $CFG_GLPI['state_types'])) {
                 array_push($CFG_GLPI['state_types'], $class);
             }
         }
         if ($item->canUseDirectConnections()) {
             if (!in_array($class, $GO_LINKED_TYPES)) {
                 array_push($GO_LINKED_TYPES, $class);
             }
             $items_class = $class . "_Item";
             //if (class_exists($items_class)) {
             $items_class::registerType();
             //}
         }
     }
     foreach (PluginGenericobjectType::getDropdownForItemtype($class) as $table) {
         $itemtype = getItemTypeForTable($table);
         $item = new $itemtype();
         //If entity dropdown, check rights to view & create
         if ($itemtype::canView()) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$itemtype]['links']['search'] = Toolbox::getItemTypeSearchURL($itemtype, false);
             if ($itemtype::canCreate()) {
                 $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = Toolbox::getItemTypeFormURL($class, false);
             }
         }
     }
 }