Commit 8b04c7f0 authored by Steven Wittens's avatar Steven Wittens

#51002: Admins could not see unpublished comments (plus minor usability...

#51002: Admins could not see unpublished comments (plus minor usability enhancements for previewing/unpublished)
parent 361c7c7e
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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>';
......
......@@ -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>';
......
<div class="comment">
<div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>">
<?php if ($picture) {
print $picture;
} ?>
......
<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;
}?>
......
......@@ -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";
......
<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>
......
<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; ?>
......
<div class="comment">
<div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>">
<?php if ($picture) : ?>
<?php print $picture ?>
<?php endif; ?>
......
<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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment