(no commit message)
[atutor.git] / mods / _core / cats_categories / admin / course_categories.php
1 <?php\r
2 /****************************************************************************/\r
3 /* ATutor                                                                                                                                       */\r
4 /****************************************************************************/\r
5 /* Copyright (c) 2002-2010                                                  */\r
6 /* Inclusive Design Institute                                               */\r
7 /* http://atutor.ca                                                                                                                     */\r
8 /*                                                                                                                                                      */\r
9 /* This program is free software. You can redistribute it and/or                        */\r
10 /* modify it under the terms of the GNU General Public License                          */\r
11 /* as published by the Free Software Foundation.                                                        */\r
12 /****************************************************************************/\r
13 // $Id$\r
14 \r
15 define('AT_INCLUDE_PATH', '../../../../include/');\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
17 require(AT_INCLUDE_PATH.'../mods/_core/themes/lib/themes.inc.php');\r
18 admin_authenticate(AT_ADMIN_PRIV_CATEGORIES);\r
19 \r
20 if (isset($_POST['delete'], $_POST['cat_id'])) {\r
21         header('Location: delete_category.php?cat_id='.$_POST['cat_id']);\r
22         exit;\r
23 } else if (isset($_POST['edit'], $_POST['cat_id'])) {\r
24         header('Location: edit_category.php?cat_id='.$_POST['cat_id']);\r
25         exit;\r
26 } else if (!empty($_POST)) {\r
27         $msg->addError('NO_ITEM_SELECTED');\r
28 }\r
29 \r
30 require(AT_INCLUDE_PATH.'header.inc.php'); \r
31 \r
32 ?>\r
33 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
34 <table summary="" class="data" rules="cols" align="center" style="width: 95%;">\r
35 \r
36 <thead>\r
37 <tr>\r
38         <th scope="col">&nbsp;</th>\r
39         <th scope="col"><?php echo _AT('name'); ?></th>\r
40         <th scope="col"><?php echo _AT('parent'); ?></th>\r
41 <?php if (defined('AT_ENABLE_CATEGORY_THEMES') && AT_ENABLE_CATEGORY_THEMES) : ?>\r
42         <th scope="col"><?php echo _AT('theme'); ?></th>\r
43 <?php endif; ?>\r
44 </tr>\r
45 </thead>\r
46 <tfoot>\r
47 <tr>\r
48         <td colspan="4">\r
49                 <div class="row buttons">\r
50                 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /> \r
51                 </div>\r
52         </td>\r
53 </tr>\r
54 </tfoot>\r
55 <tbody>\r
56 <?php\r
57 $sql    = "SELECT * FROM ".TABLE_PREFIX."course_cats ORDER BY cat_name";\r
58 $result = mysql_query($sql, $db);\r
59 if ($row = mysql_fetch_assoc($result)): ?>\r
60         <?php\r
61         do {\r
62                 $parent_cat_name = '';\r
63                 if ($row['cat_parent']) {\r
64                         $sql_cat        = "SELECT cat_name FROM ".TABLE_PREFIX."course_cats WHERE cat_id=".$row['cat_parent'];\r
65                         $result_cat = mysql_query($sql_cat, $db);\r
66                         $row_cat = mysql_fetch_assoc($result_cat);\r
67                         $parent_cat_name = $row_cat['cat_name'];\r
68                 } \r
69         ?>\r
70                 <tr onmousedown="document.form['m<?php echo $row['cat_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['cat_id']; ?>">\r
71                         <td width="10"><input type="radio" name="cat_id" value="<?php echo $row['cat_id']; ?>" id="m<?php echo $row['cat_id']; ?>" /></td>\r
72                         <td><label for="m<?php echo $row['cat_id']; ?>"><?php echo AT_print($row['cat_name'], 'course_cats.cat_name'); ?></label></td>\r
73                         <td><?php echo AT_print($parent_cat_name, 'course_cats.cat_name'); ?></td>\r
74                         <?php if (defined('AT_ENABLE_CATEGORY_THEMES') && AT_ENABLE_CATEGORY_THEMES) : ?>\r
75                                 <td><?php echo AT_print(get_theme_name($row['theme']), 'themes.title'); ?></td>\r
76                         <?php endif; ?>\r
77 \r
78                 </tr>\r
79         <?php } while ($row = mysql_fetch_assoc($result)); ?>\r
80 <?php else: ?>\r
81         <tr>\r
82                 <td colspan="3"><?php echo _AT('none_found'); ?></td>\r
83         </tr>\r
84 <?php endif; ?>\r
85 </tbody>\r
86 </table>\r
87 \r
88 </form>\r
89 \r
90 \r
91 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>