Added user deletion.
User is deleted from database the Comments are deleted too, unknown reason for me Noting else is deleted so far.
This commit is contained in:
parent
557a82e7be
commit
8eaaa6a7ca
@ -144,6 +144,9 @@ class UserPage extends SimpleExtension {
|
|||||||
// join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
|
// join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
|
||||||
$this->theme->display_user_list($page, User::by_list(0), $user);
|
$this->theme->display_user_list($page, User::by_list(0), $user);
|
||||||
}
|
}
|
||||||
|
else if($event->get_arg(0) == "delete_user") {
|
||||||
|
$this->delete_user($page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
|
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
|
||||||
@ -463,6 +466,32 @@ class UserPage extends SimpleExtension {
|
|||||||
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function delete_user($page) {
|
||||||
|
global $user;
|
||||||
|
global $config;
|
||||||
|
global $database;
|
||||||
|
|
||||||
|
$page->set_title("Error");
|
||||||
|
$page->set_heading("Error");
|
||||||
|
$page->add_block(new NavBlock());
|
||||||
|
|
||||||
|
if (!$user->is_admin()) {
|
||||||
|
$page->add_block(new Block("Not Admin", "Only admins can delete accounts"));
|
||||||
|
}
|
||||||
|
else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) {
|
||||||
|
$page->add_block(new Block("No ID Specified",
|
||||||
|
"You need to specify the account number to edit"));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$database->execute("DELETE FROM users
|
||||||
|
WHERE id = :id"
|
||||||
|
, array("id"=>$_POST['id']));
|
||||||
|
}
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link("post/list"));
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
add_event_listener(new UserPage());
|
add_event_listener(new UserPage());
|
||||||
|
@ -181,6 +181,11 @@ class UserPageTheme extends Themelet {
|
|||||||
<input type='submit' value='Set'>
|
<input type='submit' value='Set'>
|
||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
|
$html .="
|
||||||
|
<p>".make_form(make_link("user_admin/delete_user"))."
|
||||||
|
<input type='hidden' name='id' value='$i_user_id'>
|
||||||
|
<input type='submit' value='Delete User' onclick='confirm(\"Delete the user?\");' />
|
||||||
|
</form>";
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user