2001-03-24 16:37:44 +00:00
< ? php
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 ();
comment_reply ( check_input ( $cid ), check_input ( $id ));
$theme -> footer ();
break ;
case " reply " :
$theme -> header ();
comment_reply ( check_input ( $pid ), check_input ( $id ));
$theme -> footer ();
break ;
case t ( " Update settings " ) :
comment_settings ( check_input ( $mode ), check_input ( $order ), check_input ( $threshold ));
$theme -> header ();
node_view ( $node );
comment_render ( $id , $cid );
$theme -> footer ();
break ;
case t ( " Moderate comments " ) :
comment_moderate ( $moderate );
$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-04-04 21:09:24 +00:00
$theme -> box ( t ( " Not found " ), t ( " The node you are looking for does not exist yet or is no longer accessible: " ) . " <UL><LI><A HREF= \" search.php \" > " . t ( " search node " ) . " </A></LI><LI><A HREF= \" submit.php \" > " . t ( " add node " ) . " </A></LI></UL> \n " );
2001-03-29 19:50:31 +00:00
$theme -> footer ();
}
2001-03-24 16:37:44 +00:00
function node_history ( $node ) {
2001-03-25 10:57:01 +00:00
global $status ;
if ( $node -> status == $status [ expired ] || $node -> status == $status [ posted ]) {
$output .= " <DT><B> " . format_date ( $node -> timestamp ) . " by " . format_username ( $node -> userid ) . " :</B></DT><DD> " . check_output ( $node -> log , 1 ) . " <P></DD> " ;
}
if ( $node -> pid ) {
2001-05-20 16:47:50 +00:00
$output .= node_history ( node_get_object ( array ( " nid " => $node -> pid )));
2001-03-25 10:57:01 +00:00
}
return $output ;
2001-03-24 16:37:44 +00:00
}
2001-03-29 20:14:49 +00:00
$number = ( $title ? db_result ( db_query ( " SELECT COUNT(nid) FROM node WHERE title = ' $title ' AND status = $status[posted] " )) : 1 );
2001-03-24 16:37:44 +00:00
2001-03-29 19:50:31 +00:00
if ( $number > 1 ) {
$result = db_query ( " SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = ' $title ' " );
while ( $node = db_fetch_object ( $result )) {
if ( node_visible ( $node )) {
$output .= " <P><B><A HREF= \" node.php?id= $node->nid\ " > " . check_output( $node->title ) . " </ A ></ B >< BR >< SMALL > $node -> type - " . format_username( $node->userid ) . " - " . format_date( $node->timestamp , " small " ) . " </ SMALL ></ P > " ;
}
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-06-15 12:09:37 +00:00
$node = ( $title ? node_get_object ( array ( " title " => $title )) : node_get_object ( array ( " nid " => ( $edit [ id ] ? $edit [ id ] : $id ))));
2001-03-29 19:50:31 +00:00
if ( $node && node_visible ( $node )) {
switch ( $op ) {
case " history " :
$theme -> header ();
2001-04-04 12:54:10 +00:00
$theme -> box ( t ( " History " ), node_control ( $node ) . " <DL> " . node_history ( $node ) . " </DL> " );
2001-03-29 19:50:31 +00:00
$theme -> footer ();
break ;
default :
2001-03-31 14:58:37 +00:00
user_rehash ();
2001-04-16 18:21:22 +00:00
node_render ( $node );
2001-03-29 19:50:31 +00:00
}
}
2001-04-04 21:09:24 +00:00
else {
node_failure ();
}
}
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-04-15 17:01:32 +00:00
2001-03-24 16:37:44 +00:00
?>