index.php 3.8 KB

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