Location: PHPKode > projects > ACollab > drafting/folder_manager.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: folders.php 301 2005-01-17 20:49:13Z joel $

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

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

$_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';


/* get all the folders: */
$folders = get_folders();

if (isset($_POST['form_submit']) && !isset($_POST['delete']) && !isset($_POST['cancel'])) {
	/* insert or update a category */
	$id			      = intval($_POST['id']);
	$parent_folder_id = intval($_POST['parent_folder_id']);
	$title            = trim($_POST['title']);

	if ($id == 0) {
		$title  = $addslashes($title);

		$sql = "INSERT INTO ".TABLE_PREFIX."folders VALUES (0, $parent_folder_id, $_SESSION[group_id], $_SESSION[member_id], '$title')";
		$result = mysql_query($sql, $db);
		$id = mysql_insert_id($db);
		//$msg->addFeedback('CAT_ADDED');
	} else {
		$title = $addslashes($_POST['title']);

		$sql = "UPDATE ".TABLE_PREFIX."folders SET parent_folder_id=$parent_folder_id, title='$title' WHERE folder_id=$id AND group_id=$_SESSION[group_id]";
		$result = mysql_query($sql, $db);
		//$msg->addFeedback('CAT_UPDATE_SUCCESSFUL');
	}

	header('Location: '.$_SESSION['PHP_SELF'].'?id='.$id);
	exit;
} else if (isset($_POST['delete'])) {
	/* want to delete a folder, next step: confirmation */
	$id	= intval($_POST['id']);
} else if (isset($_GET['d'])) {
	/* delete has been confirmed, delete this folder */
	$id	= intval($_GET['id']);
	if (!is_array($folders[$id]['children'])) {
		$sql = "DELETE FROM ".TABLE_PREFIX."folders WHERE folder_id=$id AND group_id=$_SESSION[group_id]";
		$result = mysql_query($sql, $db);

		//$msg->addFeedback('CAT_DELETED');
		header('Location: '.$_SERVER['PHP_SELF']);
		exit;
	}
} else if (isset($_POST['cancel'])) {
	unset($_REQUEST);
}


if (isset($_GET['id'])) {
	$id = intval($_GET['id']);
}
if (isset($_GET['pid'])) {
	$pid = intval($_GET['pid']);
}

require(AC_INCLUDE_PATH.'header.inc.php');
echo '<p align="center"><a href="drafting/folder_create.php" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"></a></p>';

if ($_GET['f']) {
	print_feedback($_GET['f']);
}


echo '<a href="'.$_SERVER['PHP_SELF'].'">ยป '._AC('create_folder').'</a><br /><br />';
?>
<table cellspacing="0" cellpadding="0" border="0" summary="" align="center" width="100%">
<tr>
	<td valign="top"><?php

			echo '<p><small>[SELECT FOLDER TO EDIT]</small></p>';

			/* print the list of nested folders */
			/* @See: include/lib/folders */
			if (is_array($folders)) {
				print_folders($folders);
			} else {
				echo '[NO FOLDERS]';
			}
	?></td>
	<td valign="top"><?php 
			/* print the folder editor */
			require(AC_INCLUDE_PATH.'html/folder_editor.inc.php');
		?></td>
</tr>
</table>

<?php require(AC_INCLUDE_PATH.'footer.inc.php');  ?>
Return current item: ACollab