1fd3d367e3bb2ea8d445cdd6d8c3092b2a41a99f
[atutor.git] / docs / mods / _core / modules / module_uninstall_step_2.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_MODULES);
18
19 $mod = isset($_REQUEST['mod']) ? $_REQUEST['mod'] : "";
20 $args = isset($_REQUEST['args']) ? $_REQUEST['args'] : "";
21 $permission_granted = isset($_REQUEST['permission_granted']) ? $_REQUEST['permission_granted'] : "";
22
23 if (isset($_POST['submit_no']))
24 {
25         // if write permission on the mods folder has been granted, re-direct to the page of removing permission,
26         // otherwise, back to start page.
27         if ($_POST['permission_granted']==1)
28                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/module_uninstall_step_3.php?mod='.$_POST['mod'].SEP.'cancelled=1'.SEP.'args='.urlencode($_POST['args']));
29         else
30         {
31                 $msg->addFeedback('CANCELLED');
32                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/index.php?'.urlencode($_POST["args"]));
33         }
34         
35         exit;
36
37 else if (isset($_POST['submit_yes'], $_POST['mod'])) 
38 {
39         $module = $moduleFactory->getModule($_POST['mod']);
40         $module->uninstall($_POST['del_data']);
41
42         if ($_POST['permission_granted']==1)
43         {
44                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/module_uninstall_step_3.php?uninstalled=1'.SEP.'args='.urlencode($_POST["args"]));
45         }
46         else
47         {
48                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
49                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/index.php?'.$_POST['args']);
50         }
51
52         exit;
53 }
54
55 require(AT_INCLUDE_PATH.'header.inc.php'); 
56
57 ?>
58 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
59 <input type="hidden" name="mod" value="<?php echo $mod; ?>" />
60 <input type="hidden" name="args" value="<?php echo $args; ?>" />
61 <input type="hidden" name="permission_granted" value="<?php echo $permission_granted; ?>" />
62
63 <div class="input-form">
64         <div class="row">
65                 <?php echo _AT('uninstall_module_info', $mod); ?><br />
66                 <input type="checkbox" name="del_data" value="1" id="del_data" checked="checked" /><label for="del_data"><?php echo _AT('delete_module_data'); ?></label>
67         </div>
68
69         <div class="row buttons">
70                 <input type="submit" name="submit_yes" value="<?php echo _AT('submit_yes'); ?>" /> 
71                 <input type="submit" name="submit_no" value="<?php echo _AT('submit_no'); ?>" />
72         </div>
73 </div>
74 </form>
75
76 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>