public function ajax() { $id = awpcp_post_param('id', 0); try { $listing = awpcp_listings_collection()->get($id); } catch (AWPCP_Exception $e) { $message = _x("The specified Ad doesn't exists.", 'ajax delete ad', 'AWPCP'); $response = json_encode(array('status' => 'error', 'message' => $message)); return $this->ajax_response($response); } if (!awpcp_listing_authorization()->is_current_user_allowed_to_edit_listing($listing)) { return false; } $errors = array(); if (isset($_POST['remove'])) { $result = deletead($id, $adkey = '', $editemail = '', $force = true, $errors); if (empty($errors)) { $response = json_encode(array('status' => 'success')); } else { $response = json_encode(array('status' => 'error', 'message' => join('<br/>', $errors))); } } else { $columns = 10; ob_start(); include AWPCP_DIR . '/admin/templates/delete_form.tpl.php'; $html = ob_get_contents(); ob_end_clean(); $response = json_encode(array('status' => 'success', 'html' => $html)); } return $this->ajax_response($response); }
// Deletes the specific ad you chose function deletead($dbc) { $deleteid = Input::get('adid'); $deletequery = $dbc->prepare('DELETE FROM ads WHERE id = :id'); $deletequery->bindValue(':id', $deleteid, PDO::PARAM_INT); $deletequery->execute(); header("location: users.show.php"); die; } // Decides when to run the deletion functions if (Input::notempty('id')) { deleteprofile($dbc); } if (Input::notempty('adid')) { deletead($dbc); } ?> <!DOCTYPE html> <!-- Carried over from the index --> <html lang="en"> <?php require_once '../views/header.php'; ?> <body class = "meetColor"> <?php require_once '../views/navbar.php'; ?> <!-- Your username, box, and icon --> <div class="container"> <div class ="row">