/** * Process POSTed form data. */ function POSTprocess() { global $post_action, $session; $processed = false; switch ($post_action) { // Posted project details form.. case "details_update": $this->chtype = $this->new_project ? "create" : "update"; // Some forced settings for QAMS.. $_POST["request_type"] = "90"; if ($this->new_project) { $_POST["status_code"] = "I"; // Make sure creator is always allocated initially.. $alloc = array(); if (isset($_POST["new_allocations"])) { $alloc = $_POST["new_allocations"]; } if (!in_array($session->user_no, $alloc)) { $alloc[] = $session->user_no; } $_POST["new_allocations"] = $alloc; } // Stash posted QAMS-specific stuff.. foreach ($this->post_fields as $posted_name) { if (isset($_POST["{$posted_name}"])) { $this->{$posted_name} = $_POST["{$posted_name}"]; } } // This will trigger a save.. $processed = true; break; // Posted project QA Plan form. This contains possible mods // to the required approvals per QA step.. // Posted project QA Plan form. This contains possible mods // to the required approvals per QA step.. case "config_update": // Process special notes updates.. $q = "SELECT * FROM qa_project_step"; $q .= " WHERE project_id={$this->request_id}"; $qry = new PgQuery($q); if ($qry->Exec("qa_project::POSTprocess") && $qry->rows > 0) { while ($row = $qry->Fetch()) { $step_id = $row->qa_step_id; $original_notes = stripslashes($row->notes); $new_notes = "special_notes_{$step_id}"; global ${$new_notes}; if (isset(${$new_notes}) && ${$new_notes} != $original_notes) { $q = "UPDATE qa_project_step"; $q .= " SET notes='" . addslashes(${$new_notes}) . "'"; $q .= " WHERE project_id={$this->request_id}"; $q .= " AND qa_step_id={$step_id}"; $up = new PgQuery($q); $up->Exec("qa_project::POSTprocess"); } } } // Process changes to approval types required.. $this->POSTprocess_approval_updates(); // Process removal of QA steps.. global $step_removals; if (isset($step_removals) && count($step_removals) > 0) { $remkeys = implode(",", $step_removals); $qry = new PgQuery("BEGIN"); $ok = $qry->Exec("qa_project::POSTprocess"); if ($ok) { $q = "DELETE FROM qa_project_approval"; $q .= " WHERE project_id={$this->request_id}"; $q .= " AND qa_step_id IN ({$remkeys})"; $qry = new PgQuery($q); $ok = $qry->Exec("qa_project::POSTprocess"); } if ($ok) { $q = "DELETE FROM qa_project_step_approval"; $q .= " WHERE project_id={$this->request_id}"; $q .= " AND qa_step_id IN ({$remkeys})"; $qry = new PgQuery($q); $ok = $qry->Exec("qa_project::POSTprocess"); } if ($ok) { $q = "DELETE FROM qa_project_step"; $q .= " WHERE project_id={$this->request_id}"; $q .= " AND qa_step_id IN ({$remkeys})"; $qry = new PgQuery($q); $ok = $qry->Exec("qa_project::POSTprocess"); } // Commit or rollback.. $qry = new PgQuery($ok ? "COMMIT;" : "ROLLBACK;"); $res = $qry->Exec("qa_project::POSTprocess"); } // Process addition of QA steps.. global $step_additions; if (isset($step_additions) && count($step_additions) > 0) { $_POST = array(); $this->get_project(); $this->get_allocated(); $this->get_interested(); foreach ($step_additions as $new_step_id) { $newstep = new qa_project_step($this->request_id); $newstep->get_step_data($new_step_id); $newstep->insert_into_project($this); } // foreach } break; } // switch global $action; if (isset($action)) { // Actions are usually activated by clickable links. Eg. removing // an interested user etc. We handle these here. The action will // make any DB mods it needs to make.. $this->Actions(true); } return $processed; }