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