summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-16 20:40:05 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-16 20:40:05 +0000
commit53aa4c6c6adff310c0afc8c3a09da93bb9438bb0 (patch)
tree0be7e694db1344f5e204dd1774cbbd0a4365c418
parent045074d4c51025a7c1561a9bf2e2a8b05441b23d (diff)
downloadbrdo-53aa4c6c6adff310c0afc8c3a09da93bb9438bb0.tar.gz
brdo-53aa4c6c6adff310c0afc8c3a09da93bb9438bb0.tar.bz2
- Patch #606608 by q0rban, sun, David_Rothstein: use proper menu router paths for comment/*.
-rw-r--r--modules/comment/comment.admin.inc23
-rw-r--r--modules/comment/comment.module67
-rw-r--r--modules/comment/comment.pages.inc22
-rw-r--r--modules/comment/comment.test8
-rw-r--r--modules/comment/comment.tokens.inc2
5 files changed, 52 insertions, 70 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc
index 150d0f71b..ddabc017c 100644
--- a/modules/comment/comment.admin.inc
+++ b/modules/comment/comment.admin.inc
@@ -90,7 +90,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
'author' => theme('username', array('account' => $comment)),
'posted_in' => l($comment->node_title, 'node/' . $comment->nid),
'changed' => format_date($comment->changed, 'short'),
- 'operations' => l(t('edit'), 'comment/edit/' . $comment->cid, array('query' => $destination)),
+ 'operations' => l(t('edit'), 'comment/' . $comment->cid .'/edit', array('query' => $destination)),
);
}
@@ -206,27 +206,6 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
}
/**
- * Menu callback; delete a comment.
- *
- * @param $cid
- * The comment to be deleted.
- */
-function comment_delete_page($cid = NULL) {
- $comment = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = :cid', array(':cid' => $cid))->fetch();
- $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output = '';
-
- if (is_object($comment) && is_numeric($comment->cid)) {
- $output = drupal_get_form('comment_confirm_delete', $comment);
- }
- else {
- drupal_set_message(t('The comment no longer exists.'));
- }
-
- return $output;
-}
-
-/**
* Form builder; Builds the confirmation form for deleting a single comment.
*
* @ingroup forms
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index b38f6381b..9588633ea 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -166,20 +166,44 @@ function comment_menu() {
'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK,
);
- $items['comment/delete'] = array(
- 'title' => 'Delete comment',
- 'page callback' => 'comment_delete_page',
- 'access arguments' => array('administer comments'),
+ $items['comment/%comment'] = array(
+ 'title' => 'Comment permalink',
+ 'page callback' => 'comment_permalink',
+ 'page arguments' => array(1),
+ 'access arguments' => array('access comments'),
'type' => MENU_CALLBACK,
- 'file' => 'comment.admin.inc',
);
- $items['comment/edit/%comment'] = array(
- 'title' => 'Edit comment',
+ $items['comment/%comment/view'] = array(
+ 'title' => 'View comment',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['comment/%comment/edit'] = array(
+ 'title' => 'Edit',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('comment_form', 2),
+ 'page arguments' => array('comment_form', 1),
'access callback' => 'comment_access',
- 'access arguments' => array('edit', 2),
- 'type' => MENU_CALLBACK,
+ 'access arguments' => array('edit', 1),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 0,
+ );
+ $items['comment/%comment/approve'] = array(
+ 'title' => 'Approve',
+ 'page callback' => 'comment_approve',
+ 'page arguments' => array(1),
+ 'access arguments' => array('administer comments'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'comment.pages.inc',
+ 'weight' => 1,
+ );
+ $items['comment/%comment/delete'] = array(
+ 'title' => 'Delete',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('comment_confirm_delete', 1),
+ 'access arguments' => array('administer comments'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'comment.admin.inc',
+ 'weight' => 2,
);
$items['comment/reply/%node'] = array(
'title' => 'Add new comment',
@@ -190,21 +214,6 @@ function comment_menu() {
'type' => MENU_CALLBACK,
'file' => 'comment.pages.inc',
);
- $items['comment/approve'] = array(
- 'title' => 'Approve a comment',
- 'page callback' => 'comment_approve',
- 'page arguments' => array(2),
- 'access arguments' => array('administer comments'),
- 'type' => MENU_CALLBACK,
- 'file' => 'comment.pages.inc',
- );
- $items['comment/%comment'] = array(
- 'title' => 'Comment permalink',
- 'page callback' => 'comment_permalink',
- 'page arguments' => array(1),
- 'access arguments' => array('access comments'),
- 'type' => MENU_CALLBACK,
- );
return $items;
}
@@ -870,12 +879,12 @@ function comment_links($comment, $node) {
if (user_access('administer comments') && user_access('post comments')) {
$links['comment_delete'] = array(
'title' => t('delete'),
- 'href' => "comment/delete/$comment->cid",
+ 'href' => "comment/$comment->cid/delete",
'html' => TRUE,
);
$links['comment_edit'] = array(
'title' => t('edit'),
- 'href' => "comment/edit/$comment->cid",
+ 'href' => "comment/$comment->cid/edit",
'html' => TRUE,
);
$links['comment_reply'] = array(
@@ -886,7 +895,7 @@ function comment_links($comment, $node) {
if ($comment->status == COMMENT_NOT_PUBLISHED) {
$links['comment_approve'] = array(
'title' => t('approve'),
- 'href' => "comment/approve/$comment->cid",
+ 'href' => "comment/$comment->cid/approve",
'html' => TRUE,
);
}
@@ -895,7 +904,7 @@ function comment_links($comment, $node) {
if (comment_access('edit', $comment)) {
$links['comment_edit'] = array(
'title' => t('edit'),
- 'href' => "comment/edit/$comment->cid",
+ 'href' => "comment/$comment->cid/edit",
'html' => TRUE,
);
}
diff --git a/modules/comment/comment.pages.inc b/modules/comment/comment.pages.inc
index b428a7f6b..72b490497 100644
--- a/modules/comment/comment.pages.inc
+++ b/modules/comment/comment.pages.inc
@@ -103,20 +103,14 @@ function comment_reply($node, $pid = NULL) {
/**
* Menu callback; publish specified comment.
*
- * @param $cid ID of comment to be published.
+ * @param $comment
+ * A comment object.
*/
-function comment_approve($cid) {
- // Load the comment whose cid = $cid
- if ($comment = comment_load($cid)) {
- $comment->status = COMMENT_PUBLISHED;
- $comment->comment_format = $comment->format;
- comment_save($comment);
+function comment_approve($comment) {
+ $comment->status = COMMENT_PUBLISHED;
+ $comment->comment_format = $comment->format;
+ comment_save($comment);
- drupal_set_message(t('Comment approved.'));
- drupal_goto('node/' . $comment->nid);
- }
- else {
- drupal_set_message(t('The comment you are approving does not exist.'), 'error');
- drupal_goto();
- }
+ drupal_set_message(t('Comment approved.'));
+ drupal_goto('node/' . $comment->nid);
}
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 265bf0705..96e3398e7 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -111,7 +111,7 @@ class CommentHelperCase extends DrupalWebTestCase {
* Comment to delete.
*/
function deleteComment($comment) {
- $this->drupalPost('comment/delete/' . $comment->id, array(), t('Delete'));
+ $this->drupalPost('comment/' . $comment->id . '/delete', array(), t('Delete'));
$this->assertText(t('The comment and all its replies have been deleted.'), t('Comment deleted.'));
}
@@ -320,7 +320,7 @@ class CommentInterfaceTest extends CommentHelperCase {
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, t('Thread of second reply grows correctly.'));
// Edit reply.
- $this->drupalGet('comment/edit/' . $reply->id);
+ $this->drupalGet('comment/' . $reply->id . '/edit');
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.'));
@@ -444,7 +444,7 @@ class CommentPreviewTest extends CommentHelperCase {
$edit['date'] = '2008-03-02 17:23 +0300';
$expected_date = format_date(strtotime($edit['date']));
$comment = $this->postComment($this->node, $edit['subject'], $edit['comment'], TRUE);
- $this->drupalPost('comment/edit/' . $comment->id, $edit, t('Preview'));
+ $this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));
// Check that the preview is displaying the subject, comment, author and date correctly.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
@@ -494,7 +494,7 @@ class CommentAnonymous extends CommentHelperCase {
$this->setCommentAnonymous('1');
// Attempt to edit anonymous comment.
- $this->drupalGet('comment/edit/' . $anonymous_comment1->id);
+ $this->drupalGet('comment/' . $anonymous_comment1->id . '/edit');
$edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.'));
$this->drupalLogout();
diff --git a/modules/comment/comment.tokens.inc b/modules/comment/comment.tokens.inc
index 896ab0e7b..e22aea4fd 100644
--- a/modules/comment/comment.tokens.inc
+++ b/modules/comment/comment.tokens.inc
@@ -184,7 +184,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'edit-url':
- $replacements[$original] = url('comment/edit/' . $comment->cid, array('absolute' => TRUE));
+ $replacements[$original] = url('comment/' . $comment->cid . '/edit', array('absolute' => TRUE));
break;
// Default values for the chained tokens handled below.