summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-03-09 20:23:02 +0000
committerlsces <lester@lsces.co.uk>2026-03-09 20:23:02 +0000
commit27b224f36d0587e79447fce1e5cb62161005e616 (patch)
tree065d8d1767672ad08cd3e3a3197e6630769b6f6b /includes
parent23dd61e8cabda4b922e2ef28ad6a52db847f2cf0 (diff)
downloadboards-27b224f36d0587e79447fce1e5cb62161005e616.tar.gz
boards-27b224f36d0587e79447fce1e5cb62161005e616.tar.bz2
boards-27b224f36d0587e79447fce1e5cb62161005e616.zip
As with articles, boards has had a blanket Smarty5 and PHP8.4 sweep of the code, but as yet this has not been tested. VSCode is currently saying the files are now clean.
Diffstat (limited to 'includes')
-rwxr-xr-x[-rw-r--r--]includes/bit_setup_inc.php48
-rwxr-xr-x[-rw-r--r--]includes/classes/BitBoard.php143
-rwxr-xr-x[-rw-r--r--]includes/classes/BitBoardPost.php130
-rwxr-xr-x[-rw-r--r--]includes/classes/BitBoardTopic.php188
-rwxr-xr-x[-rw-r--r--]includes/edit_topic_inc.php6
-rwxr-xr-x[-rw-r--r--]includes/list_boards_inc.php24
-rwxr-xr-x[-rw-r--r--]includes/lookup_inc.php8
-rwxr-xr-x[-rw-r--r--]includes/user_preferences_inc.php22
-rwxr-xr-x[-rw-r--r--]includes/view_board_inc.php29
-rwxr-xr-x[-rw-r--r--]includes/view_topic_inc.php37
10 files changed, 317 insertions, 318 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 978e245..10c46e6 100644..100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -1,25 +1,34 @@
<?php
+use \Bitweaver\Boards\BitBoard;
+use \Bitweaver\Liberty\LibertyComment;
+use \Bitweaver\BitMailer;
+
global $gBitSystem, $gBitThemes;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'boards',
'package_path' => dirname( dirname( __FILE__ ) ).'/',
- 'homeable' => TRUE,
-);
-$gBitSystem->registerPackage( $registerHash );
+ 'homeable' => true,
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+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_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+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' )) {
- $menuHash = array(
+ $menuHash = [
'package_name' => BOARDS_PKG_NAME,
'index_url' => BOARDS_PKG_URL.'index.php',
'menu_template' => 'bitpackage:boards/menu_boards.tpl',
- );
+ ];
$gBitSystem->registerAppMenu( $menuHash );
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
-
- $registerArray = array(
+ $registerArray = [
'content_display_function' => 'boards_content_display',
'content_preview_function' => 'boards_content_edit',
'content_edit_function' => 'boards_content_edit',
@@ -30,7 +39,7 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa
// 'content_view_tpl' => 'bitpackage:boards/service_view_boards.tpl',
'content_icon_tpl' => 'bitpackage:boards/boards_service_icons.tpl',
'content_list_sql_function' => 'boards_content_list_sql',
- );
+ ];
if ( !$gBitSystem->isFeatureActive( 'boards_hide_edit_tpl' ) &&
!$gBitSystem->isFeatureActive( 'boards_link_by_pigeonholes' ) ) {
@@ -40,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 intval( substr( $pThreadForwardSequence, 0, 9 ) );
}
$gBitThemes->loadCss(BOARDS_PKG_PATH.'styles/boards.css');
@@ -50,7 +59,7 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa
* we need to include its bit_setup_inc incase comments gets loaded first
*/
if( file_exists(BIT_ROOT_PATH.'moderation/bit_setup_inc.php') ) {
- require_once( BIT_ROOT_PATH.'moderation/bit_setup_inc.php' );
+ require_once BIT_ROOT_PATH.'moderation/bit_setup_inc.php';
global $gModerationSystem;
if( $gBitSystem->isPackageActive( 'moderation' ) ) {
@@ -62,26 +71,26 @@ if( $gBitSystem->isPackageActive( 'boards' ) && $gBitUser->hasPermission( 'p_boa
// And define the function we use to handle the observation.
function board_comments_moderation($pModerationInfo) {
if( $pModerationInfo['type'] == 'comment_post' ) {
- $storeComment = new LibertyComment( NULL, $pModerationInfo['content_id'] );
+ $storeComment = new LibertyComment( null, $pModerationInfo['content_id'] );
$storeComment->load();
$comments_return_url = '';
$root_id = $storeComment->mInfo['root_id'];
global $gContent;
- $board = new BitBoard(NULL, $root_id);
+ $board = new BitBoard(null, $root_id);
$board->load();
$boardSync = $board->getPreference('board_sync_list_address');
$code = $storeComment->getPreference('board_confirm_code');
$approved = $board->getPreference('boards_mailing_list_password');
// Possible race. Did we beat the cron?
if( empty($code) ) {
- require_once(BOARDS_PKG_INCLUDE_PATH.'admin/boardsync_inc.php');
+ require_once BOARDS_PKG_INCLUDE_PATH.'admin/boardsync_inc.php';
// Try to pick up the message!
- board_sync_run(TRUE);
+ board_sync_run(true);
}
if( !empty($code) && !empty($boardSync) && !empty($approved) ) {
$boardSync = str_replace('@', '-request@', $boardSync);
$code = 'confirm '.$code;
-uire_once(KERNEL_PKG_CLASS_PATH.'BitMailer.php');
+ require_once KERNEL_PKG_CLASS_PATH.'BitMailer.php';
$mailer = new BitMailer();
if( $pModerationInfo['last_status'] == MODERATION_DELETE ) {
@@ -103,5 +112,4 @@ uire_once(KERNEL_PKG_CLASS_PATH.'BitMailer.php');
}
}
}
-}
-?>
+} \ No newline at end of file
diff --git a/includes/classes/BitBoard.php b/includes/classes/BitBoard.php
index c0a296f..6104a00 100644..100755
--- a/includes/classes/BitBoard.php
+++ b/includes/classes/BitBoard.php
@@ -14,7 +14,13 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyMime.php' );
+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
@@ -34,7 +40,7 @@ class BitBoard extends LibertyMime {
/**
* During initialisation, be sure to call our base constructors
**/
- function __construct( $pBitBoardId=NULL, $pContentId=NULL ) {
+ function __construct( $pBitBoardId=null, $pContentId=null ) {
parent::__construct();
$this->mBitBoardId = (int)$pBitBoardId;
$this->mContentId = (int)$pContentId;
@@ -58,16 +64,16 @@ class BitBoard extends LibertyMime {
/**
* Load the data from the database
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
**/
- function load( $pContentId = NULL, $pPluginParams = NULL ) {
+ public function load( $pContentId = null, $pPluginParams = null ) {
if( $this->verifyId( $this->mBitBoardId ) || $this->verifyId( $this->mContentId ) ) {
// LibertyContent::load()assumes you have joined already, and will not execute any sql!
// This is a significant performance optimization
$lookupColumn = $this->verifyId( $this->mBitBoardId ) ? 'board_id' : 'content_id';
- $bindVars = array();
+ $bindVars = [];
$selectSql = $joinSql = $whereSql = '';
- array_push( $bindVars, (int)($lookupId = @BitBase::verifyId( $this->mBitBoardId ) ? $this->mBitBoardId : $this->mContentId) );
+ array_push( $bindVars, (int)($lookupId = BitBase::verifyId( $this->mBitBoardId ) ? $this->mBitBoardId : $this->mContentId) );
$this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
$query = "SELECT s.*, lc.*, " .
@@ -86,20 +92,20 @@ class BitBoard extends LibertyMime {
$this->mContentId = $result->fields['content_id'];
$this->mBitBoardId = $result->fields['board_id'];
- $this->mInfo['creator'] =( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] );
- $this->mInfo['editor'] =( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] );
+ $this->mInfo['creator'] =( $result->fields['creator_real_name'] ?? $result->fields['creator_user'] );
+ $this->mInfo['editor'] =( $result->fields['modifier_real_name'] ?? $result->fields['modifier_user'] );
$this->mInfo['display_url'] = $this->getDisplayUrl();
$this->parseData();
LibertyMime::load();
}
}
- return( count( $this->mInfo ) );
+ return count( $this->mInfo );
}
public static function lookupByMigrateBoard( $pMigrateBoardId ) {
global $gBitDb;
- $ret = NULL;
+ $ret = null;
if( BitBase::verifyId( $pMigrateBoardId ) ) {
$ret = $gBitDb->getOne( "SELECT `board_id` FROM `".BIT_DB_PREFIX."boards` bb WHERE `migrate_board_id`=?", array( $pMigrateBoardId ) );
}
@@ -108,31 +114,26 @@ class BitBoard extends LibertyMime {
/**
* Any method named Store inherently implies data will be written to the database
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
* This is the ONLY method that should be called in order to store( create or update )an bitboard!
* It is very smart and will figure out what to do for you. It should be considered a black box.
*
* @param array pParams hash of values that will be used to store the page
*
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
*
* @access public
**/
- function store( &$pParamHash ) {
+ public function store( array &$pParamHash ): bool {
if( $this->verify( $pParamHash )&& LibertyMime::store( $pParamHash ) ) {
$table = BIT_DB_PREFIX."boards";
$this->StartTrans();
if( $this->mBitBoardId ) {
- $locId = array( "board_id" => $pParamHash['board_id'] );
+ $locId = [ "board_id" => $pParamHash['board_id'] ];
$result = $this->mDb->associateUpdate( $table, $pParamHash['board_store'], $locId );
} else {
$pParamHash['board_store']['content_id'] = $pParamHash['content_id'];
- if( @$this->verifyId( $pParamHash['board_id'] ) ) {
- // if pParamHash['board_id'] is set, some is requesting a particular board_id. Use with caution!
- $pParamHash['board_store']['board_id'] = $pParamHash['board_id'];
- } else {
- $pParamHash['board_store']['board_id'] = $this->mDb->GenID( 'boards_board_id_seq' );
- }
+ $pParamHash['board_store']['board_id'] = ( @$this->verifyId( $pParamHash['board_id'] ) ) ? $pParamHash['board_id'] : $this->mDb->GenID( 'boards_board_id_seq' );
$this->mBitBoardId = $pParamHash['board_store']['board_id'];
$result = $this->mDb->associateInsert( $table, $pParamHash['board_store'] );
@@ -142,7 +143,7 @@ class BitBoard extends LibertyMime {
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' ) ) )) ) {
- $this->storePreference( 'boards_mailing_list', !empty( $pParamHash['boards_mailing_list'] ) ? $pParamHash['boards_mailing_list'] : NULL );
+ $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
mailman_addmember( $this->getPreference( 'boards_mailing_list'), $gBitUser->getField('email') );
@@ -164,8 +165,8 @@ class BitBoard extends LibertyMime {
$this->load();
} else {
$this->mDb->RollbackTrans();
- $this->mContentId = NULL;
- $this->mBitBoardId = NULL;
+ $this->mContentId = null;
+ $this->mBitBoardId = null;
}
}
return( count( $this->mErrors )== 0 );
@@ -173,17 +174,16 @@ class BitBoard extends LibertyMime {
/**
* Make sure the data is safe to store
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
* This function is responsible for data integrity and validation before any operations are performed with the $pParamHash
* NOTE: This is a PRIVATE METHOD!!!! do not call outside this class, under penalty of death!
*
* @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
- *
- * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
+ * @return bool true on success, false if verify failed. If false, $this->mErrors will have reason why
*
* @access private
**/
- function verify( &$pParamHash ) {
+ public function verify( array &$pParamHash ): bool {
// make sure we're all loaded up of we have a mBitBoardId
if( $this->verifyId( $this->mBitBoardId ) && empty( $this->mInfo ) ) {
$this->load();
@@ -272,8 +272,7 @@ class BitBoard extends LibertyMime {
/**
* This function removes a bitboard entry
**/
- function expunge() {
- $ret = FALSE;
+ public function expunge(): bool {
if( $this->isValid() ) {
$this->StartTrans();
$mailingList = $this->getPreference( 'boards_mailing_list' );
@@ -283,18 +282,17 @@ class BitBoard extends LibertyMime {
$result = $this->mDb->query( $query, array( $this->mContentId ) );
if( LibertyMime::expunge() ) {
if( $mailingList ) {
- require_once( UTIL_PKG_INCLUDE_PATH.'mailman_lib.php' );
+ require_once UTIL_PKG_INCLUDE_PATH.'mailman_lib.php';
if( $error = mailman_rmlist( $mailingList ) ) {
$this->mErrors['mailing_list'] = $error;
}
}
- $ret = TRUE;
$this->CompleteTrans();
} else {
$this->mDb->RollbackTrans();
}
}
- return $ret;
+ return true;
}
/**
@@ -306,9 +304,9 @@ class BitBoard extends LibertyMime {
function getAllMap() {
$b = new BitBoard();
- $listHash = array();
+ $listHash = [];
$l = $b->getList($listHash);
- $ret = array();
+ $ret = [];
foreach ($l as $k => $boardd) {
$board = new BitBoard($boardd['board_id']);
$board->mInfo=$boardd;
@@ -327,7 +325,7 @@ class BitBoard extends LibertyMime {
function getUnMapped() {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
$sql = "SELECT
lc.`title`,
lc.`content_id`,
@@ -359,7 +357,7 @@ class BitBoard extends LibertyMime {
}
function addContent($content_id) {
- if (@BitBase::verifyId($content_id)) {
+ if (BitBase::verifyId($content_id)) {
$data = array(
'board_content_id'=>$this->mContentId,
'topic_content_id'=>$content_id,
@@ -369,7 +367,7 @@ class BitBoard extends LibertyMime {
}
function removeContent($content_id) {
- if (@BitBase::verifyId($content_id) && @BitBase::verifyId($this->mContentId)) {
+ 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 ) );
}
@@ -392,7 +390,7 @@ class BitBoard extends LibertyMime {
}
function fixContentMap() {
- if( $this->isValid() && @BitBase::verifyId($this->mContentId)) {
+ if( $this->isValid() && BitBase::verifyId($this->mContentId)) {
$this->removeContent($this->mContentId);
$this->addContent($this->mContentId);
}
@@ -400,8 +398,8 @@ class BitBoard extends LibertyMime {
function lookupMapRev($content_id) {
global $gBitDb;
- $ret = NULL;
- if (@BitBase::verifyId($content_id)) {
+ $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 ));
}
@@ -410,7 +408,7 @@ class BitBoard extends LibertyMime {
function getMap() {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
if( $this->isValid() ) {
$sql = "SELECT
lc.`title` AS t_title,
@@ -440,7 +438,7 @@ class BitBoard extends LibertyMime {
return $ret;
}
- public static function prepGetList( &$pParamHash ) {
+ public static function prepGetList( array &$pParamHash ): void {
if( empty( $pParamHash['sort_mode'] ) ) {
// default sort_mode for boards is alphabetical
$pParamHash['sort_mode'] = 'title_asc';
@@ -457,7 +455,7 @@ class BitBoard extends LibertyMime {
$this->prepGetList( $pParamHash );
$selectSql = $joinSql = $whereSql = '';
- $bindVars = array();
+ $bindVars = [];
array_push( $bindVars, $this->mContentTypeGuid );
$this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
@@ -510,7 +508,7 @@ class BitBoard extends LibertyMime {
INNER JOIN `".BIT_DB_PREFIX."liberty_comments` s_lcom ON (map.`topic_content_id` = s_lcom.`root_id`)
INNER JOIN `".BIT_DB_PREFIX."liberty_content` s_lc ON (s_lcom.`content_id` = s_lc.`content_id`)
LEFT JOIN `".BIT_DB_PREFIX."boards_posts` s ON( s_lcom.`comment_id` = s.`comment_id` )
-WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`is_approved` = 0 OR s.`is_approved` IS NULL) )
+WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`is_approved` = 0 OR s.`is_approved` IS null) )
) AS unreg";
} else {
$selectSql .= ", 0 AS unreg";
@@ -542,7 +540,7 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
$result = $this->mDb->query( $query, $bindVars );
- $ret = array();
+ $ret = [];
while( $res = $result->fetchRow() ) {
$res['url']= BOARDS_PKG_URL."index.php?b={$res['board_id']}";
@@ -551,23 +549,19 @@ 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))", array( $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))", array( $res['content_id'] ) );
if($track) {
if ($gBitUser->isRegistered()) {
$res['track']['on'] = true;
$res['track']['count'] = $res['track_count'];
- if ($res['post_count']>$res['track_count']) {
- $res['track']['mod'] = true;
- } else {
- $res['track']['mod'] = false;
- }
+ $res['track']['mod'] = ( $res['post_count'] > $res['track_count'] ) ? true : false;
} else {
$res['track']['on'] = false;
}
@@ -592,7 +586,7 @@ 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` IS NULL OR fp.`is_approved` = 1) OR (slc.`user_id` >= 0))
+ 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'] ) );
@@ -608,19 +602,18 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
/**
* Generates the URL to the bitboard page
- * @return the link to display the page.
+ * @return string link to display the page.
*/
public static function getDisplayUrlFromHash( &$pParamHash ) {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
if( !empty( $pParamHash['comment'] ) && !empty( $pParamHash['comment']['thread_forward_sequence'] ) ){
- // look up base of comment sequece which is BitBoardTopic
+ // look up base of comment sequence which is BitBoardTopic
$seq = explode( ".", $pParamHash['comment']['thread_forward_sequence'] );
$topicRootId = (int)$seq[0];
if( BitBase::verifyId( $topicRootId )) {
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
- $hash = array( 'topic_id' => $topicRootId );
+ $hash = [ 'topic_id' => $topicRootId ];
$ret = BitBoardTopic::getDisplayUrlFromHash( $hash );
// we're out of here with our topic url
return $ret;
@@ -641,12 +634,12 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
return $ret;
}
- function getBoardSelectList( $pBlankFirst=FALSE ) {
+ public function getBoardSelectList( $pBlankFirst=false ) {
global $gBitSystem, $gBitUser;
// invoke list sql principly to enforce permission services
$selectSql = $joinSql = $whereSql = '';
- $bindVars = array();
+ $bindVars = [];
$this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
@@ -670,7 +663,7 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
WHERE lc.`content_id` = b.`content_id` $whereSql
ORDER BY lc.`title` ASC";
- $ret = array();
+ $ret = [];
if( $rslt = $this->mDb->query( $query, $bindVars ) ){
if( $pBlankFirst ) {
@@ -691,7 +684,7 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
if( LibertyContent::verifyId( $contentId ) ) {
// LibertyContent::load()assumes you have joined already, and will not execute any sql!
// This is a significant performance optimization
- $bindVars = array();
+ $bindVars = [];
$selectSql = $joinSql = $whereSql = '';
array_push( $bindVars, $contentId );
$gBitUser->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
@@ -703,7 +696,7 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
WHERE lc.`content_id`=? $whereSql";
$result = $gBitDb->query( $query, $bindVars );
- $ret = array();
+ $ret = [];
if( $result && $result->numRows() ) {
$ret = $result->fields;
@@ -712,12 +705,12 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
$ret['display_url'] = BIT_ROOT_URL."index.php?content_id=$contentId";
}
}
- return( $ret );
+ return $ret;
}
public static function getLinkedBoard( $pContentId ) {
global $gBitDb;
- $ret = NULL;
+ $ret = null;
if( BitBase::verifyId( $pContentId ) ) {
$sql = "SELECT b.`board_id`, b.`content_id` AS `board_content_id`, COUNT(lcom.`comment_id`) AS `post_count`
FROM `".BIT_DB_PREFIX."boards_map` bm
@@ -743,7 +736,7 @@ WHERE map.`board_content_id`=lc.`content_id` AND ((s_lc.`user_id` < 0) AND (s.`i
function getBoardMailingList() {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
if( $this->isValid() && $gBitSystem->getConfig( 'boards_sync_mail_server' ) && $this->getPreference( 'boards_mailing_list' ) ) {
$ret = $this->getPreference( 'boards_mailing_list' ).'@'.$gBitSystem->getConfig( 'boards_email_host', $gBitSystem->getConfig( 'kernel_server_name' ) );
}
@@ -770,16 +763,15 @@ function boards_content_edit ( $pContent, $pParamHash ) {
}
require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
$board = new BitBoard();
- $boardList = $board->getBoardSelectList( TRUE );
+ $boardList = $board->getBoardSelectList( true );
$gBitSmarty->assign( 'boardList', $boardList );
}
}
-// store services for boads
+// store services for boards
function boards_content_store( $pContent, $pParamHash ) {
global $gBitDb, $gBitSmarty, $gBitSystem;
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
// do not allow unassigning topics. the UI should prevent this, but just to make sure...
if( $pContent->isValid() && !$pContent->isContentType( BITBOARDTOPIC_CONTENT_TYPE_GUID ) && !$pContent->isContentType( BITBOARD_CONTENT_TYPE_GUID ) ) {
// wipe out all previous assignments for good measure. Not the sanest thing to do, but edits are infrequent - at least for now
@@ -791,7 +783,6 @@ function boards_content_store( $pContent, $pParamHash ) {
$p = null;
if ( ! empty( $pParamHash['pigoneholes'] ) ) {
foreach( $pParamHash['pigeonholes']['pigeonhole'] as $p_id ) {
- require_once(PIGEONHOLES_PKG_CLASS_PATH.'Pigeonholes.php');
if (empty($p)) {
$p = new Pigeonholes();
}
@@ -804,7 +795,7 @@ function boards_content_store( $pContent, $pParamHash ) {
// Insert into these boards
foreach ($boards as $board) {
- if( @BitBase::verifyId( $board['content_id'] ) ) {
+ 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 ) );
}
}
@@ -813,13 +804,13 @@ function boards_content_store( $pContent, $pParamHash ) {
}
else {
$pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", array( $pContent->mContentId ) );
- if( @BitBase::verifyId( $pParamHash['linked_board_cid'] ) ) {
+ 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 ) );
}
}
$gBitSmarty->assign( 'boardInfo', BitBoard::getLinkedBoard( $pContent->mContentId ) );
} else {
- if( @BitBase::verifyId( $pParamHash['content_id'] ) && @BitBase::verifyId( $pParamHash['linked_board_cid'] ) ) {
+ 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'] ) );
}
}
@@ -845,13 +836,13 @@ function boards_comment_store( &$pObject, &$pParamHash ) {
}
}
-function boards_content_verify( $pObject, &$pParamHash ){
+function boards_content_verify( &$pObject, &$pParamHash ){
// board posts ( e.g. liberty comments ) service
global $gBitSystem, $gBitUser;
// use is_a instead of isContentType( BITCOMMENT_CONTENT_TYPE_GUID ) as isContentType() checks isValid(), and this service method will not properly handle new object stores
if( $gBitSystem->isPackageActive( 'boards' ) && is_a( $pObject , 'LibertyComment' ) ) {
if( BitBoardTopic::isLockedMsg( $pParamHash['parent_id'] )) {
- $pObject->mErrors['warning']=tra("The selected Topic is Locked posting is disabled");
+ $pObject->mErrors['warning'] = KernelTools::tra("The selected Topic is Locked posting is disabled");
}
}
}
@@ -862,5 +853,3 @@ function boards_content_expunge( $pContent ) {
$pContent->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."boards_map` WHERE `topic_content_id`=?", array( $pContent->mContentId ) );
}
}
-
-?>
diff --git a/includes/classes/BitBoardPost.php b/includes/classes/BitBoardPost.php
index 63bb3f4..e77e947 100644..100755
--- a/includes/classes/BitBoardPost.php
+++ b/includes/classes/BitBoardPost.php
@@ -14,8 +14,12 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyMime.php' );
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
+namespace Bitweaver\Boards;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+use Bitweaver\Liberty\LibertyComment;
+use Bitweaver\Users\RoleUser;
+use Messages;
/**
* @package boards
@@ -24,7 +28,7 @@ class BitBoardPost extends LibertyComment {
/**
* During initialisation, be sure to call our base constructors
*/
- function __construct($pCommentId = NULL, $pContentId = NULL, $pInfo = NULL) {
+ function __construct($pCommentId = null, $pContentId = null, $pInfo = null) {
parent::__construct($pCommentId,$pContentId,$pInfo);
// Permission setup
@@ -36,17 +40,17 @@ class BitBoardPost extends LibertyComment {
/**
* This function verifies the data for a post
*/
- function verify( &$pParamHash ) {
+ public function verify( array &$pParamHash ): bool {
if( isset( $pParamHash['is_approved'] ) ) {
if( !is_numeric( $pParamHash['is_approved'] ) || $pParamHash['is_approved'] > 1 || $pParamHash['is_approved'] < 0 ) {
- $this->mErrors[]=("Invalid post approved state");
+ $this->mErrors[]= "Invalid post approved state";
} else {
$pParamHash['post_store']['is_approved'] = $pParamHash['is_approved'];
}
}
if( isset( $pParamHash['is_warned'] ) ) {
if( !is_numeric( $pParamHash['warned'] ) || $pParamHash['is_warned'] > 1 || $pParamHash['is_warned'] < 0 ) {
- $this->mErrors[]=("Invalid warned state");
+ $this->mErrors[]= "Invalid warned state";
} else {
$pParamHash['post_store']['is_warned'] = $pParamHash['is_warned'];
}
@@ -61,15 +65,15 @@ class BitBoardPost extends LibertyComment {
$pParamHash['post_store']['migrate_post_id'] = $pParamHash['migrate_post_id'];
}
- return( count( $this->mErrors ) == 0 && !empty( $pParamHash['post_store'] ) );
+ return count( $this->mErrors ) == 0 && !empty( $pParamHash['post_store'] );
}
/**
* This function stores a post
*/
- function store( &$pParamHash ) {
+ public function store( array &$pParamHash ): bool {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
if( $this->mCommentId && $this->verify( $pParamHash ) ) {
//$gBitSystem->verifyPermission('p_boards_update');
//$pParamHash = (($pParamHash + 1)%2);
@@ -81,7 +85,7 @@ class BitBoardPost extends LibertyComment {
$pParamHash['post_store']['comment_id'] = $this->mCommentId;
$result = $this->mDb->associateInsert( 'boards_posts', $pParamHash['post_store'] );
}
- $ret = TRUE;
+ $ret = true;
}
return $ret;
}
@@ -89,7 +93,7 @@ class BitBoardPost extends LibertyComment {
/**
* This function gets the meta data relating to a post
*/
- function loadMetaData() {
+ public function loadMetaData(): void {
if ($this->isValid()) {
if (!isset($this->mInfo['accepted'])) {
$key = array('comment_id' => $this->mCommentId);
@@ -112,30 +116,28 @@ class BitBoardPost extends LibertyComment {
/**
* This function removes a bitboard entry
**/
- function expunge() {
- $ret = FALSE;
+ public function expunge(): bool {
if( $this->isValid() ) {
$this->StartTrans();
// parent actually has deletion of rows in boards for constraint reasons
if( parent::expunge() ) {
$this->CompleteTrans();
- $ret = TRUE;
} else {
$this->mDb->RollbackTrans();
}
}
- return $ret;
+ return true;
}
/**
* This function gets all the post relating to a topic
*/
- function getComments( $pContentId = NULL, $pMaxComments = NULL, $pOffset = NULL, $pSortOrder = NULL, $pDisplayMode = NULL ) {
+ public function getComments( $pContentId = null, $pMaxComments = null, $pOffset = null, $pSortOrder = null, $pDisplayMode = null ) {
global $gBitUser, $gBitSystem;
$joinSql = $selectSql = $whereSql = '';
- $ret = array();
+ $ret = [];
$contentId = $this->mCommentId;
$mid = 'thread_forward_sequence ASC';
@@ -155,7 +157,7 @@ class BitBoardPost extends LibertyComment {
}
$mid = 'order by ' . $mid;
- $bindVars = array();
+ $bindVars = [];
if (is_array( $contentId ) ) {
$mid2 = 'in ('.implode(',', array_fill(0, count( $pContentId ), '?')).')';
$bindVars = $contentId;
@@ -171,7 +173,7 @@ 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 );
+ $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 );
if ($pContentId) {
@@ -192,26 +194,22 @@ class BitBoardPost extends LibertyComment {
LEFT JOIN `".BIT_DB_PREFIX."boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
WHERE $mid2 $whereSql $mid";
- $flat_comments = array();
+ $flat_comments = [];
if( $result = $this->mDb->query( $sql, $bindVars, $pMaxComments, $pOffset ) ) {
while( $row = $result->FetchRow() ) {
if (empty($row['anon_name'])) {
$row['anon_name'] = "Anonymous";
}
- if( $row['avatar_file_name'] ) {
- $row['user_avatar_url'] = liberty_fetch_thumbnail_url( array(
- 'source_file' => 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'] ) ),
- 'size' => 'avatar'
- ));
- } else {
- $row['user_avatar_url'] = FALSE;
- }
+ $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'] ) ),
+ 'size' => 'avatar',
+ ) ) : false;
if (!empty($row['warned_message'])) {
$row['warned_message'] = str_replace("\n","<br />\n",$row['warned_message']);
}
$row['data'] = trim( $row['data'] );
- $row['user_url'] = BitUser::getDisplayUrlFromHash( $row );
+ $row['user_url'] = RoleUser::getDisplayUrlFromHash( $row );
$row['parsed_data'] = self::parseDataHash( $row );
$row['level'] = substr_count ( $row['thread_forward_sequence'], '.' ) - 1;
$c = new LibertyComment();
@@ -227,7 +225,7 @@ class BitBoardPost extends LibertyComment {
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
if( empty( $row['storage'][$row2['attachment_id']] )) {
- $row['storage'][$row2['attachment_id']] = array();
+ $row['storage'][$row2['attachment_id']] = [];
}
$row['storage'][$row2['attachment_id']] = $func( $row2, $row['storage'][$row2['attachment_id']] );
} else {
@@ -253,19 +251,19 @@ class BitBoardPost extends LibertyComment {
/**
* This function gets a list of posts
*/
- function getList( &$pListHash ) {
+ public function getList( &$pListHash ) {
global $gBitUser, $gBitSystem;
$this->prepGetList( $pListHash );
$joinSql = $selectSql = $whereSql = '';
- $ret = array();
+ $ret = [];
$contentId = $this->mCommentId;
// $mid = 'ORDER BY `thread_forward_sequence` ASC';
- $bindVars = array();
+ $bindVars = [];
if( !empty( $pListHash['content_id'] ) ) {
if (is_array( $contentId ) ) {
$mid2 = 'in ('.implode(',', array_fill(0, count( $pListHash['content_id'] ), '?')).')';
@@ -289,7 +287,7 @@ class BitBoardPost extends LibertyComment {
array_push( $bindVars, (int)$pListHash['board_id'] );
}
- if( BitBase::verifyId( $pListHash['user_id'] ) ) {
+ if( BitBase::verifyId( $pListHash['user_id'] ?? 0 ) ) {
$whereSql .= ' AND lc.`user_id`=? ';
array_push( $bindVars, $pListHash['user_id'] );
}
@@ -311,25 +309,21 @@ class BitBoardPost extends LibertyComment {
LEFT JOIN `".BIT_DB_PREFIX."boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
$whereSql ORDER BY ".$this->mDb->convertSortmode( $pListHash['sort_mode'] );
- $ret = array();
+ $ret = [];
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";
- if( !empty( $row['avatar_file_name'] )) {
- $row['user_avatar_url'] = liberty_fetch_thumbnail_url( array(
- 'source_file' => 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'] ) ),
- 'size' => 'avatar'
- ));
- } else {
- $row['user_avatar_url'] = FALSE;
- }
+ $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'] ) ),
+ 'size' => 'avatar',
+ ) ) : false;
unset($row['avatar_file_name']);
if (!empty($row['warned_message'])) {
$row['warned_message'] = str_replace("\n","<br />\n",$row['warned_message']);
}
$row['data'] = trim($row['data']);
- $row['user_url']=BitUser::getDisplayUrlFromHash($row);
+ $row['user_url']=RoleUser::getDisplayUrlFromHash($row);
$row['parsed_data'] = self::parseDataHash( $row );
$row['level'] = substr_count ( $row['thread_forward_sequence'], '.' ) - 1;
$row['topic_id'] = boards_get_topic_comment( $row['thread_forward_sequence'] );
@@ -348,15 +342,15 @@ class BitBoardPost extends LibertyComment {
/**
* This function counts the posts relating to a topic
*/
- function getNumComments($pContentId = NULL) {
+ public function getNumComments($pContentId = null) {
$ret = 0;
$contentId = $this->mCommentId;
- $bindVars = array();
+ $bindVars = [];
$joinSql = $selectSql = $whereSql = '';
- $paramHash = array( 'include_comments' => TRUE );
+ $paramHash = array( 'include_comments' => true );
$this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $paramHash );
if ($pContentId) {
@@ -375,8 +369,8 @@ class BitBoardPost extends LibertyComment {
/**
* This function generates a valid lookup URL
*/
- function getDisplayUrl() {
- $ret = NULL;
+ public function getDisplayUrl() {
+ $ret = null;
if( $this->isValid() ) {
$urlHash['comment_id'] = $this->mCommentId;
$urlHash['topic_id'] = $this->getTopicId();
@@ -387,12 +381,12 @@ class BitBoardPost extends LibertyComment {
/**
* Generates the URL to the bitboard page
- * @return the link to display the page.
+ * @return string link to display the page.
*/
public static function getDisplayUrlFromHash( &$pParamHash ) {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
if( static::verifyId( $pParamHash['comment_id'] ) ) {
if( $gBitSystem->isFeatureActive( 'pretty_urls' ) || $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
$rewrite_tag = $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ? 'view/' : '';
@@ -408,20 +402,31 @@ class BitBoardPost extends LibertyComment {
return $ret;
}
- function getTopicId() {
+ /**
+ * Summary of getContactUrl
+ * @return string
+ */
+ public function getContactUrl(): string {
+ return '';
+ }
+ /**
+ * Summary of getTopicId
+ * @return int
+ */
+ public function getTopicId() {
return boards_get_topic_comment( $this->getField( 'thread_forward_sequence') );
}
- function modApprove() {
+ public function modApprove() {
$data['is_approved'] = 1;
$this->setMetaData($data);
}
- function modReject() {
+ public function modReject() {
$this->deleteComment();
}
- function modWarn($message) {
+ public function modWarn($message) {
global $gBitSystem, $gBitUser;
if (empty($message)) {
@@ -432,27 +437,25 @@ class BitBoardPost extends LibertyComment {
$this->setMetaData($data);
if ($gBitSystem->isPackageActive('messages')) {
- require_once(MESSAGES_PKG_CLASS_PATH.'Messages.php');
-
- $u = new BitUser($this->mInfo['user_id']);
+ $u = new RoleUser($this->mInfo['user_id']);
$u->load();
$userInfo = $u->mInfo;
$pm = new Messages();
$message = "Your post \"".$this->mInfo['title']."\" [http://".$_SERVER['HTTP_HOST'].$this->getContactUrl()."] has been warned with the following message:\n$message\n";
- $msgHash = array(
+ $msgHash = [
'to_login' => $userInfo['login'],
'to' => $userInfo['real_name'],
- 'subject' => tra( 'Warned Post' ).': '.$this->mInfo['title'],
+ 'subject' => KernelTools::tra( 'Warned Post' ) . ': ' . $this->mInfo['title'],
'priority' => 4,
- );
+ ];
$pm->postMessage( $msgHash );
}
}
- function setMetaData($data) {
+ public function setMetaData($data) {
if ($this->isValid()) {
- $key = array('comment_id' => $this->mCommentId);
+ $key = [ 'comment_id' => $this->mCommentId ];
$query_sel = "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."boards_posts` WHERE comment_id=?";
$c = $this->mDb->getOne( $query_sel , array_values($key));
if ($c == 0) {
@@ -465,4 +468,3 @@ class BitBoardPost extends LibertyComment {
}
}
}
-?>
diff --git a/includes/classes/BitBoardTopic.php b/includes/classes/BitBoardTopic.php
index 1f12a89..68e52bd 100644..100755
--- a/includes/classes/BitBoardTopic.php
+++ b/includes/classes/BitBoardTopic.php
@@ -14,8 +14,13 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' );
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' );
+namespace Bitweaver\Boards;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+use Bitweaver\Liberty\LibertyBase;
+use Bitweaver\Liberty\LibertyComment;
+use Bitweaver\Liberty\LibertyMime;
+use function sprintf;
/**
* This is used to uniquely identify the object
@@ -32,6 +37,7 @@ class BitBoardTopic extends LibertyMime {
* @public
*/
public $mRootId;
+ public $mRootObj;
/**
* the content id of the topic comment object
@@ -42,7 +48,7 @@ class BitBoardTopic extends LibertyMime {
/**
* During initialisation, be sure to call our base constructors
**/
- function __construct( $pRootId=NULL ) {
+ function __construct( $pRootId=null ) {
parent::__construct();
$this->mRootId = (int)$pRootId;
@@ -51,22 +57,22 @@ class BitBoardTopic extends LibertyMime {
$this->mUpdateContentPerm = 'p_boards_update';
$this->mAdminContentPerm = 'p_boards_admin';
- $this->mRootObj = NULL; //a reference to the root obj
+ $this->mRootObj = null; //a reference to the root obj
}
/**
* Load the data from the database
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
**/
- function load( $pContentId = NULL, $pPluginParams = NULL ) {
+ function load( $pContentId = null, $pPluginParams = null ) {
global $gBitUser, $gBitSystem;
if( $this->verifyId( $this->mRootId ) || $this->verifyId( $this->mContentId ) ) {
// This is a significant performance optimization
$lookupColumn = $this->verifyId( $this->mRootId ) ? 'lcom.`comment_id`' : 'lc.`content_id`';
- $bindVars = array();
+ $bindVars = [];
$selectSql = $joinSql = $whereSql = '';
- array_push( $bindVars, $lookupId = @BitBase::verifyId( $this->mRootId ) ? $this->mRootId : $this->mContentId );
- $paramHash = array( array( 'include_comments' => TRUE ) );
+ array_push( $bindVars, $lookupId = BitBase::verifyId( $this->mRootId ) ? $this->mRootId : $this->mContentId );
+ $paramHash = array( array( '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'))) {
@@ -140,7 +146,7 @@ class BitBoardTopic extends LibertyMime {
public static function lookupByMigratePost( $pMigratePostId ) {
global $gBitDb;
- $ret = NULL;
+ $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 ) );
if( $path ) {
@@ -152,14 +158,14 @@ class BitBoardTopic extends LibertyMime {
public static function lookupByMigrateTopic( $pMigrateTopicId ) {
global $gBitDb;
- $ret = NULL;
+ $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 ) );
}
return $ret;
}
- function verify( &$pParamHash ) {
+ public function verify( array &$pParamHash ): bool {
if( isset( $pParamHash['is_locked'] ) ) {
if( !is_numeric( $pParamHash['is_locked'] ) || $pParamHash['is_locked'] > 1 || $pParamHash['is_locked'] < 0 ) {
$this->mErrors[]=("Invalid topic state");
@@ -191,9 +197,9 @@ class BitBoardTopic extends LibertyMime {
/**
* This function stickies a topic
*/
- function store( &$pParamHash ) {
+ public function store( array &$pParamHash ): bool {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
if( $this->mCommentContentId && $this->verify( $pParamHash ) ) {
//$pParamHash = (($pParamHash + 1)%2);
$query_sel = "SELECT * FROM `".BIT_DB_PREFIX."boards_topics` WHERE `parent_id` = ?";
@@ -204,7 +210,7 @@ class BitBoardTopic extends LibertyMime {
$pParamHash['topic_store']['parent_id'] = $this->mCommentContentId;
$result = $this->mDb->associateInsert( 'boards_topics', $pParamHash['topic_store'] );
}
- $ret = TRUE;
+ $ret = true;
}
return $ret;
}
@@ -214,7 +220,7 @@ class BitBoardTopic extends LibertyMime {
*/
function lock($state) {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
if ($state==null || !is_numeric($state) || $state > 1 || $state<0) {
$this->mErrors[]=("Invalid current state");
} else {
@@ -238,7 +244,7 @@ class BitBoardTopic extends LibertyMime {
*/
function sticky($state) {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
if ($state==null || !is_numeric($state) || $state > 1 || $state<0) {
$this->mErrors[]=("Invalid current state");
} else {
@@ -252,7 +258,7 @@ class BitBoardTopic extends LibertyMime {
$query_up = "UPDATE `".BIT_DB_PREFIX."boards_topics` SET `is_sticky` = ? WHERE `parent_id` = ?";
$result = $this->mDb->query( $query_up, array( $state, $this->mCommentContentId) );
}
- $ret = TRUE;
+ $ret = true;
}
return $ret;
}
@@ -276,7 +282,7 @@ class BitBoardTopic extends LibertyMime {
$lcom->storeComment($lcom_hash);
// map the move to the topic table
- $data = array();
+ $data = [];
$data['parent_id']=$lcom->mContentId;
$data['is_moved']=$this->mRootId;
$this->mDb->associateInsert( BIT_DB_PREFIX."boards_topics", $data );
@@ -293,7 +299,7 @@ class BitBoardTopic extends LibertyMime {
// end transaction
$this->CompleteTrans();
- return TRUE;
+ return true;
}
/**
@@ -306,9 +312,9 @@ class BitBoardTopic extends LibertyMime {
LibertyMime::prepGetList( $pParamHash );
$selectSql = $joinSql = $whereSql = '';
- $bindVars = array();
+ $bindVars = [];
$pParamHash['include_comments'] = 'y';
- $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash );
+ $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, null, $pParamHash );
// this will set $find, $sort_mode, $max_records and $offset
extract( $pParamHash );
@@ -327,8 +333,8 @@ 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'] )) ) {
- $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`)";
+ $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'])) {
$whereSql .= " AND b.`board_id` = ?";
$bindVars[] = (int)$pParamHash['b'];
@@ -343,21 +349,19 @@ class BitBoardTopic extends LibertyMime {
// use adodb's substr property
$substr = $this->mDb->substr();
- if ( $this->mDb->mType == 'firebird' ) {
- $substrSql = "SUBSTRING(s_lcom.`thread_forward_sequence` FROM 1 FOR 10) LIKE SUBSTRING(lcom.`thread_forward_sequence` FROM 1 FOR 10)";
- } else {
- $substrSql = "$substr(s_lcom.`thread_forward_sequence`, 1, 10) LIKE $substr(lcom.`thread_forward_sequence`, 1, 10)";
- }
+ $substrSql = $this->mDb->mType == 'firebird' || $this->mDb->mType == 'pdo'
+ ? "SUBSTRING(s_lcom.`thread_forward_sequence` FROM 1 FOR 10) LIKE SUBSTRING(lcom.`thread_forward_sequence` FROM 1 FOR 10)"
+ : "$substr(s_lcom.`thread_forward_sequence`, 1, 10) LIKE $substr(lcom.`thread_forward_sequence`, 1, 10)";
if ($gBitSystem->isFeatureActive('boards_posts_anon_moderation') && !($gBitUser->hasPermission('p_boards_update') || $gBitUser->hasPermission('p_boards_post_update'))) {
$whereSql .= " AND ((post.`is_approved` = 1) OR (lc.`user_id` >= 0))";
}
if ($gBitSystem->isFeatureActive('boards_posts_anon_moderation') && ($gBitUser->hasPermission('p_boards_update') || $gBitUser->hasPermission('p_boards_post_update'))) {
$selectSql .= ", ( SELECT COUNT(*)
- FROM `${BIT_DB_PREFIX}liberty_comments` AS s_lcom
+ FROM `{$BIT_DB_PREFIX}liberty_comments` AS s_lcom
INNER JOIN `".BIT_DB_PREFIX."liberty_content` s_lc ON (s_lcom.`content_id` = s_lc.`content_id`)
- LEFT JOIN `${BIT_DB_PREFIX}boards_posts` s ON( s_lcom.`comment_id` = s.`comment_id` )
- WHERE (".$substrSql.") AND ((s_lc.`user_id` < 0) AND (s.`is_approved` = 0 OR s.`is_approved` IS NULL))) AS unreg";
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_posts` s ON( s_lcom.`comment_id` = s.`comment_id` )
+ WHERE (".$substrSql.") AND ((s_lc.`user_id` < 0) AND (s.`is_approved` = 0 OR s.`is_approved` IS null))) AS unreg";
} else {
$selectSql .= ", 0 AS unreg";
}
@@ -401,10 +405,10 @@ class BitBoardTopic extends LibertyMime {
) AS last_post
$selectSql
- FROM `${BIT_DB_PREFIX}liberty_comments` lcom
- INNER JOIN `${BIT_DB_PREFIX}liberty_content` lc ON( lc.`content_id` = lcom.`content_id` )
- LEFT JOIN `${BIT_DB_PREFIX}boards_topics` th ON (th.`parent_id`=lcom.`content_id`)
- LEFT JOIN `${BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
+ FROM `{$BIT_DB_PREFIX}liberty_comments` lcom
+ INNER JOIN `{$BIT_DB_PREFIX}liberty_content` lc ON( lc.`content_id` = lcom.`content_id` )
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_topics` th ON (th.`parent_id`=lcom.`content_id`)
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
$joinSql
WHERE
lcom.`root_id`=lcom.`parent_id`
@@ -417,24 +421,20 @@ class BitBoardTopic extends LibertyMime {
";
$query_cant = "SELECT count(*)
- FROM `${BIT_DB_PREFIX}liberty_comments` lcom
- INNER JOIN `${BIT_DB_PREFIX}liberty_content` lc ON( lc.`content_id` = lcom.`content_id` )
- LEFT JOIN `${BIT_DB_PREFIX}boards_topics` th ON (th.`parent_id`=lcom.`content_id`)
- LEFT JOIN `${BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
+ FROM `{$BIT_DB_PREFIX}liberty_comments` lcom
+ INNER JOIN `{$BIT_DB_PREFIX}liberty_content` lc ON( lc.`content_id` = lcom.`content_id` )
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_topics` th ON (th.`parent_id`=lcom.`content_id`)
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
$joinSql
WHERE
lcom.`root_id`=lcom.`parent_id`
$whereSql";
$result = $this->mDb->query( $query, $bindVars, $max_records, $offset );
- $ret = array();
+ $ret = [];
while( $res = $result->fetchRow() ) {
if (empty($res['anon_name'])) $res['anon_name'] = "Anonymous";
- if ($res['th_is_moved']>0) {
- $res['url']=BOARDS_PKG_URL."index.php?t=".$res['th_is_moved'];
- } else {
- $res['url']=BOARDS_PKG_URL."index.php?t=".$res['th_thread_id'];
- }
+ $res['url'] = ( $res['th_is_moved'] > 0 ) ? BOARDS_PKG_URL . "index.php?t=" . $res['th_is_moved'] : BOARDS_PKG_URL . "index.php?t=" . $res['th_thread_id'];
$llc_data = BitBoardTopic::getLastPost($res);
$res = array_merge($res,$llc_data);
BitBoardTopic::track($res);
@@ -452,11 +452,10 @@ class BitBoardTopic extends LibertyMime {
function getLastPost($data) {
global $gBitSystem;
- if ( $this->mDb->mType == 'firebird' ) {
- $substrSql = "SUBSTRING(lcom.`thread_forward_sequence` FROM 1 FOR 10)";
- } else {
- $substrSql = "".$this->mDb->substr()."(lcom.`thread_forward_sequence`, 1, 10)";
- }
+ $substrSql = $this->mDb->mType == 'firebird' || $this->mDb->mType == 'pdo'
+ ? "SUBSTRING(lcom.`thread_forward_sequence` FROM 1 FOR 10)"
+ : "".$this->mDb->substr()."(lcom.`thread_forward_sequence`, 1, 10)";
+
$whereSql = '';
if ($gBitSystem->isFeatureActive('boards_posts_anon_moderation')) {
$whereSql = " AND ((post.`is_approved` = 1) OR (lc.`user_id` >= 0))";
@@ -465,7 +464,7 @@ class BitBoardTopic extends LibertyMime {
$query="SELECT lc.`last_modified` AS llc_last_modified, lc.`user_id` AS llc_user_id, lc.`content_id` AS llc_content_id, lcom.`anon_name` AS l_anon_name
FROM `".BIT_DB_PREFIX."liberty_comments` lcom
INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lcom.`content_id` = lc.`content_id`)
- LEFT JOIN `${BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
+ LEFT JOIN `{$BIT_DB_PREFIX}boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)
WHERE (".$substrSql.") LIKE '".sprintf("%09d.",$data['th_thread_id'])."%' $whereSql
ORDER BY lc.`last_modified` DESC
";
@@ -476,11 +475,11 @@ class BitBoardTopic extends LibertyMime {
/**
* Generates the URL to the bitboard page
- * @return the link to display the page.
+ * @return string the link to display the page.
*/
public static function getDisplayUrlFromHash( &$pParamHash ) {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
if( !empty( $pParamHash['topic_id'] ) && static::verifyId( $pParamHash['topic_id'] ) ) {
$topicId = $pParamHash['topic_id'];
@@ -499,7 +498,7 @@ class BitBoardTopic extends LibertyMime {
return $ret;
}
- public static function isLocked( $pThreadId ) {
+ public static function isThreadLocked( $pThreadId ) {
global $gBitSystem;
/*
// remove mixed static / dynamic function invocation
@@ -514,10 +513,10 @@ class BitBoardTopic extends LibertyMime {
}
public static function isLockedMsg( $parent_id ) {
- // $parentComment = new LibertyComment(NULL,$parent_id);
+ // $parentComment = new LibertyComment(null,$parent_id);
// $topicId = $parentComment->mInfo['thread_forward_sequence'];
if (!empty($parent_id)) {
- return BitBoardTopic::isLocked($parent_id);
+ return BitBoardTopic::isThreadLocked($parent_id);
}
return false;
}
@@ -530,42 +529,48 @@ class BitBoardTopic extends LibertyMime {
if (!$pThreadId) {
$pThreadId = $this->mRootId;
}
- if (is_numeric($pThreadId)) {
- $topicId = sprintf("%09d.",$pThreadId);
- }
*/
- return $gBitSystem->mDb->getOne("SELECT SUM(`notify`) FROM `".BIT_DB_PREFIX."boards_tracking` WHERE topic_id=?", array( (int)$topicId ) );
+ $topicId = ( is_numeric( $pThreadId ) ) ? sprintf( "%09d.", $pThreadId ) : 0;
+
+ return $gBitSystem->mDb->getOne("SELECT SUM(`notify`) FROM `".BIT_DB_PREFIX."boards_tracking` WHERE topic_id=?", [ (int) $topicId ] );
}
return false;
}
- function getNotificationData($pThreadId) {
- global $gBitSystem, $gBitUser;
+ public function getNotification($pThreadId) {
+ global $gBitSystem;
if ($gBitSystem->isPackageActive('boards') && $gBitSystem->isFeatureActive('boards_thread_track')) {
if (!$pThreadId) {
$pThreadId = $this->mRootId;
}
+ BitBoardTopic::getNotificationData($pThreadId);
+ }
+ }
+ public static function getNotificationData($pThreadId) {
+ global $gBitSystem, $gBitUser;
+ if ($gBitSystem->isPackageActive('boards') && $gBitSystem->isFeatureActive('boards_thread_track')) {
if (is_numeric($pThreadId)) {
- $topicId = sprintf("%09d.",$pThreadId);
+ $topicId = \sprintf("%09d.",$pThreadId);
}
+
$query = "SELECT uu.user_id, uu.email, uu.login, uu.real_name, trk.`track_date`, trk.`notify` AS track_notify, trk.`notify_date` AS track_notify_date
FROM `".BIT_DB_PREFIX."boards_tracking` trk
LEFT JOIN `".BIT_DB_PREFIX."users_users` uu ON( uu.`user_id` = trk.`user_id` )
WHERE topic_id=?";
- $result = $gBitSystem->mDb->query( $query, array( $topicId ) );
- $ret = array();
- $ret['users']=array();
+ $result = $gBitSystem->mDb->query( $query, [ $topicId ] );
+ $ret = [];
+ $ret['users']=[];
while( $res = $result->fetchRow() ) {
- $res['user'] =( isset( $res['real_name'] )? $res['real_name'] : $res['login'] );
+ $res['user'] =( $res['real_name'] ?? $res['login'] );
$ret['users'][$res['login']] = $res;
}
- $ret['topic'] = new BitBoardTopic(intval($topicId));
+ $ret['topic'] = new BitBoardTopic(\intval($topicId));
$ret['topic']->load();
return $ret;
}
- return array();
+ return [];
}
function sendNotification($user) {
@@ -610,20 +615,20 @@ class BitBoardTopic extends LibertyMime {
$flip['is_locked']['req']=2;
$flip['is_locked']['id']=$arr['th_thread_id'];
$flip['is_locked']['idname']='t';
- $flip['is_locked']['up']='fa-lock';
- $flip['is_locked']['upname']=tra('Thread Locked');
- $flip['is_locked']['down']='fa-unlock';
- $flip['is_locked']['downname']=tra('Thread Unlocked');
+ $flip['is_locked']['up']='icon-lock';
+ $flip['is_locked']['upname']= KernelTools::tra('Thread Locked');
+ $flip['is_locked']['down']='icon-unlock';
+ $flip['is_locked']['downname']= KernelTools::tra('Thread Unlocked');
$flip['is_locked']['perm']='p_boards_update';
$flip['is_sticky']['state']=$arr['th_is_sticky'];
$flip['is_sticky']['req'] = 3;
$flip['is_sticky']['id']=$arr['th_thread_id'];
$flip['is_sticky']['idname']='t';
- $flip['is_sticky']['up']='fa-circle-exclamation';
- $flip['is_sticky']['upname']=tra('Sticky Thread');
- $flip['is_sticky']['down']='fa-list-ul';
- $flip['is_sticky']['downname']=tra('Non Sticky Thread');
+ $flip['is_sticky']['up']='icon-exclamation-sign';
+ $flip['is_sticky']['upname']= KernelTools::tra('Sticky Thread');
+ $flip['is_sticky']['down']='icon-list';
+ $flip['is_sticky']['downname']= KernelTools::tra('Non Sticky Thread');
$flip['is_sticky']['perm']='p_boards_update';
if ($gBitSystem->isFeatureActive('boards_thread_notification') && $gBitUser->isRegistered()) {
@@ -631,10 +636,10 @@ class BitBoardTopic extends LibertyMime {
$flip['notify']['req']=5;
$flip['notify']['id']=$arr['th_thread_id'];
$flip['notify']['idname']='t';
- $flip['notify']['up']='fa-bell';
- $flip['notify']['upname']=tra('Reply Notification');
+ $flip['notify']['up']='icon-bell-alt';
+ $flip['notify']['upname']= KernelTools::tra('Reply Notification');
$flip['notify']['down']='icon-bell';
- $flip['notify']['downname']=tra('Reply Notification Disabled');
+ $flip['notify']['downname']= KernelTools::tra('Reply Notification Disabled');
$flip['notify']['perm']='p_boards_read';
}
if ($gBitSystem->isFeatureActive('boards_thread_track') && $gBitUser->isRegistered()) {
@@ -642,10 +647,10 @@ class BitBoardTopic extends LibertyMime {
$flip['new']['req']=4;
$flip['new']['id']=$arr['th_thread_id'];
$flip['new']['idname']='t';
- $flip['new']['up']='fa-asterisk';
- $flip['new']['upname']=tra('New Posts');
-// $flip['new']['down']='fa-comment';
-// $flip['new']['downname']=tra('No new posts');
+ $flip['new']['up']='icon-asterisk';
+ $flip['new']['upname']= KernelTools::tra('New Posts');
+// $flip['new']['down']='icon-comment-alt';
+// $flip['new']['downname']= KernelTools::tra('No new posts');
$flip['new']['perm']='p_boards_read';
}
@@ -682,7 +687,7 @@ class BitBoardTopic extends LibertyMime {
global $gBitUser, $gBitSystem;
if ($gBitSystem->isFeatureActive('boards_thread_track') && $gBitUser->isRegistered()) {
$topicId = sprintf("%09d.",$this->mRootId);
- $ret = FALSE;
+ $ret = false;
if ($pState==null || !is_numeric($pState) || $pState > 1 || $pState<0) {
$this->mErrors[]=("Invalid current state");
} else {
@@ -702,7 +707,7 @@ class BitBoardTopic extends LibertyMime {
global $gBitUser, $gBitSystem;
if ($gBitSystem->isFeatureActive('boards_thread_track') && $gBitUser->isRegistered()) {
$topicId = sprintf("%09d.",$this->mRootId);
- $ret = FALSE;
+ $ret = false;
if ($pState==null || !is_numeric($pState) || $pState > 1 || $pState<0) {
$this->mErrors[]=("Invalid current state");
} else {
@@ -733,7 +738,7 @@ class BitBoardTopic extends LibertyMime {
global $gBitUser, $gBitSystem;
if($gBitUser->isRegistered() && ($gBitSystem->isFeatureActive('boards_thread_track') || $gBitSystem->isFeatureActive('boards_thread_notify'))) {
$selectSql .= ", trk.`track_date`, trk.`notify` AS track_notify, trk.`notify_date` AS track_notify_date ";
- $joinSql .= " LEFT JOIN `".BIT_DB_PREFIX."boards_tracking` trk ON (trk.`topic_id`=lcom.`thread_forward_sequence` AND ( trk.`user_id` = ".$gBitUser->mUserId." OR trk.`user_id` IS NULL ) ) ";
+ $joinSql .= " LEFT JOIN `".BIT_DB_PREFIX."boards_tracking` trk ON (trk.`topic_id`=lcom.`thread_forward_sequence` AND ( trk.`user_id` = ".$gBitUser->mUserId." OR trk.`user_id` IS null ) ) ";
}
}
@@ -745,11 +750,7 @@ class BitBoardTopic extends LibertyMime {
if (empty($res['llc_last_modified'])) {
$res['llc_last_modified']=0;
}
- if ($res['llc_last_modified']>$res['track_date']) {
- $res['track']['mod'] = true;
- } else {
- $res['track']['mod'] = false;
- }
+ $res['track']['mod'] = ( $res['llc_last_modified'] > $res['track_date'] ) ? true : false;
} else {
$res['track']['on'] = false;
}
@@ -775,4 +776,3 @@ class BitBoardTopic extends LibertyMime {
return $this->mRootObj;
}
}
-?>
diff --git a/includes/edit_topic_inc.php b/includes/edit_topic_inc.php
index c1cbbf2..952d7af 100644..100755
--- a/includes/edit_topic_inc.php
+++ b/includes/edit_topic_inc.php
@@ -24,7 +24,7 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU
// user cancelled - just continue on, doing nothing
} elseif( empty( $_REQUEST['confirm'] ) ) {
$formHash['b'] = $_REQUEST['b'];
- $formHash['delete'] = TRUE;
+ $formHash['delete'] = true;
$formHash['submit_mult'] = 'remove_boards';
foreach( $_REQUEST["checked"] as $del ) {
$formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>';
@@ -40,12 +40,12 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU
$deleteComment = new LibertyComment( $deleteId );
if( $deleteComment->isValid() && $gBitUser->hasPermission('p_liberty_admin_comments') ) {
if( !$deleteComment->expunge() ) {
- $gBitSmarty->assignByRef( 'errors', $deleteComment->mErrors );
+ $gBitSmarty->assign( 'errors', $deleteComment->mErrors );
}
}
}
if( !empty( $errors ) ) {
- $gBitSmarty->assignByRef( 'errors', $errors );
+ $gBitSmarty->assign( 'errors', $errors );
}
}
}
diff --git a/includes/list_boards_inc.php b/includes/list_boards_inc.php
index c269de1..f368e0c 100644..100755
--- a/includes/list_boards_inc.php
+++ b/includes/list_boards_inc.php
@@ -23,8 +23,8 @@ $gBitSystem->verifyPackage( 'boards' );
$gBitSystem->verifyPermission( 'p_boards_read' );
// Get a list of boards
-$ns = array();
-$board_all_cids =array();
+$ns = [];
+$board_all_cids =[];
// @TODO move pigeonholes to its own file library or something
if($gBitSystem->isPackageActive('pigeonholes')) {
@@ -33,11 +33,11 @@ if($gBitSystem->isPackageActive('pigeonholes')) {
$p = new Pigeonholes();
$s = new LibertyStructure();
- $listHash = array('load_only_root'=> TRUE);
+ $listHash = array('load_only_root'=> true);
$l = $p->getList($listHash);
foreach ($l as $e) {
$d = $s->getSubTree( $e['structure_id'] );
- $d_o = array();
+ $d_o = [];
foreach ($d as $c) {
$pos_var = &$d_o;
if($c['level']!=0) {
@@ -45,22 +45,22 @@ if($gBitSystem->isPackageActive('pigeonholes')) {
$pos_var = &$d_o;
foreach ($pos as $pos_v) {
if (!isset($pos_var['children'])) {
- $pos_var['children']=array();
+ $pos_var['children']=[];
}
if (!isset($pos_var['children'][$pos_v-1])) {
- $pos_var['children'][$pos_v-1]=array();
+ $pos_var['children'][$pos_v-1]=[];
}
$pos_var = &$pos_var['children'][$pos_v-1];
}
}
if (empty($pos_var['data'])) {
- $pos_var['children']=array();
+ $pos_var['children']=[];
$pos_var['data']=$c;
- $mlHash=array();
+ $mlHash=[];
$mlHash['content_id']=$c['content_id'];
$mlHash['content_type_guid']=BITBOARD_CONTENT_TYPE_GUID;
$pos_var['members']=$p->getMemberList($mlHash);
- $board_cids =array();
+ $board_cids =[];
foreach ($pos_var['members'] as $boardKey) {
$board_cids[] = $boardKey['content_id'];
}
@@ -79,13 +79,13 @@ if($gBitSystem->isPackageActive('pigeonholes')) {
}
// get our boards list
-$ret =array();
+$ret =[];
if($gBitSystem->isPackageActive('pigeonholes')) {
// $ret['data']['title']="Uncategorised Boards";
} else {
// $ret['data']['title']="Board List";
}
-$ret['children']=array();
+$ret['children']=[];
$listHash = array('nboards'=>$board_all_cids,'paginationOff'=>'y');
$board = new BitBoard();
$ret['members'] = $board->getList($listHash);
@@ -97,7 +97,7 @@ if (count($ret['members']) == 1) {
$ns[] = $ret;
}
-$gBitSmarty->assignByRef('ns',$ns);
+$gBitSmarty->assign('ns',$ns);
// this might be for getting a count of nested boards - not entirely sure, if you figure it out please clarify this comment.
function countBoards(&$a) {
diff --git a/includes/lookup_inc.php b/includes/lookup_inc.php
index 68a7937..69b33d2 100644..100755
--- a/includes/lookup_inc.php
+++ b/includes/lookup_inc.php
@@ -11,12 +11,12 @@ require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php');
require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' );
require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
// if t supplied, use that
-if( @BitBase::verifyId( $_REQUEST['t'] ) ) {
+if( BitBase::verifyId( $_REQUEST['t'] ?? 0 ) ) {
$gContent = new BitBoardTopic( $_REQUEST['t'] );
// if p supplied, use that
-} elseif( @BitBase::verifyId( $_REQUEST['p'] ) ) {
+} elseif( BitBase::verifyId( $_REQUEST['p'] ?? 0 ) ) {
$gContent = new BitBoardPost( $_REQUEST['p'] );
-} elseif( @BitBase::verifyId( $_REQUEST['b'] ) ) {
+} elseif( BitBase::verifyId( $_REQUEST['b'] ?? 0 ) ) {
$gContent = new BitBoard( $_REQUEST['b'] );
} elseif (isset($_REQUEST['p'])) {
$gContent = new BitBoardPost();
@@ -28,6 +28,6 @@ if( @BitBase::verifyId( $_REQUEST['t'] ) ) {
}
$gContent->load();
-$gBitSmarty->assignByRef( "gContent", $gContent );
+$gBitSmarty->assign( "gContent", $gContent );
?>
diff --git a/includes/user_preferences_inc.php b/includes/user_preferences_inc.php
index 201acd9..27a56bd 100644..100755
--- a/includes/user_preferences_inc.php
+++ b/includes/user_preferences_inc.php
@@ -1,26 +1,28 @@
<?php
+
+use Bitweaver\Liberty\LibertyContent;
/**
* @package boards
* @subpackage functions
*/
-$boardsSettings = array(
+$boardsSettings = [
/*
- 'boards_show_avatars' => array(
+ 'boards_show_avatars' => [
'pref' => 'boards_show_avatars',
'label' => "Show Avatars",
'type' => "checkbox",
'default' => 'y',
'note' => "",
- ),
+ ],
*/
-);
+];
if (!empty( $_REQUEST['boards'] ) ) {
foreach( $boardsSettings as $option => $op) {
if ($op['type']=="checkbox") {
- $editUser->storePreference($op['pref'], !empty( $_REQUEST['boards'][$option]) ? 'y' : 'n', 'users');
+ $editUser->storePreference($op['pref'], !empty( $_REQUEST['boards'][$option]) ? 'y' : 'n');
} else {
- $editUser->storePreference($op['pref'], !empty( $_REQUEST['boards'][$option]) ? $_REQUEST['boards'][$option] : '', 'users');
+ $editUser->storePreference($op['pref'], !empty( $_REQUEST['boards'][$option]) ? $_REQUEST['boards'][$option] : '');
}
}
}
@@ -38,7 +40,7 @@ if (!empty($content_type) && !empty($content_data)) {
$signatureContent->mInfo['format_guid']=$editUser->getPreference('signature_content_type');
$signatureContent->mInfo['data']=$content_data;
}
-$gBitSmarty->assignByRef( 'signatureContent', $signatureContent );
+$gBitSmarty->assign( 'signatureContent', $signatureContent );
if( isset( $_REQUEST["format_guid"] ) ) {
@@ -60,8 +62,6 @@ if( !empty( $_REQUEST["save_bitboarduprefs"] ) ) {
// Check if all Request values are delivered, and if not, set them
// to avoid error messages. This can happen if some features are
// disabled
- $editUser->storePreference('signature_content_type',$signatureContent->mInfo['format_guid'], 'users');
- $editUser->storePreference('signature_content_data',$signatureContent->mInfo['data'], 'users');
+ $editUser->storePreference('signature_content_type',$signatureContent->mInfo['format_guid']);
+ $editUser->storePreference('signature_content_data',$signatureContent->mInfo['data']);
}
-
-?>
diff --git a/includes/view_board_inc.php b/includes/view_board_inc.php
index 98a26a0..6b6fa33 100644..100755
--- a/includes/view_board_inc.php
+++ b/includes/view_board_inc.php
@@ -11,14 +11,16 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
+namespace Bitweaver\Boards;
+require_once '../kernel/includes/setup_inc.php';
+use Bitweaver\BitBase;
+use Bitweaver\HttpStatusCodes;
// Is package installed and enabled
$gBitSystem->verifyPackage( 'boards' );
// if we're getting a migrate id then lets move on right away
-if ( @BitBase::verifyId( $_REQUEST['migrate_board_id'] ) ) {
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
+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'] );
@@ -28,10 +30,10 @@ if ( @BitBase::verifyId( $_REQUEST['migrate_board_id'] ) ) {
$_REQUEST['board_id'] = BitBase::getParameter( $_REQUEST, 'b' );
// Load up the board
-require_once( BOARDS_PKG_INCLUDE_PATH.'lookup_inc.php' );
+require_once BOARDS_PKG_INCLUDE_PATH.'lookup_inc.php';
if( !$gContent->isValid() ) {
- $gBitSystem->fatalError( "The board you requested could not be found. <a href='".BOARDS_PKG_URL."'>View all boards</a>", NULL, NULL, HttpStatusCodes::HTTP_GONE );
+ $gBitSystem->fatalError( "The board you requested could not be found. <a href='".BOARDS_PKG_URL."'>View all boards</a>", null, null, HttpStatusCodes::HTTP_GONE );
}
// approve or reject ananymous comments
@@ -43,7 +45,7 @@ if (!empty($_REQUEST['action'])) {
$gBitUser->verifyTicket();
// Load up the comment as a board post
- require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' );
+ require_once BOARDS_PKG_CLASS_PATH.'BitBoardPost.php';
$comment = new BitBoardPost($_REQUEST['comment_id']);
$comment->loadComment();
@@ -75,7 +77,7 @@ if (!empty($_REQUEST['action'])) {
*
* @TODO perhaps move this into the action process above
*/
-require_once( BOARDS_PKG_INCLUDE_PATH.'edit_topic_inc.php' );
+require_once BOARDS_PKG_INCLUDE_PATH.'edit_topic_inc.php';
// Ok finally we can get on with viewing our board
@@ -89,10 +91,10 @@ $commentsParentId=$gContent->mContentId;
$comments_return_url= BOARDS_PKG_URL."index.php?b=".urlencode($gContent->mBitBoardId);
// @TODO not clear why we load up comments and topics after this when its likely to get both. If someone figures it out please clarify.
-require_once( BOARDS_PKG_INCLUDE_PATH.'boards_comments_inc.php' );
+require_once BOARDS_PKG_INCLUDE_PATH.'boards_comments_inc.php';
// get the topics for this board
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
+require_once BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php';
$threads = new BitBoardTopic( $gContent->mContentId );
@@ -101,16 +103,15 @@ $threads->mRootObj = $gContent;
$threadsListHash = $_REQUEST;
$threadList = $threads->getList( $threadsListHash );
-$gBitSmarty->assignByRef( 'threadList', $threadList );
+$gBitSmarty->assign( 'threadList', $threadList );
// getList() has now placed all the pagination information in $_REQUEST['listInfo']
-$gBitSmarty->assignByRef( 'listInfo', $threadsListHash['listInfo'] );
+$gBitSmarty->assign( 'listInfo', $threadsListHash['listInfo'] );
-$gBitSmarty->assignByRef( 'board', $gContent );
+$gBitSmarty->assign( 'board', $gContent );
$gBitSmarty->assign( 'cat_url', BOARDS_PKG_URL."index.php"); //?ct=".urlencode($gContent->mInfo['content_type_guid']));
$gBitThemes->loadAjax( 'mochikit' );
// Display the template
-$gBitSystem->display( 'bitpackage:boards/list_topics.tpl', tra( 'Message Board Threads: ' . $gContent->getField('title') ) , array( 'display_mode' => 'display' ));
-?>
+$gBitSystem->display( 'bitpackage:boards/list_topics.tpl', tra( 'Message Board Threads: ' . $gContent->getField('title') ) , array( 'display_mode' => 'display' )); \ No newline at end of file
diff --git a/includes/view_topic_inc.php b/includes/view_topic_inc.php
index efee35e..ceec213 100644..100755
--- a/includes/view_topic_inc.php
+++ b/includes/view_topic_inc.php
@@ -7,19 +7,19 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
-
-// we need all three
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
-require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' );
+use Bitweaver\BitBase;
+use Bitweaver\HttpStatusCodes;
+use Bitweaver\Boards\BitBoard;
+use Bitweaver\Boards\BitBoardTopic;
+use Bitweaver\Boards\BitBoardPost;
+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'] ) ) {
+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'] );
}
-} elseif( @BitBase::verifyId( $_REQUEST['migrate_post_id'] ) ) {
+} 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'] );
}
@@ -34,7 +34,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( tra("Invalid Comment"), null, null, HttpStatusCodes::HTTP_GONE );
}
switch ($_REQUEST['action']) {
case 1:
@@ -59,7 +59,7 @@ $thread = new BitBoardTopic($_REQUEST['t']);
$thread->load();
if( !$thread->isValid() ) {
- $gBitSystem->fatalError( tra("Unknown discussion"), NULL, NULL, HttpStatusCodes::HTTP_GONE );
+ $gBitSystem->fatalError( tra("Unknown discussion"), null, null, HttpStatusCodes::HTTP_GONE );
}
$thread->verifyViewPermission();
@@ -67,10 +67,10 @@ $thread->verifyViewPermission();
// load up the root board we need it
$gBoard = new BitBoard(null,$thread->mInfo['board_content_id']);
$gBoard->load();
-$gBitSmarty->assignByRef( 'board', $gBoard );
+$gBitSmarty->assign( 'board', $gBoard );
// force root board to be gContent
$gContent = &$gBoard;
-$gBitSmarty->assignByRef('gContent', $gContent);
+$gBitSmarty->assign('gContent', $gContent);
// if you know what this is please comment it
@@ -79,7 +79,7 @@ if (empty($thread->mInfo['th_root_id'])) {
//Invalid as a result of rejecting the post, redirect to the board
bit_redirect( $gBoard->getDisplayUrl() );
} else {
- $gBitSystem->fatalError(tra( "Invalid topic selection." ), NULL, NULL, HttpStatusCodes::HTTP_GONE );
+ $gBitSystem->fatalError(tra( "Invalid topic selection." ), null, null, HttpStatusCodes::HTTP_GONE );
}
}
@@ -90,8 +90,8 @@ $thread->invokeServices( 'content_display_function', $displayHash );
$thread->readTopic();
-$gBitSmarty->assignByRef( 'thread', $thread );
-$gBitSmarty->assign( 'topic_locked', BitBoardTopic::isLocked( $thread->mCommentContentId ) );
+$gBitSmarty->assign( 'thread', $thread );
+$gBitSmarty->assign( 'topic_locked', BitBoardTopic::isThreadLocked( $thread->mCommentContentId ) );
// Get the thread of comments
@@ -106,7 +106,7 @@ if( empty( $_REQUEST["comments_style"] ) ) {
$_REQUEST["comments_style"] = "flat";
}
-require_once( BOARDS_PKG_INCLUDE_PATH.'boards_comments_inc.php' );
+require_once BOARDS_PKG_INCLUDE_PATH.'boards_comments_inc.php';
if( $gBitUser->isRegistered() ) {
$postComment['registration_date']=$gBitUser->mInfo['registration_date'];
@@ -116,7 +116,7 @@ if( $gBitUser->isRegistered() ) {
// display warnings - might be for edit processes - if you know please comment
-$warnings = array();
+$warnings = [];
if (!empty($_REQUEST['warning'])) {
foreach ($_REQUEST['warning'] as $id => $state) {
if (strcasecmp($state,'show')==0) {
@@ -124,11 +124,10 @@ if (!empty($_REQUEST['warning'])) {
}
}
}
-$gBitSmarty->assignByRef('warnings',$warnings);
+$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' ));
-?>