From be8e898d23a3f9ca515f59fbcc8d82e112ed7ee8 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 5 May 2001 13:57:29 +0000 Subject: - Uhm. Rewrote the module system: less code clutter, less run-time overhead, and a lot better (simpler) module API. I had to edit a LOT of files to get this refactored but I'm sure it was worth the effort. For module writers / maintainers: None of the hooks changed, so 95% of the old modules should still work. You can remove some code instead as "$module = array(...)" just became obsolete. Also - and let's thank God for this - the global variable "$repository" has been eliminated to avoid modules relying on, and poking in drupal's internal data structures. Take a look at include/module.inc to investigate the details/changes. - Improved design of the content modules "story", "book" and "node" (to aid smooth integration of permisions + moderate.module). I'm still working on the permissions but I got side tracked for which I "Oops!". --- modules/moderate.module | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'modules/moderate.module') diff --git a/modules/moderate.module b/modules/moderate.module index 5ce6d6d3a..821a588ca 100644 --- a/modules/moderate.module +++ b/modules/moderate.module @@ -1,7 +1,5 @@ "moderate_admin"); - function moderate_comment_access($cid) { global $user; return db_fetch_object(db_query("SELECT n.moderate FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.cid = '". check_input($cid) ."' AND n.moderate LIKE '%$user->userid%'")); @@ -30,29 +28,25 @@ function moderate_overview($query = array()) { return $output; } -function moderate_node_edit($id) { +function moderate_node($edit, $name) { global $user; - $node = node_get_array("nid", $id); + $node = node_get_array("nid", $edit[nid]); if ($node && strstr($node[moderate], $user->userid)) { - return node_form($node); + $edit[type] = $node[type]; + return node_invoke($edit, $name); } else { - return "access denied"; + return status(t("access denied")); } } -function moderate_node_save($edit) { - global $user; +function moderate_node_edit($edit) { + return moderate_node($edit, "form"); +} - $node = node_get_array("nid", $edit[nid]); - if ($node && strstr($node[moderate], $user->userid)) { - $edit[type] = $node[type]; - return node_invoke($edit, "save"); - } - else { - return "access denied"; - } +function moderate_node_save($edit) { + return moderate_node($edit, "save"); } function moderate_comment_edit($id) { @@ -92,7 +86,10 @@ function moderate_admin() { default: switch ($op) { case "edit": - print moderate_node_edit($id); + print moderate_node_edit(node_get_array("nid", $id)); + break; + case t("Preview"): + print moderate_node_edit($edit); break; case t("Submit"): print status(moderate_node_save($edit)); -- cgit v1.2.3