diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-04-15 04:07:18 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-04-15 04:07:18 +0000 |
commit | 8b04c7f0db4a7a483049635f961d1dcba7e568f1 (patch) | |
tree | 74f297d5b8609bf9fe4318dc912d1efad2051d4d | |
parent | 361c7c7ed89ed340e348ed73310819bda8b23ff0 (diff) | |
download | brdo-8b04c7f0db4a7a483049635f961d1dcba7e568f1.tar.gz brdo-8b04c7f0db4a7a483049635f961d1dcba7e568f1.tar.bz2 |
#51002: Admins could not see unpublished comments (plus minor usability enhancements for previewing/unpublished)
-rw-r--r-- | includes/theme.inc | 12 | ||||
-rw-r--r-- | misc/drupal.css | 6 | ||||
-rw-r--r-- | modules/comment.module | 30 | ||||
-rw-r--r-- | modules/comment/comment.module | 30 | ||||
-rw-r--r-- | themes/bluemarine/comment.tpl.php | 2 | ||||
-rw-r--r-- | themes/bluemarine/node.tpl.php | 2 | ||||
-rw-r--r-- | themes/chameleon/chameleon.theme | 4 | ||||
-rw-r--r-- | themes/engines/phptemplate/comment.tpl.php | 2 | ||||
-rw-r--r-- | themes/engines/phptemplate/node.tpl.php | 2 | ||||
-rw-r--r-- | themes/pushbutton/comment.tpl.php | 2 | ||||
-rw-r--r-- | themes/pushbutton/node.tpl.php | 2 |
11 files changed, 74 insertions, 20 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 610865a60..0baed0463 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -569,15 +569,19 @@ function theme_help() { * A string containing the node output. */ function theme_node($node, $teaser = FALSE, $page = FALSE) { + if (!$node->status) { + $output = '<div class="node-unpublished">'; + } + if (module_exist('taxonomy')) { $terms = taxonomy_link('taxonomy terms', $node); } if ($page == 0) { - $output = t('%title by %name', array('%title' => '<h2 class="title">'. check_plain($node->title) .'</h2>', '%name' => theme('username', $node))); + $output .= t('%title by %name', array('%title' => '<h2 class="title">'. check_plain($node->title) .'</h2>', '%name' => theme('username', $node))); } else { - $output = t('by %name', array('%name' => theme('username', $node))); + $output .= t('by %name', array('%name' => theme('username', $node))); } if (count($terms)) { @@ -595,6 +599,10 @@ function theme_node($node, $teaser = FALSE, $page = FALSE) { $output .= '<div class="links">'. theme('links', $node->links) .'</div>'; } + if (!$node->status) { + $output .= '</div>'; + } + return $output; } diff --git a/misc/drupal.css b/misc/drupal.css index 2421dbbd1..8870dc848 100644 --- a/misc/drupal.css +++ b/misc/drupal.css @@ -248,6 +248,12 @@ tr.odd .form-item, tr.even .form-item { .book-navigation .page-next { text-align: left; } +.node-unpublished, .comment-unpublished { + background-color: #fff4f4; +} +.preview .node, .preview .comment { + background-color: #ffffea; +} .archive { margin: 1em 0 1em 0; } diff --git a/modules/comment.module b/modules/comment.module index f81c632ce..413f56030 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -726,7 +726,14 @@ function comment_render($node, $cid = 0) { if ($cid) { // Single comment view. - $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid, COMMENT_PUBLISHED); + $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; + $query_args = array($cid); + if (!user_access('administer comments')) { + $query .= ' AND c.status = %d'; + $query_args[] = COMMENT_PUBLISHED; + } + $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users'; + $result = db_query($query, $query_args); if ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; @@ -735,7 +742,15 @@ function comment_render($node, $cid = 0) { } else { // Multiple comment view - $query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = %d"; + $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d'; + $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; + + $query_args = array($nid); + if (!user_access('administer comments')) { + $query .= ' AND c.status = %d'; + $query_count .= ' AND status = %d'; + $query_args[] = COMMENT_PUBLISHED; + } $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread'; @@ -827,7 +842,7 @@ function comment_render($node, $cid = 0) { } // Start a form, for use with comment control. - $result = pager_query($query, $comments_per_page, 0, "SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = %d", $nid, COMMENT_PUBLISHED); + $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { $output .= comment_controls($mode, $order, $comments_per_page); } @@ -1384,7 +1399,12 @@ function comment_form_add_preview($form, $edit) { if (!form_get_errors()) { $output .= theme('comment_view', $comment); } - $form['comment_preview'] = array('#value' => $output, '#weight' => -100); + $form['comment_preview'] = array( + '#value' => $output, + '#weight' => -100, + '#prefix' => '<div class="preview">', + '#suffix' => '</div>', + ); $output = ''; @@ -1531,7 +1551,7 @@ function comment_controls_submit($form_id, $form_values) { } function theme_comment($comment, $links = array()) { - $output = '<div class="comment">'; + $output = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">'; $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."</div>\n"; $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n"; $output .= '<div class="body">'. $comment->comment .'</div>'; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index f81c632ce..413f56030 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -726,7 +726,14 @@ function comment_render($node, $cid = 0) { if ($cid) { // Single comment view. - $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid, COMMENT_PUBLISHED); + $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; + $query_args = array($cid); + if (!user_access('administer comments')) { + $query .= ' AND c.status = %d'; + $query_args[] = COMMENT_PUBLISHED; + } + $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users'; + $result = db_query($query, $query_args); if ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; @@ -735,7 +742,15 @@ function comment_render($node, $cid = 0) { } else { // Multiple comment view - $query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = %d"; + $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d'; + $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; + + $query_args = array($nid); + if (!user_access('administer comments')) { + $query .= ' AND c.status = %d'; + $query_count .= ' AND status = %d'; + $query_args[] = COMMENT_PUBLISHED; + } $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread'; @@ -827,7 +842,7 @@ function comment_render($node, $cid = 0) { } // Start a form, for use with comment control. - $result = pager_query($query, $comments_per_page, 0, "SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = %d", $nid, COMMENT_PUBLISHED); + $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { $output .= comment_controls($mode, $order, $comments_per_page); } @@ -1384,7 +1399,12 @@ function comment_form_add_preview($form, $edit) { if (!form_get_errors()) { $output .= theme('comment_view', $comment); } - $form['comment_preview'] = array('#value' => $output, '#weight' => -100); + $form['comment_preview'] = array( + '#value' => $output, + '#weight' => -100, + '#prefix' => '<div class="preview">', + '#suffix' => '</div>', + ); $output = ''; @@ -1531,7 +1551,7 @@ function comment_controls_submit($form_id, $form_values) { } function theme_comment($comment, $links = array()) { - $output = '<div class="comment">'; + $output = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">'; $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."</div>\n"; $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n"; $output .= '<div class="body">'. $comment->comment .'</div>'; diff --git a/themes/bluemarine/comment.tpl.php b/themes/bluemarine/comment.tpl.php index be5149c24..1cee35cba 100644 --- a/themes/bluemarine/comment.tpl.php +++ b/themes/bluemarine/comment.tpl.php @@ -1,4 +1,4 @@ - <div class="comment"> + <div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>"> <?php if ($picture) { print $picture; } ?> diff --git a/themes/bluemarine/node.tpl.php b/themes/bluemarine/node.tpl.php index caa91e870..a5e1502b5 100644 --- a/themes/bluemarine/node.tpl.php +++ b/themes/bluemarine/node.tpl.php @@ -1,4 +1,4 @@ - <div class="node<?php if ($sticky) { print " sticky"; } ?>"> + <div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>"> <?php if ($picture) { print $picture; }?> diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index 244e6a541..5e09a294d 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -114,7 +114,7 @@ function chameleon_page($content) { function chameleon_node($node, $teaser = 0, $page = 0) { - $output = "<div class=\"node\">\n"; + $output = "<div class=\"node". ((!$node->status) ? ' node-unpublished' : '') ."\">\n"; if (!$page) { $output .= " <h2 class=\"title\">". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n"; @@ -154,7 +154,7 @@ function chameleon_node($node, $teaser = 0, $page = 0) { function chameleon_comment($comment, $links = "") { $submitted = array(t('By %author at %date', array('%author' => theme('username', $comment), '%date' => format_date($comment->timestamp. 'small')))); - $output = "<div class=\"comment\">\n"; + $output = "<div class=\"comment". ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') ."\">\n"; $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n"; $output .= " <div class=\"content\">". $comment->comment ."</div>\n"; $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n"; diff --git a/themes/engines/phptemplate/comment.tpl.php b/themes/engines/phptemplate/comment.tpl.php index 69962aeb4..2456c5819 100644 --- a/themes/engines/phptemplate/comment.tpl.php +++ b/themes/engines/phptemplate/comment.tpl.php @@ -1,4 +1,4 @@ -<div class="comment <?php print ($comment->new) ? 'comment-new' : '' ?>"> +<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ($comment->status == COMMENT_NOT_PUBLISHED) ? ' comment-unpublished' : ''; ?>"> <?php if ($comment->new) : ?> <a id="new"></a> <span class="new"><?php print $new ?></span> diff --git a/themes/engines/phptemplate/node.tpl.php b/themes/engines/phptemplate/node.tpl.php index 6f00cdb1f..028aeb3ce 100644 --- a/themes/engines/phptemplate/node.tpl.php +++ b/themes/engines/phptemplate/node.tpl.php @@ -1,4 +1,4 @@ -<div class="node<?php print ($sticky) ? " sticky" : ""; ?>"> +<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>"> <?php if ($page == 0): ?> <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2> <?php endif; ?> diff --git a/themes/pushbutton/comment.tpl.php b/themes/pushbutton/comment.tpl.php index f77041af8..2f2113b8e 100644 --- a/themes/pushbutton/comment.tpl.php +++ b/themes/pushbutton/comment.tpl.php @@ -1,4 +1,4 @@ -<div class="comment"> +<div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>"> <?php if ($picture) : ?> <?php print $picture ?> <?php endif; ?> diff --git a/themes/pushbutton/node.tpl.php b/themes/pushbutton/node.tpl.php index 441bbd00f..8eccce92d 100644 --- a/themes/pushbutton/node.tpl.php +++ b/themes/pushbutton/node.tpl.php @@ -1,4 +1,4 @@ -<div class="node<?php print ($sticky) ? " sticky" : ""; ?>"> +<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>"> <?php print $picture ?> <?php if ($page == 0): ?> <h1 class="title"><a href="<?php print $node_url ?>"><?php print $title ?></a></h1> |