drupal/modules/node/node.module

112 lines
4.6 KiB
Plaintext
Raw Normal View History

<?php
$module = array("admin" => "node_admin");
function node_overview($query = array()) {
global $user;
$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");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>title</TH><TH>category</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($node = db_fetch_object($result)) {
$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";
}
$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";
$output .= form_item("Title", check_output($node->title));
$output .= form_item("Author", format_username($node->userid));
$output .= form_item("Status", node_status($node, $node->status));
$output .= form_item("Comment", node_comment_status($node->comment));
$output .= form_item("Promote", node_promote_status($node->promote));
$output .= form_item("Moderate", check_output($node->moderate));
$output .= form_item("Date", format_date($node->timestamp));
$output .= form_submit("Edit node");
$output .= form_submit("Delete node");
$output .= "</FORM>\n";
return $output;
}
function node_admin_edit($id) {
global $user;
$node = node_get_object("nid", $id);
$output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
$output .= form_item("Title", check_output($node->title));
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
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());
$output .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of usernames."));
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
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)"));
$output .= form_hidden("nid", $node->nid);
$output .= form_submit("View node");
$output .= form_submit("Save node");
$output .= "</FORM>\n";
return $output;
}
function node_delete($id) {
return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
}
function node_query($type = "") {
global $status;
$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"));
return ($queries[$type] ? $queries[$type] : $queries);
}
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";
}
return "<OL>$output</OL>\n";
}
function node_admin() {
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";
$id = check_input($edit[nid] ? $edit[nid] : $id);
$type = ($type ? $type : 0);
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;
case "listing":
print node_listing(node_query());
break;
case "Save node":
node_save($edit);
print node_admin_view($id);
break;
case "View node":
case "view":
print node_admin_view($id);
break;
default:
print node_overview(node_query($type));
}
}
?>