diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:49:08 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:49:08 +0100 |
| commit | ef793a806a8d5a479c29c061780c56f62c4d3535 (patch) | |
| tree | dabe63be7a0cf383196bccfeb8743310e1d28fba /includes | |
| parent | 39508ee5ad8908fa720db48fcf7923f309fdce9d (diff) | |
| download | boards-ef793a806a8d5a479c29c061780c56f62c4d3535.tar.gz boards-ef793a806a8d5a479c29c061780c56f62c4d3535.tar.bz2 boards-ef793a806a8d5a479c29c061780c56f62c4d3535.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/bit_setup_inc.php | 22 | ||||
| -rw-r--r-- | includes/boards_comments_inc.php | 2 | ||||
| -rwxr-xr-x | includes/classes/BitBoard.php | 63 | ||||
| -rwxr-xr-x | includes/classes/BitBoardPost.php | 27 | ||||
| -rwxr-xr-x | includes/classes/BitBoardTopic.php | 75 | ||||
| -rwxr-xr-x | includes/edit_topic_inc.php | 8 | ||||
| -rwxr-xr-x | includes/list_boards_inc.php | 12 | ||||
| -rwxr-xr-x | includes/user_preferences_inc.php | 1 | ||||
| -rwxr-xr-x | includes/view_board_inc.php | 12 | ||||
| -rwxr-xr-x | includes/view_topic_inc.php | 9 |
10 files changed, 112 insertions, 119 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 10c46e6..fe8743e 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -15,9 +15,9 @@ $pRegisterHash = [ define( 'BOARDS_PKG_NAME', $pRegisterHash['package_name'] ); define( 'BOARDS_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'BOARDS_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); -define( 'BOARDS_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'BOARDS_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); define( 'BOARDS_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); -define( 'BOARDS_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); +define( 'BOARDS_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boards_read' )) { @@ -49,7 +49,7 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa $gLibertySystem->registerService( LIBERTY_SERVICE_FORUMS, BOARDS_PKG_NAME, $registerArray ); function boards_get_topic_comment( $pThreadForwardSequence ) { - return intval( substr( $pThreadForwardSequence, 0, 9 ) ); + return (int) ( substr( $pThreadForwardSequence, 0, 9 ) ); } $gBitThemes->loadCss(BOARDS_PKG_PATH.'styles/boards.css'); @@ -61,13 +61,13 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa if( file_exists(BIT_ROOT_PATH.'moderation/bit_setup_inc.php') ) { require_once BIT_ROOT_PATH.'moderation/bit_setup_inc.php'; global $gModerationSystem; - + if( $gBitSystem->isPackageActive( 'moderation' ) ) { // Register our event handler $gModerationSystem->registerModerationObserver(BOARDS_PKG_NAME, 'modcomments', 'board_comments_moderation'); $gModerationSystem->registerModerationObserver(BOARDS_PKG_NAME, 'liberty', 'board_comments_moderation'); - + // And define the function we use to handle the observation. function board_comments_moderation($pModerationInfo) { if( $pModerationInfo['type'] == 'comment_post' ) { @@ -92,20 +92,20 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa $code = 'confirm '.$code; require_once KERNEL_PKG_CLASS_PATH.'BitMailer.php'; $mailer = new BitMailer(); - + if( $pModerationInfo['last_status'] == MODERATION_DELETE ) { // Send a reject message $mailer->sendEmail($code, '', $boardSync, - array( 'sender' => - BitBoard::getBoardSyncInbox() ) ); + [ 'sender' => + BitBoard::getBoardSyncInbox(), ], ); } else { // Send an accept message $mailer->sendEmail($code, '', $boardSync, - array('sender' => + ['sender' => BitBoard::getBoardSyncInbox(), 'x_headers' => - array( 'Approved' => - $approved) ) ); + [ 'Approved' => + $approved, ], ], ); } } } diff --git a/includes/boards_comments_inc.php b/includes/boards_comments_inc.php index 573aef5..5b8338e 100644 --- a/includes/boards_comments_inc.php +++ b/includes/boards_comments_inc.php @@ -35,7 +35,7 @@ if (!function_exists("send_board_email")) { $headerHash['from_name'] = $storeComment->getField( 'anon_name' ); $headerHash['from'] = 'anonymous@'.$gBitSystem->getConfig('boards_sync_mail_server'); } else { - $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $storeComment->getField( 'user_id', $gBitUser->mUserId ) ) ); + $userInfo = $gBitUser->getUserInfo( [ 'user_id' => $storeComment->getField( 'user_id', $gBitUser->mUserId ) ] ); $headerHash['from_name'] = !empty( $userInfo['real_name'] ) ? $userInfo['real_name'] : $userInfo['login']; $headerHash['from'] = $userInfo['email']; $headerHash['sender'] = $userInfo['email']; diff --git a/includes/classes/BitBoard.php b/includes/classes/BitBoard.php index 7062b11..b9c9eb5 100755 --- a/includes/classes/BitBoard.php +++ b/includes/classes/BitBoard.php @@ -15,12 +15,12 @@ * required setup */ namespace Bitweaver\Boards; + use Bitweaver\BitBase; use Bitweaver\KernelTools; use Bitweaver\Pigeonholes\Pigeonholes; use Bitweaver\Liberty\LibertyContent; use Bitweaver\Liberty\LibertyMime; -use function intval; /** * This is used to uniquely identify the object @@ -45,14 +45,14 @@ class BitBoard extends LibertyMime { $this->mBitBoardId = (int)$pBitBoardId; $this->mContentId = (int)$pContentId; $this->mContentTypeGuid = BITBOARD_CONTENT_TYPE_GUID; - $this->registerContentType( BITBOARD_CONTENT_TYPE_GUID, array( + $this->registerContentType( BITBOARD_CONTENT_TYPE_GUID, [ 'content_type_guid' => BITBOARD_CONTENT_TYPE_GUID, 'content_name' => 'Message Board', 'handler_class' => 'BitBoard', 'handler_package' => 'boards', 'handler_file' => 'BitBoard.php', - 'maintainer_url' => 'https://www.bitweaver.org' - )); + 'maintainer_url' => 'https://www.bitweaver.org', + ]); // Permission setup $this->mViewContentPerm = 'p_boards_read'; @@ -107,7 +107,7 @@ class BitBoard extends LibertyMime { global $gBitDb; $ret = null; if( BitBase::verifyId( $pMigrateBoardId ) ) { - $ret = $gBitDb->getOne( "SELECT `board_id` FROM `".BIT_DB_PREFIX."boards` bb WHERE `migrate_board_id`=?", array( $pMigrateBoardId ) ); + $ret = $gBitDb->getOne( "SELECT `board_id` FROM `".BIT_DB_PREFIX."boards` bb WHERE `migrate_board_id`=?", [ $pMigrateBoardId ] ); } return $ret; } @@ -137,12 +137,12 @@ class BitBoard extends LibertyMime { $this->mBitBoardId = $pParamHash['board_store']['board_id']; $result = $this->mDb->associateInsert( $table, $pParamHash['board_store'] ); - $result = $this->mDb->associateInsert( BIT_DB_PREFIX."boards_map",array('board_content_id'=>$pParamHash['board_store']['content_id'],'topic_content_id'=>$pParamHash['board_store']['content_id'])); + $result = $this->mDb->associateInsert( BIT_DB_PREFIX."boards_map",['board_content_id'=>$pParamHash['board_store']['content_id'],'topic_content_id'=>$pParamHash['board_store']['content_id']]); if( !empty( $pParamHash['boards_mailing_list'] ) ) { global $gBitSystem, $gBitUser; require_once( UTIL_PKG_INCLUDE_PATH.'mailman_lib.php' ); if( $gBitSystem->getConfig( 'boards_sync_mail_server' ) ) { - if( !($error = mailman_newlist( array( 'listname' => $pParamHash['boards_mailing_list'], 'listhost' => $gBitSystem->getConfig( 'boards_email_host', $gBitSystem->getConfig( 'kernel_server_name' ) ), 'admin-password'=>$pParamHash['boards_mailing_list_password'], 'listadmin-addr'=>$gBitUser->getField( 'email' ) ) )) ) { + if( !($error = mailman_newlist( [ 'listname' => $pParamHash['boards_mailing_list'], 'listhost' => $gBitSystem->getConfig( 'boards_email_host', $gBitSystem->getConfig( 'kernel_server_name' ) ), 'admin-password'=>$pParamHash['boards_mailing_list_password'], 'listadmin-addr'=>$gBitUser->getField( 'email' ) ] )) ) { $this->storePreference( 'boards_mailing_list', !empty( $pParamHash['boards_mailing_list'] ) ? $pParamHash['boards_mailing_list'] : null ); $this->storePreference( 'boards_mailing_list_password', $pParamHash['boards_mailing_list_password'] ); // Subscribe the owner @@ -239,7 +239,6 @@ class BitBoard extends LibertyMime { return( count( $this->mErrors )== 0 ); } - /** * Prepare data for preview */ @@ -268,7 +267,6 @@ class BitBoard extends LibertyMime { } } - /** * This function removes a bitboard entry **/ @@ -277,9 +275,9 @@ class BitBoard extends LibertyMime { $this->StartTrans(); $mailingList = $this->getPreference( 'boards_mailing_list' ); $query = "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `board_content_id` = ?"; - $result = $this->mDb->query( $query, array( $this->mContentId ) ); + $result = $this->mDb->query( $query, [ $this->mContentId ] ); $query = "DELETE FROM `".BIT_DB_PREFIX."boards` WHERE `content_id` = ?"; - $result = $this->mDb->query( $query, array( $this->mContentId ) ); + $result = $this->mDb->query( $query, [ $this->mContentId ] ); if( LibertyMime::expunge() ) { if( $mailingList ) { require_once UTIL_PKG_INCLUDE_PATH.'mailman_lib.php'; @@ -358,10 +356,10 @@ class BitBoard extends LibertyMime { function addContent($content_id) { if (BitBase::verifyId($content_id)) { - $data = array( + $data = [ 'board_content_id'=>$this->mContentId, 'topic_content_id'=>$content_id, - ); + ]; $this->mDb->associateInsert( BIT_DB_PREFIX."boards_map",$data); } } @@ -369,7 +367,7 @@ class BitBoard extends LibertyMime { function removeContent($content_id) { if (BitBase::verifyId($content_id) && BitBase::verifyId($this->mContentId)) { $sql = "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `board_content_id` = ? AND `topic_content_id` = ?"; - $result = $this->mDb->query( $sql, array( $this->mContentId,$content_id ) ); + $result = $this->mDb->query( $sql, [ $this->mContentId,$content_id ] ); } } @@ -383,7 +381,7 @@ class BitBoard extends LibertyMime { INNER JOIN `".BIT_DB_PREFIX."boards_map` map ON (map.`board_content_id`= b.`content_id`) WHERE b.`board_id`=? AND map.`board_content_id` = map.`topic_content_id` "; - $count = $this->mDb->getOne( $sql, array( $this->mBitBoardId )); + $count = $this->mDb->getOne( $sql, [ $this->mBitBoardId ]); return ($count==1); } return $ret; @@ -401,7 +399,7 @@ class BitBoard extends LibertyMime { $ret = null; if (BitBase::verifyId($content_id)) { $sql = "SELECT `board_content_id` FROM `".BIT_DB_PREFIX."boards_map` map WHERE map.`topic_content_id`=?"; - $ret = $gBitDb->getOne( $sql, array( $content_id )); + $ret = $gBitDb->getOne( $sql, [ $content_id ]); } return $ret; } @@ -430,7 +428,7 @@ class BitBoard extends LibertyMime { WHERE b.`board_id`=? AND map.`board_content_id`!=map.`topic_content_id` ORDER BY order_key "; - $rs = $this->mDb->query( $sql, array( $this->mBitBoardId )); + $rs = $this->mDb->query( $sql, [ $this->mBitBoardId ]); while( $row = $rs->fetchRow() ) { $ret[$row['t_content_id']] = $row; } @@ -549,14 +547,14 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON (map.`topic_content_id` = lcom.`root_id`) INNER JOIN `".BIT_DB_PREFIX."liberty_content` slc ON( slc.`content_id` = lcom.`content_id` ) LEFT JOIN `".BIT_DB_PREFIX."boards_posts` fp ON (fp.`comment_id` = lcom.`comment_id`) - WHERE lcom.`root_id`=lcom.`parent_id` AND map.`board_content_id`=? AND ((fp.`is_approved` = 1) OR (fp.`is_approved` IS null))", array( $res['content_id'] ) ); + WHERE lcom.`root_id`=lcom.`parent_id` AND map.`board_content_id`=? AND ((fp.`is_approved` = 1) OR (fp.`is_approved` IS null))", [ $res['content_id'] ] ); $res['post_count'] = $this->mDb->getOne( "SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` lcom INNER JOIN `".BIT_DB_PREFIX."liberty_content` slc ON( slc.`content_id` = lcom.`content_id` ) INNER JOIN `".BIT_DB_PREFIX."boards_map` map ON (lcom.`root_id`=map.`topic_content_id`) LEFT JOIN `".BIT_DB_PREFIX."boards_posts` fp ON (fp.`comment_id` = lcom.`comment_id`) - WHERE map.`board_content_id`=? AND ((fp.`is_approved` = 1) OR (fp.`is_approved` IS null))", array( $res['content_id'] ) ); + WHERE map.`board_content_id`=? AND ((fp.`is_approved` = 1) OR (fp.`is_approved` IS null))", [ $res['content_id'] ] ); if($track) { if ($gBitUser->isRegistered()) { $res['track']['on'] = true; @@ -589,12 +587,12 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i WHERE lcom.`root_id`=lcom.`parent_id` AND map.`board_content_id`=? AND ((fp.`is_approved` IS null OR fp.`is_approved` = 1) OR (slc.`user_id` >= 0)) ORDER BY slc.`last_modified` DESC "; - $result = $this->mDb->getRow( $query, array( $data['content_id'] ) ); + $result = $this->mDb->getRow( $query, [ $data['content_id'] ] ); if (!empty($result['topic_id'])) { if (empty($result['l_anon_name'])) { $result['l_anon_name'] = "Anonymous"; } - $result['topic_id']=intval($result['topic_id']); + $result['topic_id']=(int) ($result['topic_id']); $result['url'] = BitBoardTopic::getDisplayUrlFromHash( $result ); } return $result; @@ -700,8 +698,8 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i if( $result && $result->numRows() ) { $ret = $result->fields; - $ret['creator'] =( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] ); - $ret['editor'] =( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); + $ret['creator'] =( $result->fields['creator_real_name'] ?? $result->fields['creator_user'] ); + $ret['editor'] =( $result->fields['modifier_real_name'] ?? $result->fields['modifier_user'] ); $ret['display_url'] = BIT_ROOT_URL."index.php?content_id=$contentId"; } } @@ -718,12 +716,11 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i LEFT JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON (lcom.`root_id`=bm.`topic_content_id`) WHERE bm.`topic_content_id`=? GROUP BY b.`board_id`, b.`content_id`"; - $ret = $gBitDb->getRow( $sql, array( $pContentId ) ); + $ret = $gBitDb->getRow( $sql, [ $pContentId ] ); } return $ret; } - // =-=-=-=-=-=-=-=-=-=-=-=-=-= Board Sync Methods =-=-=-=-=-=-=-=-=-=-=-=-=-= function getBoardSyncInbox() { global $gBitSystem; @@ -777,7 +774,7 @@ function boards_content_store( $pContent, $pParamHash ) { // wipe out all previous assignments for good measure. Not the sanest thing to do, but edits are infrequent - at least for now if ($gBitSystem->isFeatureActive('boards_link_by_pigeonholes') && $gBitSystem->isPackageActive('pigeonholes')) { // Delete all old mappings - $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", array( $pContent->mContentId ) ); + $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", [ $pContent->mContentId ] ); // Get the pigeonholes this content is in $p = null; @@ -789,29 +786,29 @@ function boards_content_store( $pContent, $pParamHash ) { // What boards are in the same pigeonhole? $params = - array('content_type_guid' => BITBOARD_CONTENT_TYPE_GUID, - 'content_id' => $p_id ); + ['content_type_guid' => BITBOARD_CONTENT_TYPE_GUID, + 'content_id' => $p_id, ]; $boards = $p->getMemberList( $params ); // Insert into these boards foreach ($boards as $board) { if( BitBase::verifyId( $board['content_id'] ) ) { - $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", array( $board['content_id'], $pContent->mContentId ) ); + $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", [ $board['content_id'], $pContent->mContentId ] ); } } } } } else { - $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", array( $pContent->mContentId ) ); + $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", [ $pContent->mContentId ] ); if( BitBase::verifyId( $pParamHash['linked_board_cid'] ?? 0 ) ) { - $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", array( $pParamHash['linked_board_cid'], $pContent->mContentId ) ); + $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", [ $pParamHash['linked_board_cid'], $pContent->mContentId ] ); } } $gBitSmarty->assign( 'boardInfo', BitBoard::getLinkedBoard( $pContent->mContentId ) ); } else { if( BitBase::verifyId( $pParamHash['content_id'] ?? 0 ) && BitBase::verifyId( $pParamHash['linked_board_cid'] ?? 0 ) ) { - $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", array( $pParamHash['linked_board_cid'], $pParamHash['content_id'] ) ); + $pContent->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."boards_map` (`board_content_id`,`topic_content_id`) VALUES (?,?)", [ $pParamHash['linked_board_cid'], $pParamHash['content_id'] ] ); } } } @@ -850,6 +847,6 @@ function boards_content_verify( &$pObject, &$pParamHash ){ function boards_content_expunge( $pContent ) { global $gBitSmarty; if( $pContent->isValid() ) { - $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", array( $pContent->mContentId ) ); + $pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", [ $pContent->mContentId ] ); } } diff --git a/includes/classes/BitBoardPost.php b/includes/classes/BitBoardPost.php index e77e947..ddf4786 100755 --- a/includes/classes/BitBoardPost.php +++ b/includes/classes/BitBoardPost.php @@ -15,6 +15,7 @@ * required setup */ namespace Bitweaver\Boards; + use Bitweaver\BitBase; use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyComment; @@ -78,9 +79,9 @@ class BitBoardPost extends LibertyComment { //$gBitSystem->verifyPermission('p_boards_update'); //$pParamHash = (($pParamHash + 1)%2); $query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_posts` WHERE `comment_id` = ?"; - $isStored = $this->mDb->getOne( $query_sel, array( $this->mCommentId ) ); + $isStored = $this->mDb->getOne( $query_sel, [ $this->mCommentId ] ); if( $isStored ) { - $result = $this->mDb->associateUpdate( 'boards_posts', $pParamHash['post_store'], array( 'comment_id' => $this->mCommentId ) ); + $result = $this->mDb->associateUpdate( 'boards_posts', $pParamHash['post_store'], [ 'comment_id' => $this->mCommentId ] ); } else { $pParamHash['post_store']['comment_id'] = $this->mCommentId; $result = $this->mDb->associateInsert( 'boards_posts', $pParamHash['post_store'] ); @@ -96,7 +97,7 @@ class BitBoardPost extends LibertyComment { public function loadMetaData(): void { if ($this->isValid()) { if (!isset($this->mInfo['accepted'])) { - $key = array('comment_id' => $this->mCommentId); + $key = ['comment_id' => $this->mCommentId]; $query_sel = "SELECT post.is_approved, post.is_warned, @@ -173,8 +174,8 @@ class BitBoardPost extends LibertyComment { $whereSql .= " AND ((post.`is_approved` = 1) OR (lc.`user_id` >= 0))"; } - $pListHash = array( 'content_id' => $contentId, 'max_records' => $pMaxComments, 'offset'=>$pOffset, 'sort_mode'=> $pSortOrder, 'display_mode' => $pDisplayMode, 'has_comment_view_perm' => true ); - $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $pListHash ); + $pListHash = [ 'content_id' => $contentId, 'max_records' => $pMaxComments, 'offset'=>$pOffset, 'sort_mode'=> $pSortOrder, 'display_mode' => $pDisplayMode, 'has_comment_view_perm' => true ]; + $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $pListHash ); if ($pContentId) { $sql = "SELECT lcom.`comment_id`, lcom.`parent_id`, lcom.`root_id`, @@ -201,10 +202,10 @@ class BitBoardPost extends LibertyComment { if (empty($row['anon_name'])) { $row['anon_name'] = "Anonymous"; } - $row['user_avatar_url'] = ( $row['avatar_file_name'] ) ? \Bitweaver\Liberty\liberty_fetch_thumbnail_url( array( - 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( array( 'user_id' => $row['avatar_user_id'], 'file_name' => $row['avatar_file_name'], 'mime_type' => $row['avatar_mime_type'], 'attachment_id' => $row['avatar_attachment_id'] ) ), + $row['user_avatar_url'] = ( $row['avatar_file_name'] ) ? \Bitweaver\Liberty\liberty_fetch_thumbnail_url( [ + 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( [ 'user_id' => $row['avatar_user_id'], 'file_name' => $row['avatar_file_name'], 'mime_type' => $row['avatar_mime_type'], 'attachment_id' => $row['avatar_attachment_id'] ] ), 'size' => 'avatar', - ) ) : false; + ] ) : false; if (!empty($row['warned_message'])) { $row['warned_message'] = str_replace("\n","<br />\n",$row['warned_message']); } @@ -220,7 +221,7 @@ class BitBoardPost extends LibertyComment { // get attachments for each comment global $gLibertySystem; $query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`content_id`=? ORDER BY la.`pos` ASC, la.`attachment_id` ASC"; - if( $result2 = $this->mDb->query( $query,array( (int)$row['content_id'] ))) { + if( $result2 = $this->mDb->query( $query,[ (int)$row['content_id'] ])) { while( $row2 = $result2->fetchRow() ) { if( $func = $gLibertySystem->getPluginFunction( $row2['attachment_plugin_guid'], 'load_function', 'mime' )) { // we will pass the preferences by reference that the plugin can easily update them @@ -314,10 +315,10 @@ class BitBoardPost extends LibertyComment { if( $result = $this->mDb->query( $sql, $bindVars, $pListHash['max_records'], $pListHash['offset'] ) ) { while( $row = $result->FetchRow() ) { if (empty($row['anon_name'])) $row['anon_name'] = "Anonymous"; - $row['user_avatar_url'] = ( !empty( $row['avatar_file_name'] ) ) ? \Bitweaver\Liberty\liberty_fetch_thumbnail_url( array( - 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( array( 'user_id' => $row['avatar_user_id'], 'file_name' => $row['avatar_file_name'], 'mime_type' => $row['avatar_mime_type'], 'attachment_id' => $row['avatar_attachment_id'] ) ), + $row['user_avatar_url'] = ( !empty( $row['avatar_file_name'] ) ) ? \Bitweaver\Liberty\liberty_fetch_thumbnail_url( [ + 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( [ 'user_id' => $row['avatar_user_id'], 'file_name' => $row['avatar_file_name'], 'mime_type' => $row['avatar_mime_type'], 'attachment_id' => $row['avatar_attachment_id'] ] ), 'size' => 'avatar', - ) ) : false; + ] ) : false; unset($row['avatar_file_name']); if (!empty($row['warned_message'])) { $row['warned_message'] = str_replace("\n","<br />\n",$row['warned_message']); @@ -350,7 +351,7 @@ class BitBoardPost extends LibertyComment { $bindVars = []; $joinSql = $selectSql = $whereSql = ''; - $paramHash = array( 'include_comments' => true ); + $paramHash = [ 'include_comments' => true ]; $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $paramHash ); if ($pContentId) { diff --git a/includes/classes/BitBoardTopic.php b/includes/classes/BitBoardTopic.php index 68e52bd..16d6672 100755 --- a/includes/classes/BitBoardTopic.php +++ b/includes/classes/BitBoardTopic.php @@ -15,6 +15,7 @@ * required setup */ namespace Bitweaver\Boards; + use Bitweaver\BitBase; use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyBase; @@ -72,7 +73,7 @@ class BitBoardTopic extends LibertyMime { $bindVars = []; $selectSql = $joinSql = $whereSql = ''; array_push( $bindVars, $lookupId = BitBase::verifyId( $this->mRootId ) ? $this->mRootId : $this->mContentId ); - $paramHash = array( array( 'include_comments' => true ) ); + $paramHash = [ [ 'include_comments' => true ] ]; $this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $paramHash ); if (!($gBitUser->hasPermission('p_boards_update') || $gBitUser->hasPermission('p_boards_posts_update'))) { @@ -148,7 +149,7 @@ class BitBoardTopic extends LibertyMime { global $gBitDb; $ret = null; if( BitBase::verifyId( $pMigratePostId ) ) { - $path = $gBitDb->getOne( "SELECT lcom.`thread_forward_sequence` FROM `".BIT_DB_PREFIX."boards_posts` bp INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON(bp.`comment_id`=lcom.`comment_id`) WHERE bp.`migrate_post_id`=?", array( $pMigratePostId ) ); + $path = $gBitDb->getOne( "SELECT lcom.`thread_forward_sequence` FROM `".BIT_DB_PREFIX."boards_posts` bp INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON(bp.`comment_id`=lcom.`comment_id`) WHERE bp.`migrate_post_id`=?", [ $pMigratePostId ] ); if( $path ) { $ret = boards_get_topic_comment( $path ); } @@ -160,7 +161,7 @@ class BitBoardTopic extends LibertyMime { global $gBitDb; $ret = null; if( BitBase::verifyId( $pMigrateTopicId ) ) { - $ret = $gBitDb->getOne( "SELECT lcom.`comment_id` FROM `".BIT_DB_PREFIX."boards_topics` bt INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON(bt.`parent_id`=lcom.`content_id`) WHERE `migrate_topic_id`=?", array( $pMigrateTopicId ) ); + $ret = $gBitDb->getOne( "SELECT lcom.`comment_id` FROM `".BIT_DB_PREFIX."boards_topics` bt INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON(bt.`parent_id`=lcom.`content_id`) WHERE `migrate_topic_id`=?", [ $pMigrateTopicId ] ); } return $ret; } @@ -203,9 +204,9 @@ class BitBoardTopic extends LibertyMime { if( $this->mCommentContentId && $this->verify( $pParamHash ) ) { //$pParamHash = (($pParamHash + 1)%2); $query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?"; - $isStored = $this->mDb->getOne( $query_sel, array( $this->mCommentContentId ) ); + $isStored = $this->mDb->getOne( $query_sel, [ $this->mCommentContentId ] ); if( $isStored ) { - $result = $this->mDb->associateUpdate( 'boards_topics', $pParamHash['topic_store'], array( 'parent_id' => $this->mCommentContentId ) ); + $result = $this->mDb->associateUpdate( 'boards_topics', $pParamHash['topic_store'], [ 'parent_id' => $this->mCommentContentId ] ); } else { $pParamHash['topic_store']['parent_id'] = $this->mCommentContentId; $result = $this->mDb->associateInsert( 'boards_topics', $pParamHash['topic_store'] ); @@ -226,13 +227,13 @@ class BitBoardTopic extends LibertyMime { } else { $state = (($state+1)%2); $query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?"; - $result = $this->mDb->query( $query_sel, array( $this->mCommentContentId ) ); + $result = $this->mDb->query( $query_sel, [ $this->mCommentContentId ] ); if($result->RowCount()==0) { $query_ins = "INSERT INTO `".BIT_DB_PREFIX."boards_topics` (`parent_id`,`is_locked`) VALUES ( ?, ?)"; - $result = $this->mDb->query( $query_ins, array( $this->mCommentContentId, $state ) ); + $result = $this->mDb->query( $query_ins, [ $this->mCommentContentId, $state ] ); } else { $query_up = "UPDATE `".BIT_DB_PREFIX."boards_topics` SET `is_locked` = ? WHERE `parent_id` = ?"; - $result = $this->mDb->query( $query_up, array( $state, $this->mCommentContentId ) ); + $result = $this->mDb->query( $query_up, [ $state, $this->mCommentContentId ] ); } $ret = true; } @@ -250,13 +251,13 @@ class BitBoardTopic extends LibertyMime { } else { $state = (($state+1)%2); $query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?"; - $result = $this->mDb->query( $query_sel, array( $this->mCommentContentId ) ); + $result = $this->mDb->query( $query_sel, [ $this->mCommentContentId ] ); if($result->RowCount()==0) { $query_ins = "INSERT INTO `".BIT_DB_PREFIX."boards_topics` (`parent_id`,`is_sticky`) VALUES ( ?, ? )"; - $result = $this->mDb->query( $query_ins, array( $this->mCommentContentId, $state ) ); + $result = $this->mDb->query( $query_ins, [ $this->mCommentContentId, $state ] ); } else { $query_up = "UPDATE `".BIT_DB_PREFIX."boards_topics` SET `is_sticky` = ? WHERE `parent_id` = ?"; - $result = $this->mDb->query( $query_up, array( $state, $this->mCommentContentId) ); + $result = $this->mDb->query( $query_up, [ $state, $this->mCommentContentId] ); } $ret = true; } @@ -290,11 +291,11 @@ class BitBoardTopic extends LibertyMime { // move the comment we want to move to the target board $query = "UPDATE `".BIT_DB_PREFIX."liberty_comments` SET `root_id` = ?, `parent_id` = ? WHERE `thread_forward_sequence` LIKE '".sprintf("%09d.", $this->mRootId)."%' AND `root_id`=`parent_id`"; - $result = $this->mDb->query( $query, array( $board_id, $board_id ) ); + $result = $this->mDb->query( $query, [ $board_id, $board_id ] ); $query = "UPDATE `".BIT_DB_PREFIX."liberty_comments` SET `root_id` = ? WHERE `thread_forward_sequence` LIKE '".sprintf("%09d.", $this->mRootId)."%'"; - $result = $this->mDb->query( $query, array( $board_id ) ); + $result = $this->mDb->query( $query, [ $board_id ] ); // end transaction $this->CompleteTrans(); @@ -332,7 +333,7 @@ class BitBoardTopic extends LibertyMime { // if we have the board's board_id (b) we use that, or if we have its content_id we can use that if( (!empty( $pParamHash['b'] ) && $this->verifyId( $pParamHash['b'] )) - || (!empty( $pParamHash['content_id'] ) && $this->verifyId( $pParamHash['content_id'] )) ) { + || (!empty( $pParamHash['content_id'] ) && $this->verifyId( $pParamHash['content_id'] )) ) { $joinSql .= " INNER JOIN `{$BIT_DB_PREFIX}boards_map` map ON (map.`topic_content_id` = lcom.`root_id`)"; $joinSql .= " INNER JOIN `{$BIT_DB_PREFIX}boards` b ON (b.`content_id` = map.`board_content_id`)"; if(!empty($pParamHash['b'])) { @@ -508,7 +509,7 @@ class BitBoardTopic extends LibertyMime { $pThreadId=intval($pThreadId); } */ - $ret = $gBitSystem->mDb->getOne("SELECT `is_locked` FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?", array( (int)$pThreadId ) ); + $ret = $gBitSystem->mDb->getOne("SELECT `is_locked` FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?", [ (int)$pThreadId ] ); return !empty($ret); } @@ -565,7 +566,7 @@ class BitBoardTopic extends LibertyMime { $res['user'] =( $res['real_name'] ?? $res['login'] ); $ret['users'][$res['login']] = $res; } - $ret['topic'] = new BitBoardTopic(\intval($topicId)); + $ret['topic'] = new BitBoardTopic((int) $topicId); $ret['topic']->load(); return $ret; } @@ -593,14 +594,14 @@ class BitBoardTopic extends LibertyMime { @mail($user['email'], $mail_subject , $mail_message, "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n"); - $data = array( + $data = [ 'notify_date'=>time(), - ); + ]; - $key = array( + $key = [ 'user_id' =>$user['user_id'], 'topic_id' =>sprintf("%09d.",$this->mRootId), - ); + ]; $this->mDb->associateUpdate(BIT_DB_PREFIX."boards_tracking",$data,$key); } @@ -662,21 +663,21 @@ class BitBoardTopic extends LibertyMime { if ($gBitSystem->isFeatureActive('boards_thread_track') && $gBitUser->isRegistered()) { $topicId = sprintf("%09d.",$this->mRootId); $BIT_DB_PREFIX = BIT_DB_PREFIX; - $c = $this->mDb->getOne("SELECT COUNT(*) FROM `".BIT_DB_PREFIX."boards_tracking` WHERE user_id=? AND topic_id='$topicId'",array($gBitUser->mUserId)); + $c = $this->mDb->getOne("SELECT COUNT(*) FROM `".BIT_DB_PREFIX."boards_tracking` WHERE user_id=? AND topic_id='$topicId'",[$gBitUser->mUserId]); - $data = array( + $data = [ 'user_id' =>$gBitUser->mUserId, 'topic_id' =>$topicId, 'track_date'=>time(), - ); + ]; if ($c == 0) { $this->mDb->associateInsert(BIT_DB_PREFIX."boards_tracking",$data); } else { - $key = array( + $key = [ 'user_id' =>$gBitUser->mUserId, 'topic_id' =>$topicId, - ); + ]; $this->mDb->associateUpdate(BIT_DB_PREFIX."boards_tracking",$data,$key); } $this->mInfo['track']['mod']=false; @@ -713,19 +714,19 @@ class BitBoardTopic extends LibertyMime { } else { $pState = (($pState+1)%2); $query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_tracking` WHERE user_id=$gBitUser->mUserId AND topic_id='$topicId'"; - $data = array( + $data = [ 'user_id' =>$gBitUser->mUserId, 'topic_id' =>$topicId, 'notify'=>$pState, - ); + ]; $c = $this->mDb->getOne( $query_sel ); if ($c == 0) { $this->mDb->associateInsert(BIT_DB_PREFIX."boards_tracking",$data); } else { - $key = array( + $key = [ 'user_id' =>$gBitUser->mUserId, 'topic_id' =>$topicId, - ); + ]; $this->mDb->associateUpdate(BIT_DB_PREFIX."boards_tracking",$data,$key); } $ret = true; @@ -767,12 +768,12 @@ class BitBoardTopic extends LibertyMime { unset($res['track_notify']); } - function getRootObj(){ - if ( !is_object( $this->mRootObj ) && !empty( $this->mInfo['root_id'] ) ){ - if ( $obj = LibertyBase::getLibertyObject( $this->mInfo['root_id'] ) ) { - $this->mRootObj = $obj; - } - } - return $this->mRootObj; - } + function getRootObj(){ + if ( !is_object( $this->mRootObj ) && !empty( $this->mInfo['root_id'] ) ){ + if ( $obj = LibertyBase::getLibertyObject( $this->mInfo['root_id'] ) ) { + $this->mRootObj = $obj; + } + } + return $this->mRootObj; + } } diff --git a/includes/edit_topic_inc.php b/includes/edit_topic_inc.php index 952d7af..cac54c3 100755 --- a/includes/edit_topic_inc.php +++ b/includes/edit_topic_inc.php @@ -29,11 +29,11 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU foreach( $_REQUEST["checked"] as $del ) { $formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>'; } - $gBitSystem->confirmDialog( $formHash, - array( - 'warning' => tra('Are you sure you want to delete these topics?') . ' (' . tra('Count: ') . count( $_REQUEST["checked"] ) . ')', + $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!'), - ) + ], ); } else { foreach( $_REQUEST["checked"] as $deleteId ) { diff --git a/includes/list_boards_inc.php b/includes/list_boards_inc.php index f368e0c..cd06fee 100755 --- a/includes/list_boards_inc.php +++ b/includes/list_boards_inc.php @@ -33,7 +33,7 @@ if($gBitSystem->isPackageActive('pigeonholes')) { $p = new Pigeonholes(); $s = new LibertyStructure(); - $listHash = array('load_only_root'=> true); + $listHash = ['load_only_root'=> true]; $l = $p->getList($listHash); foreach ($l as $e) { $d = $s->getSubTree( $e['structure_id'] ); @@ -65,7 +65,7 @@ if($gBitSystem->isPackageActive('pigeonholes')) { $board_cids[] = $boardKey['content_id']; } if (count($board_cids)>0) { - $listHash = array('boards'=>$board_cids,'paginationOff'=>'y'); + $listHash = ['boards'=>$board_cids,'paginationOff'=>'y']; $board = new BitBoard(); $pos_var['members'] = $board->getList($listHash); $pos_var['pagination']=$listHash['listInfo']; @@ -82,11 +82,11 @@ if($gBitSystem->isPackageActive('pigeonholes')) { $ret =[]; if($gBitSystem->isPackageActive('pigeonholes')) { // $ret['data']['title']="Uncategorised Boards"; -} else { -// $ret['data']['title']="Board List"; } +// $ret['data']['title']="Board List"; + $ret['children']=[]; -$listHash = array('nboards'=>$board_all_cids,'paginationOff'=>'y'); +$listHash = ['nboards'=>$board_all_cids,'paginationOff'=>'y']; $board = new BitBoard(); $ret['members'] = $board->getList($listHash); if (count($ret['members']) == 1) { @@ -126,6 +126,6 @@ foreach ($ns as $k=> $a) { } //$gBitSmarty->display( 'bitpackage:boards/cat_display.tpl'); -$gBitSystem->display( 'bitpackage:boards/list_boards.tpl', tra( 'Boards' ) , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:boards/list_boards.tpl', tra( 'Boards' ) , [ 'display_mode' => 'display' ]); ?> diff --git a/includes/user_preferences_inc.php b/includes/user_preferences_inc.php index 27a56bd..262114f 100755 --- a/includes/user_preferences_inc.php +++ b/includes/user_preferences_inc.php @@ -42,7 +42,6 @@ if (!empty($content_type) && !empty($content_data)) { } $gBitSmarty->assign( 'signatureContent', $signatureContent ); - if( isset( $_REQUEST["format_guid"] ) ) { $signatureContent->mInfo['format_guid'] = $_REQUEST["format_guid"]; } diff --git a/includes/view_board_inc.php b/includes/view_board_inc.php index 6b6fa33..bd17fb8 100755 --- a/includes/view_board_inc.php +++ b/includes/view_board_inc.php @@ -12,6 +12,7 @@ * required setup */ namespace Bitweaver\Boards; + require_once '../kernel/includes/setup_inc.php'; use Bitweaver\BitBase; use Bitweaver\HttpStatusCodes; @@ -40,7 +41,7 @@ if( !$gContent->isValid() ) { if (!empty($_REQUEST['action'])) { // Check edit perms on the group $gContent->verifyUpdatePermission(); - + // Check the ticket $gBitUser->verifyTicket(); @@ -52,7 +53,7 @@ if (!empty($_REQUEST['action'])) { if (!$comment->isValid()) { $gBitSystem->fatalError("Invalid Comment Id"); } - + // Take action switch ($_REQUEST['action']) { case 1: @@ -79,11 +80,10 @@ if (!empty($_REQUEST['action'])) { */ require_once BOARDS_PKG_INCLUDE_PATH.'edit_topic_inc.php'; - // Ok finally we can get on with viewing our board // liberty display services -$displayHash = array( 'perm_name' => 'p_boards_read' ); +$displayHash = [ 'perm_name' => 'p_boards_read' ]; $gContent->invokeServices( 'content_display_function', $displayHash ); // set some comment values since topics are comments @@ -99,7 +99,7 @@ require_once BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php'; $threads = new BitBoardTopic( $gContent->mContentId ); // lets pass in a ref to the root obj so we can fully mimic comments -$threads->mRootObj = $gContent; +$threads->mRootObj = $gContent; $threadsListHash = $_REQUEST; $threadList = $threads->getList( $threadsListHash ); @@ -114,4 +114,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') ) , array( 'display_mode' => 'display' ));
\ No newline at end of file +$gBitSystem->display( 'bitpackage:boards/list_topics.tpl', 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 ceec213..cb1673c 100755 --- a/includes/view_topic_inc.php +++ b/includes/view_topic_inc.php @@ -72,7 +72,6 @@ $gBitSmarty->assign( 'board', $gBoard ); $gContent = &$gBoard; $gBitSmarty->assign('gContent', $gContent); - // if you know what this is please comment it if (empty($thread->mInfo['th_root_id'])) { if ($_REQUEST['action']==3) { @@ -83,9 +82,8 @@ if (empty($thread->mInfo['th_root_id'])) { } } - // Invoke services -$displayHash = array( 'perm_name' => 'p_boards_read' ); +$displayHash = [ 'perm_name' => 'p_boards_read' ]; $thread->invokeServices( 'content_display_function', $displayHash ); $thread->readTopic(); @@ -93,7 +91,6 @@ $thread->readTopic(); $gBitSmarty->assign( 'thread', $thread ); $gBitSmarty->assign( 'topic_locked', BitBoardTopic::isThreadLocked( $thread->mCommentContentId ) ); - // Get the thread of comments $commentsParentId=$thread->mInfo['content_id']; $comments_return_url= BOARDS_PKG_URL."index.php?t={$thread->mRootId}"; @@ -114,7 +111,6 @@ if( $gBitUser->isRegistered() ) { $postComment['user_url'] = $gBitUser->getDisplayUrl(); } - // display warnings - might be for edit processes - if you know please comment $warnings = []; if (!empty($_REQUEST['warning'])) { @@ -126,8 +122,7 @@ if (!empty($_REQUEST['warning'])) { } $gBitSmarty->assign('warnings',$warnings); - // ajax support $gBitThemes->loadAjax( 'mochikit' ); -$gBitSystem->display('bitpackage:boards/list_posts.tpl', "Show Thread: " . $thread->getField('title') , array( 'display_mode' => 'display' )); +$gBitSystem->display('bitpackage:boards/list_posts.tpl', "Show Thread: " . $thread->getField('title') , [ 'display_mode' => 'display' ]); |
