/** * @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; }
Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s adds an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } else { if (isset($_POST['addme_assign'])) { $ticket_user = new Ticket_User(); $track->check($_POST['tickets_id'], READ); $input = array('tickets_id' => $_POST['tickets_id'], 'users_id' => Session::getLoginUserID(), 'use_notification' => 1, 'type' => CommonITILActor::ASSIGN); $ticket_user->add($input); Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s adds an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } else { if (isset($_REQUEST['delete_document'])) { $document_item = new Document_Item(); $found_document_items = $document_item->find("itemtype = 'Ticket' " . " AND items_id = " . intval($_REQUEST['tickets_id']) . " AND documents_id = " . intval($_REQUEST['documents_id'])); foreach ($found_document_items as $item) { $document_item->delete($item, true); } Html::back(); } } } } } } } } } if (isset($_GET["id"]) && $_GET["id"] > 0) { if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { Html::helpHeader(Ticket::getTypeName(Session::getPluralNumber()), '', $_SESSION["glpiname"]); } else {
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"); $doc->showForm($_GET["id"]);