Location: PHPKode > projects > ACollab > drafting/folder_edit.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2005  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may redistribute it and/or                        */
/* modify it under the terms of the GNU General Public License                          */
/* as published by the Free Software Foundation; either version 2 of the License,       */
/* or (at your option) any later version.                                               */
/*                                                                                      */
/* This program is distributed in the hope that it will be useful, but                  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of                           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
/* See the GNU General Public License for more details.                                 */
/*                                                                                      */
/* You may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/* Heidi Hazelton  - ATRC                                                               */
/****************************************************************************************/
// $Id: folder_edit.php 301 2005-01-17 20:49:13Z joel $

define('AC_INCLUDE_PATH', '../include/');

require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_GROUP_ADMIN);

if ($_POST['cancel']) {
	Header('Location: folders.php');
	exit;
}

$id = intval($_REQUEST['id']);

if (isset($_POST['submit'])) {
	$_POST['title'] = str_replace('<', '&lt;', trim($_POST['title']));

	if ($_POST['title'] == '') {
		$errors[] = E_FOLDER_EMPTY_TITLE;
	}

	if (!$errors) {
		$_POST['title']         = $addslashes($_POST['title']);
		$_POST['parent_folder'] = intval($_POST['parent_folder']);

		$sql	= "UPDATE ".TABLE_PREFIX."folders SET title='$_POST[title]', parent_folder_id=$_POST[parent_folder] WHERE folder_id=$id AND group_id=$_SESSION[group_id]";
		@mysql_query($sql,$db);

		header('Location: folders.php?f='.F_FOLDER_EDITED);
		exit;
	}
}

$_SECTION[0][0] = _AC('home');
$_SECTION[0][1] = 'home.php';
$_SECTION[1][0] = _AC('drafting_room');
$_SECTION[1][1] = 'drafting/';
$_SECTION[2][0] = _AC('folders');
$_SECTION[2][1] = 'drafting/folders.php';
$_SECTION[3][0] = _AC('edit_folder');
$_SECTION[3][1] = 'drafting/folder_edit.php';

require(AC_INCLUDE_PATH.'header.inc.php');

if (isset($errors)) {
	print_errors($errors);
	unset($errors);
}

	$sql = "SELECT * FROM ".TABLE_PREFIX."folders WHERE folder_id=$id AND group_id=$_SESSION[group_id]";
	$result = mysql_query($sql,$db);
	if (!($row = mysql_fetch_array($result))) {
		$errors[] = E_FOLDER_NOT_FOUND;
		print_errors($errors);
		require (AC_INCLUDE_PATH.'footer.inc.php');
		exit;
	}

	if (isset($_POST['submit'])) {
		$row['title'] = $_POST['title'];
	}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
	<input type="hidden" name="id" value="<?php echo $id; ?>">
	<p>
	<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
	<tr>
		<th colspan="5" class="box"><h3><?php echo _AC('edit_folder'); ?></h3></th>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td colspan="3" class="row1"><img src="images/clr.gif" height="1" width="1" alt="" /><br /><?php
			echo _AC('denotes_required', '<img src="images/required.gif" height="14" width="14" alt="'._AC('required_field').'" />');
		?><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="title"><b><?php echo _AC('title'); ?>:</b></label></td>
		<td class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
		<td class="row1"><input type="text" name="title" class="input" size="40" maxlength="100" id="title" value="<?php echo  htmlentities($row['title']); ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="title"><b><?php echo _AC('parent_folder'); ?>:</b></label></td>
		<td class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
		<td class="row1"><select name="parent_folder">
						<option value="0"><?php echo _AC('top_folder'); ?></option>
						<option value="0">-----</option>
						<?php
							$sql    = "SELECT * FROM ".TABLE_PREFIX."folders WHERE group_id=$_SESSION[group_id] AND member_id=0 AND parent_folder_id=0 ORDER BY title";
							$result = mysql_query($sql, $db);
							while ($row_folder = mysql_fetch_assoc($result)) {
								echo '<option value="'.$row_folder['folder_id'].'"';
								if ($row['parent_folder_id'] == $row_folder['folder_id']) {
									echo ' selected="selected"';
								}
								echo '>'.$row_folder['title'].'</option>';
							}
						?>
						</select></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td class="row1" colspan="3" align="right"><br /><input type="submit" name="submit" value=" <?php echo _AC('edit'); ?> " class="submitY" onfocus="this.className='submitY highlight'" onblur="this.className='submitY'" /> &nbsp; <input type="submit" name="cancel" value="<?php echo _AC('cancel'); ?>" class="submitN" onfocus="this.className='submitN highlight'" onblur="this.className='submitN'" /><br /><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	</table>
	</p>
</form>
<?php require(AC_INCLUDE_PATH.'footer.inc.php'); ?>
Return current item: ACollab