added a userlist to browse users and edit their settings as admin
This commit is contained in:
parent
128529c6c1
commit
ebca9d0a48
6 changed files with 85 additions and 26 deletions
|
@ -123,4 +123,10 @@ class WebUsers extends Users{
|
|||
return $reply;
|
||||
}
|
||||
|
||||
public function getUsers(){
|
||||
global $cfg;
|
||||
$dbl = new DBLayer($cfg['db']['web']);
|
||||
$data = $dbl->executeWithoutParams("SELECT * FROM ams_user");
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -32,7 +32,11 @@ function change_info(){
|
|||
$values['fName'] = $_POST['FirstName'];
|
||||
}
|
||||
if(($_POST['LastName'] != "") && ($_POST['LastName'] != $current_info['LastName'])){
|
||||
$query = $query . "LastName = :lName ";
|
||||
if($updated){
|
||||
$query = $query . ", LastName = :lName ";
|
||||
}else{
|
||||
$query = $query . "LastName = :lName ";
|
||||
}
|
||||
$updated = true;
|
||||
$values['lName'] = $_POST['LastName'];
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@ function settings(){
|
|||
if(WebUsers::isLoggedIn()){
|
||||
//in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
|
||||
if(isset($_GET['id'])){
|
||||
$result = WebUsers::getInfo($_GET['id']);
|
||||
if(WebUsers::isAdmin() && ($_GET['id']!= $_SESSION['id'])){
|
||||
$result['isAdmin'] = "TRUE";
|
||||
if(($_GET['id'] != $_SESSION['id']) && (!WebUsers::isAdmin()) ){
|
||||
print('No permission to see this page!');
|
||||
exit;
|
||||
}else{
|
||||
$result = WebUsers::getInfo($_GET['id']);
|
||||
if(WebUsers::isAdmin() && ($_GET['id']!= $_SESSION['id'])){
|
||||
$result['isAdmin'] = "TRUE";
|
||||
}
|
||||
$result['target_id'] = $_GET['id'];
|
||||
$result['current_mail'] = WebUsers::getEmail($_GET['id']);
|
||||
}
|
||||
$result['target_id'] = $_GET['id'];
|
||||
$result['current_mail'] = WebUsers::getEmail($_GET['id']);
|
||||
}else{
|
||||
$result = WebUsers::getInfo($_SESSION['id']);
|
||||
$result['target_id'] = $_SESSION['id'];
|
||||
|
|
20
code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php
Normal file
20
code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
function userlist(){
|
||||
if(WebUsers::isAdmin()){
|
||||
$users = WebUsers::getUsers();
|
||||
$i = 0;
|
||||
$pageResult['userlist'] = Array();
|
||||
while($row = $users->fetch(PDO::FETCH_ASSOC)){
|
||||
$pageResult['userlist'][$i]['id'] = $row['UId'];
|
||||
$pageResult['userlist'][$i]['username'] = $row['Login'];
|
||||
$pageResult['userlist'][$i]['permission'] = $row['Permission'];
|
||||
$pageResult['userlist'][$i]['email'] = $row['Email'];
|
||||
$i++;
|
||||
}
|
||||
return $pageResult;
|
||||
}else{
|
||||
print('no permission');
|
||||
exit;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li>
|
||||
<li class="nav-header hidden-tablet">Admin</li>
|
||||
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=libuserlist"><i class="icon-th-list"></i><span class="hidden-tablet"> Liblist</span></a></li>
|
||||
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=userlist"><i class="icon-th-list"></i><span class="hidden-tablet"> UserList</span></a></li>
|
||||
<li class="nav-header hidden-tablet">Actions</li>
|
||||
<li style="margin-left: -2px;"><a href="?page=logout"><i class="icon-off"></i><span class="hidden-tablet"> Logout </span></a></li>
|
||||
|
||||
|
|
|
@ -1,22 +1,45 @@
|
|||
{block name=content}
|
||||
<div class="row-fluid">
|
||||
<div class="box span12">
|
||||
<div class="box-header well" data-original-title>
|
||||
<h2><i class="icon-user"></i> Members</h2>
|
||||
<div class="box-icon">
|
||||
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
|
||||
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
|
||||
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<table class="table table-striped table-bordered bootstrap-datatable datatable">
|
||||
<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">{$element.username}</td>
|
||||
<td class="center">{$element.email}</td>
|
||||
{if $element.permission eq 1}<td class="center"><span class="label label-success">User</span></td>{/if}
|
||||
{if $element.permission eq 2}<td class="center"><span class="label label-warning">Admin</span></td>{/if}
|
||||
<td class="center">
|
||||
<a class="btn btn-info" href="index.php?page=settings&id={$element.id}"><i class=" icon-pencil icon-white"></i>Edit User</a>
|
||||
</td>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="box span12">
|
||||
<div class="box-header well">
|
||||
<h2><i class="icon-info-sign"></i> {$userlist_info}</h2>
|
||||
<div class="box-icon">
|
||||
<a href="#" class="btn btn-round" onclick="javascript:show_help('intro');return false;"><i class="icon-info-sign"></i></a>
|
||||
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
|
||||
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
|
||||
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<p><strong>The shard/lib/web db user list</strong> You are about to see it here!</p>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!--/span-->
|
||||
|
||||
</div><!--/row-->
|
||||
{/block}
|
||||
|
||||
|
|
Loading…
Reference in a new issue