Added deletion of user ability
This commit is contained in:
parent
4beabd5df3
commit
7226890aa1
4
TODO
4
TODO
@ -9,7 +9,3 @@ install.php :
|
|||||||
=============
|
=============
|
||||||
* Link beside password field to toggle visible / not visible
|
* Link beside password field to toggle visible / not visible
|
||||||
* TRUNCATE before CREATE TABLE in install.php
|
* TRUNCATE before CREATE TABLE in install.php
|
||||||
|
|
||||||
index.php :
|
|
||||||
===========
|
|
||||||
* Delete user (+ check if not you)
|
|
||||||
|
@ -165,4 +165,27 @@ class Storage {
|
|||||||
|
|
||||||
$this->id = (!isset($this->id) ? $this->connection->lastInsertId() : $this->id);
|
$this->id = (!isset($this->id) ? $this->connection->lastInsertId() : $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
$query = 'DELETE FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' WHERE ';
|
||||||
|
|
||||||
|
$i = false;
|
||||||
|
foreach($this->fields as $field=>$type) {
|
||||||
|
if(!empty($this->$field)) {
|
||||||
|
if($i) { $query .= ' AND '; } else { $i = true; }
|
||||||
|
|
||||||
|
$query .= $field.'=:'.$field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->connection->prepare($query);
|
||||||
|
|
||||||
|
foreach($this->fields as $field=>$type) {
|
||||||
|
if(!empty($this->$field)) {
|
||||||
|
$query->bindParam(':'.$field, $this->$field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,9 +127,10 @@
|
|||||||
case 'delete_user':
|
case 'delete_user':
|
||||||
if($_GET['user_id'] != $current_user->getId()) {
|
if($_GET['user_id'] != $current_user->getId()) {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
|
$user->setId($_GET['user_id']);
|
||||||
$user->delete();
|
$user->delete();
|
||||||
|
|
||||||
header('location: index.php');
|
header('location: index.php?do=edit_users');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user