From 72065fb8351b54eee5f1928c18e06ad81aa9b502 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 20 Jun 2001 20:00:40 +0000 Subject: - Added a brand-new access.module which allows you to manage 'roles' (groups) and 'permissions' ... (inspired by Zope's system). + Once installed, click the help-link for more information. + See updates/2.00-to-x.xx.sql for the SQL updates. - Modified loads of code to use our new access.module. The system still has to mature though: new permissions have to be added and existing permissions need stream-lining. Awaiting suggestions. - As a direct result of the new access system, I had to rewrite the way the top-level links in admin.php are rendered and displayed, and xhtml-ified admin.php while I was at it. TODO - Home-brewed modules need updating, home-brewed themes not. (Examples: file.module, trip_link.module) - As soon we *finished* the refactoring of the user system (KJ has been working on this refactoring already) we should consider to embed this role and permission code into account.module ... --- modules/node/node.module | 146 +++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 68 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 8e600e867..0b32efb40 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -26,6 +26,10 @@ function node_help() { } } +function node_perm() { + return array("add and edit nodes"); +} + function node_conf_options() { $output .= form_select(t("Default number of nodes to display"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of nodes to display on the main page.")); return $output; @@ -260,77 +264,83 @@ function node_edit($node) { } function node_admin() { - global $op, $id, $edit, $query, $type, $keys; + global $user, $op, $id, $edit, $query, $type, $keys; - foreach (module_list() as $name) { - if (module_hook($name, "status") && $name != "node") { - $link[] = "add $name"; + if (user_access($user, "add and edit nodes")) { + + foreach (module_list() as $name) { + if (module_hook($name, "status") && $name != "node") { + $link[] = "add $name"; + } } - } - print "". implode(" | ", $link) ." | node settings | node listings | search node | overview | help
\n"; - - $id = check_input($edit[nid] ? $edit[nid] : $id); - - switch ($op) { - case "add": - print module_invoke($type, "form"); - break; - case "help": - print node_help(); - break; - case "search": - print node_module_find($id); - print search_data($keys, $type); - break; - case "status": - print node_edit_status($id); - break; - case "option": - print node_edit_option($id); - break; - case "attribute": - print node_edit_attribute($id); - break; - case "content": - print node_edit_content(node_get_array(array("nid" => $id)), $type); - break; - case "default": - print node_setting(); - break; - case "delete": - print status(node_delete($id)); - print node_overview($query); - break; - case "listing": - print node_listing(node_query()); - break; - case "Save settings": - print status(conf_save($edit)); - print node_setting(); - break; - case "Reset to defaults": - print status(conf_default($edit)); - print node_setting(); - break; - case "Save node": - print node_admin_save($edit); - print node_overview($query); - break; - case "edit": - print node_edit(node_get_object(array("nid" => $id))); - break; - case "view": - print node_module_view(node_get_array(array("nid" => $id)), $type); - break; - case "Preview": - print node_edit_content($edit, $type); - break; - case "Submit": - print status(node_save_content($edit, $type)); - // fall through: - default: - print node_overview($query); + print "". implode(" | ", $link) ." | node settings | node listings | search node | overview | help
\n"; + + $id = check_input($edit[nid] ? $edit[nid] : $id); + + switch ($op) { + case "add": + print module_invoke($type, "form"); + break; + case "help": + print node_help(); + break; + case "search": + print node_module_find($id); + print search_data($keys, $type); + break; + case "status": + print node_edit_status($id); + break; + case "option": + print node_edit_option($id); + break; + case "attribute": + print node_edit_attribute($id); + break; + case "content": + print node_edit_content(node_get_array(array("nid" => $id)), $type); + break; + case "default": + print node_setting(); + break; + case "delete": + print status(node_delete($id)); + print node_overview($query); + break; + case "listing": + print node_listing(node_query()); + break; + case "Save settings": + print status(conf_save($edit)); + print node_setting(); + break; + case "Reset to defaults": + print status(conf_default($edit)); + print node_setting(); + break; + case "Save node": + print node_admin_save($edit); + print node_overview($query); + break; + case "edit": + print node_edit(node_get_object(array("nid" => $id))); + break; + case "view": + print node_module_view(node_get_array(array("nid" => $id)), $type); + break; + case "Preview": + print node_edit_content($edit, $type); + break; + case "Submit": + print status(node_save_content($edit, $type)); + // fall through: + default: + print node_overview($query); + } + } + else { + print message_access(); } } -- cgit v1.2.3