示例#1
0
 function pre_deleteItem()
 {
     if ($this->getFromDB($this->fields["id"])) {
         $name = $this->fields['name'];
         $itemtype = $this->fields['itemtype'];
         //Delete all network ports
         self::deleteNetworking($itemtype);
         //Drop all dropdowns associated with itemtype
         self::deleteDropdownsForItemtype($itemtype);
         //Delete loans associated with this type
         self::deleteLoans($itemtype);
         //Delete loans associated with this type
         self::deleteUnicity($itemtype);
         //Remove datainjection specific file
         self::deleteInjectionFile($name);
         //Delete profile informations associated with this type
         PluginGenericobjectProfile::deleteTypeFromProfile($itemtype);
         self::deleteTicketAssignation($itemtype);
         //Remove existing datainjection models
         self::removeDataInjectionModels($itemtype);
         //Delete specific locale directory
         self::deleteLocales($name, $itemtype);
         self::deleteItemTypeFilesAndClasses($name, $this->getTable());
         return true;
     } else {
         return false;
     }
 }
示例#2
0
 function pre_deleteItem()
 {
     if ($this->getFromDB($this->fields["id"])) {
         $name = $this->fields['name'];
         $itemtype = $this->fields['itemtype'];
         //Delete all network ports
         self::deleteNetworking($itemtype);
         //Drop all dropdowns associated with itemtype
         self::deleteDropdownsForItemtype($itemtype);
         //Delete loans associated with this type
         self::deleteLoans($itemtype);
         //Delete loans associated with this type
         self::deleteUnicity($itemtype);
         //Delete reservations with this tyoe
         self::deleteReservations($itemtype);
         self::deleteReservationItems($itemtype);
         //Remove datainjection specific file
         self::deleteInjectionFile($name);
         //Delete profile informations associated with this type
         PluginGenericobjectProfile::deleteTypeFromProfile($itemtype);
         self::deleteTicketAssignation($itemtype);
         //Remove associations to simcards with this type
         self::deleteSimcardAssignation($itemtype);
         //Remove existing datainjection models
         self::removeDataInjectionModels($itemtype);
         //Delete specific locale directory
         self::deleteLocales($name, $itemtype);
         self::deleteItemtypeReferencesInGLPI($itemtype);
         self::deleteItemTypeFilesAndClasses($name, $this->getTable(), $itemtype);
         //self::deleteNotepad($itemtype);
         if (preg_match("/PluginGenericobject(.*)/", $itemtype, $results)) {
             $newrightname = 'plugin_genericobject_' . strtolower($results[1]) . 's';
             ProfileRight::deleteProfileRights(array($newrightname));
         }
         $prof = new Profile();
         $profiles = getAllDatasFromTable('glpi_profiles');
         foreach ($profiles as $profile) {
             $helpdesk_item_types = json_decode($profile['helpdesk_item_type'], true);
             if ($helpdesk_item_types !== null) {
                 $index = array_search($itemtype, $helpdesk_item_types);
                 if ($index) {
                     unset($helpdesk_item_types[$index]);
                     $tmp['id'] = $profile['id'];
                     $tmp['helpdesk_item_type'] = json_encode($helpdesk_item_types);
                     $prof->update($tmp);
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }