From 23ca7a2d8832aa16107cf7002c35170ae2b87a1c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 1 Nov 2001 17:04:20 +0000 Subject: - Another batch of updates/improvements: + introduced basic node permissions ("create", "delete", "update" and "view") at the node level: it's up to the "<$node->type>_module" to hide gory details (if any). + made the "blog it"-feature in the blog and import module work with the new node system, in specific with the new centralized forms. + made it possible to update blogs. + made the page module work with the new node system. + various smaller improvements. --- modules/page/page.module | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'modules/page') diff --git a/modules/page/page.module b/modules/page/page.module index 84488f296..bb1affd35 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -3,6 +3,33 @@ $GLOBALS["format"] = array(0 => "HTML", 1 => "PHP", 2 => "text"); +function page_node($field) { + $info = array("name" => "static page"); + + return $info[$field]; +} + +function page_access($op, $node) { + + if ($op == "view") { + return $node->nid && $node->status && !$node->moderate; + } + + return user_access("administer nodes"); +} + +function page_insert($node) { + db_query("INSERT INTO page (nid, format, link) VALUES ('$node->nid', '$node->format', '$node->link')"); +} + +function page_update($node) { + db_query("UPDATE page SET format = '$node->format', link = '$node->link' WHERE nid = '$node->nid'"); +} + +function page_delete($node) { + db_query("DELETE FROM page WHERE nid = '$node->nid'"); +} + function page_link($type) { if ($type == "page") { $result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link"); @@ -42,7 +69,8 @@ function page_form($node) { $node->body = addslashes($node->body); } - $output .= form_textarea("Body", "body", $node->body, 60, 30); + $output .= form_textarea("Body", "body", $node->body, 60, 20); + $output .= form_textfield("Link", "link", $node->link, 60, 64); $output .= form_select("Type", "format", $node->format, $format); return $output; @@ -50,16 +78,11 @@ function page_form($node) { function page_save() { - if (user_access("administer nodes")) { - if ($node->nid) { - return array(); - } - else { - return array("promote" => 0, "moderate" => 0, "status" => 1); - } + if ($node->nid) { + return array("format", "link"); } else { - return 0; + return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1); } } -- cgit v1.2.3