$result=db_query("SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid IN (".db_placeholders(array_keys($nodes)).")",array_keys($nodes),array('fetch'=>PDO::FETCH_ASSOC));
@@ -579,11 +579,32 @@ function comment_form_alter(&$form, $form_state, $form_id) {
/**
* Implementation of hook_nodeapi_load().
*/
functioncomment_nodeapi_load(&$node,$arg=0){
if($node->comment!=COMMENT_NODE_DISABLED){
returndb_query('SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = :nid',array(':nid'=>$node->nid))->fetchAssoc();
functioncomment_nodeapi_load($nodes,$types){
$comments_enabled=array();
// Check if comments are enabled for each node. If comments are disabled,
// assign values without hitting the database.
foreach($nodesas$node){
// Store whether comments are enabled for this node.
if($node->comment!=COMMENT_NODE_DISABLED){
$comments_enabled[]=$node->nid;
}
else{
$node->last_comment_timestamp=$node->created;
$node->last_comment_name='';
$node->comment_count=0;
}
}
// For nodes with comments enabled, fetch information from the database.
if(!empty($comments_enabled)){
$result=db_query('SELECT nid, last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid IN('.db_placeholders($comments_enabled).')',$comments_enabled);
$fields=str_replace('r.timestamp','r.timestamp AS revision_timestamp',$fields);
// Change name of revision uid so it doesn't conflict with n.uid.
$fields=str_replace('r.uid','r.uid AS revision_uid',$fields);
// Retrieve the node.
// No db_rewrite_sql is applied so as to get complete indexing for search.
if($revision){
array_unshift($arguments,$revision);
$node=db_fetch_object(db_query('SELECT '.$fields.' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revision} r ON r.nid = n.nid AND r.vid = %d WHERE '.$cond,$arguments));
}
else{
$node=db_fetch_object(db_query('SELECT '.$fields.' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revision} r ON r.vid = n.vid WHERE '.$cond,$arguments));
}
// Add fields from the {node} table.
$node_fields=drupal_schema_fields_sql('node');
// vid and title are provided by node_revision, so remove them.
$result=db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'),0,variable_get('feed_default_items',10));
while($row=db_fetch_object($result)){
$nids[]=$row->nid;
}
$nids=db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'),0,variable_get('feed_default_items',10))->fetchCol();
* Menu callback; Generate a listing of promoted nodes.
*/
functionnode_page_default(){
$result=pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'),variable_get('default_nodes_main',10));
$output='';
$num_rows=FALSE;
while($node=db_fetch_object($result)){
$output.=node_view(node_load($node->nid),1);
$num_rows=TRUE;
}
$nids=pager_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'),variable_get('default_nodes_main',10))->fetchCol();