index.php 3.1 KB

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