2001-04-02 15:54:37 +00:00
<?php
$module = array("admin" => "node_admin");
2001-04-10 20:07:27 +00:00
function node_overview($query = array()) {
2001-05-02 20:52:19 +00:00
global $user;
2001-04-02 15:54:37 +00:00
2001-04-16 18:21:22 +00:00
$result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50");
2001-04-02 15:54:37 +00:00
2001-04-10 20:07:27 +00:00
$output .= status($query[0]);
2001-04-02 15:54:37 +00:00
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
2001-05-02 20:52:19 +00:00
$output .= " <TR><TH>title</TH><TH>category</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
2001-04-02 15:54:37 +00:00
while ($node = db_fetch_object($result)) {
2001-05-02 20:52:19 +00:00
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node, $node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
2001-04-02 15:54:37 +00:00
}
$output .= "</TABLE>\n";
return $output;
}
function node_admin_view($id) {
$node = node_get_object("nid", $id);
$output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
2001-04-29 12:39:55 +00:00
$output .= form_item("Title", check_output($node->title));
$output .= form_item("Author", format_username($node->userid));
2001-05-02 20:52:19 +00:00
$output .= form_item("Status", node_status($node, $node->status));
2001-04-29 12:39:55 +00:00
$output .= form_item("Comment", node_comment_status($node->comment));
$output .= form_item("Promote", node_promote_status($node->promote));
2001-05-02 20:52:19 +00:00
$output .= form_item("Moderate", check_output($node->moderate));
2001-04-29 12:39:55 +00:00
$output .= form_item("Date", format_date($node->timestamp));
$output .= form_submit("Edit node");
$output .= form_submit("Delete node");
2001-04-02 15:54:37 +00:00
$output .= "</FORM>\n";
return $output;
}
function node_admin_edit($id) {
2001-04-29 12:39:55 +00:00
global $user;
2001-04-02 15:54:37 +00:00
$node = node_get_object("nid", $id);
$output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
2001-04-29 12:39:55 +00:00
$output .= form_item("Title", check_output($node->title));
2001-04-30 17:13:08 +00:00
$output .= form_select("Author", "author", $node->author, array($node->author => $node->userid, $user->id => $user->userid));
$output .= form_select("Status", "status", $node->status, node_status($node));
$output .= form_select("Comment", "comment", $node->comment, node_comment_status());
$output .= form_select("Promote", "promote", $node->promote, node_promote_status());
2001-05-02 20:52:19 +00:00
$output .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of usernames."));
2001-04-30 17:13:08 +00:00
$output .= form_select("Date", "timestamp", $node->timestamp, array($node->timestamp => format_date($node->timestamp) ." (original)", time() => format_date(time()) ." (current)"));
2001-04-29 12:39:55 +00:00
$output .= form_hidden("nid", $node->nid);
$output .= form_submit("View node");
$output .= form_submit("Save node");
2001-04-02 15:54:37 +00:00
$output .= "</FORM>\n";
return $output;
}
function node_delete($id) {
2001-04-07 15:02:28 +00:00
return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
2001-04-02 15:54:37 +00:00
}
2001-04-10 20:07:27 +00:00
function node_query($type = "") {
global $status;
2001-04-11 19:44:24 +00:00
$queries = array(array("recent nodes", "ORDER BY n.timestamp DESC"), array("posted nodes", "WHERE n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued nodes", "WHERE n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped nodes", "WHERE n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
2001-04-10 20:07:27 +00:00
return ($queries[$type] ? $queries[$type] : $queries);
}
2001-04-11 19:44:24 +00:00
function node_listing($queries) {
global $mod;
foreach ($queries as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=$mod&type=$key\">$array[0]</A></LI>\n";
2001-04-10 20:07:27 +00:00
}
return "<OL>$output</OL>\n";
}
2001-04-02 15:54:37 +00:00
function node_admin() {
2001-04-10 20:07:27 +00:00
global $op, $id, $edit, $type;
print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
2001-04-02 15:54:37 +00:00
$id = check_input($edit[nid] ? $edit[nid] : $id);
2001-04-10 20:07:27 +00:00
$type = ($type ? $type : 0);
2001-04-02 15:54:37 +00:00
switch ($op) {
case "Edit node":
case "edit":
print node_admin_edit($id);
break;
case "Delete node":
print status(node_delete($id));
print node_overview();
break;
2001-04-10 20:07:27 +00:00
case "listing":
2001-04-11 19:44:24 +00:00
print node_listing(node_query());
2001-04-10 20:07:27 +00:00
break;
2001-04-02 15:54:37 +00:00
case "Save node":
2001-04-19 19:59:48 +00:00
node_save($edit);
2001-04-07 15:02:28 +00:00
print node_admin_view($id);
2001-04-02 15:54:37 +00:00
break;
case "View node":
case "view":
print node_admin_view($id);
break;
default:
2001-04-10 20:07:27 +00:00
print node_overview(node_query($type));
2001-04-02 15:54:37 +00:00
}
}
?>