<?php
// include libraries
require_once("../setup.php");
if($logged_in != 1) { //not logged
error_catcher(1);
exit;
}else{
// check if the user can access the page
authorized_to_access_page('manage_users');
//Get user list from DB
$users_list = users();
if($users_list=="DBError"){
error_catcher(4);
exit;
}else{
print(" <script language='JavaScript'>
function del(id){
if(confirm(\"".get_string('script', 'ScriptDeleteUserConfirmation')."\")){
location.href=\"../admin/delete_user.php?userid=\"+id;
}
}
</script>");
?>
<div id="content_area">
<p class="pagetitle"><?php echo get_string('home', 'ManageUsersListPageTitle'); ?></p>
<!-- In shibboleth mode users cannot be added -->
<?php if($_SESSION['auth_type'] == "local"){ ?>
<p class="pagesubtitle"><?php echo get_string('home', 'ManageUsersListAddNewOne'); ?></p>
<p style="margin-left: 20px; color: #000000;"><a href="../home/home.php?action=add"><?php echo get_string('home', 'ManageUsersListAddNewUser'); ?></a></p>
<?php
}
$users = count($users_list);
if(count($users_list)<=1){
?>
<p class="pagesubtitle"><?php echo get_string('home', 'ManageUsersListExistingOnes'); ?></p>
<p style="margin-left: 20px; color: #000000;"><?php echo get_string('home', 'ManageUsersListNoOtherUsersMessage'); ?></p>
<?php
}else{
?>
<p class="pagesubtitle"><?php echo get_string('home', 'ManageUsersListExistingOnes'); ?></p>
<!-- Users's table, deactivated accounts in red -->
<table id="sortabletable" class="sortable txt table_list" width="530" cellpadding="2" cellspacing="0">
<tr>
<th width="80"><nobr><?php echo get_string('home', 'ManageUsersUsername'); ?></nobr></th>
<th width="90"><nobr><?php echo get_string('home', 'ManageUsersFirstName'); ?></nobr></th>
<th width="90"><nobr><?php echo get_string('home', 'ManageUsersLastName'); ?></nobr></th>
<th width="70"><nobr><?php echo get_string('home', 'ManageUsersInstitute'); ?></nobr></th>
<th width="50" align="center"><nobr><?php echo get_string('home', 'ManageUsersEmail'); ?></nobr></th>
<th width="50" align="center"><nobr><?php echo get_string('home', 'ManageUsersPreferredLanguage'); ?></nobr></th>
<th width="50"><nobr><?php echo get_string('home', 'ManageUsersType'); ?></nobr></th>
<th align="center" class="unsortable"><nobr><?php echo get_string('home', 'ManageUsersListActions'); ?></nobr></th>
</tr>
<?php
}
if(count($users_list)!=0){
foreach($users_list as $user){
//We don't print the current user
if($user['username'] !=$_SESSION['username']){
$class = ($user['active']) ? "txt" : "deleted_light";
$available_languages = get_available_languages();
?>
<tr>
<!-- username filed, printed for non-shibboleth users -->
<td class="<?php echo $class; ?>">
<?php
if($user['pwd']!="")
echo $user['username'];
else
echo "* * * * *";
?>
</td>
<!-- First name field -->
<td class="<?php echo $class; ?>"><?php echo $user['firstname']; ?></td>
<!-- Last name field -->
<td class="<?php echo $class; ?>"><?php echo $user['lastname']; ?></td>
<!-- Institute field -->
<td class="<?php echo $class; ?>"><?php echo $user['institute']; ?></td>
<!-- Email field (image) -->
<td align="center"><a href="mailto:<?php echo htmlspecialchars($user['email']); ?>"><IMG src="../images/email.gif" title="<?php echo get_string('home', 'ManageUsersListEmailMessage') . ' ' . htmlspecialchars($user['email']);?>" BORDER=0 WIDTH=16 HEIGHT=12></a></td>
<!-- Preferred language field -->
<td class="<?php echo $class; ?>"><?php echo $available_languages[$user['preferred_language']]; ?></td>
<!-- Account type (user/admin) -->
<td class="<?php echo $class; ?>"><?php echo get_string('home', 'ManageUsersTypes', $user['type']); ?></td>
<!-- Actions (modify,delete) -->
<td width="32" align="center">
<a href="../home/home.php?action=modify&userid=<?php echo $user['id']; ?>"><IMG src="../images/edit.gif" alt="<?php echo get_string('home', 'ManageUsersListEditMessage'); ?>" title="<?php echo get_string('home', 'ManageUsersListEditMessage'); ?>" BORDER=0 WIDTH=14 HEIGHT=14></a>
<a href="javascript:del(<?php echo $user['id']?>);"><IMG src="../images/delete.gif" alt="<?php echo get_string('home', 'ManageUsersListDeleteMessage'); ?>" title="<?php echo get_string('home', 'ManageUsersListDeleteMessage'); ?>" BORDER=0 WIDTH=13 HEIGHT=16></a>
</td>
</tr>
<?php }
}
}
?>
</table>
</div>
<?php
}
}
?>