Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/notepad/delfolder.php
<? require_once("../common/includes.php"); ?>
<? require_once("../admin/util.php"); ?>
<? require_once("../util/general.php"); ?>
<?
if($HTTP_GET_VARS["posted"] == "1") {
	$strDelRecs = $HTTP_GET_VARS["delrecs"];
	$intFolderID = $HTTP_GET_VARS["folder"];
	$strNewFolder = $HTTP_GET_VARS["newfolder"];

	if($strDelRecs == "move") {
		//move the notes
		$strSQL = "UPDATE notepad SET folderid = ".$strNewFolder." WHERE folderid = ".$intFolderID;
	} else {
		//delete the notes
		$strSQL = "UPDATE notepad SET isDeleted=1 WHERE folderid = ".$intFolderID;
	}
	gendb_query($strSQL, $myDb) or die(gendb_error());

	// Delete Folder
	$strSQL = "UPDATE notepadfolders SET isDeleted=1 WHERE id = ".$intFolderID;
	gendb_query($strSQL, $myDb) or die(gendb_error());
	if(isOffline()) {makeOfflineRecord("notepadfolders", $intFolderID, "edit");}
	
	if($strNewFolder == "0") $strNewFolder = "U";

	echo("<script language=\"javascript\">");
	echo("parent.notepadFolders.location='folders.php?folder=".$strNewFolder."';");
	echo("</script>");
	exit;
}
?>
<html>
<head>
<? require_once("../common/head.php"); ?>
<script language="javascript">
function submitForm() {
	document.frm.submit();
}
function changeFolder(folderid, foldername) {
	document.frm.folder.value=folderid;
	document.getElementById('foldertitle').innerHTML = foldername;
}
</script>
</head>
<?
$intFolderID = $HTTP_GET_VARS["folderid"];
$strFolderName = $HTTP_GET_VARS["foldername"];

$strSQL = "SELECT count(*) as intRecCount FROM notepad WHERE isDeleted=0 AND folderid = ".$intFolderID;
$rows = gendb_query($strSQL, $myDb) or die(gendb_error());
$row = gendb_fetch_assoc($rows);
$intRecCount = $row["intRecCount"];
gendb_free_result($rows);

$strSQL = "SELECT * FROM notepadfolders WHERE isDeleted=0 AND id != ".$intFolderID." AND userid = ".$HTTP_SESSION_VARS["mwoid"];
$rows = gendb_query($strSQL, $myDb) or die(gendb_error());

?>
<body<? if($intRecCount == 0) echo(" onLoad=\"document.frm.submit();\"")?>>
<?=dispHeader("Notepad")?>
<?=displayErrorMessage()?>
<form name="frm" method="get" action="delfolder.php">
<input type="hidden" name="folder" value="<?=$intFolderID?>">
<input type="hidden" name="posted" value="1">

<table width="100%" cellspacing="0" cellpadding="1">
<tr>
<td>
<table>
<tr><td><?=displayDeleteButton("delfolder", "submitForm();")?></td><td><?=displayCancelButton("cancelfolder", "document.location.href='notepad.php?folder=".$intFolderID."';")?></td></tr>
</table>
</td>
</tr>
</table>
<?=dispFooter()?>
<table width="100%">
<tr>
<td class="titlebar">
<?
echo("Delete Folder : ".$strFolderName);
?>
</td>
</tr>
<tr>
<td>
The <strong><?=$strFolderName?></strong> foldler currently contains <strong><?=$intRecCount?></strong> note<? if($intRecCount > 1) echo("s")?>
<br><br>
What do you want to do with these notes after the folder is deleted?
<br><br>
<input type="radio" name="delrecs" value="move" Checked> Move notes to the <select name="newfolder"><option value="0">Unfiled</option>
<?
while ($row = gendb_fetch_assoc($rows)) {
	echo("<option value=\"".$row["id"]."\">".$row["foldername"]."</option>");
}
gendb_free_result($rows);
?>
</select> folder
<br>
<input type="radio" name="delrecs" value="del"> Delete notes (this cannot be undone)
</td>
</tr>
</table>
<?=dispFooter()?>
<script language="javascript">
parent.notepadFolders.location='folders.php?folder=<?=$intFolderID?>&nores=1';
</script>
</form>
</body>
</html>
<? require_once("../common/incFinal.php"); ?>
Return current item: Silicon Fodder