diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-23 21:38:14 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-23 21:38:14 +0000 |
commit | 9d2a1831b574d517592c0345fdf5aa173fcd42d7 (patch) | |
tree | ed21825a7efd41e89a00792861fc84ee098db995 /mod/blog/blog_lib.php | |
parent | df750ff4e9e069aff6cf9e5ada55ae0696c1e77b (diff) | |
download | elgg-9d2a1831b574d517592c0345fdf5aa173fcd42d7.tar.gz elgg-9d2a1831b574d517592c0345fdf5aa173fcd42d7.tar.bz2 |
Added filtering by archive date.
git-svn-id: http://code.elgg.org/elgg/trunk@5490 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/blog_lib.php')
-rw-r--r-- | mod/blog/blog_lib.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/mod/blog/blog_lib.php b/mod/blog/blog_lib.php index 6f52e53ec..7f83d0dc3 100644 --- a/mod/blog/blog_lib.php +++ b/mod/blog/blog_lib.php @@ -98,6 +98,72 @@ function blog_get_page_content_edit($guid, $revision = NULL) { } /** + * Show blogs with publish dates between $lower and $upper + * + * @param unknown_type $owner_guid + * @param unknown_type $lower + * @param unknown_type $upper + */ +function blog_get_page_content_archive($owner_guid, $lower, $upper) { + $now = time(); + + $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog')); + + if ($lower) { + $lower = (int)$lower; + } + + if ($upper) { + $upper = (int)$upper; + } + + $options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'full_view' => FALSE, + 'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int'), + ); + + if ($owner_guid) { + $options['owner_guid'] = $owner_guid; + } + + // 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') + ); + } + + if ($lower) { + $options['metadata_name_value_pairs'][] = array( + 'name' => 'publish_date', + 'operand' => '>', + 'value' => $lower + ); + } + + if ($upper) { + $options['metadata_name_value_pairs'][] = array( + 'name' => 'publish_date', + 'operand' => '<', + 'value' => $upper + ); + } + + $content .= elgg_list_entities_from_metadata($options); + + return array( + 'content' => $content + ); +} + +/** * Returns an appropriate excerpt for a blog. * * @param string $text |