From 8e1e221e3075f13e007f375201a32abf09779faa Mon Sep 17 00:00:00 2001
From: Gerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>
Date: Sat, 8 Apr 2006 13:13:17 +0000
Subject: [PATCH] #52710, fix node timestamp for admin users, patch by hunmonk.

---
 modules/node.module      | 13 +++++++++++--
 modules/node/node.module | 13 +++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/modules/node.module b/modules/node.module
index a48598fcc95c..91273da624b4 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1503,7 +1503,7 @@ function node_submit($node) {
       $node->uid = 0;
     }
 
-    $node->created = strtotime($node->date);
+    $node->created = $node->date ? strtotime($node->date) : NULL;
   }
   else {
     // Force defaults in case people modify the form:
@@ -1629,7 +1629,16 @@ function node_form_array($node) {
     // Node author information
     $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20);
     $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => theme('placeholder', variable_get('anonymous', 'Anonymous')))));
-    $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#required' => TRUE, '#default_value' => $node->date);
+    $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25);
+    // For new node creations only display a reference to the time of creation,
+    // so node creation time defaults to form submission time.
+    if (!isset($node->nid)) {
+      $form['author']['date']['#description'] = t('Format: %time (defaults to time of form submission)', array('%time' => $node->date));
+    }
+    else {
+      $form['author']['date']['#default_value'] = $node->date;
+      $form['author']['date']['#required'] = TRUE;
+    }
 
     // Node options for administrators
     $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);
diff --git a/modules/node/node.module b/modules/node/node.module
index a48598fcc95c..91273da624b4 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1503,7 +1503,7 @@ function node_submit($node) {
       $node->uid = 0;
     }
 
-    $node->created = strtotime($node->date);
+    $node->created = $node->date ? strtotime($node->date) : NULL;
   }
   else {
     // Force defaults in case people modify the form:
@@ -1629,7 +1629,16 @@ function node_form_array($node) {
     // Node author information
     $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20);
     $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => theme('placeholder', variable_get('anonymous', 'Anonymous')))));
-    $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#required' => TRUE, '#default_value' => $node->date);
+    $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25);
+    // For new node creations only display a reference to the time of creation,
+    // so node creation time defaults to form submission time.
+    if (!isset($node->nid)) {
+      $form['author']['date']['#description'] = t('Format: %time (defaults to time of form submission)', array('%time' => $node->date));
+    }
+    else {
+      $form['author']['date']['#default_value'] = $node->date;
+      $form['author']['date']['#required'] = TRUE;
+    }
 
     // Node options for administrators
     $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);
-- 
GitLab