index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  5. * @author Juan Carlos Raña <herodoto@telefonica.net>
  6. *
  7. * @package chamilo.wiki
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. require_once 'wiki.inc.php';
  11. global $charset;
  12. $wiki = new Wiki();
  13. $wiki->charset = $charset;
  14. // section (for the tabs)
  15. $this_section = SECTION_COURSES;
  16. $current_course_tool = TOOL_WIKI;
  17. $course_id = api_get_course_int_id();
  18. $session_id = api_get_session_id();
  19. $condition_session = api_get_session_condition($session_id);
  20. $course_id = api_get_course_int_id();
  21. $groupId = api_get_group_id();
  22. // additional style information
  23. $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
  24. // javascript for advanced parameters menu
  25. $htmlHeadXtra[] = '<script>
  26. function setFocus() {
  27. $("#search_title").focus();
  28. }
  29. $(document).ready(function() {
  30. setFocus();
  31. $("#start_date_toggle").click(function() {
  32. $("#start_date").toggle();
  33. });
  34. $("#end_date_toggle").click(function() {
  35. $("#end_date").toggle();
  36. });
  37. });
  38. </script>';
  39. /* Constants and variables */
  40. $tool_name = get_lang('ToolWiki');
  41. /* ACCESS */
  42. api_protect_course_script();
  43. api_block_anonymous_users();
  44. api_protect_course_group(GroupManager::GROUP_TOOL_WIKI);
  45. /* TRACKING */
  46. Event::event_access_tool(TOOL_WIKI);
  47. if ($groupId) {
  48. $group_properties = GroupManager::get_group_properties($groupId);
  49. $interbreadcrumb[] = array(
  50. "url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
  51. "name" => get_lang('Groups')
  52. );
  53. $interbreadcrumb[] = array(
  54. "url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
  55. "name" => get_lang('GroupSpace').' '.Security::remove_XSS($group_properties['name'])
  56. );
  57. //ensure this tool in groups whe it's private or deactivated
  58. if ($group_properties['wiki_state'] == 0) {
  59. api_not_allowed();
  60. } elseif ($group_properties['wiki_state'] == 2) {
  61. if (!api_is_allowed_to_edit(false, true) and
  62. !GroupManager :: is_user_in_group(api_get_user_id(), $group_properties)
  63. ) {
  64. api_not_allowed();
  65. }
  66. }
  67. }
  68. $is_allowed_to_edit = api_is_allowed_to_edit(false, true);
  69. // The page we are dealing with
  70. $page = isset($_GET['title']) ? $_GET['title'] : 'index';
  71. $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'showpage';
  72. $view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
  73. $wiki->page = $page;
  74. $wiki->action = $action;
  75. // Setting wiki data
  76. if (!empty($view)) {
  77. $wiki->setWikiData($view);
  78. }
  79. $wiki->blockConcurrentEditions(api_get_user_id(), $action);
  80. /* MAIN WIKI AREA */
  81. ob_start();
  82. $handleAction = $wiki->handleAction($action);
  83. if (!$handleAction && $action == 'export_to_pdf') {
  84. $wiki->handleAction('showpage');
  85. }
  86. $content = ob_get_contents();
  87. ob_end_clean();
  88. Display::display_header($tool_name, 'Wiki');
  89. // check last version
  90. if (!empty($view)) {
  91. $wiki->checkLastVersion($view);
  92. }
  93. // Tool introduction
  94. Display::display_introduction_section(TOOL_WIKI);
  95. $wiki->showActionBar();
  96. echo $content;
  97. Display::display_footer();