diff options
author | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-04-07 15:22:15 +0000 |
---|---|---|
committer | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-04-07 15:22:15 +0000 |
commit | a2c037bb699f58e1c39e0f8bccbceb4831e89423 (patch) | |
tree | 16c3bac5e7cb3b80950dec1ab410b3efa6e642ec /mod/blog | |
parent | 5a3546a65d86636b0bfb7033aaede7ecf693f1f9 (diff) | |
download | elgg-a2c037bb699f58e1c39e0f8bccbceb4831e89423.tar.gz elgg-a2c037bb699f58e1c39e0f8bccbceb4831e89423.tar.bz2 |
Creating content for the blog posts of user's friends.
git-svn-id: http://code.elgg.org/elgg/trunk@5648 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog')
-rw-r--r-- | mod/blog/blog_lib.php | 59 | ||||
-rw-r--r-- | mod/blog/languages/en.php | 11 | ||||
-rw-r--r-- | mod/blog/start.php | 10 | ||||
-rw-r--r-- | mod/blog/views/default/object/blog.php | 2 |
4 files changed, 65 insertions, 17 deletions
diff --git a/mod/blog/blog_lib.php b/mod/blog/blog_lib.php index 28c044c6b..83afab872 100644 --- a/mod/blog/blog_lib.php +++ b/mod/blog/blog_lib.php @@ -116,10 +116,16 @@ function blog_get_page_content_edit($guid, $revision = NULL) { * @param unknown_type $lower * @param unknown_type $upper */ -function blog_get_page_content_archive($owner_guid, $lower, $upper) { +function blog_get_page_content_archive($owner_guid, $lower=0, $upper=0) { + global $CONFIG; + $now = time(); - $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog')); + $content = elgg_view('page_elements/content_header', array( + 'context' => $context, + 'type' => 'blog', + 'all_link' => "{$CONFIG->site->url}pg/blog" + )); if ($lower) { $lower = (int)$lower; @@ -176,6 +182,55 @@ function blog_get_page_content_archive($owner_guid, $lower, $upper) { } /** + * Returns a view of the user's friend's posts. + * + * @param int $user_guid + * @return string + */ +function blog_get_page_content_friends($user_guid) { + global $CONFIG; + + elgg_push_breadcrumb(elgg_echo('blog:friends')); + + $content = elgg_view('page_elements/content_header', array( + 'context' => $context, + 'type' => 'blog', + 'all_link' => "{$CONFIG->site->url}pg/blog" + )); + + if (!$friends = get_user_friends($user_guid, ELGG_ENTITIES_ANY_VALUE, 0)) { + $content .= elgg_echo('blog:no_friends'); + } else { + $options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'full_view' => FALSE, + 'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int'), + ); + + foreach ($friends as $friend) { + $options['container_guids'][] = $friend->getGUID(); + } + + // admin / owners can see any posts + // everyone else can only see published posts + if (!(isadminloggedin() || (isloggedin() && $owner_guid == get_loggedin_userid()))) { + if ($upper > $now) { + $upper = $now; + } + + $options['metadata_name_value_pairs'][] = array( + array('name' => 'status', 'value' => 'published') + ); + } + + $content .= elgg_list_entities_from_metadata($options); + } + + return array('content' => $content); +} + +/** * Returns an appropriate excerpt for a blog. * * @param string $text diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php index 442a74069..f005dbf4c 100644 --- a/mod/blog/languages/en.php +++ b/mod/blog/languages/en.php @@ -1,20 +1,17 @@ <?php /** - * Blog English langauge file. + * Blog English language file. * */ $english = array( 'blog' => 'Blogs', - 'item:object:blog' => 'Blog', 'blog:blogs' => 'Blogs', 'blog:owned_blogs' => '%s', 'blog:revisions' => 'Revisions', 'blog:archives' => 'Archives', 'blog:blog' => 'Blog', - 'blog:yours' => 'Your blog', - 'blog:all' => 'All blogs', 'blog:friends' => 'Friends\' blogs', 'blog:title:user_blogs' => '%s\'s Blogs', @@ -33,11 +30,9 @@ $english = array( 'blog:status' => 'Status', 'blog:status:draft' => 'Draft', 'blog:status:published' => 'Published', - 'blog:status:unsaved_draft' => 'Recovered Draft', 'blog:revision' => 'Revision', 'blog:auto_saved_revision' => 'Auto Saved Revision', - 'blog:owner_title' => '%s\'s blogs', // messages 'blog:message:saved' => 'Blog post saved.', @@ -49,8 +44,6 @@ $english = array( // river 'blog:river:create' => '%s wrote a new blog post', - - ); -add_translation('en', $english);
\ No newline at end of file +add_translation('en', $english); diff --git a/mod/blog/start.php b/mod/blog/start.php index 06d7299f8..a04d5d0bb 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -123,22 +123,22 @@ function blog_page_handler($page) { case 'new': case 'edit': - //$sidebar = elgg_view('blog/sidebar_edit', array('blog_guid' => $page2)); + $title = elgg_echo('blog:edit'); $content_info = blog_get_page_content_edit($page2, $page3); break; case 'archive': + $title = elgg_echo('blog:archives'); $content_info = blog_get_page_content_archive($user->getGUID(), $page2, $page3); break; case 'friends': - //@todo make it go - $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); - $content .= blog_get_page_content_archive($user->getGUID()); + $title = elgg_echo('blog:friends'); + $content_info = blog_get_page_content_friends($user->getGUID()); break; default: - forward("pg/blog/{$username}/read/"); + forward("pg/blog/$username/read/"); break; } } else { diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php index 0fcd1e6e4..4b72cdc47 100644 --- a/mod/blog/views/default/object/blog.php +++ b/mod/blog/views/default/object/blog.php @@ -66,7 +66,7 @@ if ($full) { $comments = ''; } $like = elgg_view_likes($blog); - $owner_title = sprintf(elgg_echo('blog:owner_title'), $owner->name); + $owner_title = sprintf(elgg_echo('blog:title:user_blogs'), $owner->name); echo <<<___END <div class="blogpost clearfloat"> |