made a copy
[atutor.git] / admin / modules / default_side.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
18 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
19
20
21 if (isset($_POST['cancel'])) {
22         $msg->addFeedback('CANCELLED');
23         header('Location: ../courses.php');
24         exit;
25 }
26
27 if (isset($_POST['submit'])) {
28
29         $side_menu = '';
30         $_stack_names = array();
31
32         foreach($_stacks as $name=>$file) {
33                 $_stack_names[] = $name;
34         }
35
36         $_POST['stack'] = array_unique($_POST['stack']);
37         $_POST['stack'] = array_intersect($_POST['stack'], $_stack_names);
38
39         foreach($_POST['stack'] as $dropdown) {
40                 if($dropdown != '') {
41                         $side_menu .= $dropdown . '|';
42                 }
43         }
44         $side_menu = substr($side_menu, 0, -1);
45
46         if (!($_config_defaults['side_defaults'] == $side_menu) && (strlen($side_menu) < 256)) {
47                 $sql    = "REPLACE INTO ".TABLE_PREFIX."config VALUES('side_defaults', '$side_menu')";
48         } else if ($_config_defaults['side_defaults'] == $side_menu) {
49                 $sql    = "DELETE FROM ".TABLE_PREFIX."config WHERE name='side_defaults'";
50         }
51
52         $result = mysql_query($sql, $db);
53         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
54         header('Location:'. $_SERVER[PHP_SELF]);
55         exit;
56 }
57
58 require(AT_INCLUDE_PATH.'header.inc.php');
59
60 ?>
61 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="prefs">
62 <div class="input-form" style="width:50%">
63         <div class="row">
64                 <p><?php echo _AT('side_menu_text'); ?></p>
65         </div>
66
67         <div class="row">
68                 <?php
69                         $num_stack = count($_stacks);   
70
71                         $side_menu = explode('|', $_config['side_defaults']);
72
73                         for ($i=0; $i<$num_stack; $i++) {                               
74                                 echo '<select name="stack['.$i.']">';
75                                 echo '<option value=""></option>';
76                                 foreach ($_stacks as $name=>$info) {
77                                         if (isset($info['title'])) {
78                                                 $title = $info['title'];
79                                         } else {
80                                                 $title = _AT($info['title_var']);
81                                         }
82                                         echo '<option value="'.$name.'"';
83                                         if (isset($side_menu[$i]) && ($name == $side_menu[$i])) {
84                                                 echo ' selected="selected"';
85                                         }
86                                         echo '>'.$title.'</option>';
87                                 }
88                                 echo '</select>';
89                                 echo '<br />'; 
90                         } ?>
91         </div>
92
93         <div class="buttons">
94                 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
95                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"  />
96         </div>
97 </div>
98 </form>
99
100 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>