/** * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case "add_document": case "add_document_item": $documentitem = new Document_Item(); foreach ($input["item"] as $key => $val) { if (isset($input['items_id'])) { // Add items to documents $input2 = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'documents_id' => $key); } else { if (isset($input['documents_id'])) { // Add document to item $input2 = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'documents_id' => $input['documents_id']); } else { return false; } } if ($documentitem->can(-1, 'w', $input2)) { if ($documentitem->add($input2)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } break; case "remove_document": case "remove_document_item": foreach ($input["item"] as $key => $val) { if (isset($input['items_id'])) { // Remove item to documents $input2 = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'documents_id' => $key); } else { if (isset($input['documents_id'])) { // Remove contract to items $input2 = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'documents_id' => $input['documents_id']); } else { return false; } } $docitem = new Document_Item(); if ($docitem->can(-1, 'w', $input2)) { if ($item = getItemForItemtype($input2["itemtype"])) { if ($item->getFromDB($input2['items_id'])) { $doc = new self(); if ($doc->getFromDB($input2['documents_id'])) { if ($docitem->getFromDBForItems($doc, $item)) { if ($docitem->delete(array('id' => $docitem->getID()))) { $res['ok']++; } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['noright']++; } } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
$input['entities_id'] = $_POST['entities_id']; $input['profiles_id'] = $_POST['profiles_id']; $input['is_recursive'] = $_POST['is_recursive']; foreach ($_POST["item"] as $key => $val) { if ($val == 1) { $input['users_id'] = $key; $right->add($input); } } } break; case "add_document": $documentitem = new Document_Item(); foreach ($_POST["item"] as $key => $val) { $input = array('itemtype' => $_POST["itemtype"], 'items_id' => $key, 'documents_id' => $_POST['docID']); if ($documentitem->can(-1, 'w', $input)) { $documentitem->add($input); } } break; case "add_contact": if ($_POST["itemtype"] == 'Supplier') { $contactsupplier = new Contact_Supplier(); foreach ($_POST["item"] as $key => $val) { $input = array('suppliers_id' => $key, 'contacts_id' => $_POST['conID']); if ($contactsupplier->can(-1, 'w', $input)) { $contactsupplier->add($input); } } } break;
if ($doc->update($_POST)) { Event::log($_POST["id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][21]); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["adddocumentitem"])) { $documentitem->check(-1, 'w', $_POST); if ($documentitem->add($_POST)) { Event::log($_POST["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][32]); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["deletedocumentitem"])) { if (isset($_POST["item"]) && count($_POST["item"])) { foreach ($_POST["item"] as $key => $val) { if ($documentitem->can($key, 'w')) { $documentitem->delete(array('id' => $key)); } } } Event::log($_POST["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][33]); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_GET["deletedocumentitem"]) && isset($_GET["documents_id"]) && isset($_GET["id"])) { $documentitem->check($_GET["id"], 'w'); if ($documentitem->delete(array('id' => $_GET["id"]))) { Event::log($_GET["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][33]); } glpi_header($_SERVER['HTTP_REFERER']); } else { commonHeader($LANG['Menu'][27], $_SERVER['PHP_SELF'], "financial", "document");