diff options
31 files changed, 272 insertions, 286 deletions
diff --git a/.htaccess_phpbb b/.htaccess_phpbb index a6784eb..a6784eb 100644..100755 --- a/.htaccess_phpbb +++ b/.htaccess_phpbb diff --git a/admin/admin_boards_inc.php b/admin/admin_boards_inc.php index 3ece564..52be909 100755 --- a/admin/admin_boards_inc.php +++ b/admin/admin_boards_inc.php @@ -10,7 +10,9 @@ // $gBitSmarty->assign('home_bitboard', $_REQUEST["homeBitBoards"]); //} -namespace Bitweaver\Boards;; +namespace Bitweaver\Boards; + +; $formBitBoardsLists = [ 'boards_thread_track' => [ @@ -74,7 +76,7 @@ if( $processForm ) { foreach( $formBoardsEmailText as $text ) { $gBitSystem->storeConfig( $text, !empty( $_REQUEST[$text] ) ? trim( $_REQUEST[$text] ) : null, BOARDS_PKG_NAME ); } - + } $board = new BitBoard(); diff --git a/admin/boardsync_inc.php b/admin/boardsync_inc.php index 86b521a..4149f8b 100755 --- a/admin/boardsync_inc.php +++ b/admin/boardsync_inc.php @@ -5,12 +5,12 @@ function board_sync_run($pLog = false) { $gBitUser->setPermissionOverride('p_users_bypass_captcha', true); $connectionString = '{'.$gBitSystem->getConfig('boards_sync_mail_server','imap').':'.$gBitSystem->getConfig('boards_sync_mail_port','993').'/'.$gBitSystem->getConfig('boards_sync_mail_protocol','imap').'/ssl/novalidate-cert}'; - + // Can we open the mailbox? if( $mbox = imap_open( $connectionString, $gBitSystem->getConfig( 'boards_sync_user' ), $gBitSystem->getConfig( 'boards_sync_password' ) ) ) { $MC = imap_check($mbox); - + // Fetch an overview for all messages in INBOX of mailbox has messages if( $MC->Nmsgs ) { // print($MC->Nmsgs); @@ -20,7 +20,7 @@ function board_sync_run($pLog = false) { if ($pLog) print "Processing Msg#: ".$msgNum."\n"; $deleteMsg = false; $header = imap_headerinfo( $mbox, $msgNum ); - + // Is this a moderation message? if( preg_match('/.*? post from .*? requires approval/', $header->subject) ) { if ($pLog) print "Is Moderation Request.\n"; @@ -80,7 +80,7 @@ function board_sync_run($pLog = false) { } } } - + // final cleanup imap_expunge( $mbox ); imap_close( $mbox ); @@ -91,17 +91,17 @@ function board_sync_run($pLog = false) { bit_error_log( "Failed to clear directory: ".$dir." in boards package mailinglist synchronization." ); } } - + } else { bit_error_log( __FILE__." failed imap_open $connectionString ".imap_last_error() ); } - + } function board_parse_msg_parts( &$pPartHash, $pMbox, $pMsgId, $pMsgPart, $pPartNum, $pLog ) { - //fetch part - $part=imap_fetchbody( $pMbox, $pMsgId, $pPartNum); + //fetch part + $part=imap_fetchbody( $pMbox, $pMsgId, $pPartNum); switch( $pMsgPart->encoding ) { case '3': // BASE64 $part = base64_decode($part); @@ -127,8 +127,8 @@ function board_parse_msg_parts( &$pPartHash, $pMbox, $pMsgId, $pMsgPart, $pPartN // Note: alternatively one might run a check to make sure the text is really utf-8, regardless of the header // use strtolower on the attributes since different php installs do not reconcile casing consistantly if( strtolower( $params->attribute ) == 'charset' && strtolower( $params->value ) != 'utf-8' ){ - if ($pLog) print( "Msg part ".$pPartNum." charset: ".$params->value."\n" ); - $part = @iconv($params->value, 'UTF-8', $part ); + if ($pLog) print( "Msg part ".$pPartNum." charset: ".$params->value."\n" ); + $part = @iconv($params->value, 'UTF-8', $part ); } } } @@ -140,7 +140,7 @@ function board_parse_msg_parts( &$pPartHash, $pMbox, $pMsgId, $pMsgPart, $pPartN if( !preg_match( '/signature/i', $pMsgPart->subtype ) ) { //get filename of attachment if present $filename=''; - foreach( array( 'dparameters', 'parameters' ) as $prm ) { + foreach( [ 'dparameters', 'parameters' ] as $prm ) { if( empty( $filename ) ) { // if there are any dparameters present in this part if( !empty($pMsgPart->$prm) && count( $pMsgPart->$prm ) > 0 ){ @@ -165,12 +165,12 @@ function board_parse_msg_parts( &$pPartHash, $pMbox, $pMsgId, $pMsgPart, $pPartN } } break; - - } - - //if subparts... recurse into function and parse them too! - if( !empty( $pMsgPart->parts ) ){ - foreach ($pMsgPart->parts as $pno=>$parr){ + + } + + //if subparts... recurse into function and parse them too! + if( !empty( $pMsgPart->parts ) ){ + foreach ($pMsgPart->parts as $pno=>$parr){ board_parse_msg_parts( $pPartHash, $pMbox, $pMsgId, $parr, ( $pPartNum.'.'.( $pno + 1 ) ), $pLog); } } @@ -181,25 +181,25 @@ function board_sync_get_user( $pFrom ) { if( preg_match_all('/[^<\s]+@[^>\s]+/', $pFrom, $matches) ) { foreach( $matches[0] as $email ) { - $ret = $gBitUser->getUserInfo( array( 'email'=>$email ) ); + $ret = $gBitUser->getUserInfo( [ 'email'=>$email ] ); if( !empty($ret) ) { return $ret; } } } - return $gBitUser->getUserInfo( array( 'user_id'=>-1 ) ); + return $gBitUser->getUserInfo( [ 'user_id'=>-1 ] ); } function cache_check_content_prefs( $pName, $pValue, $pLower = false ) { global $gBitDb, $gBitSystem; static $prefs; - if( empty($prefs[$pLower][$pName]) ) { - $bindVars = array( $pName ); + if( empty($prefs[$pLower][$pName]) ) { + $bindVars = [ $pName ]; $prefs[$pLower][$pName] = $gBitDb->getAssoc( "SELECT " . - ($pLower ? 'LOWER(`pref_value`)' : '`pref_value`'). - ", `content_id` FROM `".BIT_DB_PREFIX."liberty_content_prefs` WHERE `pref_name`=?", $bindVars ); + ($pLower ? 'LOWER(`pref_value`)' : '`pref_value`'). + ", `content_id` FROM `".BIT_DB_PREFIX."liberty_content_prefs` WHERE `pref_name`=?", $bindVars, ); } if( !empty($prefs[$pLower][$pName][$pValue]) ) { @@ -221,7 +221,7 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu // @TODO comment or clean up, not sure why this is here -wjames5 if( empty($message_id) ) { $message_id = board_sync_get_headerinfo( $pMsgHeader, 'message_id' ); - } + } $subject = board_sync_get_headerinfo( $pMsgHeader, 'Subject' ); if( empty( $message_id ) ){ @@ -230,7 +230,6 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu if ($pLog) print("Processing: ".$message_id."\n"); if ($pLog) print(" Subject: ".$subject."\n"); - $matches = []; $toAddresses = []; $allRecipients = ""; @@ -243,7 +242,7 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $allRecipients .= (( $allRecipients != "" )?",":"") . $pMsgHeader->ccaddress; if ($pLog) print (" CC addresses: " . $pMsgHeader->ccaddress . "\n"); } - + if ($pLog) print (" All Recipients: ". $allRecipients ."\n"); $allSplit = split( ',', $allRecipients ); foreach( $allSplit as $s ) { @@ -251,21 +250,21 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $matches = []; if( strpos( $s, '<' ) !== false ) { if( preg_match( "/\s*(.*)\s*<\s*(.*)\s*>/", $s, $matches ) ) { - $toAddresses[] = array( 'name'=>$matches[1], 'email'=>$matches[2] ); + $toAddresses[] = [ 'name'=>$matches[1], 'email'=>$matches[2] ]; } elseif( preg_match('/<\s*(.*)\s*>\s*(.*)\s*/', $s, $matches) ) { - $toAddresses[] = array( 'email'=>$matches[1], 'name'=>$matches[2] ); + $toAddresses[] = [ 'email'=>$matches[1], 'name'=>$matches[2] ]; } } elseif( validate_email_syntax( $s ) ) { - $toAddresses[] = array( 'email'=>$s ); + $toAddresses[] = [ 'email'=>$s ]; } } } else { foreach ($pDeliveredTo as $address) { - $toAddresses[] = array('email' => $address); + $toAddresses[] = ['email' => $address]; } } if ($pLog) print_r($toAddresses); - + $date = board_sync_get_headerinfo($pMsgHeader, 'Date'); $from = board_sync_get_headerinfo($pMsgHeader, 'from'); $fromaddress = $from[0]->mailbox."@".$from[0]->host; @@ -289,11 +288,11 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $contentId = null; if( $message_id != null ) { $sql = "SELECT `content_id` FROM `".BIT_DB_PREFIX."liberty_comments` WHERE `message_guid`=? AND `root_id`=?"; - $contentId = $gBitDb->getOne( $sql, array( $message_id, $boardContentId ) ); + $contentId = $gBitDb->getOne( $sql, [ $message_id, $boardContentId ] ); } if( empty($contentId) ) { if( !empty( $in_reply_to ) ) { - if( $parent = $gBitDb->GetRow( "SELECT `content_id`, `root_id` FROM `".BIT_DB_PREFIX."liberty_comments` WHERE `message_guid`=?", array( $in_reply_to ) ) ) { + if( $parent = $gBitDb->GetRow( "SELECT `content_id`, `root_id` FROM `".BIT_DB_PREFIX."liberty_comments` WHERE `message_guid`=?", [ $in_reply_to ] ) ) { $replyId = $parent['content_id']; $rootId = $parent['root_id']; } else { @@ -302,7 +301,7 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $rootId = $boardContentId; } // if no reply to message guid then match on title - this looks dangerous as titles could easily be duplicated -wjames - } elseif( $parent = $gBitDb->GetRow( "SELECT lcom.`content_id`, lcom.`root_id` FROM `".BIT_DB_PREFIX."liberty_comments` lcom INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON(lcom.`content_id`=lc.`content_id`) WHERE lc.`title`=?", array( preg_replace( '/re: /i', '', $subject ) ) ) ) { + } elseif( $parent = $gBitDb->GetRow( "SELECT lcom.`content_id`, lcom.`root_id` FROM `".BIT_DB_PREFIX."liberty_comments` lcom INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON(lcom.`content_id`=lc.`content_id`) WHERE lc.`title`=?", [ preg_replace( '/re: /i', '', $subject ) ] ) ) { $replyId = $parent['content_id']; $rootId = $parent['root_id']; // attach to board as first level comment e.g. new topic @@ -324,9 +323,9 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu } $storeRow['root_id'] = $rootId; $storeRow['parent_id'] = $replyId; - + $partHash = []; - + switch( $pMsgStructure->type ) { case '0': if ($pLog) print( "Structure Type: text\n" ); @@ -347,7 +346,7 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu } $plainBody = ""; $htmlBody = ""; - + foreach( array_keys( $partHash ) as $i ) { if( !empty( $partHash[$i]['plain'] ) ) { $plainBody .= $partHash[$i]['plain']; @@ -356,15 +355,15 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $htmlBody .= $partHash[$i]['html']; } if( !empty( $partHash[$i]['attachment'] ) ) { - $storeRow['_files_override'][] = array( - 'tmp_name'=> $partHash[$i]['attachment'], - 'type'=>$gBitSystem->verifyMimeType( $partHash[$i]['attachment'] ), - 'size'=>filesize( $partHash[$i]['attachment'] ), - 'name'=>basename( $partHash[$i]['attachment'] ), - 'user_id'=>$userInfo['user_id'] ); + $storeRow['_files_override'][] = [ + 'tmp_name'=> $partHash[$i]['attachment'], + 'type'=>$gBitSystem->verifyMimeType( $partHash[$i]['attachment'] ), + 'size'=>filesize( $partHash[$i]['attachment'] ), + 'name'=>basename( $partHash[$i]['attachment'] ), + 'user_id'=>$userInfo['user_id'], ]; } } - + if( !empty( $htmlBody ) ) { $storeRow['edit'] = $htmlBody; $storeRow['format_guid'] = 'bithtml'; @@ -372,33 +371,32 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $storeRow['edit'] = nl2br( $plainBody ); $storeRow['format_guid'] = 'bithtml'; } - + // Nuke all email addresses from the body. if( !empty($storeRow['edit']) ) { $storeRow['edit'] = ereg_replace( '[-!#$%&\`*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'. '(localhost|[-!$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. - '[-!$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+)', '', $storeRow['edit'] ); + '[-!$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+)', '', $storeRow['edit'], ); } - + // We trust the user from this source // and count on moderation to handle links global $gBitUser; $gBitUser->setPermissionOverride('p_liberty_trusted_editor', true); - - // Check to add attachments - + // Check to add attachments + // NOTE: we temporarily change the gBitUser here! // This is so we can run a proper content permissions check // for attachment permission against the parent - // board object. This is sort of a hack to deal + // board object. This is sort of a hack to deal // with the fact that LibertyContent does not have a // means to check the permissions of any user except gBitUser -wjames5 - + // Important store a reference so we can switch back when we are done $gBitUserOrg = $gBitUser; - + // Load the message sending user if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) { $userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' ); @@ -409,25 +407,25 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu // flip gBitUser to our message sender $gBitUser = $newBitUser; } - + // Load the parent board $board = new BitBoard( null, $boardContentId ); $board->load(); - + // Check the permission for the user on the board - if( $gBitSystem->isFeatureActive( 'comments_allow_attachments' ) && $board->hasUserPermission( 'p_liberty_attach_attachments' ) ){ + if( $gBitSystem->isFeatureActive( 'comments_allow_attachments' ) && $board->hasUserPermission( 'p_liberty_attach_attachments' ) ){ // note we grant the permission to the anonymous user which will become gBitUser once again $gBitUserOrg->setPermissionOverride('p_liberty_attach_attachments', true); }; - + // Clear the reference to this board so we dont mistakenly use it later unset( $board ); - + // Important: switch gBitUser back! $gBitUser = $gBitUserOrg; - + // End check to add attachments to comments to the parent board - + // Check for an empty body // Duplicate subject if we have it if (empty($storeRow['edit'])) { @@ -438,14 +436,13 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $storeRow['edit'] = "."; } } - - + $storeComment = new LibertyComment( null ); $gBitDb->StartTrans(); if( $storeComment->storeComment($storeRow) ) { // undo the attachment permission $gBitUser->setPermissionOverride('p_liberty_attach_attachments', false); - + // set moderation approval if( !$pModerate && $gBitSystem->isPackageActive('moderation') && $gBitSystem->isPackageActive('modcomments') ) { global $gModerationSystem, $gBitUser; @@ -457,37 +454,35 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $gBitUser->setPermissionOverride('p_admin', false); } } - + if( !empty( $storeRow['message_guid'] ) ){ // map the message guid to the comment - $storeComment->mDb->query( "UPDATE `".BIT_DB_PREFIX."liberty_comments` SET `message_guid`=? WHERE `content_id`=?", array( $storeRow['message_guid'], $storeComment->mContentId ) ); - + $storeComment->mDb->query( "UPDATE `".BIT_DB_PREFIX."liberty_comments` SET `message_guid`=? WHERE `content_id`=?", [ $storeRow['message_guid'], $storeComment->mContentId ] ); + // Store the confirm code if( $pModerate ) { $storeComment->storePreference('board_confirm_code', $pModerate); } - + // done $gBitDb->CompleteTrans(); return true; - }else{ + } bit_error_log( "Email sync error: Message Id not set. You shouldn't have even gotten this far." ); $gBitDb->RollbackTrans(); return false; - } - } else { + + } if( count( $storeComment->mErrors ) == 1 && !empty( $storeComment->mErrors['store'] ) && $storeComment->mErrors['store'] == 'Duplicate comment.' ) { return true; - } else { + } foreach( $storeComment->mErrors as $error ){ bit_error_log( $error ); } $gBitDb->RollbackTrans(); return false; - } - } - } else { + } if ($pLog) print "Message Exists: $contentId : $boardContentId : $message_id : $pModerate\n"; // If this isn't a moderation message if( $pModerate === false ) { @@ -520,10 +515,10 @@ function board_sync_process_message( $pMbox, $pMsgNum, $pMsgHeader, $pMsgStructu $storeComment->storePreference('board_confirm_code', $pModerate); } return true; - } - } else { - if ($pLog) print "No Board match found for $to[email]\n"; + } + if ($pLog) print "No Board match found for $to[email]\n"; + } } return false; @@ -554,8 +549,8 @@ function board_sync_get_headerinfo( $header, $key ){ function board_sync_delivered_to( $raw_headers ) { $ret = null; - if (isset($raw_headers) && - preg_match_all("/Delivered-To:\s*(.*)\s*/", $raw_headers, $deliveredTo) > 0) { + if (isset($raw_headers) && + preg_match_all("/Delivered-To:\s*(.*)\s*/", $raw_headers, $deliveredTo) > 0) { $ret = []; foreach ($deliveredTo[1] as $address) { // Make sure the Delivered-To: address is valid. @@ -568,8 +563,8 @@ function board_sync_delivered_to( $raw_headers ) { } function is_utf8($string) { - // From http://w3.org/International/questions/qa-forms-utf-8.html - return preg_match('%^(?: + // From http://w3.org/International/questions/qa-forms-utf-8.html + return preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs diff --git a/admin/phpbb_migrate.php b/admin/phpbb_migrate.php index c787780..1a5c0e5 100755 --- a/admin/phpbb_migrate.php +++ b/admin/phpbb_migrate.php @@ -58,7 +58,6 @@ function migrate_phpbb() { die; } - $gBitDb->StartTrans(); if( $forumList = $gBitDb->getAssoc( "SELECT `forum_id`,`forum_name`, `forum_desc`,`content_id` FROM " . FORUMS_TABLE . " bbf LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_type_guid`='bitboard' AND bbf.`forum_name`=lc.`title`) ORDER BY bbf.forum_id" ) ) { vd( $forumList ); flush(); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index be6958a..25dd6cf 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -1,5 +1,5 @@ <?php -$tables = [ +$tables = [ 'boards_posts' => " comment_id I4 PRIMARY, is_approved I1 NOTNULL DEFAULT(0), @@ -19,7 +19,7 @@ $tables = [ 'boards_sections' => " section_id I4 PRIMARY, section_title C(255) - ", + ", 'boards' => " board_id I4 PRIMARY, content_id I4 NOTNULL, @@ -41,7 +41,7 @@ $tables = [ track_date I4 NOTNULL DEFAULT(0), notify I1 NOTNULL DEFAULT(0), notify_date I4 NOTNULL DEFAULT(0) - " + ", ]; global $gBitInstaller; @@ -79,21 +79,21 @@ $gBitInstaller->registerUserPermissions( BOARDS_PKG_NAME, [ ] ); // ### Default Preferences -$gBitInstaller->registerPreferences( BOARDS_PKG_NAME, [ +$gBitInstaller->registerPreferences( BOARDS_PKG_NAME, [ [ BOARDS_PKG_NAME, 'boards_thread_track', 'y' ], ] ); if(defined('RSS_PKG_NAME')) { - $gBitInstaller->registerPreferences( BOARDS_PKG_NAME, [ + $gBitInstaller->registerPreferences( BOARDS_PKG_NAME, [ [ RSS_PKG_NAME, BOARDS_PKG_NAME.'_rss', 'y'], ] ); } // ### Register content types -$gBitInstaller->registerContentObjects( BOARDS_PKG_NAME, [ +$gBitInstaller->registerContentObjects( BOARDS_PKG_NAME, [ 'BitBoard'=>BOARDS_PKG_CLASS_PATH.'BitBoard.php', ] ); // Requirements -$gBitInstaller->registerRequirements( BOARDS_PKG_NAME, [ +$gBitInstaller->registerRequirements( BOARDS_PKG_NAME, [ 'liberty' => [ 'min' => '5.0.0' ], ] ); diff --git a/admin/update_lists.php b/admin/update_lists.php index 195fcc7..86ce546 100644 --- a/admin/update_lists.php +++ b/admin/update_lists.php @@ -24,11 +24,11 @@ if( !$gBitUser->isAdmin() ){ if( !empty( $_REQUEST['update'] ) ) { // get all mailman lists $query = "SELECT pref_value AS listname FROM `".BIT_DB_PREFIX."liberty_content_prefs` lcp WHERE lcp.`pref_name` = ?"; - $lists = $gBitSystem->mDb->getArray( $query, array('boards_mailing_list') ); + $lists = $gBitSystem->mDb->getArray( $query, ['boards_mailing_list'] ); foreach( $lists as $list ){ // update list configuration - if( $error = mailman_config_list( array( 'listname' => $list['listname'] ) ) ) { + if( $error = mailman_config_list( [ 'listname' => $list['listname'] ] ) ) { echo $error."<br />"; }else{ echo "List: ".$list['listname']." has been updated.<br />"; diff --git a/admin/upgrades/1.0.1.php b/admin/upgrades/1.0.1.php index 6eef1b9..85c9d36 100755 --- a/admin/upgrades/1.0.1.php +++ b/admin/upgrades/1.0.1.php @@ -4,36 +4,36 @@ */ global $gBitInstaller; -$infoHash = array( +$infoHash = [ 'package' => BOARDS_PKG_NAME, 'version' => str_replace( '.php', '', basename( __FILE__ )), 'description' => "Add boards sections and positioning.", 'post_upgrade' => null, -); -$gBitInstaller->registerPackageUpgrade( $infoHash, array( +]; +$gBitInstaller->registerPackageUpgrade( $infoHash, [ -array( 'DATADICT' => array( - array( 'CREATE' => array( +[ 'DATADICT' => [ + [ 'CREATE' => [ 'boards_sections' => " section_id I4 PRIMARY, section_title C(255) - ", - )), + ", + ]], // insert new column - array( 'ALTER' => array( - 'boards' => array( - 'section_id' => array( '`section_id`', 'I4' ), - 'pos' => array( '`pos`', 'I4' ), - ))), - array( 'CREATEINDEX' => array( - 'boards_sections_idx' => array( 'boards', 'section_id', [] ), - )), - array( 'CREATESEQUENCE' => array( + [ 'ALTER' => [ + 'boards' => [ + 'section_id' => [ '`section_id`', 'I4' ], + 'pos' => [ '`pos`', 'I4' ], + ], ]], + [ 'CREATEINDEX' => [ + 'boards_sections_idx' => [ 'boards', 'section_id', [] ], + ]], + [ 'CREATESEQUENCE' => [ 'boards_sections_id_seq', - )), -)), + ]], +]], -array( 'PHP' => ' +[ 'PHP' => ' // Is package installed and enabled global $gBitSystem; @@ -88,8 +88,7 @@ while( $topic = $map_errors->fetchRow() ) { } $oTopic->CompleteTrans(); -' ), +' ], - -)); +]); ?> @@ -22,44 +22,44 @@ $gBitSystem->verifyPackage( 'boards' ); $gBitSystem->verifyPermission( 'p_boards_read' ); function ajax_nice_error($errno, $errstr, $errfile, $errline) { - $errortype = array ( - E_ERROR => array( + $errortype = [ + E_ERROR => [ 'desc'=>"Error", - 'ignore'=>false), - E_WARNING => array( + 'ignore'=>false, ], + E_WARNING => [ 'desc'=> "Warning", - 'ignore'=>false), - E_PARSE => array( + 'ignore'=>false, ], + E_PARSE => [ 'desc'=> "Parsing Error", - 'ignore'=>false), - E_NOTICE => array( + 'ignore'=>false, ], + E_NOTICE => [ 'desc'=> "Notice", - 'ignore'=>true), - E_CORE_ERROR => array( + 'ignore'=>true, ], + E_CORE_ERROR => [ 'desc'=> "Core Error", - 'ignore'=>false), - E_CORE_WARNING => array( + 'ignore'=>false, ], + E_CORE_WARNING => [ 'desc'=> "Core Warning", - 'ignore'=>false), - E_COMPILE_ERROR => array( + 'ignore'=>false, ], + E_COMPILE_ERROR => [ 'desc'=> "Compile Error", - 'ignore'=>false), - E_COMPILE_WARNING => array( + 'ignore'=>false, ], + E_COMPILE_WARNING => [ 'desc'=> "Compile Warning", - 'ignore'=>false), - E_USER_ERROR => array( + 'ignore'=>false, ], + E_USER_ERROR => [ 'desc'=> "User Error", - 'ignore'=>false), - E_USER_WARNING => array( + 'ignore'=>false, ], + E_USER_WARNING => [ 'desc'=> "User Warning", - 'ignore'=>false), - E_USER_NOTICE => array( + 'ignore'=>false, ], + E_USER_NOTICE => [ 'desc'=> "User Notice", - 'ignore'=>false), - E_STRICT => array( + 'ignore'=>false, ], + E_STRICT => [ 'desc'=> "Runtime Notice", - 'ignore'=>true), - ); + 'ignore'=>true, ], + ]; // set of errors for which a var trace will be saved if(!$errortype[$errno]['ignore']) { @@ -31,9 +31,9 @@ if (!empty($_REQUEST['remove'])) { $b->removeContent($content_id); } } - }else{ - // @TODO assign error and report back to user which were not processed } + // @TODO assign error and report back to user which were not processed + } } @@ -60,5 +60,5 @@ $data = BitBoard::getAllMap(); $gBitSmarty->assign('data',$data); // Display the template -$gBitSystem->display( 'bitpackage:boards/board_assign.tpl', tra('Assign content to Board') , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:boards/board_assign.tpl', tra('Assign content to Board') , [ 'display_mode' => 'display' ]); ?> diff --git a/boards_rss.php b/boards_rss.php index ce8d038..09cc042 100755 --- a/boards_rss.php +++ b/boards_rss.php @@ -60,7 +60,6 @@ $rss->title = $title; $rss->description = $description; $rss->link = $gContent->getDisplayUri(); - // get all topics of a board or all recent topics in general switch( $gContent->getField('content_type_guid') ){ case 'bitcomment': @@ -36,7 +36,7 @@ if( isset( $_REQUEST['remove'] ) ) { if( empty( $_REQUEST['confirm'] ) ) { $formHash['b'] = $_REQUEST['b']; $formHash['remove'] = true; - $gBitSystem->confirmDialog( $formHash, array( 'warning' => tra( 'Are you sure you want to remove the entire message board' ).' "'.$gContent->getTitle().'" ?', 'error' => 'This cannot be undone!' ) ); + $gBitSystem->confirmDialog( $formHash, [ 'warning' => tra( 'Are you sure you want to remove the entire message board' ).' "'.$gContent->getTitle().'" ?', 'error' => 'This cannot be undone!' ] ); } elseif( !$gContent->expunge() ) { $gBitSmarty->assign( 'errors', $deleteComment->mErrors ); } else { @@ -74,5 +74,5 @@ if( !empty( $_REQUEST["save_bitboard"] ) ) { } // Display the template -$gBitSystem->display( 'bitpackage:boards/board_edit.tpl', tra('Board') , array( 'display_mode' => 'edit' )); +$gBitSystem->display( 'bitpackage:boards/board_edit.tpl', tra('Board') , [ 'display_mode' => 'edit' ]); ?> diff --git a/edit_topic.php b/edit_topic.php index 47f448e..6ba2ded 100755 --- a/edit_topic.php +++ b/edit_topic.php @@ -39,7 +39,7 @@ $rslt = false; if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ // Check permissions to edit this topic $board->verifyUpdatePermission(); - + if ( isset($_REQUEST['is_locked']) && is_numeric($_REQUEST['is_locked']) ){ $rslt = $gContent->lock($_REQUEST['is_locked']); } elseif ( isset($_REQUEST['is_sticky']) && is_numeric($_REQUEST['is_sticky']) ){ @@ -51,17 +51,17 @@ if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ if( !(( $gContent->mInfo['root_id'] == $gContent->mInfo['board_content_id'] && $board->hasAdminPermission() ) || $gBitUser->hasPermission('p_liberty_admin_comments')) ){ $gBitSystem->fatalError( tra('You do not have permission to delete this topic.') ); } - + if( !empty( $_REQUEST['cancel'] ) ) { // user cancelled - just continue on, doing nothing } elseif( empty( $_REQUEST['confirm'] ) ) { $formHash['remove'] = true; $formHash['t'] = $_REQUEST['t']; - $gBitSystem->confirmDialog( $formHash, - array( + $gBitSystem->confirmDialog( $formHash, + [ 'warning' => tra( 'Are you sure you want to delete this topic?' ) . ' ' . $gContent->getTitle(), - 'error' => tra('This cannot be undone!') - ) + 'error' => tra('This cannot be undone!'), + ], ); } else { // @TODO Topic should extend LibertyComment - but until that day we load it up a second time @@ -69,7 +69,7 @@ if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ if( !$topicAsComment->expunge() ) { $gBitSmarty->assign( 'errors', $topicAsComment->mErrors ); } - // send us back to the baord - http_referer won't work with confirm process + // send us back to the baord - http_referer won't work with confirm process bit_redirect( BOARDS_PKG_URL.'index.php?b='. $gContent->mInfo['board_id'] ); } // User pref options on a topic - not really editing but this simplifies topic related processes putting it here @@ -87,9 +87,8 @@ if( isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky']) ){ if($rslt){ // Return us to where we came from header ("location: ".$_SERVER['HTTP_REFERER']); -}else{ +} // @TODO put error into an alert //trigger_error(var_export($gContent->mErrors,true )); -} ?> diff --git a/icons/discuss_small.gif b/icons/discuss_small.gif Binary files differindex 1b70f1f..1b70f1f 100644..100755 --- a/icons/discuss_small.gif +++ b/icons/discuss_small.gif diff --git a/icons/discuss_small.png b/icons/discuss_small.png Binary files differindex b0b8c7c..b0b8c7c 100644..100755 --- a/icons/discuss_small.png +++ b/icons/discuss_small.png diff --git a/icons/pkg_boards.gif b/icons/pkg_boards.gif Binary files differindex 537a049..537a049 100644..100755 --- a/icons/pkg_boards.gif +++ b/icons/pkg_boards.gif diff --git a/icons/pkg_boards.png b/icons/pkg_boards.png Binary files differindex b24898b..b24898b 100644..100755 --- a/icons/pkg_boards.png +++ b/icons/pkg_boards.png 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' ]); diff --git a/mailing_list.php b/mailing_list.php index 4f2e0c4..c37da31 100755 --- a/mailing_list.php +++ b/mailing_list.php @@ -36,7 +36,7 @@ if( $boardSyncInbox = BitBoard::getBoardSyncInbox() ) { if( !empty( $_REQUEST['create_list'] ) ) { //------ Email List ------// - if( !($error = mailman_newlist( array( 'listname' => $_REQUEST['boards_mailing_list'], 'admin-password'=>$_REQUEST['boards_mailing_list_password'], 'listadmin-addr'=>$gBitUser->getField( 'email' ) ) )) ) { + if( !($error = mailman_newlist( [ 'listname' => $_REQUEST['boards_mailing_list'], 'admin-password'=>$_REQUEST['boards_mailing_list_password'], 'listadmin-addr'=>$gBitUser->getField( 'email' ) ] )) ) { $gContent->storePreference( 'boards_mailing_list', !empty( $_REQUEST['boards_mailing_list'] ) ? $_REQUEST['boards_mailing_list'] : null ); $gContent->storePreference( 'boards_mailing_list_password', $_REQUEST['boards_mailing_list_password'] ); } else { @@ -54,10 +54,10 @@ if( !empty( $_REQUEST['create_list'] ) ) { $formHash['delete_list'] = true; $formHash['b'] = $gContent->getField( 'board_id' ); $gBitSystem->confirmDialog( $formHash, - array( + [ 'warning' => tra('Are you sure you want to delete this mailing list?') . ' ' . $gContent->getTitle(), 'error' => tra('This cannot be undone!'), - ) + ], ); } else { if( !($error = mailman_rmlist( $gContent->getPreference( 'boards_mailing_list' ) )) ) { @@ -75,7 +75,7 @@ if( !empty( $_REQUEST['create_list'] ) ) { // check for submits that need boards_mailing_list if( !empty( $_REQUEST['subscribe_boardsync'] ) ) { if( $gContent->getPreference('board_sync_list_address') ) { - mailman_addmember( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox ); + mailman_addmember( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox ); mailman_setmoderator( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox ); } } elseif( !empty( $_REQUEST['unsubscribe_boardsync'] ) ) { @@ -101,5 +101,5 @@ if( $gContent->getBoardMailingList() ) { // display $gBitSmarty->assign( 'board', $gContent ); -$gBitSystem->display( "bitpackage:boards/mailing_list.tpl", $gContent->getTitle() ." ". tra( 'Message Board Mailing List' ) , array( 'display_mode' => 'list' )); +$gBitSystem->display( "bitpackage:boards/mailing_list.tpl", $gContent->getTitle() ." ". tra( 'Message Board Mailing List' ) , [ 'display_mode' => 'list' ]); ?> diff --git a/modules/mod_recent_posts.php b/modules/mod_recent_posts.php index 99af120..921f144 100755 --- a/modules/mod_recent_posts.php +++ b/modules/mod_recent_posts.php @@ -21,7 +21,7 @@ if( !empty( $moduleParams ) ) { extract( $moduleParams ); } -$listHash = array( 'user_id' => $gQueryUserId, 'sort_mode' => 'created_desc' ); +$listHash = [ 'user_id' => $gQueryUserId, 'sort_mode' => 'created_desc' ]; if( !empty( $moduleParams['module_rows'] ) ) { $listHash['max_records'] = $moduleParams['module_rows']; @@ -16,7 +16,7 @@ require_once '../kernel/includes/setup_inc.php'; $gBitSystem->verifyPackage( 'boards' ); $gBitSystem->verifyPackage( 'rss' ); -$feedFormat = array( +$feedFormat = [ 0 => "RSS 0.91", 1 => "RSS 1.0", 2 => "RSS 2.0", @@ -27,7 +27,7 @@ $feedFormat = array( 7 => "OPML", 8 => "HTML", 9 => "JS", -); +]; $gBitSmarty->assign( "feedFormat", $feedFormat ); // Load up the board or topic @@ -40,7 +40,7 @@ if( !empty( $_REQUEST['get_feed'] ) ) { $feedlink['url'] .= 't='.$_REQUEST['t']."&"; }elseif( !empty($_REQUEST['b'] ) ){ $feedlink['url'] .= 'b='.$_REQUEST['b']."&"; - } + } } $feedlink['url'] .= 'version='.$_REQUEST['format'].( $gBitSystem->getConfig( 'rssfeed_httpauth' ) && $gBitUser->isRegistered()?'&httpauth=y':''); $feedlink['title'] = ( $gContent->getField('title') != null ?$gContent->getField('title'):tra('Boards')).' - '.$feedFormat[$_REQUEST['format']]; @@ -51,4 +51,4 @@ if( !empty( $_REQUEST['get_feed'] ) ) { $gBitSmarty->assign( 'feedlink', $feedlink ); -$gBitSystem->display( 'bitpackage:boards/boards_rss_form.tpl', KernelTools::tra( 'Select Feed' ) , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:boards/boards_rss_form.tpl', KernelTools::tra( 'Select Feed' ) , [ 'display_mode' => 'display' ]); diff --git a/templates/ajax.tpl b/templates/ajax.tpl index 599467a..599467a 100644..100755 --- a/templates/ajax.tpl +++ b/templates/ajax.tpl diff --git a/topic_move.php b/topic_move.php index a1a8415..8aa266d 100755 --- a/topic_move.php +++ b/topic_move.php @@ -48,5 +48,5 @@ $gBitSmarty->assign('boards', $boards); $gBitSmarty->assign('fromBoardId', $board->mContentId); -$gBitSystem->display( 'bitpackage:boards/topic_move.tpl', tra('Move Topic').':'.$gContent->getTitle(), array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:boards/topic_move.tpl', tra('Move Topic').':'.$gContent->getTitle(), [ 'display_mode' => 'display' ]); ?> |
