summaryrefslogtreecommitdiff
path: root/modules/comment/comment.pages.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-07-28 10:09:25 +0000
committerDries Buytaert <dries@buytaert.net>2009-07-28 10:09:25 +0000
commit51e638912257eb25fa3ada96777b14573e7d28b5 (patch)
treea042a1ea0909f01e9f7d225e6183cefa615e2719 /modules/comment/comment.pages.inc
parent0ae1c4d9b77ef68a1c3f81ee32f01464a37df3e9 (diff)
downloadbrdo-51e638912257eb25fa3ada96777b14573e7d28b5.tar.gz
brdo-51e638912257eb25fa3ada96777b14573e7d28b5.tar.bz2
- Patch #523950 by moshe weitzman, yched, catch: update comment rendering to take full advantage of the drupal_render() paradigm.
Diffstat (limited to 'modules/comment/comment.pages.inc')
-rw-r--r--modules/comment/comment.pages.inc35
1 files changed, 13 insertions, 22 deletions
diff --git a/modules/comment/comment.pages.inc b/modules/comment/comment.pages.inc
index 5748c4f46..dc18f8035 100644
--- a/modules/comment/comment.pages.inc
+++ b/modules/comment/comment.pages.inc
@@ -7,24 +7,14 @@
*/
/**
- * Form builder; generate a comment editing form.
+ * A menu callback; build a comment editing form.
*
- * @param $cid
- * ID of the comment to be edited.
+ * @param $comment
+ * The comment to be edited.
* @ingroup forms
*/
-function comment_edit($cid) {
- global $user;
- $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid', array(':cid' => $cid))->fetchObject();
- $comment = drupal_unpack($comment);
- $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
-
- if (comment_access('edit', $comment)) {
- return theme('comment_form_box', (array)$comment);
- }
- else {
- drupal_access_denied();
- }
+function comment_edit($comment) {
+ return drupal_get_form('comment_form', (array)$comment);
}
/**
@@ -52,13 +42,13 @@ function comment_reply($node, $pid = NULL) {
// Set the breadcrumb trail.
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
- $output = '';
+ $build = array();
if (user_access('access comments')) {
// The user is previewing a comment prior to submitting it.
if ($op == t('Preview')) {
if (user_access('post comments')) {
- $output .= theme('comment_form_box', array('pid' => $pid, 'nid' => $node->nid), NULL);
+ $build['comment_form'] = drupal_get_form('comment_form', array('pid' => $pid, 'nid' => $node->nid));
}
else {
drupal_set_message(t('You are not authorized to post comments.'), 'error');
@@ -84,7 +74,7 @@ function comment_reply($node, $pid = NULL) {
// Display the parent comment
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output .= theme('comment_view', $comment, $node);
+ $build['comment_parent'] = comment_build($comment);
}
else {
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
@@ -93,7 +83,7 @@ function comment_reply($node, $pid = NULL) {
}
// This is the case where the comment is in response to a node. Display the node.
elseif (user_access('access content')) {
- $output .= drupal_render(node_build($node));
+ $build['comment_node'] = node_build($node);
}
// Should we show the reply box?
@@ -102,7 +92,8 @@ function comment_reply($node, $pid = NULL) {
drupal_goto("node/$node->nid");
}
elseif (user_access('post comments')) {
- $output .= theme('comment_form_box', array('pid' => $pid, 'nid' => $node->nid), t('Add new comment'));
+ $edit = array('nid' => $node->nid, 'pid' => $pid);
+ $build['comment_form'] = drupal_get_form('comment_form', $edit);
}
else {
drupal_set_message(t('You are not authorized to post comments.'), 'error');
@@ -115,11 +106,11 @@ function comment_reply($node, $pid = NULL) {
drupal_goto("node/$node->nid");
}
- return $output;
+ return $build;
}
/**
- * Publish specified comment.
+ * Menu callback; publish specified comment.
*
* @param $cid ID of comment to be published.
*/