00001 <?php
00002
00003
00016 function comment_edit($cid) {
00017 global $user;
00018 $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
00019 $comment = drupal_unpack($comment);
00020 $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00021
00022 if (comment_access('edit', $comment)) {
00023 return comment_form_box((array)$comment);
00024 }
00025 else {
00026 drupal_access_denied();
00027 }
00028 }
00029
00051 function comment_reply($node, $pid = NULL) {
00052
00053 drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
00054 $op = isset($_POST['op']) ? $_POST['op'] : '';
00055 $output = '';
00056
00057 if (user_access('access comments')) {
00058
00059 if ($op == t('Preview comment')) {
00060 if (user_access('post comments')) {
00061 $output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
00062 }
00063 else {
00064 drupal_set_message(t('You are not authorized to post comments.'), 'error');
00065 drupal_goto("node/$node->nid");
00066 }
00067 }
00068 else {
00069
00070 if ($pid) {
00071
00072 if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) {
00073
00074
00075 if ($comment->nid != $node->nid) {
00076
00077 drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
00078 drupal_goto("node/$node->nid");
00079 }
00080
00081 $comment = drupal_unpack($comment);
00082 $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00083 $output .= theme('comment_view', $comment, $node);
00084 }
00085 else {
00086 drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
00087 drupal_goto("node/$node->nid");
00088 }
00089 }
00090
00091 else if (user_access('access content')) {
00092 $output .= node_view($node);
00093 }
00094
00095
00096 if (node_comment_mode($node->nid) != COMMENT_NODE_READ_WRITE) {
00097 drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
00098 drupal_goto("node/$node->nid");
00099 }
00100 else if (user_access('post comments')) {
00101 $output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), t('Reply'));
00102 }
00103 else {
00104 drupal_set_message(t('You are not authorized to post comments.'), 'error');
00105 drupal_goto("node/$node->nid");
00106 }
00107 }
00108 }
00109 else {
00110 drupal_set_message(t('You are not authorized to view comments.'), 'error');
00111 drupal_goto("node/$node->nid");
00112 }
00113
00114 return $output;
00115 }