mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-24 09:48:46 +00:00
Promoting a user to mod/admin or mod to admin, or demoting mod to user, admin to mod/user is now possible!
This commit is contained in:
parent
a74de873c3
commit
6ec1450d26
4 changed files with 62 additions and 0 deletions
|
@ -51,6 +51,12 @@ class Ticket_User{
|
|||
|
||||
}
|
||||
|
||||
public static function change_permission($user_id, $perm){
|
||||
$user = new Ticket_User();
|
||||
$user->load_With_TUserId($user_id);
|
||||
$user->setPermission($perm);
|
||||
$user->update();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////Methods////////////////////////////////////////////////////
|
||||
public function __construct() {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
function change_permission(){
|
||||
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if(ticket_user::isAdmin($_SESSION['ticket_user'])){
|
||||
|
||||
if(isset($_GET['user_id']) && isset($_GET['value']) && $_GET['user_id'] != 1 && $_GET['value'] < 4 ){
|
||||
$user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT);
|
||||
Ticket_User::change_permission($user_id, $value);
|
||||
header("Location: index.php?page=show_user&id=".$user_id);
|
||||
exit;
|
||||
|
||||
|
||||
}else{
|
||||
//ERROR: GET PARAMS not given or trying to change admin
|
||||
header("Location: index.php?page=show_user&id=".$user_id);
|
||||
exit;
|
||||
}
|
||||
|
||||
}else{
|
||||
//ERROR: No access!
|
||||
$_SESSION['error_code'] = "403";
|
||||
header("Location: index.php?page=error");
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
//ERROR: not logged in!
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -21,6 +21,9 @@ function show_user(){
|
|||
|
||||
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
|
||||
$result['userPermission'] = $ticket_user->getPermission();
|
||||
if(Ticket_User::isAdmin($_SESSION['ticket_user'])){
|
||||
$result['isAdmin'] = "TRUE";
|
||||
}
|
||||
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
|
||||
|
||||
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category"));
|
||||
|
|
|
@ -77,6 +77,20 @@
|
|||
<li><a href="index.php?page=settings&id={$target_id}">Edit User</a></li>
|
||||
<li><a href="index.php?page=createticket&user_id={$target_id}">Send Ticket</a></li>
|
||||
<li class="divider"></li>
|
||||
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1}
|
||||
{if $userPermission eq 1}
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Make Moderator</a></li>
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
|
||||
{else if $userPermission eq 2 }
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
|
||||
{else if $userPermission eq 3 }
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
|
||||
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Demote to Moderator</a></li>
|
||||
{/if}
|
||||
<li class="divider"></li>
|
||||
{/if}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue