2001-03-24 16:37:44 +00:00
< ? php
2001-10-20 18:57:10 +00:00
// $Id$
2001-03-24 16:37:44 +00:00
2001-04-29 13:41:18 +00:00
include_once " includes/common.inc " ;
2001-03-24 16:37:44 +00:00
2001-05-20 13:51:40 +00:00
page_header ();
2001-04-15 17:01:32 +00:00
2001-04-16 18:21:22 +00:00
function node_render ( $node ) {
2001-06-29 22:08:57 +00:00
global $id , $cid , $op , $moderate , $pid , $edit , $theme , $mode , $order , $threshold , $PHP_SELF ;
2001-04-16 18:21:22 +00:00
2001-06-29 22:08:57 +00:00
if ( user_access ( " access content " )) {
2001-06-20 20:00:40 +00:00
if ( $node -> comment ) {
switch ( $op ) {
case t ( " Preview comment " ) :
$theme -> header ();
comment_preview ( $edit );
$theme -> footer ();
break ;
case t ( " Post comment " ) :
comment_post ( $edit );
$theme -> header ();
node_view ( $node );
comment_render ( $edit [ id ], $cid );
$theme -> footer ();
break ;
case t ( " Add comment " ) :
$theme -> header ();
2001-09-29 10:12:12 +00:00
comment_reply ( check_query ( $cid ), check_query ( $id ));
2001-06-20 20:00:40 +00:00
$theme -> footer ();
break ;
case " reply " :
$theme -> header ();
2001-09-29 10:12:12 +00:00
comment_reply ( check_query ( $pid ), check_query ( $id ));
2001-06-20 20:00:40 +00:00
$theme -> footer ();
break ;
case t ( " Update settings " ) :
2001-09-29 10:12:12 +00:00
comment_settings ( check_query ( $mode ), check_query ( $order ), check_query ( $threshold ));
2001-06-20 20:00:40 +00:00
$theme -> header ();
node_view ( $node );
comment_render ( $id , $cid );
$theme -> footer ();
break ;
2001-09-27 20:51:26 +00:00
case t ( " Update ratings " ) :
comment_moderate ( $moderate [ " comment " ]);
2001-06-20 20:00:40 +00:00
$theme -> header ();
node_view ( $node );
comment_render ( $id , $cid );
$theme -> footer ();
break ;
default :
$theme -> header ();
node_view ( $node );
comment_render ( $id , $cid );
$theme -> footer ();
}
}
else {
$theme -> header ();
node_view ( $node );
$theme -> footer ();
2001-04-16 18:21:22 +00:00
}
}
else {
$theme -> header ();
2001-06-20 20:00:40 +00:00
$theme -> box ( t ( " Access denied " ), message_access ());
2001-04-16 18:21:22 +00:00
$theme -> footer ();
}
}
2001-03-29 19:50:31 +00:00
function node_failure () {
global $theme ;
$theme -> header ();
2001-11-01 17:04:20 +00:00
$theme -> box ( t ( " Not found " ), t ( " The node you are looking for does no longer exist or is not accessible without the proper access rights. " ) . " \n " );
2001-03-29 19:50:31 +00:00
$theme -> footer ();
}
2001-11-01 11:00:51 +00:00
$number = ( $title ? db_num_rows ( db_query ( " SELECT nid FROM node WHERE title = ' $title ' AND status = 1 " )) : 1 );
2001-03-24 16:37:44 +00:00
2001-03-29 19:50:31 +00:00
if ( $number > 1 ) {
2001-11-01 11:00:51 +00:00
$result = db_query ( " SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.title = ' $title ' AND n.status = 1 ORDER BY created DESC " );
2001-03-29 19:50:31 +00:00
while ( $node = db_fetch_object ( $result )) {
2001-11-01 17:04:20 +00:00
if ( node_access ( " view " , $node )) {
2001-11-01 11:00:51 +00:00
$output .= " <p><b><a href= \" node.php?id= $node->nid\ " > " . check_output( $node->title ) . " </ a ></ b >< br />< small > $node -> type - " . format_name( $node ) . " - " . format_date( $node->ccreated , " small " ) . " </ small ></ p > " ;
2001-03-29 19:50:31 +00:00
}
2001-03-24 16:37:44 +00:00
}
2001-03-29 19:50:31 +00:00
2001-03-24 16:37:44 +00:00
$theme -> header ();
2001-03-29 19:50:31 +00:00
$theme -> box ( t ( " Result " ), $output );
2001-03-24 16:37:44 +00:00
$theme -> footer ();
}
2001-03-29 19:50:31 +00:00
elseif ( $number ) {
2001-11-01 11:00:51 +00:00
$node = ( $title ? node_load ( array ( " title " => $title , " status " => 1 )) : node_load ( array ( " nid " => ( $edit [ id ] ? $edit [ id ] : $id ))));
2001-11-03 18:38:30 +00:00
2001-11-01 17:04:20 +00:00
if ( node_access ( " view " , $node )) {
2001-11-03 18:38:30 +00:00
if ( isset ( $revision )) {
2001-11-04 15:57:43 +00:00
$node = $node -> revisions [ $revision ][ " node " ];
2001-11-03 18:38:30 +00:00
}
2001-11-04 15:57:43 +00:00
node_render ( $node );
2001-03-29 19:50:31 +00:00
}
2001-04-04 21:09:24 +00:00
else {
node_failure ();
}
2001-11-03 18:38:30 +00:00
2001-04-04 21:09:24 +00:00
}
else {
node_failure ();
2001-03-29 19:50:31 +00:00
}
2001-03-24 16:37:44 +00:00
2001-05-20 13:51:40 +00:00
page_footer ();
2001-11-01 11:00:51 +00:00
2001-03-24 16:37:44 +00:00
?>