aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/blog_lib.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-24 19:49:40 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-24 19:49:40 +0000
commit3b0b462b5790f15fcb612de66544838bdbce658b (patch)
tree6bd088104c04946c55f7496f5e678c5867ce17a0 /mod/blog/blog_lib.php
parentd47809ecb0dee997682fb53d220ef5377406a975 (diff)
downloadelgg-3b0b462b5790f15fcb612de66544838bdbce658b.tar.gz
elgg-3b0b462b5790f15fcb612de66544838bdbce658b.tar.bz2
Added archive view for blogs.
git-svn-id: http://code.elgg.org/elgg/trunk@5497 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/blog_lib.php')
-rw-r--r--mod/blog/blog_lib.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/mod/blog/blog_lib.php b/mod/blog/blog_lib.php
index 7f83d0dc3..8c09260a3 100644
--- a/mod/blog/blog_lib.php
+++ b/mod/blog/blog_lib.php
@@ -174,6 +174,37 @@ function blog_make_excerpt($text) {
}
/**
+ * Returns a list of years and months for all blogs optionally for a user.
+ * Very similar to get_entity_dates() except uses a metadata field.
+ *
+ * @param mixed $user_guid
+ */
+function blog_get_blog_months($user_guid = NULL, $container_guid = NULL) {
+ global $CONFIG;
+
+ $subtype = get_subtype_id('blog');
+
+ $q = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(mdv.string)) AS yearmonth
+ FROM {$CONFIG->dbprefix}entities e, {$CONFIG->dbprefix}metadata, {$CONFIG->dbprefix}metastrings mdn, {$CONFIG->dbprefix}metastrings mdv
+ WHERE e.guid = {$CONFIG->dbprefix}metadata.entity_guid
+ AND {$CONFIG->dbprefix}metadata.name_id = mdn.id
+ AND {$CONFIG->dbprefix}metadata.value_id = mdv.id
+ AND mdn.string = 'publish_date'";
+
+ if ($user_guid) {
+ $user_guid = (int)$user_guid;
+ $q .= " AND e.owner_guid = $user_guid";
+ }
+
+ if ($container_guid) {
+ $container_guid = (int)$container_guid;
+ $q .= " AND e.container_guid = $container_guid";
+ }
+
+ return get_data($q);
+}
+
+/**
* Extended class to override the time_created
*/
class ElggBlog extends ElggObject {