made a copy
[atutor.git] / tools / backup / index.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
18 $_section[0][0] = _AT('tools');
19 $_section[0][1] = 'tools/';
20 $_section[1][0] = _AT('backup_manager');
21 $_section[1][1] = 'tools/';
22
23 authenticate(AT_PRIV_ADMIN);
24
25 require(AT_INCLUDE_PATH.'classes/Backup/Backup.class.php');
26 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');
27
28 if (isset($_POST['restore'], $_POST['backup_id'])) {
29         header('Location: restore.php?backup_id=' . $_POST['backup_id']);
30         exit;
31 } else if (isset($_POST['download'], $_POST['backup_id'])) {
32         $Backup = new Backup($db, $_SESSION['course_id']);
33         $Backup->download($_POST['backup_id']);
34         exit; // never reached
35 } else if (isset($_POST['delete'], $_POST['backup_id'])) {
36         header('Location: delete.php?backup_id=' . $_POST['backup_id']);
37         exit;
38 } else if (isset($_POST['edit'], $_POST['backup_id'])) {
39         header('Location: edit.php?backup_id=' . $_POST['backup_id']);
40         exit;
41 } else if (!empty($_POST)) {
42         $msg->addError('NO_ITEM_SELECTED');
43 }
44
45 require(AT_INCLUDE_PATH.'header.inc.php');
46
47 $Backup = new Backup($db, $_SESSION['course_id']);
48 $list = $Backup->getAvailableList();
49
50 ?>
51
52 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
53
54 <table class="data" summary="" rules="cols">
55 <thead>
56 <tr>
57         <th><?php echo _AT('file_name');    ?></th>
58         <th><?php echo _AT('date_created'); ?></th>
59         <th><?php echo _AT('file_size');    ?></th>
60         <th><?php echo _AT('description');  ?></th>
61 </tr>
62 </thead>
63 <tfoot>
64 <tr>
65         <td colspan="6"><input type="submit" name="restore" value="<?php echo _AT('restore'); ?>" /> 
66                                   <input type="submit" name="download" value="<?php echo _AT('download'); ?>" /> 
67                                   <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /> 
68                                   <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /></td>
69 </tr>
70 </tfoot>
71 <tbody>
72 <?php
73
74         if (!$list) {
75                 ?>
76         <tr>
77                 <td colspan="4"><?php echo _AT('none_found'); ?></td>
78         </tr>
79         <?php
80         } else {
81
82                 foreach ($list as $row) {
83                         echo '<tr onmousedown="document.form[\'b'.$row['backup_id'].'\'].checked = true; rowselect(this);" id="r_'.$row['backup_id'].'">';
84                         echo '<td class="row1"><label><input type="radio" value="'.$row['backup_id'].'" name="backup_id" id="b'.$row['backup_id'].'" />';
85                         echo $row['file_name'].'</label></td>';
86                         echo '<td>'.AT_date(_AT('filemanager_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME).'</td>';
87                         echo '<td align="right">'.get_human_size($row['file_size']).'</td>';
88                         echo '<td>'.AT_Print($row['description'], 'backups.description').'</td>';
89                         echo '</tr>';
90                 }
91 ?>
92         <?php } ?>
93 </tbody>
94 </table>
95 </form>
96
97 <?php require (AT_INCLUDE_PATH.'footer.inc.php');  ?>