<script language="JavaScript1.2" type="text/javascript">
tb = parent.AfianHandler['allTabs']['<?echo $_GET['fromtabid'];?>'];

<?
$fromtabid	= $str->fromHTML($_GET['fromtabid']);

/* check user permission*/
if ($permissions['readonly']) {
	iframeAlert($lang->get($lang->get("You are not allowed to perform this action.")));
	echo "parent.cancelTimeOut(tb.id);</script>";
	exit();
}

/* checking input */
$split = explode("|", $str->fromHTML($_POST['itemlist']));
for ($i = 0 ; $i < sizeof($split) ; $i++) {
	if ($split[$i] != "") {
		$items[] = $split[$i];
	}
}

foreach ($items as $item) {
	if (!isCleanFilename($item)) {
	iframeAlert($lang->get("Ilegal filename: ").$item);
	echo "parent.cancelTimeOut(tb.id);</script>";
	exit();
	}
}

$retoredItems = 0;

foreach ($items as $filename) {
	$info = $trash->getObjectInfo($filename);
	$res = $trash->restore($filename);
	if ($res['result']) {
	$retoredItems++;
	$log->act("1", "trash document restoration", "TO ".$res['restorepath']);
	?>
/*remove restored item from tab*/
if (tb != undefined) {
tb.removeItem('<?echo $str->safeJS($filename);?>');
}
	<?
	} else {
	$log->act("1", "trash document restoration", "TO ".$res['restorepath']);
	$iframeAlertMsg[] = "<span class=\"nowrap\">".$lang->get("Failed to restore \"%1\".", array($res['filename']))."</span>".$res['errorMsg'];
	}
}
$quota->recalcUsedSpace();
?>

<?
if ($retoredItems > 0) {
?>
parent.AfianBubbleMessage('<?$lang->display("Object(s) restored from trash.");?>');
<?}?>

if (tb != undefined) {
	tb.showHG = false;
	parent.cancelTimeOut(tb.id);
	if (tb.active) {
		parent.TrashStatusBar();
		tb.hideHourGlass();
	}
}

<?if (!$permissions['unlimitedSpace']) {?>
parent.setQuotaIndicators ('space', <?echo $quota->currentSpace;?>, <?echo $permissions['spaceQuota'];?>);
<?}?>


<?iframeAlert($iframeAlertMsg);?>
</script>