Moved scripts in "docs" one level up into root folder. In addition, removed "docs...
[atutor.git] / mods / _standard / course_tools / side_menu.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 define('AT_INCLUDE_PATH', '../../../include/');
14 require(AT_INCLUDE_PATH.'vitals.inc.php');
15
16 authenticate(AT_PRIV_COURSE_TOOLS);
17
18
19 if (isset($_POST['cancel'])) {
20         $msg->addFeedback('CANCELLED');
21         header('Location: modules.php');
22         exit;
23         
24 }
25
26 if (isset($_POST['submit'])) {
27
28         $side_menu = '';
29         $_stack_names = array();
30
31         $_stack_names = array_keys($_stacks);
32
33         $_POST['stack'] = array_unique($_POST['stack']);
34         $_POST['stack'] = array_intersect($_POST['stack'], $_stack_names);
35
36         $side_menu = implode('|', $_POST['stack']);
37
38         $sql    = "UPDATE ".TABLE_PREFIX."courses SET side_menu='$side_menu' WHERE course_id=$_SESSION[course_id]";
39         $result = mysql_query($sql, $db);
40         $msg->addFeedback('COURSE_PREFS_SAVED');
41         header('Location: side_menu.php');
42         exit;
43 }
44
45 require(AT_INCLUDE_PATH.'header.inc.php');
46
47 ?>
48 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="prefs">
49 <div class="input-form" style="width:90%">
50         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('side_menu'); ?></legend>
51         <div class="row">
52                 <p><?php echo _AT('side_menu_text'); ?></p>
53         </div>
54
55         <div class="row">
56                 <?php
57                         $num_stack = count($_stacks);
58                         $side_menu = explode("|", $system_courses[$_SESSION['course_id']]['side_menu']);                        
59
60                         for ($i=0; $i<$num_stack; $i++) {                               
61                                 echo '<select name="stack['.$i.']">';
62                                 echo '<option value=""></option>';
63                                 foreach ($_stacks as $name=>$info) {
64                                         if (isset($info['title'])) {
65                                                 $title = $info['title'];
66                                         } else {
67                                                 $title = _AT($info['title_var']);
68                                         }
69                                         echo '<option value="'.$name.'"';
70                                         if (isset($side_menu[$i]) && ($name == $side_menu[$i])) {
71                                                 echo ' selected="selected"';
72                                         }
73                                         echo '>'.$title.'</option>';
74                                 }
75                                 echo '</select>';
76                                 echo '<br />'; 
77                         } ?>
78         </div>
79
80         <div class="buttons">
81                 <input type="submit" name="submit" value="<?php echo _AT('apply'); ?>" accesskey="s" />
82                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
83         </div>
84         </fieldset>
85 </div>
86 </form>
87
88 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>