remove old readme
[atutor.git] / docs / mods / _core / backups / admin / 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 admin_authenticate(AT_ADMIN_PRIV_BACKUPS);
18
19 require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
20 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
21
22 if (isset($_POST['backup_id'])) {
23         $ids = explode('_', $_POST['backup_id']);
24         $backup_id = $ids[0];
25         $course    = $ids[1];
26 }
27
28 if (isset($_POST['restore'], $backup_id)) {
29         header('Location: restore.php?backup_id=' . $backup_id . SEP . 'course=' . $course);
30         exit;
31
32 } else if (isset($_POST['download'], $backup_id)) {
33         $Backup = new Backup($db, $course);
34         $Backup->download($backup_id);
35         exit; // never reached
36
37 } else if (isset($_POST['delete'], $backup_id)) {
38         header('Location: delete.php?backup_id=' . $backup_id . SEP . 'course=' . $course);
39         exit;
40
41 } else if (isset($_POST['edit'], $backup_id)) {
42         header('Location: edit.php?backup_id=' . $backup_id . SEP . 'course=' . $course);
43         exit;
44 } else if (!empty($_POST) && !$backup_id) {
45         $msg->addError('NO_ITEM_SELECTED');
46 }
47
48
49 require(AT_INCLUDE_PATH.'header.inc.php');
50
51 ?>
52 <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
53 <input type="hidden" name="course" value="<?php echo $_REQUEST['course']; ?>" />
54         
55 <table class="data" summary="" rules="groups" style="width: 90%">
56 <thead>
57         <tr>
58                 <th><?php echo _AT('file_name');    ?></th>
59                 <th><?php echo _AT('date_created'); ?></th>
60                 <th><?php echo _AT('file_size');    ?></th>
61                 <th><?php echo _AT('description');  ?></th>
62         </tr>
63 </thead>
64 <tfoot>
65 <tr>
66         <td colspan="4"><input type="submit" name="restore" value="<?php echo _AT('restore'); ?>" /> 
67                                   <input type="submit" name="download" value="<?php echo _AT('download'); ?>" />  
68                                   <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /> 
69                                   <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /></td>
70 </tr>
71 </tfoot>
72 <tbody>
73 <?php
74         $num_backups = 0;
75         $Backup = new Backup($db);
76
77         if (isset($_REQUEST['course']) && $_REQUEST['course']) {
78                 $course = intval($_REQUEST['course']);
79                 $sql    = "SELECT course_id, title FROM ".TABLE_PREFIX."courses WHERE course_id=$course ORDER BY title";
80         } else {
81                 $sql    = "SELECT course_id, title FROM ".TABLE_PREFIX."courses ORDER BY title";
82         }
83         $result = mysql_query($sql, $db);
84         while ($course = mysql_fetch_assoc($result)) {
85
86                 $Backup->setCourseID($course['course_id']);
87                 $list = $Backup->getAvailableList();
88
89                 echo '<tr><th colspan="4">'.$course['title'].'</th></tr>';
90
91                 if (empty($list)) { ?>
92                         <tr>
93                                 <td colspan="4"><?php echo _AT('none_found'); ?></td>
94                         </tr><?php
95                         $num_backups ++;
96
97                 } else {
98
99                         foreach ($list as $row) {
100                                 echo '<tr onmousedown="document.form1[\'c'.$row['backup_id'].'_'.$row['course_id'].'\'].checked = true; rowselect(this);" id="r_'.$row['backup_id'].'"><td><input type="radio" value="'.$row['backup_id'].'_'.$row['course_id'].'" name="backup_id" id="c'.$row['backup_id'].'_'.$row['course_id'].'" />';
101                                 echo '<label for="c'.$row['backup_id'].'_'.$row['course_id'].'">'.$row['file_name'].'</label></td>';
102                                 echo '<td>'.AT_date(_AT('filemanager_date_format'), $row['date_timestamp'], AT_DATE_UNIX_TIMESTAMP).'</td>';
103                                 echo '<td align="right">'.get_human_size($row['file_size']).'</td>';
104                                 echo '<td>'.AT_print($row['description'], 'backups.description').'</td>';
105                                 echo '</tr>';
106                                 $num_backups ++;
107                         }
108                 }
109         }
110 ?>
111 <?php if (!$num_backups): ?>
112         <tr>
113                 <td colspan="4"><?php echo _AT('none_found'); ?></td>
114         </tr>
115 <?php endif; ?>
116 </tbody>
117 </table>
118 </form>
119
120 <?php require (AT_INCLUDE_PATH.'footer.inc.php');  ?>