Dokeos PHP Cross Reference Learning Management Systems

Source: /main/forum/reply.php - 242 lines - 10631 bytes - Summary - Text - Print

Description: These files are a complete rework of the forum. The database structure is based on phpBB but all the code is rewritten. A lot of new functionalities are added: - forum categories and forums can be sorted up or down, locked or made invisible - consistent and integrated forum administration - forum options:     are students allowed to edit their post? moderation of posts (approval) reply only forums (students cannot create new threads) multiple forums per group - sticky messages - new view option: nested view - quoting a message

   1  <?php
   2  /*
   3  ==============================================================================
   4      Dokeos - elearning and course management software
   5  
   6      Copyright (c) 2006-2008 Dokeos SPRL
   7      Copyright (c) 2006 Ghent University (UGent)
   8  
   9      For a full list of contributors, see "credits.txt".
  10      The full license can be read in "license.txt".
  11  
  12      This program is free software; you can redistribute it and/or
  13      modify it under the terms of the GNU General Public License
  14      as published by the Free Software Foundation; either version 2
  15      of the License, or (at your option) any later version.
  16  
  17      See the GNU General Public License for more details.
  18  
  19      Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
  20      Mail: info@dokeos.com
  21  ==============================================================================
  22  */
  23  
  24  /**
  25  *    These files are a complete rework of the forum. The database structure is
  26  *    based on phpBB but all the code is rewritten. A lot of new functionalities
  27  *    are added:
  28  *     - forum categories and forums can be sorted up or down, locked or made invisible
  29  *    - consistent and integrated forum administration
  30  *     - forum options:     are students allowed to edit their post?
  31  *                         moderation of posts (approval)
  32  *                         reply only forums (students cannot create new threads)
  33  *                         multiple forums per group
  34  *    - sticky messages
  35  *     - new view option: nested view
  36  *     - quoting a message
  37  *
  38  *    @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  39  *    @Copyright Ghent University
  40  *    @Copyright Patrick Cool
  41  *
  42  *     @package dokeos.forum
  43  */
  44  
  45  // name of the language file that needs to be included
  46  $language_file = array('forum','document');
  47  
  48  // including the global dokeos file
  49  require  '../inc/global.inc.php';
  50  
  51  // the section (tabs)
  52  $this_section=SECTION_COURSES;
  53  
  54  // notice for unauthorized people.
  55  api_protect_course_script(true);
  56  
  57  
  58  // including additional library scripts
  59  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  60  include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  61  $nameTools=get_lang('Forum');
  62  
  63  $origin = '';
  64  if(isset($_GET['origin'])) {
  65      $origin =  Security::remove_XSS($_GET['origin']);
  66      $origin_string = '&origin='.$origin;
  67  }
  68  
  69  /*
  70  -----------------------------------------------------------
  71      Including necessary files
  72  -----------------------------------------------------------
  73  */
  74  require  'forumconfig.inc.php';
  75  require_once  'forumfunction.inc.php';
  76  
  77  
  78  // javascript
  79  $htmlHeadXtra[] = '<script>
  80  
  81  		function advanced_parameters() {
  82              if(document.getElementById(\'id_qualify\').style.display == \'none\') {
  83                  document.getElementById(\'id_qualify\').style.display = \'block\';
  84                  document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  85  
  86              } else {
  87                  document.getElementById(\'id_qualify\').style.display = \'none\';
  88                  document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  89              }
  90          }
  91  </script>';
  92  /*
  93  ==============================================================================
  94          MAIN DISPLAY SECTION
  95  ==============================================================================
  96  */
  97  /*
  98  -----------------------------------------------------------
  99      Retrieving forum and forum categorie information
 100  -----------------------------------------------------------
 101  */
 102  // we are getting all the information about the current forum and forum category.
 103  // note pcool: I tried to use only one sql statement (and function) for this
 104  // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
 105  $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
 106  $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
 107  $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
 108  
 109  /*
 110  -----------------------------------------------------------
 111      Breadcrumbs
 112  -----------------------------------------------------------
 113  */
 114  if (isset($_SESSION['gradebook'])){
 115      $gradebook=    $_SESSION['gradebook'];
 116  }
 117  
 118  if (!empty($gradebook) && $gradebook=='view') {
 119      $interbreadcrumb[]= array (
 120              'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 121              'name' => get_lang('Gradebook')
 122          );
 123  }
 124  
 125  if (!empty($_SESSION['toolgroup'])) {
 126      $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
 127      $group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
 128      $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
 129      $interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
 130      $interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']);
 131      $interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&gradebook=".$gradebook."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']);
 132      $interbreadcrumb[]=array("url" => "javascript: void(0);","name" => get_lang('Reply'));
 133  
 134  } else {
 135      $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools);
 136      $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']);
 137      $interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']);
 138      $interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&gradebook=".$gradebook."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']);
 139      $interbreadcrumb[]=array("url" => "javascript: void(0);","name" => get_lang('Reply'));
 140  }
 141  /*
 142  -----------------------------------------------------------
 143      Resource Linker
 144  -----------------------------------------------------------
 145  */
 146  if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
 147      $_SESSION['formelements']=$_POST;
 148      $_SESSION['origin']=$_SERVER['REQUEST_URI'];
 149      $_SESSION['breadcrumbs']=$interbreadcrumb;
 150      header("Location: ../resourcelinker/resourcelinker.php");
 151  }
 152  /*
 153  -----------------------------------------------------------
 154      Header
 155  -----------------------------------------------------------
 156  */
 157  if($origin=='learnpath') {
 158      include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
 159  } else {
 160      // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
 161      Display :: display_tool_header('');
 162      //api_display_tool_title($nameTools);
 163  }
 164  /*
 165  -----------------------------------------------------------
 166      Is the user allowed here?
 167  -----------------------------------------------------------
 168  */
 169  // The user is not allowed here if
 170  // 1. the forumcategory, forum or thread is invisible (visibility==0
 171  // 2. the forumcategory, forum or thread is locked (locked <>0)
 172  // 3. if anonymous posts are not allowed
 173  // The only exception is the course manager
 174  // I have split this is several pieces for clarity.
 175  //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
 176  if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) {
 177      forum_not_allowed_here();
 178  }
 179  if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) {
 180      forum_not_allowed_here();
 181  }
 182  if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) {
 183      forum_not_allowed_here();
 184  }
 185  /*
 186  -----------------------------------------------------------
 187      Action links
 188  -----------------------------------------------------------
 189  */
 190  if ($origin != 'learnpath') {
 191      echo '<div class="actions">';
 192      echo '<span style="float:right;">'.search_link().'</span>';
 193      echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('pixel.gif', get_lang('BackToForumOverview'), array('class' => 'toolactionplaceholdericon toolactionback')).get_lang('BackToForumOverview').'</a>';
 194      echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$_SESSION['toolgroup'].'">'.Display::return_icon('pixel.gif', get_lang('BackToForum'), array('class' => 'toolactionplaceholdericon toolactionforum')).get_lang('BackToForum').'</a>';
 195      echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'">'.Display::return_icon('pixel.gif',get_lang('BackToThread'), array('class' => 'toolactionplaceholdericon toolactionsinvite')).get_lang('BackToThread').'</a>';
 196      echo '</div>';
 197  } else {
 198      echo '<div style="height:15px">&nbsp;</div>';
 199  }
 200  /*
 201  -----------------------------------------------------------
 202      Display Forum Category and the Forum information
 203  -----------------------------------------------------------
 204  */
 205  
 206  echo '<div id="content">';
 207  
 208  echo "<table class=\"data_table\" width='100%'>\n";
 209  
 210  // the forum category
 211  echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
 212  
 213  echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
 214  
 215  if (!empty ($current_forum_category['cat_title'])) {
 216      echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])." - </span>";
 217  }
 218  
 219  echo '<span class="forum_low_description">'.prepare4display($current_forum['forum_title']).'</span>';
 220  echo "</th>\n";
 221  echo "\t</tr>\n";
 222  echo '</table>';
 223  
 224  // the form for the reply
 225  $my_action   = isset($_GET['action']) ? $_GET['action'] : '';
 226  $my_post     = isset($_GET['post']) ? $_GET['post'] : '';
 227  $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '';
 228  $values=show_add_post_form($my_action,$my_post, $my_elements); // note: this has to be cleaned first
 229  
 230  if (!empty($values) AND isset($_POST['SubmitPost'])) {
 231      store_reply($values);
 232  }
 233  
 234  echo "</div>";
 235  
 236  // Display the footer
 237  if($origin!='learnpath') {
 238      echo '<div class="actions">';
 239      echo '&nbsp;';
 240      echo '</div>';
 241      Display :: display_footer();
 242  }

title

Description

title

Description

title

Description

title

title

Body