3b4ef3157f512feffdec3701fc6bb5dd1bc5db59
[atutor.git] / docs / mods / _core / content / index.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 define('AT_INCLUDE_PATH', '../../../include/');\r
15 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
16 authenticate(AT_PRIV_CONTENT);\r
17 \r
18 global $contentManager;\r
19 \r
20 if (isset($_GET['edit'], $_GET['ctid'])) {\r
21         $cid = intval($_GET['ctid']);\r
22         $result = $contentManager->getContentPage($cid);\r
23         $row = mysql_fetch_assoc($result);\r
24         \r
25         if ($row['content_type'] == CONTENT_TYPE_CONTENT || $row['content_type'] == CONTENT_TYPE_WEBLINK) {\r
26                 header('Location: '.AT_BASE_HREF.'mods/_core/editor/edit_content.php?cid='.$cid);\r
27         } else if ($row['content_type'] == CONTENT_TYPE_FOLDER) {\r
28                 header('Location: '.AT_BASE_HREF.'mods/_core/editor/edit_content_folder.php?cid='.$cid);\r
29         }\r
30         exit;\r
31 } else if (isset($_GET['delete'], $_GET['ctid'])) {\r
32         header('Location: '.AT_BASE_HREF.'mods/_core/editor/delete_content.php?cid='.intval($_GET['ctid']));\r
33         exit;\r
34 } else if (isset($_GET['view'], $_GET['ctid'])) {\r
35         $cid = intval($_GET['ctid']);\r
36         $result = $contentManager->getContentPage($cid);\r
37         $row = mysql_fetch_assoc($result);\r
38 \r
39     if ($row['content_type'] == CONTENT_TYPE_CONTENT || $row['content_type'] == CONTENT_TYPE_WEBLINK) {\r
40                 header('Location: '.AT_BASE_HREF.'content.php?cid='.intval($_GET['ctid']));\r
41     } else if ($row['content_type'] == CONTENT_TYPE_FOLDER) {\r
42                 header('Location: '.AT_BASE_HREF.'mods/_core/editor/edit_content_folder.php?cid='.$cid);\r
43     }\r
44         exit;\r
45 } else if (isset($_GET['usage'], $_GET['ctid'])) {\r
46         header('Location: '.AT_BASE_HREF.'mods/_standard/tracker/tools/page_student_stats.php?content_id='.intval($_GET['ctid']));\r
47         exit;\r
48 } else if (!isset($_GET['ctid']) && !isset($_GET['sub_content']) && (isset($_GET['usage']) || isset($_GET['view']) || isset($_GET['delete']) || isset($_GET['edit']))) {\r
49         $msg->addError('NO_ITEM_SELECTED');\r
50 }\r
51 \r
52 require(AT_INCLUDE_PATH.'header.inc.php');\r
53 \r
54 if ($_GET['col']) {\r
55         $col = addslashes($_GET['col']);\r
56 } else {\r
57         $col = 'content_parent_id, ordering';\r
58 }\r
59 \r
60 if ($_GET['order']) {\r
61         $order = addslashes($_GET['order']);\r
62 } else {\r
63         $order = 'asc';\r
64 }\r
65 \r
66 if (!isset($_GET['sub_content'])) {\r
67         $parent_id = 0; \r
68 } else {\r
69         $parent_id = intval($_GET['ctid']);\r
70 }\r
71 \r
72 \r
73 $all_content = $contentManager->getContent();\r
74 \r
75 $content = $all_content[$parent_id];\r
76 \r
77 function print_select($pid, $depth) {\r
78         global $all_content;\r
79 \r
80         if (!isset($all_content[$pid])) {\r
81                 return;\r
82         }\r
83 \r
84         foreach ($all_content[$pid] as $row) {\r
85                 if (isset($all_content[$row['content_id']])) {\r
86                         echo '<option value="'.$row['content_id'].'"';\r
87                         if ($_GET['ctid'] == $row['content_id']) {\r
88                                 echo ' selected="selected"';\r
89                         }\r
90                         echo '>';\r
91                         echo str_repeat('&nbsp;', $depth * 5);\r
92                         echo $row['title'].'</option>';\r
93 \r
94                         print_select($row['content_id'], $depth+1);\r
95                 }\r
96         }\r
97 }\r
98 $savant->assign('all_content', $all_content);\r
99 $savant->assign('content', $content);\r
100 $savant->display('instructor/content/index.tmpl.php');\r
101 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>