Commit 0d75dbbc authored by Drew Webber's avatar Drew Webber
Browse files

Issue #1374090 by droplet, mcdruid, Pancho, G.I.Joe, marthinal, brenda003,...

Issue #1374090 by droplet, mcdruid, Pancho, G.I.Joe, marthinal, brenda003, lmeurs, asirjacques, jfhovinne, dcam, pfrenssen, opdavies, andypost, webchick, lokapujya, diqidoq, le72, drumm, ofauravi, TD44, mgifford, mpv, David_Rothstein, rob.barnett, izmeez, xanderol, matt_c, Fabianx, cachee, rodrigoaguilera, wryz, stefan.r, tvn: Editing a comment still changes creation date
parent 0a7ef860
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1918,7 +1918,6 @@ function comment_form($form, &$form_state, $comment) {
  if ($is_admin) {
    $author = (!$comment->uid && $comment->name ? $comment->name : $comment->registered_name);
    $status = (isset($comment->status) ? $comment->status : COMMENT_NOT_PUBLISHED);
    $date = (!empty($comment->date) ? $comment->date : format_date($comment->created, 'custom', 'Y-m-d H:i O'));
  }
  else {
    if ($user->uid) {
@@ -1928,7 +1927,11 @@ function comment_form($form, &$form_state, $comment) {
      $author = ($comment->name ? $comment->name : '');
    }
    $status = (user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED);
  }

  $date = '';
  if ($comment->cid) {
    $date = !empty($comment->date) ? $comment->date : format_date($comment->created, 'custom', 'Y-m-d H:i:s O');
  }

  // Add the author name field depending on the current user.
@@ -2176,7 +2179,7 @@ function comment_submit($comment) {
  if (empty($comment->date)) {
    $comment->date = 'now';
  }
  $comment->created = strtotime($comment->date);
  $comment->created = strtotime($comment->date, REQUEST_TIME);
  $comment->changed = REQUEST_TIME;

  // If the comment was posted by a registered user, assign the author's ID.
+11 −2
Original line number Diff line number Diff line
@@ -1003,7 +1003,7 @@ class CommentPreviewTest extends CommentHelperCase {
   */
  function testCommentEditPreviewSave() {
    $langcode = LANGUAGE_NONE;
    $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
    $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
    $this->drupalLogin($this->admin_user);
    $this->setCommentPreview(DRUPAL_OPTIONAL);
    $this->setCommentForm(TRUE);
@@ -1017,7 +1017,7 @@ class CommentPreviewTest extends CommentHelperCase {
    $edit['date'] = '2008-03-02 17:23 +0300';
    $raw_date = strtotime($edit['date']);
    $expected_text_date = format_date($raw_date);
    $expected_form_date = format_date($raw_date, 'custom', 'Y-m-d H:i O');
    $expected_form_date = format_date($raw_date, 'custom', 'Y-m-d H:i:s O');
    $comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE);
    $this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));

@@ -1059,7 +1059,16 @@ class CommentPreviewTest extends CommentHelperCase {
    $this->assertEqual($comment_loaded->comment_body[$langcode][0]['value'], $edit['comment_body[' . $langcode . '][0][value]'], 'Comment body loaded.');
    $this->assertEqual($comment_loaded->name, $edit['name'], 'Name loaded.');
    $this->assertEqual($comment_loaded->created, $raw_date, 'Date loaded.');
    $this->drupalLogout();

    // Check that the date and time of the comment are correct when edited by
    // non-admin users.
    $user_edit = array();
    $expected_created_time = $comment_loaded->created;
    $this->drupalLogin($web_user);
    $this->drupalPost('comment/' . $comment->id . '/edit', $user_edit, t('Save'));
    $comment_loaded = comment_load($comment->id, TRUE);
    $this->assertEqual($comment_loaded->created, $expected_created_time, 'Expected date and time for comment edited.');
  }

}