/mods/_core/content/index.php

https://github.com/harriswong/ATutor · PHP · 101 lines · 74 code · 15 blank · 12 comment · 38 complexity · 61b8ff83bf38acf245ecc605a4426acc MD5 · raw file

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