getFromDB() public method

Retrieve an item from the database
public getFromDB ( $ID ) : true
$ID ID of the item to get
return true if succeed else false
Example #1
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'add':
             $input = $ma->getInput();
             $ticket = new Ticket();
             if (isset($input['link']) && isset($input['tickets_id_1'])) {
                 if ($item->getFromDB($input['tickets_id_1'])) {
                     foreach ($ids as $id) {
                         $input2 = array();
                         $input2['id'] = $input['tickets_id_1'];
                         $input2['_link']['tickets_id_1'] = $input['tickets_id_1'];
                         $input2['_link']['link'] = $input['link'];
                         $input2['_link']['tickets_id_2'] = $id;
                         if ($item->can($input['tickets_id_1'], UPDATE)) {
                             if ($ticket->update($input2)) {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                             } else {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                             $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                         }
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case "uninstall":
             $itemtype = $ma->getItemtype(false);
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     //Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
                     $_SESSION['glpi_uninstalllist'][$itemtype][$id] = $id;
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 }
             }
             Html::redirect($CFG_GLPI["root_doc"] . '/plugins/uninstall/front/action.php?device_type=' . $itemtype . "&model_id=" . $_POST["model_id"]);
             return;
             break;
     }
     return;
 }
Example #3
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case "transfert":
             $input = $ma->getInput();
             $entities_id = $input['entities_id'];
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $item->update(array("id" => $id, "entities_id" => $entities_id, "update" => __('Update')));
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 }
             }
             return;
             break;
     }
     return;
 }
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case 'Generate':
             $pbQRcode = new PluginBarcodeQRcode();
             $rand = mt_rand();
             $number = 0;
             $codes = array();
             if ($ma->POST['eliminate'] > 0) {
                 for ($nb = 0; $nb < $ma->POST['eliminate']; $nb++) {
                     $codes[] = '';
                 }
             }
             if ($ma->POST['type'] == 'QRcode') {
                 foreach ($ids as $key) {
                     $filename = $pbQRcode->generateQRcode($item->getType(), $key, $rand, $number, $ma->POST);
                     if ($filename) {
                         $codes[] = $filename;
                         $number++;
                     }
                 }
             } else {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     if ($item->isField('otherserial')) {
                         $codes[] = $item->getField('otherserial');
                     }
                 }
             }
             if (count($codes) > 0) {
                 $params['codes'] = $codes;
                 $params['type'] = $ma->POST['type'];
                 $params['size'] = $ma->POST['size'];
                 $params['border'] = $ma->POST['border'];
                 $params['orientation'] = $ma->POST['orientation'];
                 $barcode = new PluginBarcodeBarcode();
                 $file = $barcode->printPDF($params);
                 $filePath = explode('/', $file);
                 $filename = $filePath[count($filePath) - 1];
                 $msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>";
                 Session::addMessageAfterRedirect($msg);
                 $pbQRcode->cleanQRcodefiles($rand, $number);
             }
             $ma->itemDone($item->getType(), 0, MassiveAction::ACTION_OK);
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #5
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'duplicate':
             $rulecollection = new RuleCollection();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     if ($rulecollection->duplicateRule($id)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             break;
         case 'export':
             if (count($ids)) {
                 $_SESSION['exportitems'] = $ids;
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
                 $ma->setRedirect('rule.backup.php?action=download&itemtype=' . $item->getType());
             }
             break;
         case 'move_rule':
             $input = $ma->getInput();
             $collectionname = $input['rule_class_name'] . 'Collection';
             $rulecollection = new $collectionname();
             if ($rulecollection->canUpdate()) {
                 foreach ($ids as $id) {
                     if ($item->getFromDB($id)) {
                         if ($rulecollection->moveRule($id, $input['ranking'], $input['move_type'])) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
                 $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
             }
             break;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'add_actor':
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 $input2 = array('id' => $id);
                 if (isset($input['_itil_requester'])) {
                     $input2['_itil_requester'] = $input['_itil_requester'];
                 }
                 if (isset($input['_itil_observer'])) {
                     $input2['_itil_observer'] = $input['_itil_observer'];
                 }
                 if (isset($input['_itil_assign'])) {
                     $input2['_itil_assign'] = $input['_itil_assign'];
                 }
                 if ($item->can($id, UPDATE)) {
                     if ($item->update($input2)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'update_notif':
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($item->can($id, UPDATE)) {
                     $linkclass = new $item->userlinkclass();
                     foreach ($linkclass->getActors($id) as $type => $users) {
                         foreach ($users as $data) {
                             $data['use_notification'] = $input['use_notification'];
                             $linkclass->update($data);
                         }
                     }
                     $linkclass = new $this->supplierlinkclass();
                     foreach ($linkclass->getActors($id) as $type => $users) {
                         foreach ($users as $data) {
                             $data['use_notification'] = $input['use_notification'];
                             $linkclass->update($data);
                         }
                     }
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'add_task':
             if (!($task = getItemForItemtype($item->getType() . 'Task'))) {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 break;
             }
             $field = $item->getForeignKeyField();
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $input2 = array($field => $id, 'taskcategories_id' => $input['taskcategories_id'], 'content' => $input['content']);
                     if ($task->can(-1, CREATE, $input2)) {
                         if ($task->add($input2)) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #7
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'DoIt':
             if ($item->getType() == 'Computer') {
                 Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
                 Session::addMessageAfterRedirect(__('Write in item history', 'example'));
                 $changes = array(0, 'old value', 'new value');
                 foreach ($ids as $id) {
                     if ($item->getFromDB($id)) {
                         Session::addMessageAfterRedirect("- " . $item->getField("name"));
                         Log::history($id, 'Computer', $changes, 'PluginExampleExample', Log::HISTORY_PLUGIN);
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         // Example of ko count
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     }
                 }
             } else {
                 // When nothing is possible ...
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
         case 'do_nothing':
             if ($item->getType() == 'PluginExampleExample') {
                 Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
                 Session::addMessageAfterRedirect(__("But... I say I will do nothing for:", 'example'));
                 foreach ($ids as $id) {
                     if ($item->getFromDB($id)) {
                         Session::addMessageAfterRedirect("- " . $item->getField("name"));
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         // Example for noright / Maybe do it with can function is better
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #8
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $account_item = new PluginAccountsAccount_Item();
     switch ($ma->getAction()) {
         case "add_item":
             $input = $ma->getInput();
             foreach ($ma->items as $itemtype => $myitem) {
                 foreach ($myitem as $key => $value) {
                     if (!countElementsInTable('glpi_plugin_accounts_accounts_items', "itemtype='{$itemtype}' \n                                             AND items_id='{$key}' \n                                             AND plugin_accounts_accounts_id='" . $input['plugin_accounts_accounts_id'] . "'")) {
                         $myvalue['plugin_accounts_accounts_id'] = $input['plugin_accounts_accounts_id'];
                         $myvalue['itemtype'] = $itemtype;
                         $myvalue['items_id'] = $key;
                         if ($account_item->add($myvalue)) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                         }
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginAccountsAccount') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginAccountsAccountType::transfer($item->fields["plugin_accounts_accounttypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_accounts_accounttypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
         case 'install':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     $values = array('plugin_accounts_accounts_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($account_item->add($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'uninstall':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($val == 1) {
                     if ($account_item->deleteItemByAccountsAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
     }
 }
Example #9
0
 /**
  * Execute massive action for PluginFormcreatorFrom
  *
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'Duplicate':
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && $item->Duplicate()) {
                     Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 } else {
                     // Example of ko count
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'submit_validation':
             $input = $ma->getInput();
             $valid = new static();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $input2 = array(static::$items_id => $id, 'comment_submission' => $input['comment_submission']);
                     if ($valid->can(-1, CREATE, $input2)) {
                         $users = $input['users_id_validate'];
                         if (!is_array($users)) {
                             $users = array($users);
                         }
                         $ok = true;
                         foreach ($users as $user) {
                             $input2["users_id_validate"] = $user;
                             if (!$valid->add($input2)) {
                                 $ok = false;
                             }
                         }
                         if ($ok) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #11
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'add_item':
             $input = $ma->getInput();
             $item_ticket = new static();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && !empty($input['items_id'])) {
                     $input['tickets_id'] = $id;
                     $input['itemtype'] = $input['item_itemtype'];
                     if ($item_ticket->can(-1, CREATE, $input)) {
                         $ok = true;
                         if (!$item_ticket->add($input)) {
                             $ok = false;
                         }
                         if ($ok) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
         case 'delete_item':
             $input = $ma->getInput();
             $item_ticket = new static();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && !empty($input['items_id'])) {
                     $item_found = $item_ticket->find("`tickets_id` = {$id} AND `itemtype` = '" . $input['item_itemtype'] . "' AND `items_id` = " . $input['items_id']);
                     if (!empty($item_found)) {
                         $item_founds_id = array_keys($item_found);
                         $input['id'] = $item_founds_id[0];
                         if ($item_ticket->can($input['id'], DELETE, $input)) {
                             $ok = true;
                             if (!$item_ticket->delete($input)) {
                                 $ok = false;
                             }
                             if ($ok) {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                             } else {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                             $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #12
0
 /**
  * Execute massive action for PluginFormcreatorFrom
  *
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'Duplicate':
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && $item->Duplicate()) {
                     Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 } else {
                     // Example of ko count
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                 }
             }
             //return;
             break;
             //[CRI]
         //[CRI]
         case "Pedido":
             if ($item->getType() == 'Ticket') {
                 // [CRI]
                 $Plugin = new PluginFormcreatorForm();
                 $PluginItem = new PluginFormcreatorForm_Item();
                 $Target = new PluginFormcreatorTarget();
                 $helpdesk = new PluginFormcreatorTargetTicket();
                 $input = $ma->getInput();
                 foreach ($ids as $key) {
                     $listForm = $PluginItem->find("items_id = " . $key . " and itemtype = '" . $item->getType() . "'");
                     if (empty($listForm)) {
                         $input11 = array('plugin_formcreator_forms_id' => $input['plugin_formcreator_forms_id'], 'items_id' => $key, 'itemtype' => $item->getType());
                         $PluginItem->add($input11);
                     } else {
                         foreach ($listForm as $form_id => $value) {
                             $input12 = array('id' => $form_id);
                             $input12['plugin_formcreator_forms_id'] = $input['plugin_formcreator_forms_id'];
                             $input12['items_id'] = $key;
                             $input12['itemtype'] = $item->getType();
                             $PluginItem->update($input12);
                         }
                     }
                     //Actualizar Ticket
                     PluginFormcreatorForm::fromcreatorDropUserAndGrouponTicket($key);
                     //
                     PluginFormcreatorForm::updateTicketFromForm($input['plugin_formcreator_forms_id'], $key);
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                 }
             }
             break;
             //parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
     }
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginBadgesBadge') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginBadgesBadgeType::transfer($item->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_badges_badgetypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
     }
 }
 static function countForItem(CommonDBTM $item, $options = array())
 {
     global $DB;
     $ID = $item->getField('id');
     $query = "SELECT `glpi_plugin_shellcommands_shellcommands_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_shellcommands_shellcommands`.`name` AS assocName,\n                       `glpi_plugin_shellcommands_shellcommands`.*\n                FROM `glpi_plugin_shellcommands_shellcommands_items`\n                LEFT JOIN `glpi_plugin_shellcommands_shellcommands`\n                 ON (`glpi_plugin_shellcommands_shellcommands_items`.`plugin_shellcommands_shellcommands_id`=`glpi_plugin_shellcommands_shellcommands`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_shellcommands_shellcommands`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_shellcommands_shellcommands_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_shellcommands_shellcommands", '', '', true);
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $shells = array();
     if ($number) {
         while ($data = $DB->fetch_assoc($result)) {
             $shells[$data['assocID']] = $data;
         }
     }
     $countCommand = array();
     $count = 0;
     if ($number) {
         foreach ($shells as $data) {
             $link = $data["link"];
             $item->getFromDB($ID);
             if (strstr($link, '[NAME]')) {
                 // NAME
                 $countCommand['[NAME]' . $data['id']][] = 1;
                 $count++;
             } else {
                 if (strstr($link, '[ID]')) {
                     // ID
                     $countCommand['[ID]' . $data['id']][] = 1;
                     $count++;
                 } else {
                     if (strstr($link, '[DOMAIN]')) {
                         // DOMAIN
                         if (isset($item->fields['domains_id'])) {
                             $countCommand['[DOMAIN]' . $data['id']][] = 1;
                             $count++;
                         }
                     } else {
                         if (strstr($link, '[IP]') || strstr($link, '[MAC]')) {
                             $mac = array();
                             $ip = array();
                             $i = 0;
                             $query2 = "SELECT `glpi_networkports`.*, `glpi_ipaddresses`.`name` as ip\n                              FROM `glpi_networkports`\n                              LEFT JOIN `glpi_networknames`\n                                 ON (`glpi_networknames`.`items_id`=`glpi_networkports`.`id`)                            \n                              LEFT JOIN `glpi_ipaddresses`\n                                 ON (`glpi_networknames`.`id`=`glpi_ipaddresses`.`items_id`) \n                              WHERE `glpi_networkports`.`items_id` = '{$ID}' \n                              AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "' \n                              ORDER BY `glpi_networkports`.`logical_number`";
                             $result2 = $DB->query($query2);
                             if ($DB->numrows($result2) > 0) {
                                 while ($data2 = $DB->fetch_array($result2)) {
                                     if (!empty($data2["ip"]) && $data2["ip"] != '0.0.0.0') {
                                         $ip[$i]['ip'] = $data2["ip"];
                                         $i++;
                                     }
                                     if (!empty($data2["mac"])) {
                                         $mac[$i]['mac'] = $data2["mac"];
                                         $i++;
                                     }
                                 }
                             }
                             if (strstr($link, '[IP]')) {
                                 // IP internal switch
                                 if ($item->getType() == 'NetworkEquipment') {
                                     $countCommand['[IP]' . $data['id']][] = 1;
                                     $count++;
                                 }
                                 if (count($ip) > 0) {
                                     foreach ($ip as $val) {
                                         $countCommand['[IP]' . $data['id']][] = 1;
                                     }
                                     $count++;
                                 }
                             }
                             if (strstr($link, '[MAC]')) {
                                 // MAC internal switch
                                 if ($item->getType() == 'NetworkEquipment') {
                                     $countCommand['[MAC]' . $data['id']][] = 1;
                                     $count++;
                                 }
                                 if (count($mac) > 0) {
                                     foreach ($mac as $val) {
                                         $countCommand['[MAC]' . $data['id']][] = 1;
                                     }
                                     $count++;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($options['type']) && isset($options['itemId']) && isset($countCommand['[IP]' . $options['itemId']]) && stristr($options['type'], 'ip')) {
         return sizeof($countCommand['[IP]' . $options['itemId']]);
     } elseif (isset($options['type']) && isset($options['itemId']) && isset($countCommand['[MAC]' . $options['itemId']]) && stristr($options['type'], 'mac')) {
         return sizeof($countCommand['[MAC]' . $options['itemId']]);
     } elseif (isset($options['type']) && $options['type'] == 'ALL') {
         return $countCommand;
     } else {
         return $count;
     }
 }
Example #15
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'reset':
             if (Config::canUpdate()) {
                 foreach ($ids as $key) {
                     if ($item->getFromDB($key)) {
                         if ($item->resetDate()) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                 $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #16
0
 /**
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     $action = $ma->getAction();
     switch ($action) {
         case 'delete':
             foreach ($ids as $id) {
                 if ($item->can($id, DELETE)) {
                     if ($item->delete(array("id" => $id))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'restore':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     if ($item->restore(array("id" => $id))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'purge_item_but_devices':
         case 'purge_but_item_linked':
         case 'purge':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     $force = 1;
                     // Only mark deletion for
                     if ($item->maybeDeleted() && $item->useDeletedToLockIfDynamic() && $item->isDynamic()) {
                         $force = 0;
                     }
                     $delete_array = array('id' => $id);
                     if ($action == 'purge_item_but_devices') {
                         $delete_array['keep_devices'] = true;
                     }
                     if ($item instanceof CommonDropdown) {
                         if ($item->haveChildren()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item by massive actions, because it has sub-items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                         if ($item->isUsed()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item, because it is used for one or more items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                     }
                     if ($item->delete($delete_array, $force)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'update':
             if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
                 return false;
             }
             $index = $ma->POST['search_options'][$item->getType()];
             $searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
             $input = $ma->POST;
             if (isset($searchopt[$index])) {
                 /// Infocoms case
                 if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$index]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
                             $link_entity_type = $ent->fields["entities_id"];
                         }
                     }
                     foreach ($ids as $key) {
                         if ($item->getFromDB($key)) {
                             if ($link_entity_type < 0 || $link_entity_type == $item->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $item->getEntityID()))) {
                                 $input2["items_id"] = $key;
                                 $input2["itemtype"] = $item->getType();
                                 if ($ic->can(-1, CREATE, $input2)) {
                                     // Add infocom if not exists
                                     if (!$ic->getFromDBforDevice($item->getType(), $key)) {
                                         $input2["items_id"] = $key;
                                         $input2["itemtype"] = $item->getType();
                                         unset($ic->fields);
                                         $ic->add($input2);
                                         $ic->getFromDBforDevice($item->getType(), $key);
                                     }
                                     $id = $ic->fields["id"];
                                     unset($ic->fields);
                                     if ($ic->update(array('id' => $id, $input["field"] => $input[$input["field"]]))) {
                                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                                     } else {
                                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                                     }
                                 } else {
                                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                                 }
                             } else {
                                 $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                         }
                     }
                 } else {
                     /// Not infocoms
                     $link_entity_type = array();
                     /// Specific entity item
                     $itemtable = getTableForItemType($item->getType());
                     $itemtype2 = getItemTypeForTable($searchopt[$index]["table"]);
                     if ($item2 = getItemForItemtype($itemtype2)) {
                         if ($index != 80 && $searchopt[$index]["table"] != $itemtable && $item2->isEntityAssign() && $item->isEntityAssign()) {
                             if ($item2->getFromDB($input[$input["field"]])) {
                                 if (isset($item2->fields["entities_id"]) && $item2->fields["entities_id"] >= 0) {
                                     if (isset($item2->fields["is_recursive"]) && $item2->fields["is_recursive"]) {
                                         $link_entity_type = getSonsOf("glpi_entities", $item2->fields["entities_id"]);
                                     } else {
                                         $link_entity_type[] = $item2->fields["entities_id"];
                                     }
                                 }
                             }
                         }
                     }
                     foreach ($ids as $key) {
                         if ($item->canEdit($key) && $item->canMassiveAction($action, $input['field'], $input[$input["field"]])) {
                             if (count($link_entity_type) == 0 || in_array($item->fields["entities_id"], $link_entity_type)) {
                                 if ($item->update(array('id' => $key, $input["field"] => $input[$input["field"]]))) {
                                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                                 } else {
                                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                     $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                                 }
                             } else {
                                 $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                             $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                         }
                     }
                 }
             }
             break;
         case 'add_transfer_list':
             $itemtype = $item->getType();
             if (!isset($_SESSION['glpitransfer_list'])) {
                 $_SESSION['glpitransfer_list'] = array();
             }
             if (!isset($_SESSION['glpitransfer_list'][$itemtype])) {
                 $_SESSION['glpitransfer_list'][$itemtype] = array();
             }
             foreach ($ids as $id) {
                 $_SESSION['glpitransfer_list'][$itemtype][$id] = $id;
                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
             }
             $ma->setRedirect($CFG_GLPI['root_doc'] . '/front/transfer.action.php');
             break;
     }
 }
Example #17
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  * */
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginTasklistsTask') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginTasklistsTaskType::transfer($item->fields["plugin_tasklists_tasktypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_tasklists_tasktypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     $certif_item = new PluginCertificatesCertificate_Item();
     switch ($ma->getAction()) {
         case "plugin_certificates_add_item":
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 $input = array('plugin_certificates_certificates_id' => $input['plugin_certificates_certificates_id'], 'items_id' => $id, 'itemtype' => $item->getType());
                 if ($certif_item->can(-1, UPDATE, $input)) {
                     if ($certif_item->add($input)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 }
             }
             return;
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginCertificatesCertificate') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginCertificatesCertificateType::transfer($item->fields["plugin_certificates_certificatetypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_certificates_certificatetypes_id"] = $type;
                         $item->update($values);
                     }
                     $state = PluginCertificatesCertificateState::transfer($this->fields["plugin_certificates_certificatestates_id"], $input['entities_id']);
                     if ($state > 0) {
                         $values["id"] = $key;
                         $values["plugin_certificates_certificatestates_id"] = $state;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
         case 'install':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     $values = array('plugin_certificates_certificates_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($certif_item->add($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'uninstall':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($val == 1) {
                     if ($certif_item->deleteItemByCertificatesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'add_followup':
             $input = $ma->getInput();
             $fup = new self();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $input2 = array('tickets_id' => $id, 'is_private' => $input['is_private'], 'requesttypes_id' => $input['requesttypes_id'], 'content' => $input['content']);
                     if ($fup->can(-1, CREATE, $input2)) {
                         if ($fup->add($input2)) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #20
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  * */
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginSimcardSimcard') {
                 foreach ($ids as $key) {
                     // Types
                     $item->getFromDB($key);
                     $type = PluginSimcardSimcardType::transfer($item->fields["plugin_simcard_simcardtypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardtypes_id"] = $type;
                         $item->update($values);
                     }
                     // Size
                     $size = PluginSimcardSimcardSize::transfer($item->fields["plugin_simcard_simcardsizes_id"], $input['entities_id']);
                     if ($size > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardsizes_id"] = $size;
                         $item->update($values);
                     }
                     // Voltage
                     $voltage = PluginSimcardSimcardVoltage::transfer($item->fields["plugin_simcard_simcardvoltages_id"], $input['entities_id']);
                     if ($voltage > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardvoltages_id"] = $voltage;
                         $item->update($values);
                     }
                     // Phoneoperator
                     $phoneoperator = PluginSimcardPhoneOperator::transfer($item->fields["plugin_simcard_phoneoperators_id"], $input['entities_id']);
                     if ($phoneoperator > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_phoneoperators_id"] = $phoneoperator;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }