Dokeos PHP Cross Reference Learning Management Systems

Source: /main/forum/forumqualify.php - 350 lines - 16702 bytes - Summary - Text - Print

   1  <?php
   2  /*
   3  ==============================================================================
   4      Dokeos - elearning and course management software
   5  
   6      Copyright (c) 2008 Dokeos Latinoamerica SAC
   7      For a full list of contributors, see "credits.txt".
   8      The full license can be read in "license.txt".
   9  
  10      This program is free software; you can redistribute it and/or
  11      modify it under the terms of the GNU General Public License
  12      as published by the Free Software Foundation; either version 2
  13      of the License, or (at your option) any later version.
  14  
  15      See the GNU General Public License for more details.
  16  
  17      Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
  18      Mail: info@dokeos.com
  19  ==============================================================================
  20  */
  21  /**
  22  *     @package dokeos.forum
  23  */
  24  // name of the language file that needs to be included
  25  $language_file=array('admin','forum');
  26  require  '../inc/global.inc.php';
  27  require_once  'forumconfig.inc.php';
  28  require_once  'forumfunction.inc.php';
  29  $nameTools = get_lang('Forum');
  30  $this_section = SECTION_COURSES;
  31  
  32  $allowed_to_edit = api_is_allowed_to_edit(null,true);
  33  if (!$allowed_to_edit) {
  34      api_not_allowed(true);
  35  }
  36  
  37  $origin = '';
  38  $origin_string='';
  39  if (isset($_GET['origin'])) {
  40      $origin =  Security::remove_XSS($_GET['origin']);
  41  }
  42  
  43  // including additional library scripts
  44  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  45  include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  46  //require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
  47  $nameTools=get_lang('Forum');
  48  
  49  /*
  50  -----------------------------------------------------------
  51      Including necessary files
  52  -----------------------------------------------------------
  53  */
  54  
  55  //$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
  56  $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
  57                      $(document).ready(function(){ $(\'.hide-me\').slideUp() });
  58                          function hidecontent(content){ $(content).slideToggle(\'normal\'); }
  59                       </script>';
  60  
  61  //are we in a lp ?
  62  $origin = '';
  63  if (isset($_GET['origin'])) {
  64      $origin =  Security::remove_XSS($_GET['origin']);
  65  }
  66  /*
  67  ==============================================================================
  68          MAIN DISPLAY SECTION
  69  ==============================================================================
  70  */
  71  /*
  72  -----------------------------------------------------------
  73      Retrieving forum and forum categorie information
  74  -----------------------------------------------------------
  75  */
  76  // we are getting all the information about the current forum and forum category.
  77  // note pcool: I tried to use only one sql statement (and function) for this
  78  // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  79  $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  80  $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
  81  $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  82  $whatsnew_post_info=$_SESSION['whatsnew_post_info'];
  83  /*
  84  -----------------------------------------------------------
  85      Header and Breadcrumbs
  86  -----------------------------------------------------------
  87  */
  88  if (isset($_SESSION['gradebook'])){
  89      $gradebook=    $_SESSION['gradebook'];
  90  }
  91  
  92  if (!empty($gradebook) && $gradebook=='view') {
  93      $interbreadcrumb[]= array (
  94              'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  95              'name' => get_lang('Gradebook')
  96          );
  97  }
  98  
  99  if ($origin=='learnpath') {
 100      include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
 101  } else {
 102      if (!empty($_SESSION['toolgroup'])) {
 103  
 104          $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
 105          $group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
 106          $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
 107          $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
 108          $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
 109          if ($message<>'PostDeletedSpecial') {
 110              $interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;gradebook=".$gradebook."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
 111          }
 112          $interbreadcrumb[]=array("url" => "#","name" => get_lang('QualifyThread'));
 113          // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
 114          Display :: display_tool_header('');
 115          echo '<div class="actions">';
 116          echo '</div>';
 117  
 118          echo '<div id="content">';
 119          api_display_tool_title($nameTools);
 120      } else {
 121  
 122          $info_thread=get_thread_information(Security::remove_XSS($_GET['thread']));
 123          $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => $nameTools);
 124          $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
 125          $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
 126  
 127          if ($message<>'PostDeletedSpecial') {
 128              if (isset($_GET['gradebook']) and $_GET['gradebook']=='view') {
 129                  $info_thread=get_thread_information(Security::remove_XSS($_GET['thread']));
 130                  $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$info_thread['forum_id']."&amp;gradebook=".$gradebook."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
 131              } else {
 132                  $interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;gradebook=".$gradebook."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
 133              }
 134          }
 135          // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
 136          $interbreadcrumb[]=array("url" => "#","name" => get_lang('QualifyThread'));
 137          Display :: display_tool_header('');
 138          echo '<div class="actions">';
 139          echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'">'.Display::return_icon('forumthread_new.png',get_lang('BackToThread')).' '.get_lang('BackToThread').'</a>';
 140          echo '</div>';
 141  
 142          echo '<div id="content">';
 143          //api_display_tool_title($nameTools);
 144  
 145      }
 146  }
 147  
 148  /*
 149  -----------------------------------------------------------
 150      Is the user allowed here?
 151  -----------------------------------------------------------
 152  */
 153  // if the user is not a course administrator and the forum is hidden
 154  // then the user is not allowed here.
 155  if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) {
 156      forum_not_allowed_here();
 157  }
 158  
 159  
 160  /*
 161  -----------------------------------------------------------
 162      Actions
 163  -----------------------------------------------------------
 164  */
 165  if ($_GET['action']=='delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false,true)) {
 166      $message=delete_post($_GET['id']); // note: this has to be cleaned first
 167  }
 168  if (($_GET['action']=='invisible' || $_GET['action']=='visible') && isset($_GET['id']) && api_is_allowed_to_edit(false,true)) {
 169      $message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first
 170  }
 171  if ($_GET['action']=='move' and isset($_GET['post'])) {
 172      $message=move_post_form();
 173  }
 174  
 175  /*
 176  -----------------------------------------------------------
 177      Display the action messages
 178  -----------------------------------------------------------
 179  */
 180  if (!empty($message)) {
 181      Display :: display_confirmation_message(get_lang($message));
 182  }
 183  
 184  if ($message<>'PostDeletedSpecial') {// in this case the first and only post of the thread is removed
 185      // this increases the number of times the thread has been viewed
 186      increase_thread_view($_GET['thread']);
 187  
 188      /*
 189      -----------------------------------------------------------
 190          Action Links
 191      -----------------------------------------------------------
 192      */
 193  /*    echo '<div style="float:right;">';
 194      $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($_GET['search']));
 195      echo $my_url.'&amp;view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
 196      echo $my_url.'&amp;view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
 197      echo $my_url.'&amp;view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
 198      $my_url = null;
 199      echo '</div>';*/
 200      // 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.
 201      // if one of the three levels is locked then the link should not be displayed
 202      if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
 203          // The link should only appear when the user is logged in or when anonymous posts are allowed.
 204          if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
 205              //reply link
 206              /*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.'">'.get_lang('ReplyToThread').'</a>';*/
 207  
 208              //new thread link
 209              if (api_is_allowed_to_edit(false,true) 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)) {
 210                  if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
 211                      echo '&nbsp;&nbsp;';
 212                      /*echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';*/
 213                  } else {
 214                      echo get_lang('ForumLocked');
 215                  }
 216              }
 217          }
 218      }
 219      // note: this is to prevent that some browsers display the links over the table (FF does it but Opera doesn't)
 220      echo '&nbsp;';
 221  
 222      /*
 223      -----------------------------------------------------------
 224          Display Forum Category and the Forum information
 225      -----------------------------------------------------------
 226      */
 227      if (!$_SESSION['view']) {
 228          $viewmode=$current_forum['default_view'];
 229      } else {
 230          $viewmode=$_SESSION['view'];
 231      }
 232  
 233      $viewmode_whitelist=array('flat', 'threaded', 'nested');
 234      if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
 235          $viewmode=Security::remove_XSS($_GET['view']);
 236          $_SESSION['view']=$viewmode;
 237      }
 238      if (empty($viewmode)) {
 239          $viewmode = 'flat';
 240      }
 241  
 242      /*
 243      -----------------------------------------------------------
 244          Display Forum Category and the Forum information
 245      -----------------------------------------------------------
 246      */
 247      // we are getting all the information about the current forum and forum category.
 248      // note pcool: I tried to use only one sql statement (and function) for this
 249      // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
 250      echo "<table class=\"data_table\" width=\"100%\">\n";
 251  
 252      // the thread
 253      echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
 254      echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
 255  
 256      if ($origin!='learnpath') {
 257          echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' - ';
 258      }
 259  
 260      echo prepare4display($current_forum['forum_title']).'<br />';
 261      echo "</th>\n";
 262      echo "\t</tr>\n";
 263      echo '<span>'.prepare4display($current_thread['thread_comment']).'</span>';
 264      echo "</table>";
 265  
 266      include_once ('viewpost.inc.php');
 267  } // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
 268  
 269  
 270  $userinf=api_get_user_info(api_get_user_id());
 271  if ($allowed_to_edit) {
 272      //echo "<strong>".get_lang('QualifyThread')."</strong>";
 273      //echo "<br />";
 274      $current_thread=get_thread_information($_GET['thread']);
 275      $userid=(int)$_GET['user_id'];
 276      $threadid=$current_thread['thread_id'];
 277      //show current qualify in my form
 278      $qualify=current_qualify_of_thread($threadid,api_get_session_id());
 279      //show max qualify in my form
 280      $max_qualify=show_qualify('2',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
 281      require_once  'forumbody.inc.php';
 282      $value_return = store_theme_qualify($userid,$threadid,$_REQUEST['idtextqualify'],api_get_user_id(),date("Y-m-d H:i:s"),api_get_session_id());
 283      $url='cidReq='.Security::remove_XSS($_GET['cidReq']).'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']).'&origin='.$origin.'&user_id='.Security::remove_XSS($_GET['user_id']);
 284      $current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
 285  
 286      if ($value_return[0]!=$_REQUEST['idtextqualify'] && $value_return[1]=='update') {
 287          store_qualify_historical('1','',$_GET['forum'],$userid,$threadid,$_REQUEST['idtextqualify'],api_get_user_id());
 288      }
 289  
 290      if (!empty($_REQUEST['idtextqualify']) && $_REQUEST['idtextqualify'] > $max_qualify) {
 291          $return_message = get_lang('QualificationCanNotBeGreaterThanMaxScore');
 292          Display :: display_error_message($return_message,false);
 293      }
 294      // show qualifications history
 295      $user_id_thread = (int)$_GET['user_id'];
 296      $opt=Security::remove_XSS($_GET['type']);
 297      $qualify_historic = get_historical_qualify($user_id_thread, $threadid, $opt);
 298      $counter= count($qualify_historic);
 299      $act_qualify = Security::remove_XSS($_REQUEST['idtextqualify']);
 300      if ($counter>0) {
 301          if (isset($_GET['gradebook'])){
 302              $view_gradebook='&gradebook=view';
 303          }
 304          echo '<h3>'.get_lang('QualificationChangesHistory').'</h3>';
 305          if ($_GET['type'] == 'false') {
 306  
 307              echo '<div style="float:left; clear:left">'.get_lang('OrderBy').'&nbsp;:&nbsp;<a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'&thread='.$threadid.'&user='.Security::remove_XSS($_GET['user']).'&user_id='.Security::remove_XSS($_GET['user_id']).'&type=true&idtextqualify='.$act_qualify.$view_gradebook.'#history">'.get_lang('MoreRecent').'</a>&nbsp;|
 308                      '.get_lang('Older').'
 309                    </div>';
 310          } else {
 311              echo '<div style="float:left; clear:left">'.get_lang('OrderBy').'&nbsp;:&nbsp;'.get_lang('MoreRecent').' |
 312                      <a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'&thread='.$threadid.'&user='.Security::remove_XSS($_GET['user']).'&user_id='.Security::remove_XSS($_GET['user_id']).'&type=false&idtextqualify='.$act_qualify.$view_gradebook.'#history">'.get_lang('Older').'</a>&nbsp;
 313                    </div>';
 314          }
 315          $table_list.= '<a name="history" /><br /><br /><table class="data_table" style="width:100%">';
 316          $table_list.= '<tr>';
 317          $table_list.= '<th width="50%">'.get_lang('WhoChanged').'</th>';
 318          $table_list.= '<th width="10%">'.get_lang('NoteChanged').'</th>';
 319          $table_list.= '<th width="40%">'.get_lang('DateChanged').'</th>';
 320          $table_list.= '</tr>';
 321  
 322          for($i=0;$i<count($qualify_historic);$i++) {
 323                  $my_user_info=api_get_user_info($qualify_historic[$i]['qualify_user_id']);
 324                  $name = api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']);
 325                  $class = ($i%2 == 0) ? 'row_even' : 'row_odd';
 326                  $table_list.= '<tr class="'.$class.'"><td>'.$name.'</td>';
 327                  $table_list.= '<td>'.$qualify_historic[$i]['qualify'].'</td>';
 328                  $table_list.= '<td>'.$qualify_historic[$i]['qualify_time'].'</td></tr>';
 329          }
 330          $table_list.= '</table>';
 331          echo $table_list;
 332  
 333      } else {
 334          echo get_lang('NotChanged');
 335      }
 336  } else {
 337      api_not_allowed();
 338  }
 339  
 340  // Close main content
 341  echo '</div>';
 342  
 343  // Actions bar
 344  echo '<div class="actions">';
 345  echo '</div>';
 346  
 347  // footer
 348  if ($origin!='learnpath') {
 349      Display :: display_footer();
 350  }

title

Description

title

Description

title

Description

title

title

Body