diff options
| author | Tyler Bello <tylerbello@users.sourceforge.net> | 2009-08-25 19:14:44 +0000 |
|---|---|---|
| committer | Tyler Bello <tylerbello@users.sourceforge.net> | 2009-08-25 19:14:44 +0000 |
| commit | 304878f137e77f82a822fe82196a79d29ef6fb76 (patch) | |
| tree | a238f7d75944d11e2796574db3343ed77648d8d9 | |
| download | feed-304878f137e77f82a822fe82196a79d29ef6fb76.tar.gz feed-304878f137e77f82a822fe82196a79d29ef6fb76.tar.bz2 feed-304878f137e77f82a822fe82196a79d29ef6fb76.zip | |
Import feed package, makes use of liberty_action_log to implement a Facebook style feed display
| -rw-r--r-- | admin/admin_feed_inc.php | 31 | ||||
| -rw-r--r-- | admin/schema_inc.php | 32 | ||||
| -rwxr-xr-x | bit_setup_inc.php | 23 | ||||
| -rw-r--r-- | modules/mod_feed.php | 41 | ||||
| -rw-r--r-- | modules/mod_feed.tpl | 7 | ||||
| -rw-r--r-- | templates/admin_feed.tpl | 33 | ||||
| -rw-r--r-- | templates/menu_feed.tpl | 3 | ||||
| -rw-r--r-- | templates/menu_feed_admin.tpl | 5 |
8 files changed, 175 insertions, 0 deletions
diff --git a/admin/admin_feed_inc.php b/admin/admin_feed_inc.php new file mode 100644 index 0000000..530671f --- /dev/null +++ b/admin/admin_feed_inc.php @@ -0,0 +1,31 @@ +<?php + +global $gBitSmarty; + + +$contentTypes = get_content_types(); + +$deleteSql = "DELETE FROM feed_conjugation"; +$gBitDb->query($deleteSql); + +foreach ( $contentTypes as $type ){ + $insertSql = "INSERT INTO feed_conjugation (content_type_guid, conjugation_phrase, is_target_linked) VALUES ( ?, ?, ?)"; + $gBitDb->query($insertSql, array( $type['content_type_guid'], $_REQUEST[$type['content_type_guid']], empty($_REQUEST[$type['content_type_guid'].'_target'])?'t':'f' ) ); + } + +$contentTypes = get_content_types(); +$gBitSmarty->assign_by_ref('contentTypes',$contentTypes); + + + + + +function get_content_types(){ + global $gBitDb; + $selectSql = "SELECT lct.content_type_guid,conjugation_phrase, is_target_linked FROM liberty_content_types lct LEFT JOIN feed_conjugation fc ON (fc.content_type_guid = lct.content_type_guid)"; + $contentTypes = $gBitDb->getAll($selectSql); + return $contentTypes; + +} + +?> diff --git a/admin/schema_inc.php b/admin/schema_inc.php new file mode 100644 index 0000000..128a2b4 --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,32 @@ +<?php +$tables = array( + 'feed_conjugation' => " + content_type_guid C(16) NOTNULL, + conjugation_phrase C(255) NOTNULL, + 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; + +foreach( array_keys( $tables ) AS $tableName ) { + $gBitInstaller->registerSchemaTable( FEED_PKG_NAME, $tableName, $tables[$tableName] ); +} + +$gBitInstaller->registerSchemaDefault( FEED_PKG_NAME, array( + + "INSERT INTO `".BIT_DB_PREFIX."feed_conjugation` (`content_type_guid`, `conjugation_phrase`, `is_target_linked`) VALUES ('bituser', 'updated their profile', 'y')", +)); + +$gBitInstaller->registerPackageInfo( FEED_PKG_NAME, array( + '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( TAGS_PKG_NAME, array( + array( 'p_feed_admin', 'Can admin feeds', 'admin', FEED_PKG_NAME ), + array( 'p_feed_view', 'Can view feed', 'basic', FEED_PKG_NAME ), +) ); +?> diff --git a/bit_setup_inc.php b/bit_setup_inc.php new file mode 100755 index 0000000..e621277 --- /dev/null +++ b/bit_setup_inc.php @@ -0,0 +1,23 @@ +<?php +global $gBitSystem, $gBitUser, $gBitThemes; + +$registerHash = array( + 'package_name' => 'feed', + 'package_path' => dirname( __FILE__ ).'/', +// 'service' => LIBERTY_SERVICE_FEED, +); + +$gBitSystem->registerPackage( $registerHash ); + + +if( $gBitSystem->isPackageActive( 'feed' ) /*&& $gBitUser->hasPermission( 'p_tags_view' )*/) { + + $menuHash = array( + '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/modules/mod_feed.php b/modules/mod_feed.php new file mode 100644 index 0000000..f30fb03 --- /dev/null +++ b/modules/mod_feed.php @@ -0,0 +1,41 @@ +<?php + +global $gBitDb,$gQueryUser,$gBitSmarty; + +$selectSql = "SELECT user_id, content_id, log_message,last_modified FROM liberty_action_log WHERE user_id = ? ORDER BY last_modified DESC LIMIT 10"; +$selectSql2 = "SELECT * FROM feed_conjugation"; + + +if( !empty($gQueryUser) ){ + + $actions = $gBitDb->getAll( $selectSql, array( $gQueryUser->mUserId ) ); + $overrides = $gBitDb->getAssoc($selectSql2); + foreach( $actions as &$action ){ + + $content = LibertyContent::getLibertyObject($action['content_id']); + if( !empty($content) ){ + + $contentType = get_class($content); + + $action['real_log'] = '<a href="'.$gQueryUser->getDisplayUrl().'">'.$gQueryUser->mInfo['real_name'].'</a> '; + $action['real_log'].= strtolower($action['log_message']).' '; //This is the name of the core action that occured. Currently only "created or updated", which is weak + if(!empty($overrides[strtolower($contentType)])){ + $action['real_log'] .= $overrides[strtolower($contentType)]['conjugation_phrase']; + if($overrides[strtolower($contentType)]['is_target_linked'] == 't'){ + $action['real_log'] .= ' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>'; + } + }else{ + $action['real_log'] .= ' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>'; + } + } + } + + $gBitSmarty->assign( 'actions', $actions); + + +} + + + + +?> diff --git a/modules/mod_feed.tpl b/modules/mod_feed.tpl new file mode 100644 index 0000000..a7001f5 --- /dev/null +++ b/modules/mod_feed.tpl @@ -0,0 +1,7 @@ +<div class="span-8" style="margin-top:10px;"> + {foreach from=$actions item='action'} + <div> + {*{$action.icon}*} {$action.real_log} on {$action.last_modified|date_format} + </div> + {/foreach} +</div> diff --git a/templates/admin_feed.tpl b/templates/admin_feed.tpl new file mode 100644 index 0000000..8b47a3e --- /dev/null +++ b/templates/admin_feed.tpl @@ -0,0 +1,33 @@ +<div class="span-24"> + <div class="row"> + <div class="span-4"> + <h2>Content Description</h2> + </div> + + <div class="span-4"> + <h2>Feed Verb</h2> + </div> + <div class="span-4"> + <h2>Remove Target Link</h2> + </div> + </div> + <form action="{$smarty.const.KERNEL_PKG_URI}admin/index.php?page=feed" method="POST"> + + <input type="hidden" name="page" value="{$smarty.request.page}" /> + {foreach from=$contentTypes item='type'} + + <div class="row"> + <div class="span-4"> + {$type.content_type_guid} + </div> + <div class="span-4"> + <input type="text" name="{$type.content_type_guid|lower}" value="{$type.conjugation_phrase}"/>{*replace and lower to comply with BW url param standards*} + </div> + <div class="span-4"> + <input type="checkbox" name="{$type.content_type_guid|lower}_target" {if $type.is_target_linked == 'f'}checked='true'{/if} /> + </div> + </div> + {/foreach} + <input type="submit" value="Submit" /> + </form> +</div> diff --git a/templates/menu_feed.tpl b/templates/menu_feed.tpl new file mode 100644 index 0000000..fb86ae7 --- /dev/null +++ b/templates/menu_feed.tpl @@ -0,0 +1,3 @@ +{strip} +{*Put user options in here, such as ability to witthold feed messages*} +{/strip} diff --git a/templates/menu_feed_admin.tpl b/templates/menu_feed_admin.tpl new file mode 100644 index 0000000..5432298 --- /dev/null +++ b/templates/menu_feed_admin.tpl @@ -0,0 +1,5 @@ +{strip} +<ul> + <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=feed">{tr}Feed Settings{/tr}</a></li> +</ul> +{/strip} |
