static function submit() { // store data posted by the form in the session so it // is still available in case of redirection to the same form $_SESSION['activation_editmap'] = $_POST; // retrieve model instance $model = ActivationModel::getInstance(); // save or create the record $result = $model->save($_POST); $code = substr($result, 0, 2); if ($code == "OK") { $newRecord = $_POST['id'] == 0; // if this was a new record, show only this record in the list // if this was an existing record, keep the previous filter if ($newRecord) { $newId = substr($result, 2, strlen($result) - 2); $filter = "id=" . $newId; } else { $filter = $_SESSION['last_activations_filter']; } // redirect to the list ActivationsController::listRows($filter); } else { // redirect to the edit page with error message $result = str_replace("\n", "<br>", $result); // no newlines in headers! header("Location: activation_edit.php?error=" . $result); } }
// clear the search map stored in the session unset($_SESSION['activation_search_map']); // retrieve the last filter from the session $filter = $_SESSION['last_activations_filter']; } // search button was pressed if (isset($map['search'])) { // store search data in the session $_SESSION['activation_search_map'] = $map; // create a filter $filter = ActivationModel::createFilter($map); // store the last filter in the session $_SESSION['last_activations_filter'] = $filter; } // list the rows using the filter ActivationsController::listRows($filter); break; // toggle the search box visibility // toggle the search box visibility case 'togglesearch': // invert the session variable if ($_SESSION['hide_activation_searchbox'] == "false") { $_SESSION['hide_activation_searchbox'] = "true"; } else { $_SESSION['hide_activation_searchbox'] = "false"; } // redirect to the activations page header("Location: activations.php"); default: break; }