Source for file edit_topic.php
Documentation is available at edit_topic.php
* Copyright (c) 2004 bitweaver Messageboards
* All Rights Reserved. See below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
require_once( '../kernel/setup_inc.php' );
// Is package installed and enabled
$gBitSystem->verifyPackage( 'boards' );
// Look up Topic (lookup_inc is universal, gContent == BitBoardTopic)
require_once( BOARDS_PKG_PATH. 'lookup_inc.php' );
// Make sure topic exists since we only run through here for existing topics. New topics are created via comment system.
if( !$gContent->isValid() ){
$gBitSystem->fatalError( tra('No topic specified.') );
// Check the user's ticket
$gBitUser->verifyTicket();
// Load up the Topic's board - we'll respect its permissions
$board = new BitBoard( $gContent->mInfo['board_id'] );
if( isset ($_REQUEST['is_locked']) || isset ($_REQUEST['is_sticky']) ){
// Check permissions to edit this topic
$board->verifyUpdatePermission();
if ( isset ($_REQUEST['is_locked']) && is_numeric($_REQUEST['is_locked']) ){
$rslt = $gContent->lock($_REQUEST['is_locked']);
} elseif ( isset ($_REQUEST['is_sticky']) && is_numeric($_REQUEST['is_sticky']) ){
$rslt = $gContent->sticky($_REQUEST['is_sticky']);
}elseif( isset ( $_REQUEST['remove'] ) ) {
// Check permissions to edit this topic if the root object is the board check its perms, otherwise check general comment admin perms
if( !(( $gContent->mInfo['root_id'] == $gContent->mInfo['board_content_id'] && $board->hasAdminPermission() ) || $gBitUser->hasPermission('p_liberty_admin_comments')) ){
$gBitSystem->fatalError( tra('You do not have permission to delete this topic.') );
if( !empty( $_REQUEST['cancel'] ) ) {
// user cancelled - just continue on, doing nothing
} elseif( empty( $_REQUEST['confirm'] ) ) {
$formHash['remove'] = TRUE;
$formHash['t'] = $_REQUEST['t'];
$gBitSystem->confirmDialog( $formHash,
'warning' => tra( 'Are you sure you want to delete this topic?' ) . ' ' . $gContent->getTitle(),
'error' => tra('This cannot be undone!')
// @TODO Topic should extend LibertyComment - but until that day we load it up a second time
if( !$topicAsComment->expunge() ) {
$gBitSmarty->assign_by_ref( 'errors', $topicAsComment->mErrors );
// send us back to the baord - http_referer won't work with confirm process
bit_redirect( BOARDS_PKG_URL. 'index.php?b='. $gContent->mInfo['board_id'] );
// User pref options on a topic - not really editing but this simplifies topic related processes putting it here
}elseif( isset ($_REQUEST['new']) || isset ($_REQUEST['notify']) ){
// Check permissions to view this topic
$gContent->verifyViewPermission();
if( isset ($_REQUEST['new']) && is_numeric($_REQUEST['new']) ){
}elseif( isset ($_REQUEST['notify']) && is_numeric($_REQUEST['notify']) ){
$rslt = $gContent->notify($_REQUEST['notify']);
// Return us to where we came from
header ("location: ". $_SERVER['HTTP_REFERER']);
// @TODO put error into an alert
//trigger_error(var_export($gContent->mErrors,true ));
|