<?
//$db->debug=1;
if (!$settings->config['demomode']){
	//acting ...
	if ($sys['act'] && !$tmp['cancelAction']) {
		require_once($sys['root']."/system/includes/admin/notifications/actions/".$sys['act'].".inc");
	}
}

require_once($sys['root']."/system/templates/popup/header.inc");
?>

<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;" valign="top">
<!-- Popup Contents -->


<div class="adminContent">
<div style="padding-left:5px;padding-top:10px;">



<table cellspacing="0" cellpadding="0" border="0">
<tr>
    <td colspan="2">
	 <table class="boxTitle" cellspacing="0" cellpadding="0" border="0"><tr><td><?$lang->display("Notifications");?></td></tr></table>
	 </td>
</tr>
<tr>
    <td rowspan="2" valign="top" width="50" align="center" style="padding:5px;"><img src="images/icons/other/sendmail.gif" width="32" height="32" border="0" alt=""></td>
    <td height="70" valign="top" style="padding:5px;">
<?$lang->display("The administrator can be automatically notified on e-mail of key operations performed by users or groups.");?>
	 </td>
</tr>
<tr>
    <td style="padding:5px;">
<div class="separator"><img src="images/interface/hr.gif" width="100%" height="2" border="0" alt=""></div>

<table border="0" cellpadding="1" cellspacing="0" width="90%">
<tr>
	<td><?$lang->display("User/Group");?></td>
	<td><?$lang->display("Performed action");?></td>
	<td><?$lang->display("E-mail address");?></td>
</tr>
<form action="?admin=1&sub=notifications&act=adm_add_notification" method="post" name="frm">
<tr valign="top">
	<td style="padding-right:40px;">
	<select name="who">
		<?
$rs = $db->query("SELECT * from ".$settings->config['groups_tablename']."");
while (!$rs->EOF) {
	echo "<option value=\"".$rs->fields['id']."|group\">".$rs->fields['name']."</option>";
	$us = $db->query("SELECT ".$settings->config['interauth_tablename'].".username, ".$settings->config['users_tablename'].".id FROM ".$settings->config['users_tablename'].",".$settings->config['interauth_tablename'].",".$settings->config['auth_tablename']." WHERE ".$settings->config['users_tablename'].".gid='".$rs->fields['id']."' AND ".$settings->config['interauth_tablename'].".username=".$settings->config['auth_tablename'].".username AND ".$settings->config['interauth_tablename'].".id=".$settings->config['users_tablename'].".id");
	$usernames = "";;
	while (!$us->EOF) {
		echo "<option value=\"".$us->fields["id"]."|user\">  &nbsp;	&nbsp;  ".$us->fields["username"]."</option>";
		$us->MoveNext();
	}
	$rs->MoveNext();
		?>
<?}?>
	</select>
	</td>
	<td>
	<select name="action[]" size="4" multiple>
		<option value="upload"><?$lang->display("Upload");?></option>
		<option value="download"><?$lang->display("Download");?></option>
		<option value="folder share"><?$lang->display("Folder share");?></option>
		<option value="login"><?$lang->display("Login");?></option>
		<option value="comment"><?$lang->display("Add comment on file");?></option>
		<option value="email"><?$lang->display("Send files by mail");?></option>
		<option value="new text file"><?$lang->display("Edit files as text");?></option>
		<option value="move"><?$lang->display("Move");?></option>
		<option value="copy"><?$lang->display("Copy");?></option>
		<option value="delete"><?$lang->display("Delete");?></option>
		<option value="rename"><?$lang->display("Rename");?></option>
		<option value="zip"><?$lang->display("Zip");?></option>
		<option value="unzip"><?$lang->display("UnZip");?></option>
	</select>
	</td>
	<td><input type="text" name="email_address" value-""></td>
	<td>
<?
$tpl->btn(
$lang->get("Add"), 
"document.frm.submit()"
);
?>
	</td>
</tr>

<?
$rs = $db->query("SELECT * FROM ".$settings->config['notifications_tablename']."");
while (!$rs->EOF) {
	if ($rs->fields['object_type'] == "group") {
		$objectInfo = $auth->getGroupInfo($rs->fields['object_id']);
	} else {
		$objectInfo = $auth->getUserInfoById($rs->fields['object_id']);
	}
?>
<tr>
	<td colspan="4">
	<hr noshade size="1" color="silver">
	</td>
</tr>
<tr>
	<td valign="top"><?if ($rs->fields['object_type'] == "group"){
		$lang->display("Group");
		echo " ";
		echo $objectInfo['name'];
	} else {
		$lang->display("User");
		echo " ";
		echo $objectInfo['username'];
	}?></td>
	<td>
	<?foreach (explode("|", $rs->fields['action']) as $action) {?>
		<li><?$lang->display(str_replace("'", "", $action))?></li>
	<?}?>
	</td>
	<td valign="top"><?echo $str->safeHTML($rs->fields['email_address'])?></td>
	<td>
	<?
$tpl->btn(
$lang->get("Remove"), 
"document.location.href='?admin=1&sub=notifications&act=remove&id=".$rs->fields['id']."'"
);
?>
	</td>
</tr>
<?
	$rs->MoveNext();
}
?>
</table>

	 </td>
</tr>
</table>


</form>
	</td>
</tr>

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

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

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