mirror of
https://github.com/glmdev/eecs448-lab10
synced 2026-03-02 03:39:24 +00:00
Initial commit
This commit is contained in:
24
DeletePost.php
Normal file
24
DeletePost.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require './configuration.php';
|
||||
|
||||
$request = common\Request::capture();
|
||||
$page = new common\Page;
|
||||
$posts = new app\PostRepository;
|
||||
|
||||
$post_ids = [];
|
||||
foreach ( $request->input() as $post_key => $value ) {
|
||||
if ( $value !== 'yes' ) continue;
|
||||
|
||||
$post_id = explode('-', $post_key)[1];
|
||||
$post_ids[] = $post_id;
|
||||
|
||||
$posts->delete(['post_id' => $post_id]);
|
||||
}
|
||||
|
||||
$page->title('EECS 448 Lab 10 - Exercise 7')
|
||||
->header('Posts Deleted')
|
||||
->writes('<p>Posts with the following IDs were deleted: ' . implode(', ', $post_ids) . '</p>')
|
||||
->writes('<a href="' . system_url('AdminHome.html') . '">Admin Home</a>');
|
||||
|
||||
$page->write();
|
||||
Reference in New Issue
Block a user