function cleanDBonPurge() { global $DB; $supplierjob = new Supplier_Ticket(); $supplierjob->cleanDBonItemDelete($this->getType(), $this->fields['id']); $ps = new Problem_Supplier(); $ps->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Change_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); $query1 = "DELETE\n FROM `glpi_projecttaskteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'"; $DB->query($query1); $query1 = "DELETE\n FROM `glpi_projectteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'"; $DB->query($query1); $cs = new Contract_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Contact_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); // Ticket rules use suppliers_id_assign Rule::cleanForItemAction($this, 'suppliers_id%'); }
if (isset($_POST['delete_user'])) { $problem_user = new Problem_User(); $problem_user->check($_POST['id'], 'd'); $problem_user->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { if (isset($_POST['delete_group'])) { $group_problem = new Group_Problem(); $group_problem->check($_POST['id'], 'd'); $group_problem->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { if (isset($_POST['delete_supplier'])) { $problem_supplier = new Problem_Supplier(); $problem_supplier->check($_POST['id'], 'd'); $problem_supplier->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { Html::header(Problem::getTypeName(2), $_SERVER['PHP_SELF'], "maintain", "problem"); $problem->showForm($_GET["id"], $_GET); Html::footer(); } } } } } } }
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. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * @since version 0.85 */ if (!defined('GLPI_ROOT')) { include '../inc/includes.php'; } $link = new Problem_Supplier(); Session::checkLoginUser(); Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']); if (isset($_POST["update"])) { $link->check($_POST["id"], UPDATE); $link->update($_POST); echo "<script type='text/javascript' >\n"; echo "window.parent.location.reload();"; echo "</script>"; } else { if (isset($_POST['delete'])) { $link->check($_POST['id'], DELETE); $link->delete($_POST); Event::log($link->fields['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $link->fields['problems_id']); } else {
/** * Transfer suppliers for specified tickets or problems * * @since version 0.84 * * @param $itemtype itemtype : Problem / Ticket * @param $ID original ticket ID * @param $newID new ticket ID **/ function transferLinkedSuppliers($itemtype, $ID, $newID) { global $DB; switch ($itemtype) { case 'Ticket': $table = 'glpi_suppliers_tickets'; $field = 'tickets_id'; $link = new Supplier_Ticket(); break; case 'Problem': $table = 'glpi_problems_suppliers'; $field = 'problems_id'; $link = new Problem_Supplier(); break; } $query = "SELECT *\n FROM `{$table}`\n WHERE `{$field}` = '{$ID}'"; if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { while ($data = $DB->fetch_assoc($result)) { $input = array(); if ($data['suppliers_id'] > 0) { $supplier = new Supplier(); if ($supplier->getFromDB($data['suppliers_id'])) { $newID = -1; $query = "SELECT *\n FROM `glpi_suppliers`\n WHERE `entities_id` = '" . $this->to . "'\n AND `name` = '" . addslashes($supplier->fields['name']) . "'"; if ($result_search = $DB->query($query)) { if ($DB->numrows($result_search) > 0) { $newID = $DB->result($result_search, 0, 'id'); } } if ($newID < 0) { // 1 - create new item unset($supplier->fields['id']); $input = $supplier->fields; $input['entities_id'] = $this->to; // Not set new entity Do by transferItem unset($supplier->fields); $newID = $supplier->add(toolbox::addslashes_deep($input)); } $input2['id'] = $data['id']; $input2[$field] = $ID; $input2['suppliers_id'] = $newID; $link->update($input2); } } } } } }
/** * Transfer suppliers for specified tickets or problems * * @since version 0.84 * * @param $itemtype itemtype : Problem / Ticket * @param $ID original ticket ID * @param $newID new ticket ID **/ function transferLinkedSuppliers($itemtype, $ID, $newID) { global $DB; switch ($itemtype) { case 'Ticket': $table = 'glpi_suppliers_tickets'; $field = 'tickets_id'; $link = new Supplier_Ticket(); break; case 'Problem': $table = 'glpi_problems_suppliers'; $field = 'problems_id'; $link = new Problem_Supplier(); break; } $query = "SELECT *\n FROM `{$table}`\n WHERE `{$field}` = '{$ID}'"; if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { while ($data = $DB->fetch_assoc($result)) { $input = array(); if ($data['suppliers_id'] > 0) { $supplier = new Supplier(); if ($supplier->getFromDB($data['suppliers_id'])) { $inputcat['entities_id'] = $this->to; $inputcat['name'] = addslashes($supplier->fields['name']); $catid = $supplier->findID($inputcat); if ($catid < 0) { $catid = $supplier->import($inputcat); } $input['id'] = $data['id']; $input[$field] = $ID; $input['suppliers_id'] = $catid; $link->update($input); } } } } } }