remove old readme
[atutor.git] / docs / mods / _core / modules / details.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_MODULES);
17
18 require(AT_INCLUDE_PATH.'../mods/_core/modules/classes/ModuleParser.class.php');
19
20
21 if (isset($_POST['submit_no'])) {
22         $msg->addFeedback('CANCELLED');
23         header('Location: '.AT_BASE_HREF.'mods/_core/modules/add_new.php');
24         exit;
25 } else if (isset($_POST['mod']) && isset($_POST['submit_yes'])) {
26         $module = $moduleFactory->getModule($_POST['mod']);
27         $module->load();
28         $module->install();
29
30         if ($msg->containsErrors()) {
31                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/details.php?mod='.$addslashes($_POST['mod']).SEP.'new=1');
32         } else {
33                 $msg->addFeedback('MOD_INSTALLED');
34                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/index.php');
35         }
36         exit;
37 } else if (isset($_GET['submit'])) {
38         $args = '';
39
40         if (isset($_GET['enabled'])  && $_GET['enabled'])  {  $args .= 'enabled=1';      }
41         if (isset($_GET['disabled']) && $_GET['disabled']) {  $args .= SEP.'disabled=1'; }
42         if (isset($_GET['missing'])  && $_GET['missing'])  {  $args .= SEP.'missing=1';  }
43         if (isset($_GET['core'])     && $_GET['core'])     {  $args .= SEP.'core=1';     }
44         if (isset($_GET['standard']) && $_GET['standard']) {  $args .= SEP.'standard=1'; }
45         if (isset($_GET['extra'])    && $_GET['extra'])    {  $args .= SEP.'extra=1';    }
46
47         header('Location: index.php?'. $args);
48         exit;
49 }
50
51 require(AT_INCLUDE_PATH.'header.inc.php'); 
52
53 $moduleParser = new ModuleParser();
54
55 $_REQUEST['mod'] = str_replace(array('.','..'), '', $_REQUEST['mod']);
56
57 if (!file_exists('../../../mods/'.$_GET['mod'].'/module.xml')) {
58 ?>
59 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
60 <input type="hidden" name="mod" value="<?php echo $_GET['mod']; ?>" />
61 <input type="hidden" name="new" value="<?php echo $_GET['new']; ?>" />
62 <div class="input-form">
63         <div class="row">
64                 <h3><?php echo $_GET['mod']; ?></h3>
65         </div>
66
67         <div class="row">
68                 <?php echo _AT('missing_info'); ?>
69         </div>
70
71         <div class="row buttons">
72                 <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
73                 <?php if (isset($_GET['new']) && $_GET['new']): ?>
74                         <input type="submit" name="install" value="<?php echo _AT('install'); ?>" />
75                 <?php endif; ?>
76         </div>
77
78 </div>
79 </form>
80 <?php
81         require(AT_INCLUDE_PATH.'footer.inc.php');
82         exit;
83 }
84
85 $moduleParser->parse(file_get_contents('../../../mods/'.$_GET['mod'].'/module.xml'));
86
87 $module = $moduleFactory->getModule($_GET['mod']);
88
89 $properties = $module->getProperties(array('maintainers', 'url', 'date', 'license', 'state', 'notes', 'version'));
90 ?>
91
92 <?php if (isset($_REQUEST['new'])): ?>
93         <?php
94                 $hidden_vars['mod'] = $_REQUEST['mod'];
95                 $hidden_vars['new'] = '1';
96                 $msg->addConfirm(array('ADD_MODULE', $_REQUEST['mod']), $hidden_vars);
97                 $msg->printConfirm();
98         ?>
99 <?php endif; ?>
100
101 <?php 
102
103 $savant->assign('module', $module);
104 $savant->assign('properties', $properties);
105 $savant->display('admin/modules/details.tmpl.php');
106 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>