Moved scripts in "docs" one level up into root folder. In addition, removed "docs...
[atutor.git] / mods / _core / backups / restore.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: restore.php 10142 2010-08-17 19:17:26Z hwong $
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17
18 authenticate(AT_PRIV_ADMIN); 
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 $Backup = new Backup($db, $_SESSION['course_id']);
23
24 if (!isset($_REQUEST['backup_id'])) {
25         header('Location: index.php');
26         exit;
27 }
28
29 if (isset($_POST['cancel'])) {
30         $msg->addFeedback('CANCELLED');
31         header('Location: index.php');
32         exit;
33 } else if (isset($_POST['submit'])) {
34         if (!$_POST['material']) {
35                 $msg->addError(array('EMPTY_FIELDS', _AT('material')));
36         } else {
37                 $Backup->restore($_POST['material'], $_POST['action'], $_POST['backup_id']);
38                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
39                 header('Location: index.php');
40                 exit;
41         }
42 }
43
44 require(AT_INCLUDE_PATH.'header.inc.php');
45
46 $row = $Backup->getRow($_REQUEST['backup_id']);
47
48 ?>
49
50 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
51 <input type="hidden" name="backup_id" value="<?php echo $_REQUEST['backup_id']; ?>" />
52
53 <div class="input-form">
54 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('restore'); ?></legend>
55         <div class="row">
56                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php echo _AT('material'); ?><br />
57
58                 <input type="checkbox" value="1" name="all" id="all" onclick="javascript:selectAll();" /><label for="all"><?php echo _AT('material_select_all'); ?></label><br /><br />
59
60                 <input type="checkbox" value="1" name='material[properties]' id='m0' /><label for='m0'><?php echo _AT('banner'); ?></label><br />
61                 <?php
62                 $i=0;
63                 $modules = $moduleFactory->getModules(AT_MODULE_STATUS_ENABLED, 0, TRUE);
64                 $keys = array_keys($modules);
65                 ?>
66                 <?php foreach($keys as $module_name): ?>
67                         <?php $module =& $modules[$module_name]; ?>
68                         <?php if ($module->isBackupable()): ?>
69                                 <input type="checkbox" value="1" name="material[<?php echo $module_name; ?>]" id="m<?php echo ++$i; ?>" /><label for="m<?php echo $i; ?>"><?php echo $module->getName(); ?></label><br />
70                         <?php endif; ?>
71                 <?php endforeach; ?>
72         </div>
73
74         <div class="row">
75                 <?php echo _AT('action'); ?><br />
76                 <input type="radio" checked="checked" name="action" value="append" id="append" /><label for="append"><?php echo _AT('append_content'); ?></label><br />
77                 
78                 <input type="radio" name="action" value="overwrite" id="overwrite" /><label for="overwrite"><?php echo _AT('overwite_content'); ?></label><br />
79         </div>
80
81         <div class="row buttons">
82                 <input type="submit" name="submit" value="<?php echo _AT('restore'); ?>"  class="button"/> 
83                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"  class="button"/>
84         </div>
85 </fieldset>
86 </div>
87 </form>
88 <?php $i=0; ?>
89 <script language="javascript" type="text/javascript">
90         
91         function selectAll() {
92                 if (document.form.all.checked == true) {
93                         document.form.m0.checked = true;
94                         <?php foreach($keys as $module_name): $module =& $modules[$module_name]; if ($module->isBackupable()): ?>
95                                 document.form.m<?php echo ++$i; ?>.checked = true;
96                         <?php endif; endforeach; ?>
97                 } else {
98                         document.form.m0.checked = false;
99                         <?php $i=0;?>
100                         <?php foreach($keys as $module_name): $module =& $modules[$module_name]; if ($module->isBackupable()): ?>
101                                 document.form.m<?php echo ++$i; ?>.checked = false;
102                         <?php endif; endforeach; ?>
103
104                 }
105         }
106 </script>
107
108 <?php require (AT_INCLUDE_PATH.'footer.inc.php');  ?>