userlist works, show reply works, also possible to change the permissions of the users (though relying on the libs permission system atm..)

This commit is contained in:
Quitta 2013-09-05 04:16:28 +02:00
parent 4e36f5575d
commit 5eb052da4b
10 changed files with 209 additions and 11 deletions

View file

@ -207,7 +207,7 @@ class WebUsers extends Users{
} }
public static function getAllUsersQuery(){ public static function getAllUsersQuery(){
return "SELECT * FROM ams_user"; return "SELECT * FROM users WHERE `uid` > 0";
} }
public static function createWebuser($name, $pass, $mail){ public static function createWebuser($name, $pass, $mail){

View file

@ -8,9 +8,9 @@
$cfg['db']['web']['host'] = variable_get('ryzommanage_webserverurl', 'localhost'); $cfg['db']['web']['host'] = variable_get('ryzommanage_webserverurl', 'localhost');
$cfg['db']['web']['port'] = variable_get('ryzommanage_webmysqlport', '3306'); $cfg['db']['web']['port'] = variable_get('ryzommanage_webmysqlport', '3306');
$cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'ryzom_ams'); $cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'drupal');
$cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'shard'); $cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'root');
$cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', ''); $cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', 'lol123');
$cfg['db']['lib']['host'] = variable_get('ryzommanage_libserverurl', 'localhost'); $cfg['db']['lib']['host'] = variable_get('ryzommanage_libserverurl', 'localhost');
$cfg['db']['lib']['port'] = variable_get('ryzommanage_libmysqlport', '3306'); $cfg['db']['lib']['port'] = variable_get('ryzommanage_libmysqlport', '3306');

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -556,7 +556,7 @@ function top_bar()
if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){ if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> | return "<div class='ryzomuserbar'><a href='ams?page=show_user&id=".$userId."'>Profile</a> |
<a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> | <a href='ams?page=createticket&id=".$userId."'>Create Ticket</a> |
<a href='/user/".$userId."/edit'>Settings</a> | <a href='ams?page=userlist".$userId."'>Users</a> | <a href='/user/".$userId."/edit'>Settings</a> | <a href='ams?page=userlist'>Users</a> |
<a href='ams?page=show_queue&get=todo'>Queues</a> | <a href='ams?page=show_queue&get=todo'>Queues</a> |
<a href='ams?page=sgroup_list'>Support Groups</a> | <a href='/user/logout'>Logout</a></div>"; <a href='ams?page=sgroup_list'>Support Groups</a> | <a href='/user/logout'>Logout</a></div>";

View file

@ -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}

View file

@ -96,13 +96,13 @@
{if $ticket_forwardedGroupName eq "0"} {if $ticket_forwardedGroupName eq "0"}
<i>{$public_sgroup}</i> <i>{$public_sgroup}</i>
{else} {else}
<a href="index.php?page=show_sgroup&id={$ticket_forwardedGroupId}">{$ticket_forwardedGroupName}</a> <a href="ams?page=show_sgroup&id={$ticket_forwardedGroupId}">{$ticket_forwardedGroupName}</a>
{/if} {/if}
</span> </span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width=33%><strong>Assigned To: </strong>{if $ticket_assignedTo neq ""} <a href="index.php?page=show_user&id={$ticket_assignedTo}">{$ticket_assignedToText}</a> {else}<i> {$not_assigned}</i> {/if}</td> <td width=33%><strong>Assigned To: </strong>{if $ticket_assignedTo neq ""} <a href="ams?page=show_user&id={$ticket_assignedTo}">{$ticket_assignedToText}</a> {else}<i> {$not_assigned}</i> {/if}</td>
<td width=33%></td> <td width=33%></td>
<td width=33%></td> <td width=33%></td>
</tr> </tr>
@ -117,9 +117,9 @@
<p> <p>
<font color="blue"> {$reply.timestamp}</font> <font color="blue"> {$reply.timestamp}</font>
{if $reply.permission eq '1'} {if $reply.permission eq '1'}
<span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="index.php?page=show_user&id={$reply.authorExtern}"> {$reply.author}{else} {$reply.author} {/if}</a></strong></span> <span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}"> {$reply.author}{else} {$reply.author} {/if}</a></strong></span>
{else if $reply.permission gt '1'} {else if $reply.permission gt '1'}
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="index.php?page=show_user&id={$reply.authorExtern}">{$reply.author}{else} {$reply.author} {/if}</a></strong></span> <span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}">{$reply.author}{else} {$reply.author} {/if}</a></strong></span>
{/if} {/if}
</p> </p>
<p><pre{if $reply.permission gt '1'} {if $reply.hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $reply.hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $reply.hidden eq 1}<i>{/if}{$reply.replyContent}{if $reply.hidden eq 1}</i>{/if}</pre></p> <p><pre{if $reply.permission gt '1'} {if $reply.hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $reply.hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $reply.hidden eq 1}<i>{/if}{$reply.replyContent}{if $reply.hidden eq 1}</i>{/if}</pre></p>

View file

@ -63,8 +63,6 @@
<h2><i class="icon-tag"></i> Tickets of {$target_name}</h2> <h2><i class="icon-tag"></i> Tickets of {$target_name}</h2>
<legend>Tickets</legend>
<table> <table>
<thead> <thead>
<tr> <tr>

View file

@ -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">&laquo;</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}">&raquo;</a>
</center>
{/block}