function plugin_geninventorynumber_uninstall()
{
    $migration = new Migration("0.85+1.0");
    include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/config.class.php';
    include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/profile.class.php';
    include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/configfield.class.php';
    PluginGeninventorynumberConfig::uninstall($migration);
    PluginGeninventorynumberProfile::removeRightsFromSession();
    PluginGeninventorynumberProfile::uninstallProfile();
    PluginGeninventorynumberConfigField::uninstall($migration);
    return true;
}
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     switch ($tabnum) {
         case 0:
             $item->showForm(1);
             break;
         case 1:
             PluginGeninventorynumberConfigField::showForConfig($item->getID());
             break;
     }
     return TRUE;
 }
 static function preItemUpdate(CommonDBTM $item)
 {
     if (!Session::haveRight("plugin_geninventorynumber", UPDATE)) {
         return array('noright');
     }
     if (PluginGeninventorynumberConfig::isGenerationActive() && PluginGeninventorynumberConfigField::isActiveForItemType(get_class($item)) && !isset($item->input['massiveaction'])) {
         if (isset($item->fields['otherserial']) && isset($item->input['otherserial']) && $item->fields['otherserial'] != $item->input['otherserial']) {
             $item->input['otherserial'] = $item->fields['otherserial'];
             if (!isCommandLine()) {
                 Session::addMessageAfterRedirect(__('GenerateInventoryNumberDenied', 'geninventorynumber'), true, ERROR);
                 return array('ko');
             }
         }
         return array('ok');
     }
     return '';
 }
Beispiel #4
0
 static function registerType()
 {
     global $DB, $PLUGIN_HOOKS, $UNINSTALL_TYPES, $ORDER_TYPES, $CFG_GLPI, $GO_LINKED_TYPES, $GENINVENTORYNUMBER_TYPES;
     $class = get_called_class();
     $item = new $class();
     $fields = PluginGenericobjectSingletonObjectField::getInstance($class);
     $plugin = new Plugin();
     PluginGenericobjectType::includeLocales($item->getObjectTypeName());
     PluginGenericobjectType::includeConstants($item->getObjectTypeName());
     $options = array("document_types" => $item->canUseDocuments(), "helpdesk_visible_types" => $item->canUseTickets(), "linkgroup_types" => isset($fields["groups_id"]), "linkuser_types" => isset($fields["users_id"]), "linkgroup_tech_types" => isset($fields["groups_id_tech"]), "linkuser_tech_types" => isset($fields["users_id_tech"]), "ticket_types" => $item->canUseTickets(), "infocom_types" => $item->canUseInfocoms(), "networkport_types" => $item->canUseNetworkPorts(), "reservation_types" => $item->canBeReserved(), "contract_types" => $item->canUseContracts(), "unicity_types" => $item->canUseUnicity(), "location_types" => isset($fields['locations_id']));
     Plugin::registerClass($class, $options);
     if (plugin_genericobject_haveRight($class, READ)) {
         //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);
         if (plugin_genericobject_haveRight($class, UPDATE)) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = $add_url;
         }
         //Add configuration icon, if user has right
         if (Session::haveRight('config', UPDATE)) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['config'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false) . "?itemtype={$class}";
         }
         if ($item->canUsePluginUninstall()) {
             if (!in_array($class, $UNINSTALL_TYPES)) {
                 array_push($UNINSTALL_TYPES, $class);
             }
         }
         if ($item->canUsePluginSimcard()) {
             if ($plugin->isActivated('simcard') && $plugin->isActivated('simcard')) {
                 PluginSimcardSimcard_Item::registerItemtype($class);
             }
         }
         if ($item->canUsePluginOrder()) {
             if (!in_array($class, $ORDER_TYPES)) {
                 array_push($ORDER_TYPES, $class);
             }
         }
         if ($item->canUseGlobalSearch()) {
             if (!in_array($class, $CFG_GLPI['asset_types'])) {
                 array_push($CFG_GLPI['asset_types'], $class);
             }
             if (!in_array($class, $CFG_GLPI['globalsearch_types'])) {
                 array_push($CFG_GLPI['globalsearch_types'], $class);
             }
             if (!in_array($class, $CFG_GLPI['state_types'])) {
                 array_push($CFG_GLPI['state_types'], $class);
                 array_push($CFG_GLPI['globalsearch_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();
             //}
         }
         if ($item->canUseProjects()) {
             if (!in_array($class, $CFG_GLPI['project_asset_types'])) {
                 array_push($CFG_GLPI['project_asset_types'], $class);
             }
         }
         if ($item->canUsePluginGeninventorynumber()) {
             if (!in_array($class, $GENINVENTORYNUMBER_TYPES)) {
                 include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/profile.class.php';
                 PluginGeninventorynumberConfigField::registerNewItemType($class);
                 array_push($GENINVENTORYNUMBER_TYPES, $class);
             }
         } elseif ($plugin->isActivated('geninventorynumber')) {
             include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/profile.class.php';
             PluginGeninventorynumberConfigField::unregisterNewItemType($class);
         }
     }
     foreach (PluginGenericobjectType::getDropdownForItemtype($class) as $table) {
         $itemtype = getItemTypeForTable($table);
         if (class_exists($itemtype)) {
             $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);
                 }
             }
         }
     }
 }
 geninventorynumber plugin is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 geninventorynumber plugin is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 This file is part of geninventorynumber plugin.
 You should have received a copy of the GNU General Public License
 along with GLPI; along with geninventorynumber. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   geninventorynumber
 @author    the geninventorynumber plugin team
 @copyright Copyright (c) 2008-2013 geninventorynumber plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/geninventorynumber
 @link      http://www.glpi-project.org/
 @since     2008
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
$configfield = new PluginGeninventorynumberConfigField();
if (isset($_POST["update_fields"]) && isset($_POST["ids"])) {
    foreach ($_POST['ids'] as $itemtype => $data) {
        $configfield->update($data);
    }
}
Html::back();