create ManageUserController and admin-only access
This commit is contained in:
parent
ddc47761d7
commit
fd9e25ca8c
25
Controllers/ManageUserController.php
Normal file
25
Controllers/ManageUserController.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
final class ManageUserController
|
||||
{
|
||||
|
||||
public static function admin_or_die(){
|
||||
Session::login_or_die();
|
||||
|
||||
$O_userModel = new UserModel();
|
||||
if (!$O_userModel->isUserAdmin($_SESSION["ID"])) {
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public function defaultAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
self::admin_or_die();
|
||||
}
|
||||
|
||||
public function searchAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -69,6 +69,18 @@ final class UserModel
|
||||
if ($row === false) return false;
|
||||
return $row["DISABLED"] !== 1;
|
||||
}
|
||||
|
||||
public function isUserAdmin($I_id)
|
||||
{
|
||||
$O_model = Model::get();
|
||||
$stmt = $O_model->prepare("SELECT ADMIN FROM USER WHERE ID=:id");
|
||||
$stmt->bindParam("id", $I_id);
|
||||
$stmt->execute();
|
||||
|
||||
$row = $stmt->fetch();
|
||||
if ($row === false) return false;
|
||||
return $row["ADMIN"] === 1;
|
||||
}
|
||||
|
||||
public function updateEmailByID($I_id, $S_newEmail){
|
||||
$O_model = Model::get();
|
||||
|
||||
4
Views/manageruser/default.php
Normal file
4
Views/manageruser/default.php
Normal file
@ -0,0 +1,4 @@
|
||||
<p> Default view </p>
|
||||
|
||||
<p> Please search : </p>
|
||||
<input> </input>
|
||||
Loading…
Reference in New Issue
Block a user