Active
Project:
Book Review
Version:
4.7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
13 Oct 2006 at 04:22 UTC
Updated:
24 May 2007 at 01:08 UTC
I would expect that unpublished reviews would not show up in the list of reviews. This can easily be fixed by adding a check to see if the node is published in the sql query on line 499
$sql = db_rewrite_sql("SELECT b.nid, n.title, b.booktitle, b.cover, b.publisher, b.isbn, b.copyright, b.pages, b.rating FROM {bookreview} b INNER JOIN {node} n ON b.nid = n.nid WHERE n.type = 'bookreview'<strong> AND n.status=1</strong>");
Comments
Comment #1
pdb commentedI have a more complete solution for this now. What I did is theme the listing to get rid of the ISBN column as well as limit it to only published bookreviews by adding this function to my templates.php. I added the AND n.status=1 to the query and put in a query to correctly count the published reviews in the call to the pager.
It seems like it would be better default behavior to integrate the status check into bookreview.module. If the powers that be don't agree, then I guess this issue can be closed.
Comment #2
alexgarmi commentedthe next function works very good!!!!
function theme_bookreview_list() {
$header = array(' ', array('data' => t('Title'), 'field' => 'b.booktitle', 'sort' => 'asc'), array('data' => t('Copyright'), 'field' => 'b.copyright'), array('data' => t('ISBN'), 'field' => 'b.isbn'));
$sql = db_rewrite_sql("SELECT DISTINCT n.nid, n.title, b.booktitle, b.cover, b.publisher, b.isbn, b.copyright, b.pages, b.rating FROM {bookreview} b INNER JOIN {node} n ON b.nid = n.nid WHERE n.type = 'bookreview' AND n.status=1");
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20);
while ($node = db_fetch_object($result)) {
cover' border='0'>";
$authors = '';
$count = 0;
$a = db_query('SELECT author, weight FROM {bookreview_authors} WHERE nid = %d ORDER BY weight', $node->nid);
while ($author = db_fetch_object($a)) {
$count++;
if ($authors) {
$authors .= ", $author->author";
}
else {
$authors = $author->author;
}
}
if ($authors) {
$output = t('%tag: %authors', array('%tag' => format_plural($count, 'Author', 'Authors'), '%authors' => $authors)) .'
';
}
if ($node->booktitle) {
$output .= t('Title: %title', array('%title' => $node->booktitle)) .'
';
}
if ($node->copyright) {
$output .= t('Copyright: %copyright', array('%copyright' => $node->copyright)) .'
';
}
if ($node->publisher) {
$output .= t('Publisher: %publisher', array('%publisher' => $node->publisher)) .'
';
}
if ($node->isbn) {
$output .= t('ISBN: %isbn', array('%isbn' => $node->isbn)) .'
';
}
if ($node->pages) {
$output .= t('Pages: %pages', array('%pages' => $node->pages)) .'
';
}
if ($node->rating) {
$output .= t('Rating: %rating', array('%rating' => $node->rating)) .'
';
}
if ($node->cover) {
$cover = "
}
else {
$cover = ' ';
}
$rows[] = array($cover, array('data' => l($node->title, "node/$node->nid", array('title' => t('View this posting.'))) ."
$output", 'colspan' => '3'));
}
if (!$rows) {
$rows[] = array(array('data' => t('No book reviews available.'), 'colspan' => '4'));
}
$pager = theme('pager', NULL, 20, 0);
if (!empty($pager)) {
$rows[] = array(array('data' => $pager, 'colspan' => '2'));
}
return theme('table', $header, $rows);
}