Merge pull request #81 from ThomasRubini/manage-user-controller
This commit is contained in:
commit
f030eff9c9
@ -5,12 +5,15 @@ final class ManageUserController
|
|||||||
|
|
||||||
public function defaultAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
public function defaultAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
|
Session::admin_or_die();
|
||||||
|
|
||||||
self::searchAction($A_urlParams, $A_postParams, $A_getParams);
|
self::searchAction($A_urlParams, $A_postParams, $A_getParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
Session::admin_or_die();
|
Session::admin_or_die();
|
||||||
|
|
||||||
if (isset($A_getParams["query"])) {
|
if (isset($A_getParams["query"])) {
|
||||||
self::searchQueryViewAction($A_urlParams, $A_postParams, $A_getParams);
|
self::searchQueryViewAction($A_urlParams, $A_postParams, $A_getParams);
|
||||||
} else {
|
} else {
|
||||||
@ -20,11 +23,15 @@ final class ManageUserController
|
|||||||
|
|
||||||
private function searchViewAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
private function searchViewAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
|
Session::admin_or_die();
|
||||||
|
|
||||||
View::show("manageUser/manage_users", array("QUERY" => null));
|
View::show("manageUser/manage_users", array("QUERY" => null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function searchQueryViewAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
private function searchQueryViewAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
|
Session::admin_or_die();
|
||||||
|
|
||||||
$S_query = $A_getParams["query"];
|
$S_query = $A_getParams["query"];
|
||||||
|
|
||||||
$A_results = UserModel::searchUsers($S_query);
|
$A_results = UserModel::searchUsers($S_query);
|
||||||
@ -35,4 +42,24 @@ final class ManageUserController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
|
{
|
||||||
|
Session::admin_or_die();
|
||||||
|
|
||||||
|
$I_user_id = Utils::intOrDie(Utils::getOrDie($A_postParams, "user_id"));
|
||||||
|
$O_user = UserModel::getByID($I_user_id);
|
||||||
|
|
||||||
|
if (isset($A_postParams["enable"])) {
|
||||||
|
$O_user->B_DISABLED = 0;
|
||||||
|
$O_user->update();
|
||||||
|
}else if (isset($A_postParams["disable"])) {
|
||||||
|
$O_user->B_DISABLED = 1;
|
||||||
|
$O_user->update();
|
||||||
|
}else if (isset($A_postParams["delete"])) {
|
||||||
|
$O_user->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ final class UserModel extends UserSessionModel
|
|||||||
}
|
}
|
||||||
public function update(){
|
public function update(){
|
||||||
$O_model = Model::get();
|
$O_model = Model::get();
|
||||||
$stmt = $O_model->prepare("UPDATE USER SET EMAIL=:email, USERNAME=:username, PASSWORD_HASH=:password_hash, FIRST_SEEN:first_seen, LAST_SEEN:last_seen, ADMIN=:admin, DISABLED=:disabled WHERE ID=:id");
|
$stmt = $O_model->prepare("UPDATE USER SET EMAIL=:email, USERNAME=:username, PASS_HASH=:password_hash, FIRST_SEEN=:first_seen, LAST_SEEN=:last_seen, ADMIN=:admin, DISABLED=:disabled WHERE ID=:id");
|
||||||
$stmt->bindParam("id", $this->I_ID);
|
$stmt->bindParam("id", $this->I_ID);
|
||||||
$stmt->bindParam("email", $this->S_EMAIL);
|
$stmt->bindParam("email", $this->S_EMAIL);
|
||||||
$stmt->bindParam("username", $this->S_USERNAME);
|
$stmt->bindParam("username", $this->S_USERNAME);
|
||||||
|
|||||||
@ -24,15 +24,16 @@
|
|||||||
<img class="user_acccount_picture" src=' . $O_user->getProfilePicLink() . ' alt="Photo de profil de ' . $O_user->S_USERNAME . '">
|
<img class="user_acccount_picture" src=' . $O_user->getProfilePicLink() . ' alt="Photo de profil de ' . $O_user->S_USERNAME . '">
|
||||||
<h3 class="user_account_name">' . $O_user->S_USERNAME . '</h3>
|
<h3 class="user_account_name">' . $O_user->S_USERNAME . '</h3>
|
||||||
</li>';
|
</li>';
|
||||||
|
|
||||||
|
echo '</ul>
|
||||||
|
<form method="POST" action="/manageUser/update">
|
||||||
|
<input type="hidden" name="user_id" value="'.$O_user->I_ID.'" id="accounts_to_manage">
|
||||||
|
<input type="submit" name="enable" value="Activer">
|
||||||
|
<input type="submit" name="disable" value="Désactiver">
|
||||||
|
<input type="submit" name="delete" value="Supprimer">
|
||||||
|
</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</ul>
|
|
||||||
<form method="POST" action="manage_users">
|
|
||||||
<input id="accounts_to_manage" type="text" hidden>
|
|
||||||
<input type="submit" name="enable" value="Activer">
|
|
||||||
<input type="submit" name="disable" value="Désactiver">
|
|
||||||
<input type="submit" value="Supprimer">
|
|
||||||
</form>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user