]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2229: Using time_created instead of publish_date metadata to sort.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Mar 2011 02:48:19 +0000 (02:48 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Mar 2011 02:48:19 +0000 (02:48 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8624 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/lib/blog.php
mod/blog/views/default/blog/sidebar/archives.php

index 4d5106bfb69e1ff4d3d40b01d96eaaf74f47c53b..0a2c3a8ac1770112b024def80d6fb854edb43152 100644 (file)
@@ -63,7 +63,6 @@ function blog_get_page_content_list($container_guid = NULL) {
                'type' => 'object',
                'subtype' => 'blog',
                'full_view' => FALSE,
-               //'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int')
        );
 
        $loggedin_userid = elgg_get_logged_in_user_guid();
@@ -109,7 +108,6 @@ function blog_get_page_content_list($container_guid = NULL) {
        if (!(elgg_is_admin_logged_in() || (elgg_is_logged_in() && $container_guid == $loggedin_userid))) {
                $options['metadata_name_value_pairs'] = array(
                        array('name' => 'status', 'value' => 'published'),
-                       //array('name' => 'publish_date', 'operand' => '<', 'value' => time())
                );
        }
 
@@ -150,7 +148,6 @@ function blog_get_page_content_friends($user_guid) {
                        'type' => 'object',
                        'subtype' => 'blog',
                        'full_view' => FALSE,
-                       'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int'),
                );
 
                foreach ($friends as $friend) {
@@ -211,7 +208,6 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
                'type' => 'object',
                'subtype' => 'blog',
                'full_view' => FALSE,
-               'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int'),
        );
 
        if ($owner_guid) {
@@ -231,19 +227,11 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
        }
 
        if ($lower) {
-               $options['metadata_name_value_pairs'][] = array(
-                       'name' => 'publish_date',
-                       'operand' => '>',
-                       'value' => $lower
-               );
+               $options['created_time_lower'] = $lower;
        }
 
        if ($upper) {
-               $options['metadata_name_value_pairs'][] = array(
-                       'name' => 'publish_date',
-                       'operand' => '<',
-                       'value' => $upper
-               );
+               $options['created_time_upper'] = $upper;
        }
 
        $list = elgg_list_entities_from_metadata($options);
@@ -355,7 +343,6 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {
                'title' => NULL,
                'description' => NULL,
                'status' => 'published',
-               'publish_date' => NULL,
                'access_id' => ACCESS_DEFAULT,
                'comments_on' => 'On',
                'excerpt' => NULL,
@@ -404,42 +391,6 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {
        return $values;
 }
 
-/**
- * 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 int $user_guid
- * @param int $container_guid
- * @return array
- */
-function blog_get_blog_months($user_guid = NULL, $container_guid = NULL) {
-
-       $db_prefix = elgg_get_config('dbprefix');
-
-       $subtype = get_subtype_id('object', 'blog');
-
-       $q = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(mdv.string)) AS yearmonth
-               FROM {$db_prefix}entities e, {$db_prefix}metadata, {$db_prefix}metastrings mdn, {$db_prefix}metastrings mdv
-               WHERE e.guid = {$db_prefix}metadata.entity_guid
-               AND {$db_prefix}metadata.name_id = mdn.id
-               AND {$db_prefix}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";
-       }
-
-       $q .= ' AND ' . get_access_sql_suffix('e');
-
-       return get_data($q);
-}
-
 /**
  * Forward to the new style of URLs
  *
index a761938313b9de123a1d947c28e6863842936e7f..5eda64afb7efd669dd7cbb08482c3270162c8004 100644 (file)
@@ -8,14 +8,12 @@ $page_owner = elgg_get_page_owner_entity();
 
 // This is a limitation of the URL schema.
 if ($page_owner && $vars['page'] != 'friends') {
-       $dates = blog_get_blog_months($user);
-
+       $dates = get_entity_dates('object', 'blog', $page_owner->getGUID());
+       
        if ($dates) {
                $title = elgg_echo('blog:archives');
                $content = '<ul class="blog-archives">';
                foreach($dates as $date) {
-                       $date = $date->yearmonth;
-
                        $timestamplow = mktime(0, 0, 0, substr($date,4,2) , 1, substr($date, 0, 4));
                        $timestamphigh = mktime(0, 0, 0, ((int) substr($date, 4, 2)) + 1, 1, substr($date, 0, 4));