<?
if ($auth->currentUserInfo['username'] == "admin") {


if ($_GET['transferTo']) {
	if ($_GET['uid'] == "1") {
		$msg = $lang->get("You cannot transfer user \"admin\".");
		$statusBarMessage[] = array($msg, 1);
	} else {
		$groupInfo = $auth->getGroupInfo($_GET['transferTo']);
		$userinfo = $auth->getUserInfoById($_GET['uid']);
		if ($groupInfo) {
			if ($auth->transferUser($_GET['uid'], $_GET['transferTo'])) {
				$msg = $lang->get("User \"%1\" transfered to group \"%2\".", array($userinfo['username'], $groupInfo['name']));
				$statusBarMessage[] = array($msg, 0);
				$log->act("0", "user transfer", $userinfo['username'] . "(".$userinfo['id'].") TO " . $groupInfo['name']." (".$groupInfo['id'].")");
			} else {
				$msg = $lang->get("Failed to transfer user \"%1\" to group \"%2\".", array($userinfo['username'], $groupInfo['name']));
				$statusBarMessage[] = array($msg, 1);
				$log->act("1", "user transfer", $userinfo['username'] . "(".$userinfo['id'].") TO " . $groupInfo['name']." (".$groupInfo['id'].")");
			}
		} else {
			$msg = $lang->get("Invalid group \"%1\".", array($_GET['transferTo']));
			$statusBarMessage[] = array($msg, 1);
		}
	}
}




$userinfo = $auth->getUserInfoById($_GET['uid']);


if ($_GET['resetTraffic']) {
		$data["traffic"] = 0;
		$data["trafficdate"] = time();
		if ($auth->updateUser($_GET['uid'], $data)) {
			$msg = $lang->get("Traffic reset for user \"%1\".", array($userinfo['username']));
			$statusBarMessage[] = array($msg, 0);
			$log->act("0", "traffic quota reset", "FOR USER: ".$userinfo['username']);
		} else {
			$msg = $lang->get("Failed to reset traffic for user \"%1\".", array($userinfo['username']));
			$statusBarMessage[] = array($msg, 1);
			$log->act("1", "traffic quota reset", "FOR USER: ".$userinfo['username']);
		}
}



if (!$userinfo) {
	exit($lang->get("Invalid user."));
}

$groupinfo = $auth->getGroupInfo($userinfo['gid']);


$title = $lang->get("%1's summary", array($userinfo['username']));
//template header
require_once($sys['root']."/system/templates/popup/header.inc");
?>
<script type="text/javascript" language="JavaScript1.2">
<?echo $js?>
</script>


<table cellspacing="0" cellpadding="0" border="0" style="width:100%;height:100%;background-color:#F2F2F2">
<tr>
    <td background="images/popup/top-bg.gif" height="26">&nbsp;</td>
</tr>

<tr>
    <td style="padding:10px;">
<!-- Popup Contents -->


<style type="text/css">
.row-title {
background-color: #d4d4d4;
border:1px solid white;
border-right: 1px solid #808080 ;
border-bottom: 1px solid #808080;
padding:6px;
text-align:right;
}

.row-contents {
background-color:#ebebeb;
border:none;border-top:1px solid white;
border-bottom:1px solid silver;
vertical-align:top;
padding:6px;
}

.row-action {
background-color:#ebebeb;
border:1px solid white;
border-bottom: 1px solid silver;
border-right: 1px solid silver;
vertical-align:top;
padding:6px;
}
</style>


<table cellspacing="1" cellpadding="0" border="0" align="center">

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Username");?></td>
	<td valign="top"" class="row-contents"><?echo $userinfo['username'];?></td>
	<td valign="top" class="row-action">
&nbsp;
</td>
</tr>


<?if (strlen($userinfo['firstname']) > 0) {?>
<tr>
	<td valign="top" class="row-title"><?$lang->display("First name");?></td>
	<td valign="top"" class="row-contents"><?echo $userinfo['firstname'];?></td>
	<td valign="top" class="row-action">&nbsp;</td>
</tr>
<?}?>
<?if (strlen($userinfo['lastname']) > 0) {?>
<tr>
	<td valign="top" class="row-title"><?$lang->display("Last Name");?></td>
	<td valign="top"" class="row-contents"><?echo $userinfo['lastname'];?></td>
	<td valign="top" class="row-action">&nbsp;</td>
</tr>
<?}?>
<?if (strlen($userinfo['company']) > 0) {?>
<tr>
	<td valign="top" class="row-title"><?$lang->display("Company");?></td>
	<td valign="top"" class="row-contents"><?echo $userinfo['company'];?></td>
	<td valign="top" class="row-action">&nbsp;</td>
</tr>
<?}?>
<?if (strlen($userinfo['email']) > 0) {?>
<tr>
	<td valign="top" class="row-title"><?$lang->display("E-mail address");?></td>
	<td valign="top"" class="row-contents"><?echo $userinfo['email'];?></td>
	<td valign="top" class="row-action">&nbsp;</td>
</tr>
<?}?>


<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Parent group");?></td>
	<td valign="top"" class="row-contents"><?echo $groupinfo['name'];?></td>
	<td valign="top" class="row-action">
&nbsp;
</td>
</tr>

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Access");?></td>
	<td valign="top"" class="row-contents">
<?if ($userinfo['suspended']==""){
	if ($groupinfo['suspended'] == "1") {
		echo $lang->get("User has been suspended, inheriting group settings.");
	} else {
		echo $lang->get("User may login, inheriting group settings.");
	}
}?>
<?if ($userinfo['suspended']=="1"){echo $lang->get("User has been suspended manually.");}?>

<?if ($userinfo['suspended']=="0"){echo $lang->get("User may login even if the group is suspended.");}?>
	<br>
	Last login : <?if ($userinfo['lastlogin'] > 0){echo date("l, j F Y (H:i)", $userinfo['lastlogin']);}else{echo $lang->get("user have never logged in.");}?>
	</td>
	<td valign="top" class="row-action">
&nbsp;
</td>
</tr>

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Home folder");?></td>
	<td valign="top"" class="row-contents">
	<?
	if ($userinfo['path']==""){
		$homefolder = $groupinfo['path'];
	}else{
		$homefolder = $userinfo['path'];
	}
	echo $homefolder;
	?>
	</td>
	<td valign="top" class="row-action"><?if ($userinfo['path']==""){$lang->display("inherited");}else{ $lang->display("custom");}?></td>
</tr>

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Disk space");?></td>
	<td valign="top"" class="row-contents"><?
$trash = gluePath((($settings->config['trashpath'])?$settings->config['trashpath']:gluePath($sys['root'], "/system/data/trash/")), $userinfo['username']);
$userUsedSpace = $fm->getDirSize($homefolder) + $fm->getDirSize($trash);



echo $fm->formatFileSize($userUsedSpace, 2, "0");?> / <?
if ($userinfo['spacequota'] == "") {
	if ($groupinfo['spacequota'] == "") {
		echo $lang->get("Unlimited");
	} else {
		echo $fm->formatFileSize($groupinfo['spacequota'],2,"0");
	}
} else {
	if ($userinfo['spacequota'] == "-") {
		echo $lang->get("Unlimited");
	} else {
		echo $fm->formatFileSize($userinfo['spacequota'],2,"0");
	}
}

?>


</td>
	<td valign="top" class="row-action"><?if ($userinfo['spacequota']==""){$lang->display("quota inherited");}else{$lang->display("custom quota");}?></td>
</tr>

<tr>
	<td valign="top" class="row-title"><?$lang->display("Traffic");?></td>
	<td valign="top"" class="row-contents"><?
echo $fm->formatFileSize($userinfo['traffic'], 2, "0");
?> / <?
if ($userinfo['trafficquota'] == "") {
	if ($groupinfo['trafficquota'] == "") {
		echo $lang->get("Unlimited");
		$unlimitedTraffic = 1;
	} else {
		echo $fm->formatFileSize($groupinfo['trafficquota'],2,"0")."/month";
	}
} else {
	if ($userinfo['trafficquota'] == "-") {
		echo $lang->get("Unlimited");
		$unlimitedTraffic = 1;
	} else {
		echo $fm->formatFileSize($userinfo['trafficquota'],2,"0")."/month";
	}
}

if (!$unlimitedTraffic) {
?>
	<br>
	<?$lang->display("Traffic reset scheduled for:");?> <?echo date("l, j F Y (H:i)", $userinfo['trafficdate']+2592000);?>
<?}?>
	</td>
	<td valign="top" class="row-action"><?if ($userinfo['trafficquota']==""){echo $lang->get("quota inherited");}else{echo $lang->get("custom quota");}?>
<?if (!$unlimitedTraffic) {?>
<br><br>
<?
$tpl->btn(
$lang->get("Reset his traffic"), 
"document.location.href='?file=adm_user_summary&uid=".$str->safeJS($str->forURL($userinfo['id']))."&resetTraffic=1'"
);
}
?>
</td>
</tr>

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
    <td rowspan="5" valign="top" class="row-title"><?$lang->display("Permisions");?></td>
    <td valign="top"" class="row-contents">
<?if ($userinfo['upload']==""){
	if ($groupinfo['upload'] == "1") {
		echo $lang->get("User may upload");
	} else {
		echo $lang->get("User may not upload.");
	}
}else{
	if ($userinfo['upload'] == "1") {
		echo $lang->get("User may upload.");
	} else {
		echo $lang->get("User may not upload");
	}
}?></td>
    <td valign="top" class="row-action"><?if ($userinfo['upload']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?></td>
</tr>
<tr>
    <td valign="top"" class="row-contents">
<?if ($userinfo['readonly']==""){
	if ($groupinfo['readonly'] == "1") {
		echo $lang->get("User may not change files/folders.");
	} else {
		echo $lang->get("User may change files/folders");
	}
}else{
	if ($userinfo['readonly'] == "1") {
		echo $lang->get("User may not change files/folders.");
	} else {
		echo $lang->get("User may change files/folders");
	}
}?>
</td>
    <td valign="top" class="row-action"><?if ($userinfo['readonly']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?></td>
</tr>
<tr>
    <td valign="top"" class="row-contents">
<?if ($userinfo['sendbyemail']==""){
	if ($groupinfo['sendbyemail'] == "1") {
		echo $lang->get("User may send files by e-mail");
	} else {
		echo $lang->get("User may not send files by e-mail");
	}
}else{
	if ($userinfo['sendbyemail'] == "1") {
		echo $lang->get("User may send files by e-mail");
	} else {
		echo $lang->get("User may not send files by e-mail");
	}
}?>
	 </td>
    <td valign="top" class="row-action"><?if ($userinfo['sendbyemail']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?></td>
</tr>
<tr>
    <td valign="top"" class="row-contents">
<?if ($userinfo['sharing']==""){
	if ($groupinfo['sharing'] == "1") {
		echo $lang->get("User may share folders");
	} else {
		echo $lang->get("User may not share folders");
	}
}else{
	if ($userinfo['sharing'] == "1") {
		echo $lang->get("User may share folders");
	} else {
		echo $lang->get("User may not share folders");
	}
}?>
	 </td>
    <td valign="top" class="row-action"><?if ($userinfo['sharing']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?>

</td>
</tr>
<tr>
    <td valign="top"" class="row-contents">
<?if ($userinfo['shareaccess']==""){
	if ($groupinfo['shareaccess'] == "1") {
		echo $lang->get("User may access shared folders");
	} else {
		echo $lang->get("User may not access shared folders");
	}
}else{
	if ($userinfo['shareaccess'] == "1") {
		echo $lang->get("User may access shared folders");
	} else {
		echo $lang->get("User may not access shared folders");
	}
}?>
	 </td>
    <td valign="top" class="row-action"><?if ($userinfo['shareaccess']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?></td>
</tr>

<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

<tr>
    <td rowspan="2" valign="top" class="row-title"><?$lang->display("Options");?></td>
    <td valign="top"" class="row-contents">
<?if ($userinfo['uploadnotice']==""){
	if ($groupinfo['uploadnotice'] == "1") {
		echo $lang->get("User \"admin\" is notified on this user's upload.");
	} else {
		echo $lang->get("User \"admin\" will not be notified on this user's upload.");
	}
}else{
	if ($userinfo['uploadnotice'] == "1") {
		echo $lang->get("User \"admin\" is notified on this user's upload.");
	} else {
		echo $lang->get("User \"admin\" will not be notified on this user's upload.");
	}
}?>
	 </td>
    <td valign="top" class="row-action"><?if ($userinfo['uploadnotice']==""){echo $lang->get("inherited");}else{echo $lang->get("custom");}?></td>
</tr>
<tr>
    <td valign="top"" class="row-contents"><?if ($userinfo['downloadnotice']==""){
	if ($groupinfo['downloadnotice'] == "1") {
		echo $lang->get("User \"admin\" is notified on this user's download.");
	} else {
		echo $lang->get("User \"admin\" will not be notified on this user's download.");
	}
}else{
	if ($userinfo['downloadnotice'] == "1") {
		echo $lang->get("User \"admin\" is notified on this user's download.");
	} else {
		echo $lang->get("User \"admin\" will not be notified on this user's download.");
	}
}?></td>
    <td valign="top" class="row-action"><?if ($userinfo['downloadnotice']==""){echo "inherited";}else{echo "custom";}?></td>
</tr>


<tr><td colspan="3" style="font-size:2px;height:8px">&nbsp;</td></tr>

</table>

	
	

<script language="JavaScript1.2" type="text/javascript">
preloadStupidMSIEElementsPosition();
</script>


	</td>
</tr>
<tr>
    <td align="center" height="20">
<div style="position:relative;top:16px;z-index:1">
<?
$tpl->btn(
$lang->get("Ok"), 
"window.close();self.close();"
);
?>
</div>
	</td>
</tr>

<tr>
    <td background="images/popup/bottom-bg.gif" height="46">&nbsp;</td>
</tr>
</table>


<?
//template footer
require_once($sys['root']."/system/templates/popup/footer.inc");

} //end if username == admin
?>