<?php
/****************************************************************************************/
/* ACollab */
/****************************************************************************************/
/* Copyright (c) 2002-2004 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 */
/****************************************************************************************/
// $Id: add_version.php 234 2004-06-07 19:43:50Z boonhau $
exit('no longer used');
define('AC_INCLUDE_PATH', '../include/');
require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_CLIENT, USER_GROUP_ADMIN, USER_ADMIN);
$id = intval($_REQUEST['id']);
if (isset($_POST['cancel'])) {
header('Location: revisions.php?id='.$id);
exit;
}
$_SECTION[0][0] = _AC('home');
$_SECTION[0][1] = 'home.php';
$_SECTION[1][0] = _AC('library');
$_SECTION[1][1] = 'library/';
$_SECTION[2][0] = _AC('add_version');
$_SECTION[2][1] = 'library/add_version.php';
$hash = md5($id . date('Y-m-d'));
if ($hash != $_REQUEST['hash']) {
require(AC_INCLUDE_PATH.'header.inc.php');
echo _AC('comments_not_accepted');
require(AC_INCLUDE_PATH.'footer.inc.php');
exit;
}
if (isset($_POST['submit'])) {
$_POST['comments'] = trim($_POST['comments']);
if($_FILES['file']['name'] != '') {
$ext = substr($_FILES['file']['name'], strrpos($_FILES['file']['name'], '.')+1);
if (!isset($_file_types[$ext])) {
$error[] = E_DRAFT_ILLEGAL_FILE_TYPE;
}
}
if ($_POST['comments'] == '') {
$error[] = E_DRAFT_EMPTY_COMM;
}
if (!isset($error)) {
$sql = "INSERT INTO ".TABLE_PREFIX."files_revisions VALUES (0, '$_POST[language]', $id, $_SESSION[group_id], $_SESSION[member_id], ".FILE_DRAFTING.", NOW(), NOW(), '', '', '{$_FILES[file][name]}', '{$_FILES[file][size]}', '$_POST[comments]', 0, 0)";
if (mysql_query($sql, $db)) {
$file_id = mysql_insert_id($db);
$sql = "UPDATE ".TABLE_PREFIX."files_revisions SET num_revisions=num_revisions+1 WHERE file_id=$id AND group_id=$_SESSION[group_id]";
$result = mysql_query($sql, $db);
if ($_FILES['file']['name'] != '') {
$char = substr($file_id, 0, 1).'/';
move_uploaded_file($_FILES['file']['tmp_name'], UPLOAD_DIR.$char.$file_id);
}
header('Location: revisions.php?id='.$id.SEP.'f='.F_DRAFT_UPLOADED);
exit;
}
$error[] = E_DRAFT_UPLOAD;
}
}
require(AC_INCLUDE_PATH.'header.inc.php');
if (isset($error)) {
print_errors($error);
}
?><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" name="form" id="form">
<input type="hidden" name="MAX_FILE_SIZE" value="512000" />
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="hash" value="<?php echo $_REQUEST['hash']; ?>" />
<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
<tr>
<th colspan="5" class="box"><h3><?php echo _AC('add_revision'); ?></h3></th>
</tr>
<tr>
<td class="row1"> </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"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" align="right"><b><?php echo _AC('language'); ?>:</b></td>
<td class="row1"> </td>
<td class="row1"><input type="radio" name="language" id="en" value="en" checked="checked" /><label for="en"><?php echo _AC('english'); ?></label>, <input type="radio" name="language" id="fr" value="fr" /><label for="fr"><?php echo _AC('french'); ?></label>, <input type="radio" name="language" id="bi" value="bi" /><label for="bi"><?php echo _AC('bilingual'); ?></label></td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" align="right"><label for="file"><b><?php echo _AC('file'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="file" name="file" id="file" class="input" size="30" onChange='selectFile(this);' onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" align="right" valign="top"><label for="comments"><b><?php echo _AC('comments'); ?>:</b></label></td>
<td class="row1" valign="top"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" class="img" /></td>
<td class="row1"><textarea name="comments" id="comments" class="input" onfocus="this.className='input highlight'" onblur="this.className='input'" cols="40" rows="5"><?php echo $_POST['description']; ?></textarea></td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" colspan="3" align="right"><br /><input type="submit" name="submit" value="<?php echo _AC('add_revision'); ?>" class="submitY" onfocus="this.className='submitY highlight'" onblur="this.className='submitY'" /> <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"> </td>
</tr>
</table>
</form>
<?php
require(AC_INCLUDE_PATH.'footer.inc.php');