]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2229. Removed published data metadata in blog. Added upgrade to set all status...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Mar 2011 03:20:34 +0000 (03:20 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Mar 2011 03:20:34 +0000 (03:20 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8626 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/upgrades/2011030700-1.8_svn-blog_status_metadata-4645225d7b440876.php [new file with mode: 0644]
mod/blog/actions/blog/auto_save_revision.php
mod/blog/actions/blog/save.php
mod/blog/classes/ElggBlog.php
mod/blog/languages/en.php
mod/blog/views/default/blog/sidebar/revisions.php
mod/blog/views/default/forms/blog/save.php
mod/blog/views/default/input/datetime.php [deleted file]
mod/blog/views/default/js/blog/save_draft.php
mod/blog/views/default/object/blog.php
version.php

diff --git a/engine/lib/upgrades/2011030700-1.8_svn-blog_status_metadata-4645225d7b440876.php b/engine/lib/upgrades/2011030700-1.8_svn-blog_status_metadata-4645225d7b440876.php
new file mode 100644 (file)
index 0000000..e4ab9c1
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Elgg 1.8-svn upgrade 2011030700
+ * blog_status_metadata
+ *
+ * Add a "status" metadata entry to every blog entity because in 1.8 you can have status = draft or
+ * status = published
+ */
+$ia = elgg_set_ignore_access(true);
+$options = array(
+       'type' => 'object',
+       'subtype' => 'blog'
+);
+$batch = new ElggBatch('elgg_get_entities', $options);
+
+foreach ($batch as $entity) {
+       if (!$entity->status) {
+               // create metadata owned by the original owner
+               create_metadata($entity->getGUID(), 'status', 'published', '', $entity->owner_guid,
+                       $entity->access_id);
+       }
+}
+elgg_set_ignore_access($ia);
\ No newline at end of file
index 86812c6d3bbc353ecb79f76b84439a105d564959..1acf3b31b18dc02def6fc9d1596d5441161b575b 100644 (file)
@@ -38,8 +38,6 @@ if ($title && $description) {
                $blog->title = $title;
                $blog->description = $description;
                $blog->excerpt = elgg_get_excerpt($excerpt);
-               // must be present or doesn't show up when metadata sorting.
-               $blog->publish_date = time();
 
                // mark this as a brand new post so we can work out the
                // river / revision logic in the real save action.
index 5dccab45de09911e2be6466a0dfda9139c9b8028..099a89cc09a1fe04d8cc5609110dfedd5c00cba3 100644 (file)
@@ -106,18 +106,6 @@ foreach ($values as $name => $default) {
        }
 }
 
-// build publish_date
-//$publish_month = get_input('publish_month');
-//$publish_day = get_input('publish_day');
-//$publish_year = get_input('publish_year');
-//$publish_hour = get_input('publish_hour');
-//$publish_minute = get_input('publish_minute');
-//$datetime = "$publish_year-$publish_month-$publish_day $publish_hour:$publish_minute:00";
-//$values['publish_date'] = date('U', strtotime($datetime));
-
-// setting publish_date to now until the problems with locale dates can be resolved.
-$values['publish_date'] = time();
-
 // assign values to the entity, stopping on error.
 if (!$error) {
        foreach ($values as $name => $value) {
@@ -154,8 +142,6 @@ if (!$error) {
                // because we remove it for drafts.
                if (($new_post || $old_status == 'draft') && $status == 'published') {
                        add_to_river('river/object/blog/create', 'create', elgg_get_logged_in_user_guid(), $blog->getGUID());
-                       
-                       $date = $blog->publish_date;
 
                        if ($guid) {
                                $q = "UPDATE {$db_prefix}entities SET time_created = '$date'
index 0f0f27cf84a113699e8c35e9da37076810c36ba7..ee2ec73effbd2c92b1848668ceb0644fac450e8d 100644 (file)
@@ -13,33 +13,6 @@ class ElggBlog extends ElggObject {
                $this->attributes['subtype'] = "blog";
        }
 
-       /**
-        * @todo this won't work until we have date l10n working.
-        * Rewrite the time created to be publish time.
-        * This is a bit dirty, but required for proper sorting.
-        */
-//     public function save() {
-//             if (parent::save()) {
-//                     global $CONFIG;
-//
-//                     // try to grab the publish date, but default to now.
-//                     foreach (array('publish_date', 'time_created') as $field) {
-//                             if (isset($this->$field) && $this->field) {
-//                                     $published = $this->field;
-//                                     break;
-//                             }
-//                     }
-//                     if (!$published) {
-//                             $published = time();
-//                     }
-//
-//                     $sql = "UPDATE {$CONFIG->dbprefix}entities SET time_created = '$published', time_updated = '$published' WHERE guid = '{$this->getGUID()}'";
-//                     return update_data($sql);
-//             }
-//
-//             return FALSE;
-//     }
-
        /**
         * Can a user comment on this blog?
         *
index b5a9f070d625cd8ff2af14fa7eade0a7089dadf6..b11eb1e7532dc3ed451ca5ec9e65ccba77f17877 100644 (file)
@@ -27,7 +27,6 @@ $english = array(
        'blog:body' => 'Body',
        'blog:save_status' => 'Last saved: ',
        'blog:never' => 'Never',
-       'blog:publish_date' => 'Publish Date',
 
        // Statuses
        'blog:status' => 'Status',
index b8f07b336cfe7b6ca46f876aaf60493ecdbdf1d2..5e4f45bd9396ff85806cd30fb990df9aafa54bda 100644 (file)
@@ -43,7 +43,7 @@ if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) {
                        ));
 
                        $time = "<span class='elgg-subtext'>"
-                               . elgg_view_friendly_time($blog->publish_date) . "</span>";
+                               . elgg_view_friendly_time($blog->time_created) . "</span>";
 
                        $body .= "<li>$load : $time</li>";
                }
index c8c0fde553ee07187df086286bf60fec8c805dc3..b2d20579f465d699ff834a9eab69ed90de150827 100644 (file)
@@ -48,8 +48,9 @@ $body_input = elgg_view('input/longtext', array(
 ));
 
 $save_status = elgg_echo('blog:save_status');
-if ($vars['publish_date']) {
-       $saved = date('F j, Y @ H:i', $vars['publish_date']);
+if ($vars['guid']) {
+       $entity = get_entity($vars['guid']);
+       $saved = date('F j, Y @ H:i', $entity->time_created);
 } else {
        $saved = elgg_echo('blog:never');
 }
@@ -87,14 +88,6 @@ $access_input = elgg_view('input/access', array(
        'value' => $vars['access_id']
 ));
 
-// not being used
-$publish_date_label = elgg_echo('blog:publish_date');
-$publish_date_input = elgg_view('input/datetime', array(
-       'name' => 'publish_date',
-       'id' => 'blog_publish_date',
-       'value' => $vars['publish_date']
-));
-
 $categories_input = elgg_view('categories', $vars);
 
 // hidden inputs
diff --git a/mod/blog/views/default/input/datetime.php b/mod/blog/views/default/input/datetime.php
deleted file mode 100644 (file)
index 1f4a33e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * A date-time view for the blog publication date.
- *
- * not being used
- */
-
-// default date to current time
-$publish_date = ($vars['value']) ? $vars['value'] : time();
-
-$months = array();
-for ($i=1; $i <= 12; $i++) {
-       $value = str_pad($i, 2, '0', STR_PAD_LEFT);
-       $months[$value] = date('M', strtotime("$value/01/2010"));
-}
-
-$month = elgg_view('input/dropdown', array(
-       'name' => 'publish_month',
-       'value' => date('m', $publish_date),
-       'options_values' => $months,
-       'class' => 'elgg-input-datetime-month',
-));
-
-$day = elgg_view('input/text', array(
-       'name' => 'publish_day',
-       'value' => date('d', $publish_date),
-       'class' => 'elgg-input-datetime-day',
-));
-
-$year = elgg_view('input/text', array(
-       'name' => 'publish_year',
-       'value' => date('Y', $publish_date),
-       'class' => 'elgg-input-datetime-year',
-));
-
-$hour = elgg_view('input/text', array(
-       'name' => 'publish_hour',
-       'value' => date('H', $publish_date),
-       'class' => 'elgg-input-datetime-hour',
-));
-
-$minute = elgg_view('input/text', array(
-       'name' => 'publish_minute',
-       'value' => date('i', $publish_date),
-       'class' => 'elgg-input-datetime-minute',
-));
-
-echo "$month $day, $year @ $hour:$minute";
index 990ab357d57dfd7ce63737965e07f0998f41ce85..44b54acb03deb4a9012f08806485817c65306f23 100644 (file)
@@ -55,7 +55,7 @@ elgg.blog.saveDraft = function() {
                }
        });
 
-       $.post(draftURL, postData, blogSaveDraftCallback, 'json');
+       $.post(draftURL, postData, elgg.blog.blogSaveDraftCallback, 'json');
 }
 
 elgg.blog.init = function() {
index 8c339236cc50fd3d7c11b1f0aeaa8fc3ba78e9c3..9687e8f340d8434cd4800cc0970268a346b2876a 100644 (file)
@@ -24,7 +24,7 @@ $owner_link = elgg_view('output/url', array(
 ));
 $author_text = elgg_echo('byline', array($owner_link));
 $tags = elgg_view('output/tags', array('tags' => $blog->tags));
-$date = elgg_view_friendly_time($blog->publish_date);
+$date = elgg_view_friendly_time($blog->time_created);
 
 // The "on" status changes for comments, so best to check for !Off
 if ($blog->comments_on != 'Off') {
index fcc2112be02b980884d101551210a8cb53f8ca48..1fae23d17662491db96e2ceb9f45344992bfcba3 100644 (file)
@@ -11,7 +11,7 @@
 
 // YYYYMMDD = Elgg Date
 // XX = Interim incrementer
-$version = 2011022000;
+$version = 2011030700;
 
 // Human-friendly version name
 $release = '1.8-svn';