Dokeos PHP Cross Reference Learning Management Systems

Source: /main/forum/viewthread.php - 320 lines - 13947 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4  ==============================================================================
   5      Dokeos - elearning and course management software
   6  
   7      Copyright (c) 2004-2008 Dokeos SPRL
   8      Copyright (c) 2003 Ghent University (UGent)
   9      Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10      Copyright (c) various contributors
  11  
  12      For a full list of contributors, see "credits.txt".
  13      The full license can be read in "license.txt".
  14  
  15      This program is free software; you can redistribute it and/or
  16      modify it under the terms of the GNU General Public License
  17      as published by the Free Software Foundation; either version 2
  18      of the License, or (at your option) any later version.
  19  
  20      See the GNU General Public License for more details.
  21  
  22      Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  23      Mail: info@dokeos.com
  24  ==============================================================================
  25  */
  26  
  27  /**
  28  *    @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  29  *    @Copyright Ghent University
  30  *    @Copyright Patrick Cool
  31  *
  32  *     @package dokeos.forum
  33  */
  34  // name of the language file that needs to be included
  35  $language_file = array (
  36  'forum',
  37  'group'
  38  );
  39  
  40  // including the global dokeos file
  41  require  '../inc/global.inc.php';
  42  
  43  // the section (tabs)
  44  $this_section=SECTION_COURSES;
  45  
  46  // notice for unauthorized people.
  47  api_protect_course_script(true);
  48  
  49  // including additional library scripts
  50  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  51  require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  52  //require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
  53  $nameTools=get_lang('Forum');
  54  
  55  /*
  56  -----------------------------------------------------------
  57      Including necessary files
  58  -----------------------------------------------------------
  59  */
  60  require  'forumconfig.inc.php';
  61  require_once  'forumfunction.inc.php';
  62  
  63  
  64  //are we in a lp ?
  65  $origin = '';
  66  if (isset($_GET['origin'])) {
  67      $origin =  Security::remove_XSS($_GET['origin']);
  68  }
  69  
  70  
  71  /*
  72  ==============================================================================
  73          MAIN DISPLAY SECTION
  74  ==============================================================================
  75  */
  76  /*
  77  -----------------------------------------------------------
  78      Retrieving forum and forum categorie information
  79  -----------------------------------------------------------
  80  */
  81  // we are getting all the information about the current forum and forum category.
  82  // note pcool: I tried to use only one sql statement (and function) for this
  83  // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  84  $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  85  $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
  86  $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  87  
  88  $whatsnew_post_info=$_SESSION['whatsnew_post_info'];
  89  
  90  /*
  91  -----------------------------------------------------------
  92      Header and Breadcrumbs
  93  -----------------------------------------------------------
  94  */
  95  
  96  
  97  
  98  if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
  99      $_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']);
 100      $gradebook=    $_SESSION['gradebook'];
 101  } /*elseif (empty($_GET['gradebook'])) {
 102      unset($_SESSION['gradebook']);
 103      $gradebook=    '';
 104  } */
 105  
 106  if (!empty($gradebook) && $gradebook=='view') {
 107      $interbreadcrumb[] = array (
 108          'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
 109          'name' => get_lang('Gradebook')
 110      );
 111  }
 112  
 113  if (!empty($_SESSION['toolgroup'])) {
 114  
 115      $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
 116      $group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
 117      $interbreadcrumb[] = array("url"=>"../group/group.php", "name" => get_lang('Groups'));
 118      $interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
 119      $interbreadcrumb[] = array("url"=>"viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;gidReq=".$_SESSION['toolgroup']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum['forum_title']));
 120      $interbreadcrumb[] = array("url"=>"viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&gradebook=".$gradebook."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
 121  
 122  //    Display :: display_tool_header('');
 123  //    api_display_tool_title($nameTools);
 124      Display::display_tool_header();
 125  
 126  } else {
 127  
 128      $my_search=isset($_GET['search']) ? $_GET['search'] : '';
 129  
 130  
 131      if ($origin=='learnpath') {
 132          include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
 133      } else {
 134  
 135          $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&search=".Security::remove_XSS(urlencode($my_search)),"name" => $nameTools);
 136          $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum_category['cat_title']));
 137          $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum['forum_title']));
 138          $message = isset($message) ? $message : '';
 139          // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
 140      //    Display :: display_tool_header('');
 141      //    api_display_tool_title($nameTools);
 142          Display::display_tool_header();
 143      }
 144  }
 145  /*
 146  -----------------------------------------------------------
 147      Is the user allowed here?
 148  -----------------------------------------------------------
 149  */
 150  // if the user is not a course administrator and the forum is hidden
 151  // then the user is not allowed here.
 152  if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) {
 153      forum_not_allowed_here();
 154  }
 155  
 156  
 157  // getting all the information that is new for this user
 158  get_whats_new();
 159  $whatsnew_post_info = array();
 160  $whatsnew_post_info = $_SESSION['whatsnew_post_info'];
 161  
 162  /*
 163  -----------------------------------------------------------
 164      Actions
 165  -----------------------------------------------------------
 166  */
 167  $post_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : '';
 168  $my_action = isset($_GET['action']) ? $_GET['action'] : '';
 169  if ($my_action=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 170      $message=delete_post($post_id); // note: this has to be cleaned first
 171  }
 172  if (($my_action=='invisible' OR $my_action=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 173      $message=approve_post($post_id,$my_action); // note: this has to be cleaned first
 174  }
 175  if ($my_action=='move' AND isset($_GET['post'])) {
 176      $message=move_post_form();
 177  }
 178  
 179  /*
 180  -----------------------------------------------------------
 181      Display the action messages
 182  -----------------------------------------------------------
 183  */
 184  $my_message = isset($message) ? $message : '';
 185  if ($my_message) {
 186      Display :: display_confirmation_message(get_lang($my_message));
 187  }
 188  
 189  if ($my_message<>'PostDeletedSpecial') {
 190      // in this case the first and only post of the thread is removed
 191      // this increases the number of times the thread has been viewed
 192      increase_thread_view($_GET['thread']);
 193      /*
 194      -----------------------------------------------------------
 195          Action Links
 196      -----------------------------------------------------------
 197      */
 198      if ($origin=='learnpath') {
 199          echo '<div style="height:15px">&nbsp;</div>';
 200      }
 201      echo '<div class="actions">';
 202      echo '<span style="float:right;">'.search_link().'</span>';
 203      if ($origin != 'learnpath') {
 204          echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('pixel.gif',get_lang('BackToForumOverview'),array('class' => 'toolactionplaceholdericon toolactionback')).get_lang('BackToForumOverview').'</a>';
 205          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>';
 206      }
 207      // the reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
 208      // if one of the three levels is locked then the link should not be displayed
 209      if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
 210          // The link should only appear when the user is logged in or when anonymous posts are allowed.
 211          if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
 212              //reply link
 213              if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) {
 214                  echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&origin='.$origin.'">'.Display::return_icon('pixel.gif',get_lang('ReplyToThread'), array('class' => 'toolactionplaceholdericon toolactionsinvite')).get_lang('ReplyToThread').'</a>';
 215              }
 216              //new thread link
 217              if ((api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1)) {
 218                  if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
 219                      //echo '&nbsp;&nbsp;';
 220  /*                    if ( isset($_GET['gradebook']) && $_GET['gradebook']!=""){
 221                          $info_thread=get_thread_information($_GET['thread']);
 222                          echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.$info_thread['forum_id'].'&origin='.$origin.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'">'.Display::return_icon('forumthread_new.gif', get_lang('NewTopic')).' '.get_lang('NewTopic').'</a>';
 223                      } else {
 224                          echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'">'.Display::return_icon('forumthread_new.gif', get_lang('NewTopic')).' '.get_lang('NewTopic').'</a>';
 225                      } */
 226                  } else {
 227                      echo get_lang('ForumLocked');
 228                  }
 229              }
 230          }
 231      }
 232  
 233      // the different views of the thread
 234  /*    if ($origin != 'learnpath') {
 235          $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS(urlencode($my_search));
 236          echo $my_url.'&amp;view=flat&origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_listview.gif',get_lang('FlatView')).get_lang('FlatView').'</a>';
 237          echo $my_url.'&amp;view=threaded&origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_threadedview.gif',get_lang('ThreadedView')).get_lang('ThreadedView').'</a>';
 238          echo $my_url.'&amp;view=nested&origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_nestedview.gif',get_lang('NestedView')).get_lang('NestedView').'</a>';
 239      }*/
 240      $my_url = null;
 241  
 242      echo '</div>';
 243  
 244  
 245      /*
 246      -----------------------------------------------------------
 247          Display Forum Category and the Forum information
 248      -----------------------------------------------------------
 249      */
 250  
 251      if (!isset($_SESSION['view']))    {
 252          $viewmode=$current_forum['default_view'];
 253      } else {
 254          $viewmode=$_SESSION['view'];
 255      }
 256  
 257      $viewmode_whitelist=array('flat', 'threaded', 'nested');
 258      if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
 259          $viewmode= Security::remove_XSS($_GET['view']);
 260          $_SESSION['view']=$viewmode;
 261      }
 262      if(empty($viewmode)) {
 263          $viewmode = 'flat';
 264      }
 265  
 266      /*
 267      -----------------------------------------------------------
 268          Display Forum Category and the Forum information
 269      -----------------------------------------------------------
 270      */
 271      // we are getting all the information about the current forum and forum category.
 272      // note pcool: I tried to use only one sql statement (and function) for this
 273      // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
 274      echo '<div id="content">';
 275      echo "<table class=\"data_table\" width='100%'>\n";
 276  
 277      // the thread
 278      echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
 279      echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
 280  
 281      if ($origin!='learnpath') {
 282          echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' - ';
 283      }
 284  
 285      echo prepare4display($current_forum['forum_title']).'<br />';
 286      echo "</th>\n";
 287      echo "\t</tr>\n";
 288      echo '<span>'.prepare4display(isset($current_thread['thread_comment'])?$current_thread['thread_comment']:'').'</span>';
 289      echo "</table>";
 290      
 291  
 292      switch ($viewmode) {
 293          case 'flat':
 294              include_once ('viewthread_flat.inc.php');
 295              break;
 296          case 'threaded':
 297              include_once ('viewthread_threaded.inc.php');
 298              break;
 299          case 'nested':
 300              include_once ('viewthread_nested.inc.php');
 301              break;
 302          default:
 303              include_once ('viewthread_flat.inc.php');
 304              break;
 305      }
 306  } // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
 307      echo "</div>";
 308  
 309  /*
 310  ==============================================================================
 311          FOOTER
 312  ==============================================================================
 313  */
 314  if ($origin!='learnpath') {
 315  //    Display :: display_footer();
 316      echo '<div class="actions">';
 317      echo '&nbsp;';
 318      echo '</div>';
 319      Display::display_tool_footer();
 320  }

title

Description

title

Description

title

Description

title

title

Body