[ Index ]
 

Code source de Claroline 188

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/claroline/phpbb/ -> reply.php (source)

   1  <?php // $Id: reply.php,v 1.71 2007/02/15 14:09:09 zefredz Exp $
   2  /**
   3   * CLAROLINE
   4   *
   5   * Script view topic for forum tool
   6   *
   7   * @version 1.8 $Revision: 1.71 $
   8   *
   9   * @copyright 2001-2006 Universite catholique de Louvain (UCL)
  10   * @copyright (C) 2001 The phpBB Group
  11   *
  12   * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
  13   *
  14   * @author Claro Team <cvs@claroline.net>
  15   *
  16   * @package CLFRM
  17   *
  18   */
  19  
  20  /*=================================================================
  21    Init Section
  22   =================================================================*/
  23  
  24  $tlabelReq = 'CLFRM';
  25  
  26  require  '../inc/claro_init_global.inc.php';
  27  
  28  if ( ! claro_is_in_a_course() || ! claro_is_course_allowed() ) claro_disp_auth_form(true);
  29  
  30  claro_set_display_mode_available(true);
  31  
  32  /*-----------------------------------------------------------------
  33    Stats
  34   -----------------------------------------------------------------*/
  35  
  36  event_access_tool(claro_get_current_tool_id(), claro_get_current_course_tool_data('label'));
  37  
  38  /*-----------------------------------------------------------------
  39    Library
  40   -----------------------------------------------------------------*/
  41  
  42  include_once get_path('incRepositorySys') . '/lib/forum.lib.php';
  43  include_once get_path('incRepositorySys') . '/lib/pager.lib.php';
  44  
  45  // for notification
  46  include_once get_path('incRepositorySys') . '/lib/sendmail.lib.php';
  47  
  48  $error = FALSE;
  49  $error_message = '';
  50  $allowed = TRUE;
  51  $pagetype  = 'reply';
  52  
  53  /*=================================================================
  54    Main Section
  55   =================================================================*/
  56  
  57  
  58  
  59  if ( isset($_REQUEST['forum']) ) $forum_id = (int) $_REQUEST['forum'];
  60  else                             $forum_id = 0;
  61  
  62  if ( isset($_REQUEST['topic']) ) $topic_id = (int) $_REQUEST['topic'];
  63  else                             $topic_id = 0;
  64  
  65  if ( isset($_REQUEST['cancel']) )
  66  {
  67      claro_redirect('viewtopic.php?topic=' . $topic_id . '&forum='.$forum_id);
  68      exit();
  69  }
  70  
  71  if ( isset($_REQUEST['message']) ) $message = $_REQUEST['message'];
  72  else                               $message = '';
  73  
  74  // XSS
  75  $message = preg_replace( '/<script[^\>]*>|<\/script>|(onabort|onblur|onchange|onclick|ondbclick|onerror|onfocus|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onresize|onselect|onsubmit|onunload)\s*=\s*"[^"]+"/i', '', $message );
  76  
  77  
  78  $topicSettingList = get_topic_settings($topic_id);
  79  
  80  if ( ! claro_is_user_authenticated() || ! claro_is_in_a_course())
  81  {
  82      claro_disp_auth_form(true);
  83  }
  84  elseif ( $topicSettingList )
  85  {
  86      if ( $forum_id != $topicSettingList['forum_id'] )
  87      {
  88          $allowed = FALSE;
  89          $error_message = get_lang('Not allowed') ;
  90      }
  91      else
  92      {
  93          // Get forum and topics settings
  94          $forum_id         = $topicSettingList['forum_id'];
  95          $topic_title      = $topicSettingList['topic_title'];
  96  
  97          $forumSettingList = get_forum_settings($forum_id);
  98  
  99          $forum_name         = $forumSettingList['forum_name'  ];
 100          $forum_post_allowed = ( $forumSettingList['forum_access'] != 0 ) ? true : false;
 101          $forum_type         = $forumSettingList['forum_type'  ];
 102          $forum_groupId      = $forumSettingList['idGroup'     ];
 103          $forum_cat_id       = $forumSettingList['cat_id'      ];
 104  
 105          /**
 106           * Check if the topic isn't attached to a group,  or -- if it is attached --,
 107           * check the user is allowed to see the current group forum.
 108           */
 109  
 110          if ( ! $forum_post_allowed
 111              || ( ! is_null($forumSettingList['idGroup'])
 112                  && ( !claro_is_in_a_group() || !claro_is_group_allowed() || $forumSettingList['idGroup'] != claro_get_current_group_id() ) ) )
 113          {
 114              // NOTE : $forumSettingList['idGroup'] != claro_get_current_group_id() is necessary to prevent any hacking
 115              // attempt like rewriting the request without $cidReq. If we are in group
 116              // forum and the group of the concerned forum isn't the same as the session
 117              // one, something weird is happening, indeed ...
 118              $allowed = FALSE;
 119              $error_message = get_lang('Not allowed') ;
 120          }
 121  
 122          if ( isset($_REQUEST['submit']) )
 123          {
 124              if ( trim(strip_tags($message)) != '' )
 125              {
 126  
 127                  if ( get_conf('allow_html') == 0 || isset($html) ) $message = htmlspecialchars($message);
 128  
 129                  $lastName   = claro_get_current_user_data('lastName');
 130                  $firstName  = claro_get_current_user_data('firstName');
 131                  $poster_ip  = $_SERVER['REMOTE_ADDR'];
 132                  $time       = date('Y-m-d H:i');
 133  
 134                  create_new_post($topic_id, $forum_id, claro_get_current_user_id(), $time, $poster_ip, $lastName, $firstName, $message);
 135  
 136                  // notify eventmanager that a new message has been posted
 137  
 138                  $eventNotifier->notifyCourseEvent("forum_answer_topic",claro_get_current_course_id(), claro_get_current_tool_id(), $forum_id."-".$topic_id, claro_get_current_group_id(), "0");
 139  
 140                  trig_topic_notification($topic_id);
 141              }
 142              else
 143              {
 144                  $error = TRUE;
 145                  $error_message = get_lang('You cannot post an empty message');
 146              }
 147          }
 148      }
 149  }
 150  else
 151  {
 152      // topic doesn't exist
 153      $error = 1;
 154      $error_message = get_lang('Not allowed');
 155  }
 156  
 157  /*=================================================================
 158    Display Section
 159   =================================================================*/
 160  
 161  $interbredcrump[] = array ('url' => 'index.php', 'name' => get_lang('Forums'));
 162  $noPHP_SELF       = true;
 163  
 164  include get_path('incRepositorySys') . '/claro_init_header.inc.php';
 165  
 166  $pagetype  = 'reply';
 167  
 168  $is_allowedToEdit = claro_is_allowed_to_edit();
 169  
 170  echo claro_html_tool_title(get_lang('Forums'),
 171                        $is_allowedToEdit ? 'help_forum.php' : false);
 172  
 173  if ( !$allowed )
 174  {
 175      // not allowed
 176      echo claro_html_message_box($error_message);
 177  }
 178  else
 179  {
 180  
 181      if ( isset($_REQUEST['submit']) && !$error )
 182      {
 183          // DISPLAY SUCCES MESSAGE
 184          disp_confirmation_message (get_lang('Your message has been entered'), $forum_id, $topic_id);
 185      }
 186      else
 187      {
 188          if ( $error )
 189          {
 190              echo claro_html_message_box($error_message);
 191          }
 192  
 193          echo claro_html_menu_horizontal(disp_forum_toolbar($pagetype, $forum_id, 0, $topic_id));
 194  
 195          echo disp_forum_breadcrumb($pagetype, $forum_id, $forum_name, $topic_id, $topic_title);
 196  
 197          echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">' . "\n"
 198              . '<input type="hidden" name="forum" value="' . $forum_id . '" />' . "\n"
 199              . '<input type="hidden" name="topic" value="' . $topic_id . '" />' . "\n";
 200  
 201          echo '<table border="0" width="100%">' . "\n"
 202              . '<tr valign="top">' . "\n"
 203              . '<td align="right"><br />' . get_lang('Message body') . '&nbsp;:</td>'
 204              . '<td>'
 205              .claro_html_textarea_editor('message', $message)
 206              .'</td>'
 207              . '</tr>'
 208              . '<tr valign="top"><td>&nbsp;</td>'
 209              . '<td>'
 210              . '<input type="submit" name="submit" value="' . get_lang('Ok') . '" />&nbsp; '
 211              . '<input type="submit" name="cancel" value="' . get_lang('Cancel') . '" />'
 212              . '</tr>'
 213              . '</table>'
 214              . '</form>' ;
 215  
 216          echo '<p align="center"><a href="viewtopic.php?topic=' . $topic_id . '&forum=' . $forum_id . '" target="_blank">' . get_lang('Topic review') . '</a>';
 217  
 218      } // end else if submit
 219  }
 220  
 221  // Display Forum Footer
 222  
 223  include(get_path('incRepositorySys').'/claro_init_footer.inc.php');
 224  ?>


Généré le : Thu Nov 29 14:38:42 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics