]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Creating content for the blog posts of user's friends.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 7 Apr 2010 15:22:15 +0000 (15:22 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 7 Apr 2010 15:22:15 +0000 (15:22 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5648 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/blog_lib.php
mod/blog/languages/en.php
mod/blog/start.php
mod/blog/views/default/object/blog.php

index 28c044c6b367b40c57c7a4dff2395da75c79682a..83afab87200399cea88d9a86916a1367e902a060 100644 (file)
@@ -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;
@@ -175,6 +181,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.
  *
index 442a74069e8e466b3d971a6fdfe5122630a65131..f005dbf4cd04bca6d7877489384bb38acc7fd8c9 100644 (file)
@@ -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);
index 06d7299f8dc0db35e802de00b716590043b6729c..a04d5d0bbb84593167e2a2b49f550db82e807405 100644 (file)
@@ -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 {
index 0fcd1e6e4fb1c037cf69520249f24bd390f08e51..4b72cdc47688c88c64cb1c85013b85bfb0fbb305 100644 (file)
@@ -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">