userlist works, show reply works, also possible to change the permissions of the users (though relying on the libs permission system atm..)
--HG-- branch : quitta-gsoc-2013hg/feature/sse2
parent
d86f3cf755
commit
9362db15c2
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
function change_permission(){
|
||||
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if(ticket_user::isAdmin(unserialize($_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(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value);
|
||||
header("Location: ams?page=show_user&id=".$user_id);
|
||||
exit;
|
||||
|
||||
|
||||
}else{
|
||||
//ERROR: GET PARAMS not given or trying to change admin
|
||||
header("Location: ams?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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
function show_reply(){
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
|
||||
|
||||
$result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$reply = new Ticket_Reply();
|
||||
$reply->load_With_TReplyId($result['reply_id']);
|
||||
|
||||
|
||||
$ticket = new Ticket();
|
||||
$ticket->load_With_TId($reply->getTicket());
|
||||
|
||||
if(( $ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && ! $reply->getHidden()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){
|
||||
$content = new Ticket_Content();
|
||||
$content->load_With_TContentId($reply->getContent());
|
||||
|
||||
$author = new Ticket_User();
|
||||
$author->load_With_TUserId($reply->getAuthor());
|
||||
|
||||
$result['hidden'] = $reply->getHidden();
|
||||
$result['ticket_id'] = $reply->getTicket();
|
||||
$result['reply_timestamp'] = $reply->getTimestamp();
|
||||
$result['author_permission'] = $author->getPermission();
|
||||
$result['reply_content'] = $content->getContent();
|
||||
$result['author'] = $author->getExternId();
|
||||
$webUser = new WebUsers($author->getExternId());
|
||||
$result['authorName'] = $webUser->getUsername();
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
$result['isMod'] = "TRUE";
|
||||
}
|
||||
return $result;
|
||||
|
||||
}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;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
function userlist(){
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
|
||||
$pagination = new Pagination(WebUsers::getAllUsersQuery(),"web",10,"WebUsers");
|
||||
$pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email"));
|
||||
$pageResult['links'] = $pagination->getLinks(5);
|
||||
$pageResult['lastPage'] = $pagination->getLast();
|
||||
$pageResult['currentPage'] = $pagination->getCurrent();
|
||||
|
||||
$i = 0;
|
||||
foreach( $pageResult['userlist'] as $user ){
|
||||
$pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission();
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$pageResult['isAdmin'] = "TRUE";
|
||||
}
|
||||
return $pageResult;
|
||||
}else{
|
||||
//ERROR: No access!
|
||||
$_SESSION['error_code'] = "403";
|
||||
header("Location: index.php?page=error");
|
||||
exit;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
{block name=content}
|
||||
<h1>Show Reply</h1>
|
||||
|
||||
<h2>Reply ID#{$reply_id} of Ticket <a href="ams?page=show_ticket&id={$ticket_id}">#{$ticket_id}</a></h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<p><font color="blue"> {$reply_timestamp}</font>
|
||||
{if $author_permission eq '1'}
|
||||
<span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$author}">{$authorName}{else} {$authorName} {/if}</a></strong></span></p>
|
||||
{else if $author_permission gt '1'}
|
||||
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$author}">{$authorName}{else} {$authorName} {/if}</a></strong></span></p>
|
||||
{/if}
|
||||
<p><pre{if $author_permission gt '1'} {if $hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $hidden eq 1}<i>{/if}{$reply_content}{if $hidden eq 1}</i>{/if}</pre></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
{/block}
|
||||
|
@ -0,0 +1,62 @@
|
||||
{block name=content}
|
||||
<h1Members</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Permission</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$userlist item=element}
|
||||
<tr>
|
||||
<td>{$element.id}</td>
|
||||
<td class="center"><a href="ams?page=show_user&id={$element.id}">{$element.username}</a></td>
|
||||
<td class="center">{$element.email}</td>
|
||||
{if $element.permission eq 1}<td class="center"><font color="green">User</font></td>{/if}
|
||||
{if $element.permission eq 2}<td class="center"><font color="orange">Moderator</font></td>{/if}
|
||||
{if $element.permission eq 3}<td class="center"><font color="red">Admin</font></td>{/if}
|
||||
<td class="center">
|
||||
<table>
|
||||
<tr><td>
|
||||
<a class="btn btn-primary" href="ams?page=show_user&id={$element.id}"><i class=" icon-eye-open icon-white"></i> Show User</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-info" href="ams?page=settings&id={$element.id}"><i class=" icon-pencil icon-white"></i> Edit User</a>
|
||||
</td>
|
||||
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $element.id neq 1}
|
||||
|
||||
{if $element.permission eq 1}
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=2">Make Moderator</a></td>
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=3">Make Admin</a></td>
|
||||
{else if $element.permission eq 2 }
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=1">Demote to User</a></td>
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=3">Make Admin</a></td>
|
||||
{else if $element.permission eq 3 }
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=1">Demote to User</a></td>
|
||||
<td><a href="ams?page=change_permission&user_id={$element.id}&value=2">Demote to Moderator</a></td>
|
||||
{/if}
|
||||
{/if}
|
||||
<tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<center>
|
||||
|
||||
<a href="ams?page=userlist&pagenum=1">«</a> |
|
||||
{foreach from=$links item=link}
|
||||
<a href="ams?page=userlist&pagenum={$link}">{if $link == $currentPage}<u>{/if}{$link}{if $link == $currentPage}</u>{/if}</a> |
|
||||
{/foreach}
|
||||
<a href="ams?page=userlist&pagenum={$lastPage}">»</a>
|
||||
|
||||
</center>
|
||||
|
||||
{/block}
|
||||
|
Loading…
Reference in New Issue