function delete($id = FALSE) { if ($id) { $faq = new Faq($id); $faq->delete(); set_notify('success', lang('delete_data_complete')); } redirect($_SERVER['HTTP_REFERER']); }
break; case validateRoute('GET', 'faq'): $faq = new Faq($db, $user); httpResponse($faq->query()); break; case validateRoute('POST', 'faq'): $faq = new Faq($db, $user); httpResponse($faq->create($postdata)); break; case validateRoute('PATCH', 'faq/\\d+'): $faq = new Faq($db, $user); httpResponse($faq->update($params[1], $postdata)); break; case validateRoute('DELETE', 'faq/\\d+'): $faq = new Faq($db, $user); httpResponse($faq->delete($params[1])); break; case validateRoute('GET', 'polls'): $polls = new Polls($db, $user); httpResponse($polls->query()); break; case validateRoute('GET', 'polls/latest'): $polls = new Polls($db, $user); httpResponse($polls->getLatest()); break; case validateRoute('POST', 'polls/votes/\\d+'): $polls = new Polls($db, $user); httpResponse($polls->vote($params[2], (int) $postdata["choise"])); break; case validateRoute('POST', 'polls'): $forum = new Forum($db, $user);
$postVars = array('id'); // Form fields names //Validate the POST variables and add up to error message if empty foreach ($postVars as $postVar) { switch ($postVar) { default: $faqObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : ''; if ($faqObj->{$postVar} === "") { array_push($errorArr, "Please enter {$postVar} "); } break; } } //If validated and not empty submit it to database if (count($errorArr) < 1) { echo $faqObj->delete(); } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } if (filter_input(INPUT_POST, "addNewFaq") != NULL && filter_input(INPUT_POST, "addNewFaq") == "editFaq") { $postVars = array('id', 'question', 'answer'); // Form fields names //Validate the POST variables and add up to error message if empty foreach ($postVars as $postVar) { switch ($postVar) { default:
<?php // TODO: Uncomment include "access.php"; include_once "../includes/SystemConfiguration.class.php"; global $systemConfiguration; global $logger; // If we have id, then we are trying to delete if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; Faq::delete($id); } header("Location: faqs_list.php");