made a copy
[atutor.git] / tools / backup / upload.php
1 <?php
2 /****************************************************************************/
3 /* ATutor                                                                                                                                       */
4 /****************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton        */
6 /* Adaptive Technology Resource Centre / University of Toronto                          */
7 /* http://atutor.ca                                                                                                                     */
8 /*                                                                                                                                                      */
9 /* This program is free software. You can redistribute it and/or                        */
10 /* modify it under the terms of the GNU General Public License                          */
11 /* as published by the Free Software Foundation.                                                        */
12 /****************************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_ADMIN); 
18
19 $_SESSION['done'] = 0;
20
21 require(AT_INCLUDE_PATH.'classes/Backup/Backup.class.php');
22 $Backup = new Backup($db, $_SESSION['course_id']);
23
24 if (isset($_POST['cancel'])) {
25         $msg->addFeedback('CANCELLED');
26         header('Location: index.php');
27         exit;
28 } else if (isset($_POST['upload']) && ($Backup->getNumAvailable() < AT_COURSE_BACKUPS)) {
29         $Backup->upload($_FILES, $_POST['description']);
30
31         $_SESSION['done'] = 1;
32
33         if($msg->containsErrors()) {
34                 header('Location: upload.php');
35                 exit;
36         } else {
37                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
38                 header('Location: index.php');
39                 exit;
40         }
41 }
42
43 require(AT_INCLUDE_PATH.'header.inc.php');
44
45 ?>
46
47 <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" >
48 <div class="input-form">
49         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('upload'); ?></legend>
50         <div class="row">
51                 <p><?php echo _AT('restore_upload'); ?></p>
52         </div>
53
54         <?php if ($Backup->getNumAvailable() >= AT_COURSE_BACKUPS): ?>
55                 <div class="row">
56                         <p><strong><?php echo _AT('max_backups_reached'); ?></strong></p>
57                 </div>
58         <?php else: ?>
59                 <div class="row">
60                         <label for="descrip"><?php echo _AT('optional_description'); ?></label><br />
61                         <textarea id="descrip" cols="30" rows="2" name="description"></textarea>
62                 </div>
63                 
64                 <div class="row">
65                         <label for="file"><div class="required" title="<?php echo _AT('required_field'); ?>">*</div><?php echo _AT('file'); ?></label><br />
66                         <input type="file" name="file" id="file" />
67                 </div>
68
69                 <div class="row buttons">
70                 <input type="submit" name="upload" value="<?php echo _AT('upload_backup'); ?>" onclick="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php');" /> 
71                         <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
72                 </div>
73         <?php endif; ?>
74         </fieldset>
75 </div>
76 </form>
77
78 <script language="javascript" type="text/javascript">
79 function openWindow(page) {
80         newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
81         newWindow.focus();
82 }
83 </script>
84
85 <?php require (AT_INCLUDE_PATH.'footer.inc.php');  ?>