From f153346086d1bd206a2d5a26647980b87c50a631 Mon Sep 17 00:00:00 2001 From: "spider@dav" Date: Tue, 13 May 2025 15:35:49 -0400 Subject: cleanup for PHP8 and new bw includes layout --- FeedStatus.php | 66 --------------- feed_lib.php | 175 ---------------------------------------- includes/classes/FeedStatus.php | 66 +++++++++++++++ includes/feed_lib.php | 175 ++++++++++++++++++++++++++++++++++++++++ index.php | 2 +- modules/mod_feed.php | 2 +- modules/mod_status.php | 2 +- 7 files changed, 244 insertions(+), 244 deletions(-) delete mode 100644 FeedStatus.php delete mode 100644 feed_lib.php create mode 100644 includes/classes/FeedStatus.php create mode 100644 includes/feed_lib.php diff --git a/FeedStatus.php b/FeedStatus.php deleted file mode 100644 index 8edf1be..0000000 --- a/FeedStatus.php +++ /dev/null @@ -1,66 +0,0 @@ -mViewContentPerm = 'p_boards_read'; - $this->mUpdateContentPerm = 'p_boards_post_update'; - $this->mAdminContentPerm = 'p_boards_admin'; -*/ - - $this->mContentTypeGuid = FEEDSTATUS_CONTENT_TYPE_GUID; - $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, array( - 'content_type_guid' => FEEDSTATUS_CONTENT_TYPE_GUID, - 'content_name' => 'Feed Status', - 'handler_class' => 'FeedStatus', - 'handler_package' => 'feed', - 'handler_file' => 'FeedStatus.php', - 'maintainer_url' => 'http://www.bitweaver.org' - ) ); -/* - $this->mViewContentPerm = 'p_loc_view'; - $this->mCreateContentPerm = 'p_loc_edit'; - $this->mUpdateContentPerm = 'p_loc_edit'; - $this->mAdminContentPerm = 'p_loc_admin'; -*/ - } - - function getThumbnailUrl($pSize = 'avatar', $pInfoHash = NULL){ - $rootUser = new BitUser(NULL,$this->mInfo['root_id']); - $rootUser->load(); - $thumbnailUrl = $rootUser->getThumbnailUrl( $pSize ); - if( empty ($thumbnailUrl) ){ - $thumbnailUrl = USERS_PKG_URL.'icons/silhouette.png'; - } - return $thumbnailUrl; - } - -} -?> diff --git a/feed_lib.php b/feed_lib.php deleted file mode 100644 index fcfb7d8..0000000 --- a/feed_lib.php +++ /dev/null @@ -1,175 +0,0 @@ -query( $query, $bindVars, $pListHash['max_records'] ); - $conjugationQuery = "SELECT * FROM feed_conjugation"; - $overrides = $gBitDb->getAssoc( $conjugationQuery ); - - $actions = array(); - - //loop through directed actions - while ( $action = $res->fetchRow() ){ - if( !empty($action['content_id']) ) { //indicates that this isn't a direct action, more of a "status update" ex. "Ronald is pleased with his artwork" - if( $content = LibertyContent::getLibertyObject($action['content_id']) ) { - $contentType = $content->getContentType(); - $action['real_log'] = BitUser::getDisplayNameFromHash( empty( $pListHash['no_link_user'] ), $action ).' '; - if(!empty($overrides[strtolower($contentType)])){ - $action['real_log'] .= $overrides[$contentType]['conjugation_phrase']; - if($overrides[$contentType]['is_target_linked'] == 'y'){ - $action['real_log'] .= ' '.$content->getTitle().''; - } - if( !empty( $overrides[$contentType]['feed_icon_url'] ) ) { - $action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url']; - } - }else{ - $action['real_log'] .= tra( 'edited' ).' '.$content->getTitle().''; - } - } else { - unset( $action ); //invalid content_id - } - - if( empty( $action['feed_icon_url'] ) ) { - $action['feed_icon_url'] = FEED_PKG_URL.'icons/pixelmixerbasic/pencil_16.png'; - } - - $actions[] = $action; - } - } - - return $actions; -} - -function feed_get_status( $pListHash ){ - - global $gBitDb; - - $whereSql = ''; - $bindVars = array(); - $statuses = array(); - - BitBase::prepGetList( $pListHash ); - if( !empty( $pListHash['user_id'] ) ) { - $whereSql = " WHERE lal.user_id = ? "; - $bindVars[] = $pListHash['user_id']; - }else{ - $whereSql = "WHERE 1=1 "; - } - - $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, lc.data, uu.login, uu.real_name, uu.email - FROM liberty_action_log lal - INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id) - INNER JOIN liberty_comments lcs ON (lcs.content_id = lc.content_id) - INNER JOIN users_users uu ON (uu.user_id=lal.user_id) - $whereSql AND lc.content_type_guid = 'feedstatus' - GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message,lc.data - ORDER BY MAX(lal.last_modified) DESC"; - - $res = $gBitDb->query( $query, $bindVars, $pListHash['max_records'] ); - - $user = new BitUser($pListHash['user_id']); - $user->load(); - - - while ( $status = $res->fetchRow() ){ - $avatarUrl = $user->getThumbnailUrl(); - if(empty($avatarUrl)){ - $avatarUrl = USERS_PKG_URI."icons/silhouette.png"; - } - - $status['feed_icon_url'] = $avatarUrl; - - $comment = new LibertyComment(NULL,$status['content_id']); - $replies = $comment->getComments($status['content_id'],null,null,'commentDate_asc'); - $status['replies'] = $replies; - - foreach ( $status['replies'] as &$reply ){ - $replyUser = new BitUser($reply['user_id']); - $replyUser->load(); - $replyAvatarUrl = $replyUser->getThumbnailUrl(); - if(empty($replyAvatarUrl)){ - $replyAvatarUrl = USERS_PKG_URI."icons/silhouette.png"; - } - $reply['feed_icon_url'] = $replyAvatarUrl; - - } - //after loading up the thumbnails in the prior array layout for ease, we break up the array to split long comment threads - $MAX_SHOWN_REPLIES = 3; - if ( count( $status['replies'] ) > $MAX_SHOWN_REPLIES ){ - $maxIteration = count( $status['replies'] ) - $MAX_SHOWN_REPLIES; - $i = 0; - foreach( $status['replies'] as $excess ){ - if($i < $maxIteration){ - $status['replies_excess'][$excess['content_id']] = $excess; //use content_id to index for consistency with normal replies array - unset($status['replies'][$excess['content_id']]); //remove from the normal replies array - }else{ - break; - } - $i++; - } - } - $statuses[] = $status; - } - - return $statuses; -} - -function feed_get_status_and_actions( $pParamHash ) { - - -} - -function feed_set_status( $pParamHash ){ - - global $gBitDb; - - require_once ('FeedStatus.php'); - - $status = new FeedStatus(); - - global $gBitUser; - - $pParamHash['root_id'] = $gBitUser->mContentId; - $pParamHash['parent_id'] = $gBitUser->mContentId; - - $pParamHash['comment_data'] = $pParamHash['status_message']; - $pParamHash['title'] = substr($pParamHash['status_message'],0,20); - - $status->storeComment($pParamHash); - -} - - -?> diff --git a/includes/classes/FeedStatus.php b/includes/classes/FeedStatus.php new file mode 100644 index 0000000..8edf1be --- /dev/null +++ b/includes/classes/FeedStatus.php @@ -0,0 +1,66 @@ +mViewContentPerm = 'p_boards_read'; + $this->mUpdateContentPerm = 'p_boards_post_update'; + $this->mAdminContentPerm = 'p_boards_admin'; +*/ + + $this->mContentTypeGuid = FEEDSTATUS_CONTENT_TYPE_GUID; + $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, array( + 'content_type_guid' => FEEDSTATUS_CONTENT_TYPE_GUID, + 'content_name' => 'Feed Status', + 'handler_class' => 'FeedStatus', + 'handler_package' => 'feed', + 'handler_file' => 'FeedStatus.php', + 'maintainer_url' => 'http://www.bitweaver.org' + ) ); +/* + $this->mViewContentPerm = 'p_loc_view'; + $this->mCreateContentPerm = 'p_loc_edit'; + $this->mUpdateContentPerm = 'p_loc_edit'; + $this->mAdminContentPerm = 'p_loc_admin'; +*/ + } + + function getThumbnailUrl($pSize = 'avatar', $pInfoHash = NULL){ + $rootUser = new BitUser(NULL,$this->mInfo['root_id']); + $rootUser->load(); + $thumbnailUrl = $rootUser->getThumbnailUrl( $pSize ); + if( empty ($thumbnailUrl) ){ + $thumbnailUrl = USERS_PKG_URL.'icons/silhouette.png'; + } + return $thumbnailUrl; + } + +} +?> diff --git a/includes/feed_lib.php b/includes/feed_lib.php new file mode 100644 index 0000000..2f4f949 --- /dev/null +++ b/includes/feed_lib.php @@ -0,0 +1,175 @@ +query( $query, $bindVars, $pListHash['max_records'] ); + $conjugationQuery = "SELECT * FROM feed_conjugation"; + $overrides = $gBitDb->getAssoc( $conjugationQuery ); + + $actions = array(); + + //loop through directed actions + while ( $action = $res->fetchRow() ){ + if( !empty($action['content_id']) ) { //indicates that this isn't a direct action, more of a "status update" ex. "Ronald is pleased with his artwork" + if( $content = LibertyContent::getLibertyObject($action['content_id']) ) { + $contentType = $content->getContentType(); + $action['real_log'] = BitUser::getDisplayNameFromHash( $action, empty( $pListHash['no_link_user'] ) ).' '; + if(!empty($overrides[strtolower($contentType)])){ + $action['real_log'] .= $overrides[$contentType]['conjugation_phrase']; + if($overrides[$contentType]['is_target_linked'] == 'y'){ + $action['real_log'] .= ' '.$content->getTitle().''; + } + if( !empty( $overrides[$contentType]['feed_icon_url'] ) ) { + $action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url']; + } + }else{ + $action['real_log'] .= tra( 'edited' ).' '.$content->getTitle().''; + } + } else { + unset( $action ); //invalid content_id + } + + if( empty( $action['feed_icon_url'] ) ) { + $action['feed_icon_url'] = FEED_PKG_URL.'icons/pixelmixerbasic/pencil_16.png'; + } + + $actions[] = $action; + } + } + + return $actions; +} + +function feed_get_status( $pListHash ){ + + global $gBitDb; + + $whereSql = ''; + $bindVars = array(); + $statuses = array(); + + BitBase::prepGetList( $pListHash ); + if( !empty( $pListHash['user_id'] ) ) { + $whereSql = " WHERE lal.user_id = ? "; + $bindVars[] = $pListHash['user_id']; + }else{ + $whereSql = "WHERE 1=1 "; + } + + $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, lc.data, uu.login, uu.real_name, uu.email + FROM liberty_action_log lal + INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id) + INNER JOIN liberty_comments lcs ON (lcs.content_id = lc.content_id) + INNER JOIN users_users uu ON (uu.user_id=lal.user_id) + $whereSql AND lc.content_type_guid = 'feedstatus' + GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message,lc.data + ORDER BY MAX(lal.last_modified) DESC"; + + $res = $gBitDb->query( $query, $bindVars, $pListHash['max_records'] ); + + $user = new BitUser($pListHash['user_id']); + $user->load(); + + + while ( $status = $res->fetchRow() ){ + $avatarUrl = $user->getThumbnailUrl(); + if(empty($avatarUrl)){ + $avatarUrl = USERS_PKG_URI."icons/silhouette.png"; + } + + $status['feed_icon_url'] = $avatarUrl; + + $comment = new LibertyComment(NULL,$status['content_id']); + $replies = $comment->getComments($status['content_id'],null,null,'commentDate_asc'); + $status['replies'] = $replies; + + foreach ( $status['replies'] as &$reply ){ + $replyUser = new BitUser($reply['user_id']); + $replyUser->load(); + $replyAvatarUrl = $replyUser->getThumbnailUrl(); + if(empty($replyAvatarUrl)){ + $replyAvatarUrl = USERS_PKG_URI."icons/silhouette.png"; + } + $reply['feed_icon_url'] = $replyAvatarUrl; + + } + //after loading up the thumbnails in the prior array layout for ease, we break up the array to split long comment threads + $MAX_SHOWN_REPLIES = 3; + if ( count( $status['replies'] ) > $MAX_SHOWN_REPLIES ){ + $maxIteration = count( $status['replies'] ) - $MAX_SHOWN_REPLIES; + $i = 0; + foreach( $status['replies'] as $excess ){ + if($i < $maxIteration){ + $status['replies_excess'][$excess['content_id']] = $excess; //use content_id to index for consistency with normal replies array + unset($status['replies'][$excess['content_id']]); //remove from the normal replies array + }else{ + break; + } + $i++; + } + } + $statuses[] = $status; + } + + return $statuses; +} + +function feed_get_status_and_actions( $pParamHash ) { + + +} + +function feed_set_status( $pParamHash ){ + + global $gBitDb; + + require_once ( FEED_PKG_CLASSES_PATH.'FeedStatus.php'); + + $status = new FeedStatus(); + + global $gBitUser; + + $pParamHash['root_id'] = $gBitUser->mContentId; + $pParamHash['parent_id'] = $gBitUser->mContentId; + + $pParamHash['comment_data'] = $pParamHash['status_message']; + $pParamHash['title'] = substr($pParamHash['status_message'],0,20); + + $status->storeComment($pParamHash); + +} + + +?> diff --git a/index.php b/index.php index 354f54e..2e1f7d1 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ // +----------------------------------------------------------------------+ require_once( '../kernel/includes/setup_inc.php' ); -require_once( FEED_PKG_PATH.'feed_lib.php' ); +require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' ); $gBitSystem->verifyPermission( 'p_feed_master' ); $listHash['max_records'] = 100; diff --git a/modules/mod_feed.php b/modules/mod_feed.php index 494522b..7c7584c 100644 --- a/modules/mod_feed.php +++ b/modules/mod_feed.php @@ -14,7 +14,7 @@ */ global $gQueryUser,$gBitSmarty; -require_once( FEED_PKG_PATH.'feed_lib.php' ); +require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' ); if( !empty($gQueryUser) ){ diff --git a/modules/mod_status.php b/modules/mod_status.php index d1f619b..ceb2785 100644 --- a/modules/mod_status.php +++ b/modules/mod_status.php @@ -14,7 +14,7 @@ */ global $gQueryUser,$gBitSmarty; -require_once( FEED_PKG_PATH.'feed_lib.php' ); +require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' ); if( !empty( $_REQUEST['feed_status'] ) ){ -- cgit v1.3