boards
[ class tree: boards ] [ index: boards ] [ all elements ]

Source for file view_topic_inc.php

Documentation is available at view_topic_inc.php

  1. <?php
  2. /**
  3.  * @package boards
  4.  * @subpackage functions
  5.  */
  6.  
  7. /**
  8.  * required setup
  9.  */
  10. require_once( '../kernel/setup_inc.php' );
  11.  
  12. // we need all three
  13. require_once( BOARDS_PKG_PATH.'BitBoard.php' );
  14. require_once( BOARDS_PKG_PATH.'BitBoardTopic.php' );
  15. require_once( BOARDS_PKG_PATH.'BitBoardPost.php' );
  16.  
  17. // if we're getting a migrate id then lets move on right away
  18. if( @BitBase::verifyId( $_REQUEST['migrate_topic_id'] ) ) {
  19.     if( $_REQUEST['t'] = BitBoardTopic::lookupByMigrateTopic( $_REQUEST['migrate_topic_id'] ) ) {
  20.         bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] );
  21.     }
  22. } elseif( @BitBase::verifyId( $_REQUEST['migrate_post_id'] ) ) {
  23.     if( $_REQUEST['t'] = BitBoardTopic::lookupByMigratePost( $_REQUEST['migrate_post_id'] ) ) {
  24.         bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] );
  25.     }
  26. }
  27.  
  28. // @TODO move this to edit_post
  29. if (!empty($_REQUEST['action'])) {
  30.     // Now check permissions to access this page
  31.     // @TODO load up the parent board and call verifyUpdatePermission
  32.     $gBitSystem->verifyPermission( 'p_boards_update' );
  33.  
  34.     $comment = new BitBoardPost($_REQUEST['comment_id']);
  35.     $comment->loadComment();
  36.     if (!$comment->isValid()) {
  37.         $gBitSystem->fatalError( tra("Invalid Comment"), NULL, NULL, HttpStatusCodes::HTTP_GONE );
  38.     }
  39.     switch ($_REQUEST['action']) {
  40.         case 1:
  41.             // Aprove
  42.             $comment->modApprove();
  43.             break;
  44.         case 2:
  45.             // Reject
  46.             $comment->modReject();
  47.             break;
  48.         case 3:
  49.             //Moderate
  50.             $comment->loadMetaData();
  51.             $comment->modWarn($_REQUEST['warning_message']);
  52.         default:
  53.             break;
  54.     }
  55. }
  56.  
  57. // Finally - load up our topic
  58. $thread = new BitBoardTopic($_REQUEST['t']);
  59. $thread->load();
  60.  
  61. if( !$thread->isValid() ) {
  62.     $gBitSystem->fatalError( tra("Unknown discussion"), NULL, NULL, HttpStatusCodes::HTTP_GONE );
  63. }
  64.  
  65. $thread->verifyViewPermission();
  66.  
  67. // load up the root board we need it
  68. $gBoard = new BitBoard(null,$thread->mInfo['board_content_id']);
  69. $gBoard->load();
  70. $gBitSmarty->assign_by_ref( 'board', $gBoard );
  71. // force root board to be gContent
  72. $gContent = &$gBoard;
  73. $gBitSmarty->assign_by_ref('gContent', $gContent);
  74.  
  75.  
  76. // if you know what this is please comment it
  77. if (empty($thread->mInfo['th_root_id'])) {
  78.     if ($_REQUEST['action']==3) {
  79.         //Invalid as a result of rejecting the post, redirect to the board
  80.         bit_redirect( $gBoard->getDisplayUrl() );
  81.     } else {
  82.         $gBitSystem->fatalError(tra( "Invalid topic selection." ), NULL, NULL, HttpStatusCodes::HTTP_GONE );
  83.     }
  84. }
  85.  
  86.  
  87. // Invoke services
  88. $displayHash = array( 'perm_name' => 'p_boards_read' );
  89. $thread->invokeServices( 'content_display_function', $displayHash );
  90.  
  91. $thread->readTopic();
  92.  
  93. $gBitSmarty->assign_by_ref( 'thread', $thread );
  94. $gBitSmarty->assign('topic_locked',$thread->isLocked());
  95.  
  96.  
  97. // Get the thread of comments
  98. $commentsParentId=$thread->mInfo['content_id'];
  99. $comments_return_url= BOARDS_PKG_URL."index.php?t={$thread->mRootId}";
  100. $gBitSystem->setCanonicalLink( BOARDS_PKG_URL.'index.php?t='.$thread->mRootId );
  101. $gComment = new BitBoardPost($_REQUEST['t']);
  102. $gBitSmarty->assign('comment_template','bitpackage:boards/post_display.tpl');
  103.  
  104. // set default comment display style
  105. if( empty( $_REQUEST["comments_style"] ) ) {
  106.     $_REQUEST["comments_style"] = "flat";
  107. }
  108.  
  109. require_once( BOARDS_PKG_PATH.'boards_comments_inc.php' );
  110.  
  111. if( $gBitUser->isRegistered() ) {
  112.     $postComment['registration_date']=$gBitUser->mInfo['registration_date'];
  113.     $postComment['user_avatar_url']=$gBitUser->mInfo['avatar_url'];
  114.     $postComment['user_url'] = $gBitUser->getDisplayUrl();
  115. }
  116.  
  117.  
  118. // display warnings - might be for edit processes - if you know please comment
  119. $warnings = array();
  120. if (!empty($_REQUEST['warning'])) {
  121.     foreach ($_REQUEST['warning'] as $id => $state) {
  122.         if (strcasecmp($state,'show')==0) {
  123.             $warnings[$id]=true;
  124.         }
  125.     }
  126. }
  127. $gBitSmarty->assign_by_ref('warnings',$warnings);
  128.  
  129.  
  130. // ajax support
  131. $gBitThemes->loadAjax( 'mochikit' );
  132.  
  133. $gBitSystem->display('bitpackage:boards/list_posts.tpl', "Show Thread: " . $thread->getField('title') , array( 'display_mode' => 'display' ));
  134. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:33 +0000 by phpDocumentor 1.5.0-lsces