summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]admin/admin_feed_inc.php7
-rwxr-xr-x[-rw-r--r--]admin/schema_inc.php24
-rwxr-xr-x[-rw-r--r--]includes/bit_setup_inc.php18
-rwxr-xr-x[-rw-r--r--]includes/classes/FeedStatus.php18
-rw-r--r--includes/feed_lib.php30
-rwxr-xr-x[-rw-r--r--]index.php5
-rwxr-xr-x[-rw-r--r--]modules/mod_feed.php15
-rwxr-xr-x[-rw-r--r--]modules/mod_status.php20
-rw-r--r--modules/mod_status.tpl2
-rwxr-xr-x[-rw-r--r--]templates/center_feed.php10
-rw-r--r--templates/menu_feed.tpl2
-rw-r--r--templates/menu_feed_admin.tpl2
12 files changed, 71 insertions, 82 deletions
diff --git a/admin/admin_feed_inc.php b/admin/admin_feed_inc.php
index 86115c1..b3e2512 100644..100755
--- a/admin/admin_feed_inc.php
+++ b/admin/admin_feed_inc.php
@@ -2,7 +2,6 @@
global $gBitSmarty;
-
$contentTypes = get_content_types();
if( !empty( $_REQUEST['store_feed'] ) ) {
@@ -13,14 +12,14 @@ if( !empty( $_REQUEST['store_feed'] ) ) {
foreach ( array_keys( $contentTypes ) as $type ){
if( !empty( $_REQUEST[$type]['conjugation_phrase'] ) || !empty( $_REQUEST[$type]['is_target_linked'] ) ) {
$insertSql = "INSERT INTO feed_conjugation (content_type_guid, conjugation_phrase, is_target_linked) VALUES ( ?, ?, ?)";
- $gBitDb->query($insertSql, array( $type, $_REQUEST[$type]['conjugation_phrase'], empty($_REQUEST[$type]['is_target_linked'])?'y' : NULL ) );
+ $gBitDb->query($insertSql, array( $type, $_REQUEST[$type]['conjugation_phrase'], empty($_REQUEST[$type]['is_target_linked'])?'y' : null ) );
}
}
}
$contentTypes = get_content_types();
-$gBitSmarty->assignByRef('contentTypes',$contentTypes);
+$gBitSmarty->assign('contentTypes',$contentTypes);
@@ -31,5 +30,3 @@ function get_content_types(){
return $contentTypes;
}
-
-?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index d1b38f2..d61d542 100644..100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,5 +1,5 @@
<?php
-$tables = array(
+$tables = [
'feed_conjugation' => "
content_type_guid C(16) NOTNULL,
conjugation_phrase C(255) NOTNULL,
@@ -7,7 +7,7 @@ $tables = array(
is_target_linked C(1)
"
// CONSTRAINT ', CONSTRAINT `feed_conj_content_type_ref` FOREIGN KEY (`content_type_guid`) REFERENCES `".BIT_DB_PREFIX."liberty_content_types` ( `content_type_guid` )'
-);
+];
global $gBitInstaller;
@@ -15,21 +15,19 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( FEED_PKG_NAME, $tableName, $tables[$tableName] );
}
-$gBitInstaller->registerSchemaDefault( FEED_PKG_NAME, array(
+$gBitInstaller->registerSchemaDefault( FEED_PKG_NAME, [
"INSERT INTO `".BIT_DB_PREFIX."feed_conjugation` (`content_type_guid`, `conjugation_phrase`, `is_target_linked`,`feed_icon_url`) VALUES ('bituser', 'updated their profile', 'y','".FEED_PKG_URL."icons/pixelmixerbasic/user_16.png')",
"INSERT INTO `".BIT_DB_PREFIX."feed_conjugation` (`content_type_guid`,`conjugation_phrase`,`is_target_linked`,`feed_icon_url`) VALUES ('bitcomment','commented','y','".FEED_PKG_URL."icons/pixelmixerbasic/bubble_16.png')",
-));
+] );
-$gBitInstaller->registerPackageInfo( FEED_PKG_NAME, array(
+$gBitInstaller->registerPackageInfo( FEED_PKG_NAME, [
'description' => "User feed package that makes use of Liberty action log",
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
-) );
+] );
// ### Default UserPermissions
-$gBitInstaller->registerUserPermissions( FEED_PKG_NAME, array(
- array( 'p_feed_admin', 'Can admin feeds', 'admin', FEED_PKG_NAME ),
- array( 'p_feed_master', 'Can view master feed', 'registered', FEED_PKG_NAME ),
- array( 'p_feed_view', 'Can view feed', 'basic', FEED_PKG_NAME ),
-) );
-
-?>
+$gBitInstaller->registerUserPermissions( FEED_PKG_NAME, [
+ [ 'p_feed_admin', 'Can admin feeds', 'admin', FEED_PKG_NAME ],
+ [ 'p_feed_master', 'Can view master feed', 'registered', FEED_PKG_NAME ],
+ [ 'p_feed_view', 'Can view feed', 'basic', FEED_PKG_NAME ],
+] );
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index bcfb0c5..65525f5 100644..100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -1,23 +1,25 @@
<?php
+namespace Bitweaver\Feed;
+
global $gBitSystem, $gBitUser, $gBitThemes;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'feed',
'package_path' => dirname( dirname( __FILE__ ) ).'/',
-);
-
-$gBitSystem->registerPackage( $registerHash );
+];
+define( 'FEED_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'FEED_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/');
+define( 'FEED_PKG_INCLUDE_URL', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+$gBitSystem->registerPackage( $pRegisterHash );
if( $gBitSystem->isPackageActive( 'feed' ) ) {
if( $gBitUser->hasPermission( 'p_feed_view' )) {
- $menuHash = array(
+ $menuHash = [
'package_name' => FEED_PKG_NAME,
'index_url' => FEED_PKG_URL.'index.php',
'menu_template' => 'bitpackage:feed/menu_feed.tpl',
- );
+ ];
$gBitSystem->registerAppMenu( $menuHash );
}
}
-
-?>
diff --git a/includes/classes/FeedStatus.php b/includes/classes/FeedStatus.php
index 8edf1be..a079a04 100644..100755
--- a/includes/classes/FeedStatus.php
+++ b/includes/classes/FeedStatus.php
@@ -11,11 +11,12 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' );
+namespace Bitweaver\Feed;
+use Bitweaver\Liberty\LibertyComment;
+use Bitweaver\Users\RoleUser;
define( 'FEEDSTATUS_CONTENT_TYPE_GUID','feedstatus');
-
/**
* FeedStatus
* @package feed
@@ -25,7 +26,7 @@ class FeedStatus extends LibertyComment {
/**
* During initialisation, be sure to call our base constructors
**/
- function FeedStatus($pCommentId = NULL, $pContentId = NULL, $pInfo = NULL) {
+ public function FeedStatus($pCommentId = null, $pContentId = null, $pInfo = null) {
LibertyComment::LibertyComment($pCommentId,$pContentId,$pInfo);
@@ -36,14 +37,14 @@ class FeedStatus extends LibertyComment {
*/
$this->mContentTypeGuid = FEEDSTATUS_CONTENT_TYPE_GUID;
- $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, array(
+ $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, [
'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';
@@ -52,15 +53,14 @@ class FeedStatus extends LibertyComment {
*/
}
- function getThumbnailUrl($pSize = 'avatar', $pInfoHash = NULL){
- $rootUser = new BitUser(NULL,$this->mInfo['root_id']);
+ public function getThumbnailUrl( string $pSize = 'avatar', ?array $pInfoHash = null, ?int $pSecondaryId = null, ?int $pDefault = null ): string|null {
+ $rootUser = new RoleUser(null,$this->mInfo['root_id']);
$rootUser->load();
$thumbnailUrl = $rootUser->getThumbnailUrl( $pSize );
if( empty ($thumbnailUrl) ){
- $thumbnailUrl = USERS_PKG_URL.'icons/silhouette.png';
+ $thumbnailUrl = USERS_PKG_PATH.'icons/silhouette.png';
}
return $thumbnailUrl;
}
}
-?>
diff --git a/includes/feed_lib.php b/includes/feed_lib.php
index 2f4f949..e4766c2 100644
--- a/includes/feed_lib.php
+++ b/includes/feed_lib.php
@@ -12,11 +12,18 @@
/**
* feed_get_actions
*/
+namespace Bitweaver\Feed;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\Liberty\LibertyComment;
+use Bitweaver\Users\RoleUser;
+
function feed_get_actions( $pListHash ) {
global $gBitDb;
$whereSql = '';
- $bindVars = array();
+ $bindVars = [];
BitBase::prepGetList( $pListHash );
if( !empty( $pListHash['user_id'] ) ) {
@@ -38,14 +45,14 @@ function feed_get_actions( $pListHash ) {
$conjugationQuery = "SELECT * FROM feed_conjugation";
$overrides = $gBitDb->getAssoc( $conjugationQuery );
- $actions = array();
+ $actions = [];
//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'] ) ).' ';
+ $action['real_log'] = RoleUser::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'){
@@ -55,7 +62,7 @@ function feed_get_actions( $pListHash ) {
$action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url'];
}
}else{
- $action['real_log'] .= tra( 'edited' ).' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>';
+ $action['real_log'] .= KernelTools::tra( 'edited' ).' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>';
}
} else {
unset( $action ); //invalid content_id
@@ -77,8 +84,8 @@ function feed_get_status( $pListHash ){
global $gBitDb;
$whereSql = '';
- $bindVars = array();
- $statuses = array();
+ $bindVars = [];
+ $statuses = [];
BitBase::prepGetList( $pListHash );
if( !empty( $pListHash['user_id'] ) ) {
@@ -99,7 +106,7 @@ function feed_get_status( $pListHash ){
$res = $gBitDb->query( $query, $bindVars, $pListHash['max_records'] );
- $user = new BitUser($pListHash['user_id']);
+ $user = new RoleUser($pListHash['user_id']);
$user->load();
@@ -111,12 +118,12 @@ function feed_get_status( $pListHash ){
$status['feed_icon_url'] = $avatarUrl;
- $comment = new LibertyComment(NULL,$status['content_id']);
+ $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 = new RoleUser($reply['user_id']);
$replyUser->load();
$replyAvatarUrl = $replyUser->getThumbnailUrl();
if(empty($replyAvatarUrl)){
@@ -155,8 +162,6 @@ function feed_set_status( $pParamHash ){
global $gBitDb;
- require_once ( FEED_PKG_CLASSES_PATH.'FeedStatus.php');
-
$status = new FeedStatus();
global $gBitUser;
@@ -170,6 +175,3 @@ function feed_set_status( $pParamHash ){
$status->storeComment($pParamHash);
}
-
-
-?>
diff --git a/index.php b/index.php
index 2e1f7d1..3a5afbf 100644..100755
--- a/index.php
+++ b/index.php
@@ -12,9 +12,10 @@
// +----------------------------------------------------------------------+
// | Authors: spider <spider@steelsun.com>
// +----------------------------------------------------------------------+
+namespace Bitweaver\Feed;
-require_once( '../kernel/includes/setup_inc.php' );
-require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' );
+require_once '../kernel/includes/setup_inc.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 7c7584c..e515835 100644..100755
--- a/modules/mod_feed.php
+++ b/modules/mod_feed.php
@@ -12,26 +12,23 @@
/**
* global defs
*/
+namespace Bitweaver\Feed;
+
global $gQueryUser,$gBitSmarty;
-require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' );
+require_once FEED_PKG_INCLUDE_PATH . 'feed_lib.php';
if( !empty($gQueryUser) ){
if( !empty( $moduleParams['module_params']['no_link_user'] ) ) {
- $listHash['no_link_user'] = TRUE;
+ $listHash['no_link_user'] = true;
}
if( !empty( $moduleParams['module_rows'] ) ) {
$listHash['max_records'] = $moduleParams['module_rows'];
}
- if( !empty( $moduleParams['module_params']['user_id'] ) ){
- $listHash['user_id'] = $moduleParams['module_params']['user_id'];
- }else{
- $listHash['user_id'] = $gQueryUser->mUserId;
- }
+ $listHash['user_id'] = ( !empty( $moduleParams['module_params']['user_id'] ) ) ? $moduleParams['module_params']['user_id'] : $gQueryUser->mUserId;
$actions = feed_get_actions( $listHash );
- $_template->tpl_vars['actions'] = new Smarty_variable( $actions);
+ $gBitSmarty->assign( 'actions', $actions);
}
-?>
diff --git a/modules/mod_status.php b/modules/mod_status.php
index ceb2785..192617e 100644..100755
--- a/modules/mod_status.php
+++ b/modules/mod_status.php
@@ -12,9 +12,12 @@
/**
* global defs
*/
+namespace Bitweaver\Feed;
+use Bitweaver\Liberty\LibertyComment;
+
global $gQueryUser,$gBitSmarty;
-require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' );
+require_once FEED_PKG_INCLUDE_PATH . 'feed_lib.php';
if( !empty( $_REQUEST['feed_status'] ) ){
@@ -23,7 +26,7 @@ if( !empty( $_REQUEST['feed_status'] ) ){
}
if( !empty( $moduleParams['module_params']['no_link_user'] ) ) {
- $listHash['no_link_user'] = TRUE;
+ $listHash['no_link_user'] = true;
}
if( !empty( $moduleParams['module_rows'] ) ) {
$listHash['max_records'] = $moduleParams['module_rows'];
@@ -31,14 +34,10 @@ if( !empty( $moduleParams['module_rows'] ) ) {
$listHash['max_records'] = $moduleParams['module_params']['max_records'];
}
-if( !empty( $moduleParams['module_params']['user_id'] ) ){
- $listHash['user_id'] = $moduleParams['module_params']['user_id'];
-}else{
- $listHash['user_id'] = $gQueryUser->mUserId;
-}
+$listHash['user_id'] = ( !empty( $moduleParams['module_params']['user_id'] ) ) ? $moduleParams['module_params']['user_id'] : $gQueryUser->mUserId;
$statuses = feed_get_status( $listHash );
-$_template->tpl_vars['statuses'] = new Smarty_variable( $statuses);
+$gBitSmarty->assign( 'statuses', $statuses);
foreach ($statuses as $status){
@@ -57,10 +56,7 @@ foreach ($statuses as $status){
$statuses = feed_get_status( $listHash );
- $_template->tpl_vars['statuses'] = new Smarty_variable( $statuses);
+ $gBitSmarty->assign( 'statuses', $statuses);
break;
}
}
-
-?>
-
diff --git a/modules/mod_status.tpl b/modules/mod_status.tpl
index 3e1afc4..e8a8940 100644
--- a/modules/mod_status.tpl
+++ b/modules/mod_status.tpl
@@ -1,5 +1,5 @@
{literal}
-<script type="text/javascript">
+<script>
function showHideReplies( contentId , total , feedback ){
diff --git a/templates/center_feed.php b/templates/center_feed.php
index 21d87ec..82cd4e3 100644..100755
--- a/templates/center_feed.php
+++ b/templates/center_feed.php
@@ -1,12 +1,13 @@
<?php
+namespace Bitweaver\Feed;
global $gBitDb,$gQueryUser,$gBitSmarty;
-require_once( FEED_PKG_INCLUDE_PATH.'feed_lib.php' );
+require_once FEED_PKG_INCLUDE_PATH.'feed_lib.php';
if( !empty($gQueryUser) ){
if( !empty( $moduleParams['module_params']['no_link_user'] ) ) {
- $listHash['no_link_user'] = TRUE;
+ $listHash['no_link_user'] = true;
}
if( !empty( $moduleParams['module_rows'] ) ) {
$listHash['max_records'] = $moduleParams['module_rows'];
@@ -18,8 +19,3 @@ if( !empty($gQueryUser) ){
}
-
-
-
-
-?>
diff --git a/templates/menu_feed.tpl b/templates/menu_feed.tpl
index 34773be..6d442d5 100644
--- a/templates/menu_feed.tpl
+++ b/templates/menu_feed.tpl
@@ -1 +1 @@
-{if $packageMenuTitle}<a href="{$smarty.const.FEED_PKG_URL}">{tr}{$packageMenuTitle}{/tr}</a>{/if}
+{if !empty($packageMenuTitle)}<a href="{$smarty.const.FEED_PKG_URL}">{tr}{$packageMenuTitle}{/tr}</a>{/if}
diff --git a/templates/menu_feed_admin.tpl b/templates/menu_feed_admin.tpl
index 80b5b54..dc658a7 100644
--- a/templates/menu_feed_admin.tpl
+++ b/templates/menu_feed_admin.tpl
@@ -1,3 +1,3 @@
{strip}
-{if $packageMenuTitle}<a class="nosubmenu" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=feed">{tr}Feed{/tr}</a>{/if}
+{if !empty($packageMenuTitle)}<a class="nosubmenu" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=feed">{tr}Feed{/tr}</a>{/if}
{/strip}