From 805107cd2202ddee66c4743e43804a3069508f29 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 2 Apr 2001 15:54:37 +0000 Subject: Commiting my work of last Sunday: - removed ban.inc and ban.module and integrated it in account.module under the name "access control" --> the ban code was not really up to standard so this has now been dealt with. This refactoring and reintegration cuts down the code size with 100 lines too. :-) (The ban.module code was really old and it showed.) - added node.module and made the other modules reuse some of this code --> cut down the code size of modules by at least 100 lines and adds stability. - added a status() function to admin.php to display a conform status message where appropriate. See admin.php for usage. - removed $theme->control() and made comments.inc handle this itself wrapped in a $theme->box(). No need to clutter the themes with such complexity --> updated all themes already. :-) - some small visual changes to some administration pages to be more consistent across different modules. --- modules/node/node.module | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 modules/node/node.module (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module new file mode 100644 index 000000000..a16390453 --- /dev/null +++ b/modules/node/node.module @@ -0,0 +1,93 @@ + "node_admin"); + + +$nstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted); + +function node_overview($query = 0) { + global $user, $nstatus; + + $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id". ($query ? " WHERE $query" : "")); + + $output .= "\n"; + $output .= " \n"; + while ($node = db_fetch_object($result)) { + $output .= " " : "view node") ."" : "edit node") ."" : "edit $node->type") ."\n"; + } + $output .= "
titletypestatusauthordateoperations
nid\">". check_output($node->title) ."$node->type". $nstatus[$node->status] ."". format_username($node->userid) ."". format_date($node->timestamp) ."". (user_access($user, "node") ? "nid\">view node". (user_access($user, "node") ? "nid\">edit node". (user_access($user, $node->type) ? "type&op=edit&id=$node->nid\">edit $node->type
\n"; + + return $output; +} + +function node_admin_view($id) { + global $nstatus; + + $node = node_get_object("nid", $id); + + $output .= "
nid\" METHOD=\"post\">\n"; + $output .= "Title:
". check_output($node->title) ."

\n"; + $output .= "Author:
". format_username($node->userid) ."

\n"; + $output .= "Status:
". $nstatus[$node->status] ."

\n"; + $output .= "Date:
". format_date($node->timestamp) ."

\n"; + $output .= "\n"; + $output .= "\n"; + $output .= "

\n"; + + return $output; +} + +function node_admin_edit($id) { + global $status, $user; + + $node = node_get_object("nid", $id); + + foreach (array($node->userid => $node->author, $user->userid => $user->id) as $value=>$key) $author .= " \n"; + foreach (array(format_date($node->timestamp) ." (original)" => $node->timestamp, format_date(time()) ." (current)" => time()) as $value=>$key) $timestamp .= " \n"; + foreach ($status as $value=>$key) $statuz .= " \n"; + + $output .= "
nid\" METHOD=\"post\">\n"; + $output .= "Title:
". check_output($node->title) ."

\n"; + $output .= "Author:

\n"; + $output .= "Status:

\n"; + $output .= "Date:

\n"; + $output .= "nid\">\n"; + $output .= "\n"; + $output .= "\n"; + $output .= "

\n"; + + return $output; +} + +function node_delete($id) { + return (node_del("nid", $id) ? "failed to delete node: node must be dumped first." : "node has been deleted."); +} + +function node_admin() { + global $op, $id, $edit; + + $id = check_input($edit[nid] ? $edit[nid] : $id); + + 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 "Save node": + print status(node_save($edit)); + print node_overview(); + break; + case "View node": + case "view": + print node_admin_view($id); + break; + default: + print node_overview(); + } +} + +?> -- cgit v1.2.3