From f7359fb2fe916c4a631c3f5d6321123847e7dce4 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Fri, 15 May 2026 16:37:09 +0100 Subject: Namespace fixes --- admin/boardsync_inc.php | 11 ++++++----- assign.php | 3 ++- boards_rss.php | 7 ++++--- edit.php | 9 +++++---- edit_topic.php | 11 ++++++----- includes/edit_topic_inc.php | 5 +++-- includes/list_boards_inc.php | 3 ++- includes/mailman_lib.php | 21 +++++++++++---------- includes/view_board_inc.php | 5 +++-- includes/view_topic_inc.php | 13 +++++++------ mailing_list.php | 11 ++++++----- topic_move.php | 5 +++-- 12 files changed, 58 insertions(+), 46 deletions(-) diff --git a/admin/boardsync_inc.php b/admin/boardsync_inc.php index ee976fd..71b3a18 100755 --- a/admin/boardsync_inc.php +++ b/admin/boardsync_inc.php @@ -1,5 +1,6 @@ \s*(.*)\s*/', $s, $matches) ) { $toAddresses[] = [ 'email'=>$matches[1], 'name'=>$matches[2] ]; } - } elseif( validate_email_syntax( $s ) ) { + } elseif( KernelTools::validate_email_syntax( $s ) ) { $toAddresses[] = [ 'email'=>$s ]; } } @@ -555,7 +556,7 @@ function board_sync_delivered_to( $raw_headers ) { $ret = []; foreach ($deliveredTo[1] as $address) { // Make sure the Delivered-To: address is valid. - if (validate_email_syntax( $address ) ) { + if (KernelTools::validate_email_syntax( $address ) ) { $ret[] = strtolower(trim($address)); } } diff --git a/assign.php b/assign.php index 8c3c602..9d7769f 100755 --- a/assign.php +++ b/assign.php @@ -11,6 +11,7 @@ /** * required setup */ +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; // Is package installed and enabled @@ -60,5 +61,5 @@ $data = BitBoard::getAllMap(); $gBitSmarty->assign('data',$data); // Display the template -$gBitSystem->display( 'bitpackage:boards/board_assign.tpl', tra('Assign content to Board') , [ 'display_mode' => 'display' ]); +$gBitSystem->display( 'bitpackage:boards/board_assign.tpl', KernelTools::tra('Assign content to Board') , [ 'display_mode' => 'display' ]); ?> diff --git a/boards_rss.php b/boards_rss.php index c8a4244..321b2bf 100755 --- a/boards_rss.php +++ b/boards_rss.php @@ -6,6 +6,7 @@ */ use Bitweaver\Users\RoleUser; +use Bitweaver\KernelTools; /** * Initialization @@ -26,7 +27,7 @@ if( !empty( $_REQUEST['t'] ) || !empty($_REQUEST['b'] ) ){ $gContent->load(); } else{ - $gBitSystem->fatalError(tra("Unknown discussion"), null, null, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError(KernelTools::tra("Unknown discussion"), null, null, HttpStatusCodes::HTTP_GONE ); } } $gContent->verifyViewPermission(); @@ -52,8 +53,8 @@ switch( $gContent->getField('content_type_guid') ){ $cacheFile.="_".$cacheFileTail; $rss->useCached( $rss_version_name, $cacheFile, $gBitSystem->getConfig( 'rssfeed_cache_time' )); -$title = tra("Recent Discussions"); -$description = tra("All recent forum discussions on ".$gBitSystem->getConfig( 'site_title' ) ); +$title = KernelTools::tra("Recent Discussions"); +$description = KernelTools::tra("All recent forum discussions on ".$gBitSystem->getConfig( 'site_title' ) ); if( $gContent->isValid() ){ $title = $gContent->getField( 'title' )." Feed"; $description = $gContent->getParsedData(); diff --git a/edit.php b/edit.php index a5114ce..640492b 100755 --- a/edit.php +++ b/edit.php @@ -11,6 +11,7 @@ /** * required setup */ +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; // Is package installed and enabled @@ -36,11 +37,11 @@ if( isset( $_REQUEST['remove'] ) ) { if( empty( $_REQUEST['confirm'] ) ) { $formHash['b'] = $_REQUEST['b']; $formHash['remove'] = true; - $gBitSystem->confirmDialog( $formHash, [ 'warning' => tra( 'Are you sure you want to remove the entire message board' ).' "'.$gContent->getTitle().'" ?', 'error' => 'This cannot be undone!' ] ); + $gBitSystem->confirmDialog( $formHash, [ 'warning' => KernelTools::tra( 'Are you sure you want to remove the entire message board' ).' "'.$gContent->getTitle().'" ?', 'error' => 'This cannot be undone!' ] ); } elseif( !$gContent->expunge() ) { $gBitSmarty->assign( 'errors', $deleteComment->mErrors ); } else { - bit_redirect( BOARDS_PKG_URL.'index.php' ); + KernelTools::bit_redirect( BOARDS_PKG_URL.'index.php' ); } } else { $gBitSystem->fatalPermission( 'p_boards_remove' ); @@ -67,12 +68,12 @@ if( !empty( $_REQUEST["save_bitboard"] ) ) { // disabled if( $gContent->store( $storeHash ) ) { $gContent->storePreference( 'board_sync_list_address', (!empty( $_REQUEST['bitboardconfig']['board_sync_list_address'] ) ? $_REQUEST['bitboardconfig']['board_sync_list_address'] : null) ); - bit_redirect( $gContent->getDisplayUrl() ); + KernelTools::bit_redirect( $gContent->getDisplayUrl() ); } else { $gBitSmarty->assign( 'errors', $gContent->mErrors ); } } // Display the template -$gBitSystem->display( 'bitpackage:boards/board_edit.tpl', tra('Board') , [ 'display_mode' => 'edit' ]); +$gBitSystem->display( 'bitpackage:boards/board_edit.tpl', KernelTools::tra('Board') , [ 'display_mode' => 'edit' ]); ?> diff --git a/edit_topic.php b/edit_topic.php index 6ba2ded..9f89e58 100755 --- a/edit_topic.php +++ b/edit_topic.php @@ -12,6 +12,7 @@ * required setup */ use \Bitweaver\Boards\BitBoard; +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; // Is package installed and enabled @@ -22,7 +23,7 @@ require_once( BOARDS_PKG_INCLUDE_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.') ); + $gBitSystem->fatalError( KernelTools::tra('No topic specified.') ); } // Check the user's ticket @@ -49,7 +50,7 @@ if( isset($_REQUEST['is_locked']) || isset($_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.') ); + $gBitSystem->fatalError( KernelTools::tra('You do not have permission to delete this topic.') ); } if( !empty( $_REQUEST['cancel'] ) ) { @@ -59,8 +60,8 @@ if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ $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!'), + 'warning' => KernelTools::tra( 'Are you sure you want to delete this topic?' ) . ' ' . $gContent->getTitle(), + 'error' => KernelTools::tra('This cannot be undone!'), ], ); } else { @@ -70,7 +71,7 @@ if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ $gBitSmarty->assign( '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'] ); + KernelTools::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']) ){ diff --git a/includes/edit_topic_inc.php b/includes/edit_topic_inc.php index cac54c3..0fb5e3b 100755 --- a/includes/edit_topic_inc.php +++ b/includes/edit_topic_inc.php @@ -14,6 +14,7 @@ we look if any page's checkbox is on and if remove_boards is selected. then we check permission to delete boards. if so, we call histlib's method remove_all_versions for all the checked boards. */ +use Bitweaver\KernelTools; if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQUEST["submit_mult"] == "remove_boards" ) { // Now check permissions to remove the selected bitboard @@ -31,8 +32,8 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU } $gBitSystem->confirmDialog( $formHash, [ - 'warning' => tra('Are you sure you want to delete these topics?') . ' (' . tra('Count: ') . count( $_REQUEST["checked"] ) . ')', - 'error' => tra('This cannot be undone!'), + 'warning' => KernelTools::tra('Are you sure you want to delete these topics?') . ' (' . KernelTools::tra('Count: ') . count( $_REQUEST["checked"] ) . ')', + 'error' => KernelTools::tra('This cannot be undone!'), ], ); } else { diff --git a/includes/list_boards_inc.php b/includes/list_boards_inc.php index cd06fee..e2904bc 100755 --- a/includes/list_boards_inc.php +++ b/includes/list_boards_inc.php @@ -11,6 +11,7 @@ /** * required setup */ +use Bitweaver\KernelTools; require_once("../kernel/includes/setup_inc.php"); require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' ); require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' ); @@ -126,6 +127,6 @@ foreach ($ns as $k=> $a) { } //$gBitSmarty->display( 'bitpackage:boards/cat_display.tpl'); -$gBitSystem->display( 'bitpackage:boards/list_boards.tpl', tra( 'Boards' ) , [ 'display_mode' => 'display' ]); +$gBitSystem->display( 'bitpackage:boards/list_boards.tpl', KernelTools::tra( 'Boards' ) , [ 'display_mode' => 'display' ]); ?> diff --git a/includes/mailman_lib.php b/includes/mailman_lib.php index 377345d..d959d26 100755 --- a/includes/mailman_lib.php +++ b/includes/mailman_lib.php @@ -11,15 +11,16 @@ * @date created 2008-APR-06 * @author wjames spider */ +use Bitweaver\KernelTools; function mailman_verify_list( $pListName ) { $error = NULL; if( $matches = preg_match( '/[^A-Za-z0-9\-\_]/', $pListName ) ) { - $error = tra( "Invalid mailing list name" ).": ".tra( "List names can only contain letters and numbers" ); + $error = KernelTools::tra( "Invalid mailing list name" ).": ".KernelTools::tra( "List names can only contain letters and numbers" ); } else { $lists = mailman_list_lists(); if( !empty( $lists[strtolower($pListName)] ) ) { - $error = tra( "Invalid mailing list name" ).": ".tra( "List already exists" ); + $error = KernelTools::tra( "Invalid mailing list name" ).": ".KernelTools::tra( "List already exists" ); } } return $error; @@ -28,7 +29,7 @@ function mailman_verify_list( $pListName ) { function mailman_list_lists() { $ret = []; if( $ret_code = mailman_command( "list_lists", $output) ) { - mailman_fatal(tra("Unable to list lists."), $ret_code); + mailman_fatal(KernelTools::tra("Unable to list lists."), $ret_code); } else { foreach( $output as $o ) { @@ -45,7 +46,7 @@ function mailman_list_members( $pListName ) { $ret = []; $options = escapeshellarg( $pListName ); if( $ret = mailman_command( "list_members", $output, $options ) ) { - // mailman_fatal(tra('Unable to get members for list: ').$pListName, $ret); + // mailman_fatal(KernelTools::tra('Unable to get members for list: ').$pListName, $ret); } return( $output ); } @@ -55,7 +56,7 @@ function mailman_config_list( $pParamHash ){ $options = " -i ".escapeshellarg(UTIL_PKG_INCLUDE_PATH."mailman.cfg"); $options .= " ".escapeshellarg( $pParamHash["listname"] ); if( $ret = mailman_command( "config_list", $output, $options) ) { - return (tra("Unable to configure list: ").$pParamHash["listname"].":".$ret); + return (KernelTools::tra("Unable to configure list: ").$pParamHash["listname"].":".$ret); } } @@ -72,14 +73,14 @@ function mailman_newlist( $pParamHash ) { $options .= " ".escapeshellarg( $pParamHash["admin-password"] )." "; if( $ret = mailman_command( "newlist", $output, $options ) ) { - return (tra("Unable to create list: ").$pParamHash["listname"].":".$ret); + return (KernelTools::tra("Unable to create list: ").$pParamHash["listname"].":".$ret); } $options = " -i ".escapeshellarg(UTIL_PKG_INCLUDE_PATH."mailman.cfg"); $options .= " ".escapeshellarg( $pParamHash["listname"] ); if( $ret = mailman_command( "config_list", $output, $options) ) { // @TODO if this fails we should roll back the newlist created - return (tra("Unable to configure list: ").$pParamHash["listname"].":".$ret); + return (KernelTools::tra("Unable to configure list: ").$pParamHash["listname"].":".$ret); } $newList = $pParamHash["listname"]; @@ -197,7 +198,7 @@ function mailman_addmember( $pListName, $pEmail, $pType = NULL ) { function mailman_findmember( $pListName, $pEmail ) { $options = " -l ".escapeshellarg( $pListName )." ".escapeshellarg( $pEmail ); if( $ret = mailman_command( "find_member", $output, $options ) ) { - mailman_fatal(tra("Unable to find member in list: ").$pListName, $ret); + mailman_fatal(KernelTools::tra("Unable to find member in list: ").$pListName, $ret); } return $output; } @@ -230,7 +231,7 @@ function mailman_rmlist( $pListName ) { if( mailman_verify_list( $pListName ) ) { $options = " -a ".escapeshellarg( $pListName ); if( $ret = mailman_command( "rmlist", $output, $options ) ) { - mailman_fatal(tra("Unable to remove list: ").$pListName, $ret); + mailman_fatal(KernelTools::tra("Unable to remove list: ").$pListName, $ret); } $newList = $pListName; @@ -340,7 +341,7 @@ function mailman_command( $pCommand, &$output, $pOptions=NULL ) { function mailman_fatal($pMessage, $pRetCode) { global $gBitSystem; - $gBitSystem->fatalError($pMessage.tra(" Command returned: ").$pRetCode); + $gBitSystem->fatalError($pMessage.KernelTools::tra(" Command returned: ").$pRetCode); die; } diff --git a/includes/view_board_inc.php b/includes/view_board_inc.php index bd17fb8..035fae0 100755 --- a/includes/view_board_inc.php +++ b/includes/view_board_inc.php @@ -16,6 +16,7 @@ namespace Bitweaver\Boards; require_once '../kernel/includes/setup_inc.php'; use Bitweaver\BitBase; use Bitweaver\HttpStatusCodes; +use Bitweaver\KernelTools; // Is package installed and enabled $gBitSystem->verifyPackage( 'boards' ); @@ -24,7 +25,7 @@ $gBitSystem->verifyPackage( 'boards' ); if ( BitBase::verifyId( $_REQUEST['migrate_board_id'] ?? 0 ) ) { if( $_REQUEST['b'] = BitBoard::lookupByMigrateBoard( $_REQUEST['migrate_board_id'] ) ) { - bit_redirect( BOARDS_PKG_URL.'index.php?b='. $_REQUEST['b'] ); + KernelTools::bit_redirect( BOARDS_PKG_URL.'index.php?b='. $_REQUEST['b'] ); } } @@ -114,4 +115,4 @@ $gBitSmarty->assign( 'cat_url', BOARDS_PKG_URL."index.php"); //?ct=".urlencode($ $gBitThemes->loadAjax( 'mochikit' ); // Display the template -$gBitSystem->display( 'bitpackage:boards/list_topics.tpl', tra( 'Message Board Threads: ' . $gContent->getField('title') ) , [ 'display_mode' => 'display' ]); \ No newline at end of file +$gBitSystem->display( 'bitpackage:boards/list_topics.tpl', KernelTools::tra( 'Message Board Threads: ' . $gContent->getField('title') ) , [ 'display_mode' => 'display' ]); \ No newline at end of file diff --git a/includes/view_topic_inc.php b/includes/view_topic_inc.php index cb1673c..8c76fea 100755 --- a/includes/view_topic_inc.php +++ b/includes/view_topic_inc.php @@ -12,16 +12,17 @@ use Bitweaver\HttpStatusCodes; use Bitweaver\Boards\BitBoard; use Bitweaver\Boards\BitBoardTopic; use Bitweaver\Boards\BitBoardPost; +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; // if we're getting a migrate id then lets move on right away if( BitBase::verifyId( $_REQUEST['migrate_topic_id'] ?? 0 ) ) { if( $_REQUEST['t'] = BitBoardTopic::lookupByMigrateTopic( $_REQUEST['migrate_topic_id'] ) ) { - bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] ); + KernelTools::bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] ); } } elseif( BitBase::verifyId( $_REQUEST['migrate_post_id'] ?? 0 ) ) { if( $_REQUEST['t'] = BitBoardTopic::lookupByMigratePost( $_REQUEST['migrate_post_id'] ) ) { - bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] ); + KernelTools::bit_redirect( BOARDS_PKG_URL.'index.php?t='. $_REQUEST['t'] ); } } @@ -34,7 +35,7 @@ if (!empty($_REQUEST['action'])) { $comment = new BitBoardPost($_REQUEST['comment_id']); $comment->loadComment(); if (!$comment->isValid()) { - $gBitSystem->fatalError( tra("Invalid Comment"), null, null, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError( KernelTools::tra("Invalid Comment"), null, null, HttpStatusCodes::HTTP_GONE ); } switch ($_REQUEST['action']) { case 1: @@ -59,7 +60,7 @@ $thread = new BitBoardTopic($_REQUEST['t']); $thread->load(); if( !$thread->isValid() ) { - $gBitSystem->fatalError( tra("Unknown discussion"), null, null, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError( KernelTools::tra("Unknown discussion"), null, null, HttpStatusCodes::HTTP_GONE ); } $thread->verifyViewPermission(); @@ -76,9 +77,9 @@ $gBitSmarty->assign('gContent', $gContent); if (empty($thread->mInfo['th_root_id'])) { if ($_REQUEST['action']==3) { //Invalid as a result of rejecting the post, redirect to the board - bit_redirect( $gBoard->getDisplayUrl() ); + KernelTools::bit_redirect( $gBoard->getDisplayUrl() ); } else { - $gBitSystem->fatalError(tra( "Invalid topic selection." ), null, null, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError(KernelTools::tra( "Invalid topic selection." ), null, null, HttpStatusCodes::HTTP_GONE ); } } diff --git a/mailing_list.php b/mailing_list.php index c09baae..098d311 100755 --- a/mailing_list.php +++ b/mailing_list.php @@ -12,6 +12,7 @@ /** * required setup */ +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' ); require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' ); @@ -24,7 +25,7 @@ $gBitSystem->verifyPackage( 'boards' ); // Verify we found a board if( !$gContent->isValid() ) { - $gBitSystem->fatalError(tra("Error: No such board.")); + $gBitSystem->fatalError(KernelTools::tra("Error: No such board.")); } // Now check permissions to access this page @@ -55,15 +56,15 @@ if( !empty( $_REQUEST['create_list'] ) ) { $formHash['b'] = $gContent->getField( 'board_id' ); $gBitSystem->confirmDialog( $formHash, [ - 'warning' => tra('Are you sure you want to delete this mailing list?') . ' ' . $gContent->getTitle(), - 'error' => tra('This cannot be undone!'), + 'warning' => KernelTools::tra('Are you sure you want to delete this mailing list?') . ' ' . $gContent->getTitle(), + 'error' => KernelTools::tra('This cannot be undone!'), ], ); } else { if( !($error = mailman_rmlist( $gContent->getPreference( 'boards_mailing_list' ) )) ) { $gContent->storePreference( 'boards_mailing_list', null ); $gContent->storePreference( 'boards_mailing_list_password', null ); - bit_redirect( BOARDS_PKG_URL."mailing_list.php?b=".$gContent->getField( 'board_id' ) ); + KernelTools::bit_redirect( BOARDS_PKG_URL."mailing_list.php?b=".$gContent->getField( 'board_id' ) ); } else { $gBitSmarty->assign( 'errorMsg', $error ); } @@ -101,5 +102,5 @@ if( $gContent->getBoardMailingList() ) { // display $gBitSmarty->assign( 'board', $gContent ); -$gBitSystem->display( "bitpackage:boards/mailing_list.tpl", $gContent->getTitle() ." ". tra( 'Message Board Mailing List' ) , [ 'display_mode' => 'list' ]); +$gBitSystem->display( "bitpackage:boards/mailing_list.tpl", $gContent->getTitle() ." ". KernelTools::tra( 'Message Board Mailing List' ) , [ 'display_mode' => 'list' ]); ?> diff --git a/topic_move.php b/topic_move.php index 8aa266d..f7546d8 100755 --- a/topic_move.php +++ b/topic_move.php @@ -7,6 +7,7 @@ /** * required setup */ +use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; // Is package installed and enabled @@ -36,7 +37,7 @@ if( isset( $_REQUEST["target"] ) ) { } if( $gContent->moveTo($_REQUEST["target"]) ) { - bit_redirect( $gContent->getDisplayUrl() ); + KernelTools::bit_redirect( $gContent->getDisplayUrl() ); } else { $gBitSystem->fatalError( "There was an error moving the topic: ".vc( $gContent->mErrors )); } @@ -48,5 +49,5 @@ $gBitSmarty->assign('boards', $boards); $gBitSmarty->assign('fromBoardId', $board->mContentId); -$gBitSystem->display( 'bitpackage:boards/topic_move.tpl', tra('Move Topic').':'.$gContent->getTitle(), [ 'display_mode' => 'display' ]); +$gBitSystem->display( 'bitpackage:boards/topic_move.tpl', KernelTools::tra('Move Topic').':'.$gContent->getTitle(), [ 'display_mode' => 'display' ]); ?> -- cgit v1.3