Dokeos PHP Cross Reference Learning Management Systems

Source: /main/forum/editpost.php - 273 lines - 11801 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) 2004-2008 Dokeos SPRL
   7      Copyright (c) 2003 Ghent University (UGent)
   8      Copyright (c) 2001 Universite catholique de Louvain (UCL)
   9      Copyright (c) various contributors
  10  
  11      For a full list of contributors, see "credits.txt".
  12      The full license can be read in "license.txt".
  13  
  14      This program is free software; you can redistribute it and/or
  15      modify it under the terms of the GNU General Public License
  16      as published by the Free Software Foundation; either version 2
  17      of the License, or (at your option) any later version.
  18  
  19      See the GNU General Public License for more details.
  20  
  21      Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  22      Mail: info@dokeos.com
  23  ==============================================================================
  24  */
  25  
  26  /**
  27  *    These files are a complete rework of the forum. The database structure is
  28  *    based on phpBB but all the code is rewritten. A lot of new functionalities
  29  *    are added:
  30  *     - forum categories and forums can be sorted up or down, locked or made invisible
  31  *    - consistent and integrated forum administration
  32  *     - forum options:     are students allowed to edit their post?
  33  *                         moderation of posts (approval)
  34  *                         reply only forums (students cannot create new threads)
  35  *                         multiple forums per group
  36  *    - sticky messages
  37  *     - new view option: nested view
  38  *     - quoting a message
  39  *
  40  *    @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  41  *    @Copyright Ghent University
  42  *    @Copyright Patrick Cool
  43  *
  44  *     @package dokeos.forum
  45  */
  46  
  47  /**
  48   **************************************************************************
  49   *                        IMPORTANT NOTICE
  50   * Please do not change anything is this code yet because there are still
  51   * some significant code that need to happen and I do not have the time to
  52   * merge files and test it all over again. So for the moment, please do not
  53   * touch the code
  54   *                             -- Patrick Cool <patrick.cool@UGent.be>
  55   **************************************************************************
  56   */
  57  
  58  /*
  59  ==============================================================================
  60          INIT SECTION
  61  ==============================================================================
  62  */
  63  // name of the language file that needs to be included
  64  $language_file = array (
  65      'forum',
  66      'group'
  67  );
  68  
  69  // including the global dokeos file
  70  require  ('../inc/global.inc.php');
  71  require_once ('../gradebook/lib/gradebook_functions.inc.php');
  72  require_once ('../gradebook/lib/be/gradebookitem.class.php');
  73  require_once ('../gradebook/lib/be/evaluation.class.php');
  74  require_once ('../gradebook/lib/be/abstractlink.class.php');
  75  require_once ('../gradebook/lib/gradebook_functions.inc.php');
  76  // the section (tabs)
  77  $this_section=SECTION_COURSES;
  78  // notice for unauthorized people.
  79  api_protect_course_script(true);
  80  
  81  // including additional library scripts
  82  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  83  include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  84  
  85  $nameTools=get_lang('Forum');
  86  
  87  /*
  88  -----------------------------------------------------------
  89      Including necessary files
  90  -----------------------------------------------------------
  91  */
  92  include ('forumconfig.inc.php');
  93  include ('forumfunction.inc.php');
  94  
  95  // javascript
  96  $htmlHeadXtra[] = '<script>
  97  
  98  		function advanced_parameters() {
  99              if(document.getElementById(\'id_qualify\').style.display == \'none\') {
 100                  document.getElementById(\'id_qualify\').style.display = \'block\';
 101                  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').'\';
 102  
 103              } else {
 104                  document.getElementById(\'id_qualify\').style.display = \'none\';
 105                  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').'\';
 106              }
 107          }
 108  </script>';
 109  
 110  /*
 111  ==============================================================================
 112          MAIN DISPLAY SECTION
 113  ==============================================================================
 114  */
 115  /*
 116  -----------------------------------------------------------
 117      Retrieving forum and forum categorie information
 118  -----------------------------------------------------------
 119  */
 120  // we are getting all the information about the current forum and forum category.
 121  // note pcool: I tried to use only one sql statement (and function) for this
 122  // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
 123  $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
 124  $current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
 125  $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
 126  $current_post=get_post_information($_GET['post']);
 127  /*
 128  -----------------------------------------------------------
 129      Header and Breadcrumbs
 130  -----------------------------------------------------------
 131  */
 132  if (isset($_SESSION['gradebook'])){
 133      $gradebook=    $_SESSION['gradebook'];
 134  }
 135  
 136  if (!empty($gradebook) && $gradebook=='view') {
 137      $interbreadcrumb[]= array (
 138              'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 139              'name' => get_lang('Gradebook')
 140          );
 141  }
 142  
 143  
 144  if (!empty($_SESSION['toolgroup'])) {
 145  
 146      $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
 147      $group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
 148      $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
 149      $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
 150      $interbreadcrumb[] = array("url" => "viewforum.php?origin=".$origin."&amp;gidReq=".$_SESSION['toolgroup']."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title']));
 151      $interbreadcrumb[] = array("url" => "javascript: void (0);","name" => get_lang('EditPost'));
 152  
 153  } else {
 154      $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools);
 155      $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
 156      $interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title']));
 157      $interbreadcrumb[]=array("url" => "viewthread.php?gradebook=$gradebook&amp;origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title']));
 158      $interbreadcrumb[]=array("url" => "javascript: void (0);","name" => get_lang('EditPost'));
 159  }
 160  /*
 161  -----------------------------------------------------------
 162      Resource Linker
 163  -----------------------------------------------------------
 164  */
 165  if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
 166      $_SESSION['formelements']=$_POST;
 167      $_SESSION['origin']=$_SERVER['REQUEST_URI'];
 168      $_SESSION['breadcrumbs']=$interbreadcrumb;
 169      header("Location: ../resourcelinker/resourcelinker.php");
 170  }
 171  $table_link             = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
 172  /*
 173  -----------------------------------------------------------
 174      Header
 175  -----------------------------------------------------------
 176  */
 177  //are we in a lp ?
 178  $origin = '';
 179  if (isset($_GET['origin'])) {
 180      $origin =  Security::remove_XSS($_GET['origin']);
 181  }
 182  
 183  if ($origin=='learnpath') {
 184      include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
 185  } else {
 186      Display :: display_tool_header(null);
 187      //api_display_tool_title($nameTools);
 188  }
 189  //echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
 190  /*
 191  -----------------------------------------------------------
 192      Is the user allowed here?
 193  -----------------------------------------------------------
 194  */
 195  // the user is not allowed here if
 196  // 1. the forumcategory, forum or thread is invisible (visibility==0)
 197  // 2. the forumcategory, forum or thread is locked (locked <>0)
 198  // 3. if anonymous posts are not allowed
 199  // 4. if editing of replies is not allowed
 200  // The only exception is the course manager
 201  // I have split this is several pieces for clarity.
 202  //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)))
 203  if (!api_is_allowed_to_edit(null,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) {
 204      forum_not_allowed_here();
 205  }
 206  if (!api_is_allowed_to_edit(null,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) {
 207      forum_not_allowed_here();
 208  }
 209  if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) {
 210      forum_not_allowed_here();
 211  }
 212  if (!api_is_allowed_to_edit(null,true) AND $current_forum['allow_edit']==0) {
 213      forum_not_allowed_here();
 214  }
 215  
 216  
 217  // action links
 218  if ($origin!='learnpath') {
 219      echo '<div class="actions">';
 220      echo '<span style="float:right;">'.search_link().'</span>';
 221      echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('pixel.gif', get_lang('BackToForumOverview'), array('class' => 'toolactionplaceholdericon toolactionback')).get_lang('BackToForumOverview').'</a>';
 222      echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'">'.Display::return_icon('pixel.gif', get_lang('BackToForum'), array('class' => 'toolactionplaceholdericon toolactionforum')).get_lang('BackToForum').'</a>';
 223      echo '</div>';
 224  }
 225  
 226  /*
 227  -----------------------------------------------------------
 228      Display Forum Category and the Forum information
 229  -----------------------------------------------------------
 230  */
 231  echo '<div id="content">';
 232  echo "<table class=\"data_table\" width='100%'>\n";
 233  // the forum category
 234  echo "\t<tr>\n\t\t<th align=\"left\" colspan=\"2\">";
 235  echo '<a href="viewforum.php?&origin='.$origin.'&forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
 236  echo '<span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';echo "</th>\n";
 237  echo "</th>\n";
 238  echo "\t</tr>\n";
 239  echo '</table>';
 240  
 241  
 242  // the form for the reply
 243  $values=show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements'])?$_SESSION['formelements']:'');
 244  
 245  if (!empty($values) and isset($_POST['SubmitPost'])) {
 246      store_edit_post($values);
 247  
 248      $option_chek=isset($values['thread_qualify_gradebook'])?$values['thread_qualify_gradebook']:null;// values 1 or 0
 249      if ( 1== $option_chek ) {
 250              $id=$values['thread_id'];
 251              $title_gradebook=$values['calification_notebook_title'];
 252              $value_calification=$values['numeric_calification'];
 253              $weight_calification=$values['weight_calification'];
 254              $description="";
 255              $session_id=api_get_session_id();
 256              $link_id=is_resource_in_course_gradebook(api_get_course_id(),5,$id,$session_id);
 257              if ($link_id==false) {
 258                  add_resource_to_course_gradebook(api_get_course_id(), 5, $id, $title_gradebook,$weight_calification,$value_calification,$description,time(),1,api_get_session_id());
 259              } else {
 260                  Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.'');
 261              }
 262  
 263      }
 264  
 265  }
 266  echo '</div>';
 267  // footer
 268  if ($origin!='learnpath') {
 269      echo '<div class="actions">';
 270      echo '&nbsp;';
 271      echo '</div>';
 272      Display :: display_footer();
 273  }

title

Description

title

Description

title

Description

title

title

Body