aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/blog_lib.php
diff options
context:
space:
mode:
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-07 15:22:15 +0000
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-07 15:22:15 +0000
commita2c037bb699f58e1c39e0f8bccbceb4831e89423 (patch)
tree16c3bac5e7cb3b80950dec1ab410b3efa6e642ec /mod/blog/blog_lib.php
parent5a3546a65d86636b0bfb7033aaede7ecf693f1f9 (diff)
downloadelgg-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/blog_lib.php')
-rw-r--r--mod/blog/blog_lib.php59
1 files changed, 57 insertions, 2 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