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

Source for file edit_topic.php

Documentation is available at edit_topic.php

  1. <?php
  2. /**
  3.  * $Header$
  4.  * Copyright (c) 2004 bitweaver Messageboards
  5.  * All Rights Reserved. See below for details and a complete list of authors.
  6.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  7.  * @package boards
  8.  * @subpackage functions
  9.  */
  10.  
  11. /**
  12.  * required setup
  13.  */
  14. require_once'../kernel/setup_inc.php' );
  15.  
  16. // Is package installed and enabled
  17. $gBitSystem->verifyPackage'boards' );
  18.  
  19. // Look up Topic (lookup_inc is universal, gContent == BitBoardTopic)
  20. require_onceBOARDS_PKG_PATH.'lookup_inc.php' );
  21.  
  22. // Make sure topic exists since we only run through here for existing topics. New topics are created via comment system.
  23. if!$gContent->isValid() ){
  24.     $gBitSystem->fatalErrortra('No topic specified.') );
  25. }
  26.  
  27. // Check the user's ticket
  28. $gBitUser->verifyTicket();
  29.  
  30. // Load up the Topic's board - we'll respect its permissions
  31. $board new BitBoard$gContent->mInfo['board_id');
  32. $board->load();
  33.  
  34. $rslt false;
  35.  
  36. // Edit calls
  37. // Set locked or sticky
  38. ifisset($_REQUEST['is_locked']|| isset($_REQUEST['is_sticky']) ){
  39.     // Check permissions to edit this topic
  40.     $board->verifyUpdatePermission();
  41.     
  42.     if isset($_REQUEST['is_locked']&& is_numeric($_REQUEST['is_locked']) ){
  43.         $rslt $gContent->lock($_REQUEST['is_locked']);
  44.     elseif isset($_REQUEST['is_sticky']&& is_numeric($_REQUEST['is_sticky']) ){
  45.         $rslt $gContent->sticky($_REQUEST['is_sticky']);
  46.     }
  47. // Remove a topic
  48. }elseifisset$_REQUEST['remove') ) {
  49.     // Check permissions to edit this topic if the root object is the board check its perms, otherwise check general comment admin perms
  50.     if!(( $gContent->mInfo['root_id'== $gContent->mInfo['board_content_id'&& $board->hasAdminPermission() ) || $gBitUser->hasPermission('p_liberty_admin_comments')) ){
  51.         $gBitSystem->fatalErrortra('You do not have permission to delete this topic.') );
  52.     }
  53.     
  54.     if!empty$_REQUEST['cancel') ) {
  55.         // user cancelled - just continue on, doing nothing
  56.     elseifempty$_REQUEST['confirm') ) {
  57.         $formHash['remove'TRUE;
  58.         $formHash['t'$_REQUEST['t'];
  59.         $gBitSystem->confirmDialog$formHash
  60.             array
  61.                 'warning' => tra'Are you sure you want to delete this topic?' ' ' $gContent->getTitle(),
  62.                 'error' => tra('This cannot be undone!')
  63.             )
  64.         );
  65.     else {
  66.         // @TODO Topic should extend LibertyComment - but until that day we load it up a second time
  67.         $topicAsComment new LibertyComment$_REQUEST['t');
  68.         if!$topicAsComment->expunge() ) {
  69.             $gBitSmarty->assign_by_ref'errors'$topicAsComment->mErrors );
  70.         }
  71.         // send us back to the baord - http_referer won't work with confirm process 
  72.         bit_redirectBOARDS_PKG_URL.'index.php?b='$gContent->mInfo['board_id');
  73.     }
  74. // User pref options on a topic - not really editing but this simplifies topic related processes putting it here
  75. }elseifisset($_REQUEST['new']|| isset($_REQUEST['notify']) ){
  76.     // Check permissions to view this topic
  77.     $gContent->verifyViewPermission();
  78.  
  79.     ifisset($_REQUEST['new']&& is_numeric($_REQUEST['new']) ){
  80.         $rslt $gContent->readTopicSet($_REQUEST['new']);
  81.     }elseifisset($_REQUEST['notify']&& is_numeric($_REQUEST['notify']) ){
  82.         $rslt $gContent->notify($_REQUEST['notify']);
  83.     }
  84. }
  85.  
  86. if($rslt){
  87.     // Return us to where we came from
  88.     header ("location: ".$_SERVER['HTTP_REFERER']);
  89. }else{
  90.     // @TODO put error into an alert
  91.     //trigger_error(var_export($gContent->mErrors,true ));
  92. }
  93.  
  94. ?>

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