made a copy
[atutor.git] / admin / modules / details.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto                  */
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_ADMIN);
18
19 require(AT_INCLUDE_PATH.'classes/Module/ModuleParser.class.php');
20
21
22 if (isset($_POST['submit_no'])) {
23         $msg->addFeedback('CANCELLED');
24         header('Location: '.AT_BASE_HREF.'admin/modules/add_new.php');
25         exit;
26 } else if (isset($_POST['mod']) && isset($_POST['submit_yes'])) {
27         $module = $moduleFactory->getModule($_POST['mod']);
28         $module->load();
29         $module->install();
30
31         if ($msg->containsErrors()) {
32                 header('Location: '.AT_BASE_HREF.'admin/modules/details.php?mod='.$addslashes($_POST['mod']).SEP.'new=1');
33         } else {
34                 $msg->addFeedback('MOD_INSTALLED');
35                 header('Location: '.AT_BASE_HREF.'admin/modules/index.php');
36         }
37         exit;
38 } else if (isset($_GET['submit'])) {
39         $args = '';
40
41         if (isset($_GET['enabled'])  && $_GET['enabled'])  {  $args .= 'enabled=1';      }
42         if (isset($_GET['disabled']) && $_GET['disabled']) {  $args .= SEP.'disabled=1'; }
43         if (isset($_GET['missing'])  && $_GET['missing'])  {  $args .= SEP.'missing=1';  }
44         if (isset($_GET['core'])     && $_GET['core'])     {  $args .= SEP.'core=1';     }
45         if (isset($_GET['standard']) && $_GET['standard']) {  $args .= SEP.'standard=1'; }
46         if (isset($_GET['extra'])    && $_GET['extra'])    {  $args .= SEP.'extra=1';    }
47
48         header('Location: index.php?'. $args);
49         exit;
50 }
51
52 require(AT_INCLUDE_PATH.'header.inc.php'); 
53
54 $moduleParser = new ModuleParser();
55
56 $_REQUEST['mod'] = str_replace(array('.','..'), '', $_REQUEST['mod']);
57
58 if (!file_exists('../../mods/'.$_GET['mod'].'/module.xml')) {
59 ?>
60 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
61 <input type="hidden" name="mod" value="<?php echo $_GET['mod']; ?>" />
62 <input type="hidden" name="new" value="<?php echo $_GET['new']; ?>" />
63 <div class="input-form">
64         <div class="row">
65                 <h3><?php echo $_GET['mod']; ?></h3>
66         </div>
67
68         <div class="row">
69                 <?php echo _AT('missing_info'); ?>
70         </div>
71
72         <div class="row buttons">
73                 <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
74                 <?php if (isset($_GET['new']) && $_GET['new']): ?>
75                         <input type="submit" name="install" value="<?php echo _AT('install'); ?>" />
76                 <?php endif; ?>
77         </div>
78
79 </div>
80 </form>
81 <?php
82         require(AT_INCLUDE_PATH.'footer.inc.php');
83         exit;
84 }
85
86 $moduleParser->parse(file_get_contents('../../mods/'.$_GET['mod'].'/module.xml'));
87
88 $module = $moduleFactory->getModule($_GET['mod']);
89
90 $properties = $module->getProperties(array('maintainers', 'url', 'date', 'license', 'state', 'notes', 'version'));
91 ?>
92 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
93 <input type="hidden" name="mod" value="<?php echo $_GET['mod']; ?>" />
94 <input type="hidden" name="new" value="<?php echo $_GET['new']; ?>" />
95
96 <input type="hidden" name="enabled" value="<?php echo (int) isset($_GET['enabled']); ?>" />
97 <input type="hidden" name="disabled" value="<?php echo (int) isset($_GET['disabled']); ?>" />
98 <input type="hidden" name="core" value="<?php echo (int) isset($_GET['core']); ?>" />
99 <input type="hidden" name="standard" value="<?php echo (int) isset($_GET['standard']); ?>" />
100 <input type="hidden" name="extra" value="<?php echo (int) isset($_GET['extra']); ?>" />
101 <input type="hidden" name="missing" value="<?php echo (int) isset($_GET['missing']); ?>" />
102
103 <div class="input-form">
104         <div class="row">
105                 <h3><?php echo $module->getName(); ?></h3>
106         </div>
107
108         <div class="row">
109                 <?php echo _AT('description'); ?><br />
110                 <?php echo nl2br($module->getDescription($_SESSION['lang'])); ?>
111         </div>
112
113         <div class="row">
114                 <?php echo _AT('maintainers'); ?><br />
115                         <ul class="horizontal">
116                                 <?php foreach ($properties['maintainers'] as $maintainer): ?>
117                                         <li><?php echo $maintainer['name'] .' &lt;'.$maintainer['email'].'&gt;'; ?></li>
118                                 <?php endforeach; ?>
119                         </ul>
120         </div>
121
122         <div class="row">
123                 <?php echo _AT('url'); ?><br />
124                 <?php echo $properties['url']; ?>
125         </div>
126
127         <div class="row">
128                 <?php echo _AT('version'); ?><br />
129                 <?php echo $properties['version']; ?>
130         </div>
131
132         <div class="row">
133                 <?php echo _AT('date'); ?><br />
134                 <?php echo $properties['date']; ?>
135         </div>
136
137         <div class="row">
138                 <?php echo _AT('license'); ?><br />
139                 <?php echo $properties['license']; ?>
140         </div>
141
142         <div class="row">
143                 <?php echo _AT('state'); ?><br />
144                 <?php echo $properties['state']; ?>
145         </div>
146
147         <div class="row">
148                 <?php echo _AT('notes'); ?><br />
149                 <?php echo nl2br($properties['notes']); ?>
150         </div>
151
152         <?php if (is_array($module->_pages)): ?>
153                 <div class="row">
154                         <?php if (!isset($_GET['files'])): ?>
155                                 <a href="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES).SEP; ?>files#files"><?php echo _AT('files'); ?></a><br />
156                         <?php else: ?>
157                                 <?php $module_pages = array_keys($module->_pages); ?>
158                                 <?php natsort($module_pages); ?>
159                                 <a name="files"></a><?php echo _AT('files'); ?><br />
160                                 <ul style="margin-top: 0px;">
161                                         <?php foreach ($module_pages as $key): ?>
162                                                 <?php if (defined($key)) : continue; endif; ?>
163                                                 <li><kbd><?php echo $key; ?></kbd></li>
164                                         <?php endforeach; ?>
165                                 </ul>
166                         <?php endif; ?>
167                 </div>
168         <?php endif; ?>
169
170 <?php if (!isset($_REQUEST['new'])): ?>
171         <div class="row buttons">
172                 <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
173         </div>
174 <?php endif; ?>
175 </div>
176 </form>
177 <?php if (isset($_REQUEST['new'])): ?>
178         <?php
179                 $hidden_vars['mod'] = $_REQUEST['mod'];
180                 $hidden_vars['new'] = '1';
181                 $msg->addConfirm(array('ADD_MODULE', $_REQUEST['mod']), $hidden_vars);
182                 $msg->printConfirm();
183         ?>
184 <?php endif; ?>
185
186 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>