diff --git a/account.php b/account.php index ff9bf3dd3b23c1b99099d1f43e82853635378b60..a3b0d08996292d49cc67a79fb671dc66c433f0c1 100644 --- a/account.php +++ b/account.php @@ -152,7 +152,7 @@ function account_content_edit() { // construct form: $result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module"); while ($block = db_fetch_object($result)) { - $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '$block->name' AND user = '$user->id'")); + $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '". check_input($block->name) ."' AND user = '$user->id'")); $options .= "<INPUT TYPE=\"checkbox\" NAME=\"edit[$block->name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."<BR>\n"; } diff --git a/admin.php b/admin.php index ffc4cdfccb14c9da36606cc93ee04c09cc859f11..830f866623e4177eefe13e495383e2d61be15321 100644 --- a/admin.php +++ b/admin.php @@ -7,13 +7,7 @@ function status($message) { } function admin_page($mod) { - global $menu, $user; - - function module($name) { - global $menu, $user; - if (module_hook($name, "admin")) $output .= "<A HREF=\"admin.php?mod=$name\">$name</A> | "; - $menu .= $output; - } + global $user; ?> <html> @@ -31,10 +25,11 @@ function module($name) { <body bgcolor="#FFFFFF" link="#005599" vlink="#004499" alink="#FF0000"> <h1>Administration</h1> <?php + + $links[] = "<a href=\index.php\">home</a>"; foreach (module_list() as $name) { - if (module_hook($name, "admin")) $links[] = "<a href=\"admin.php?mod=$name\">$name</a>"; + if (module_hook($name, "link")) $links = array_merge($links, module_invoke($name, "link", "admin")); } - $links[] = "<a href=\"index.php\">home</a>"; print implode(" | ", $links) ."<hr />"; @@ -45,7 +40,7 @@ function module($name) { <?php } -if (user_access($user, "access administration pages")) { +if (user_access("access administration pages")) { user_rehash(); admin_page($mod); } diff --git a/includes/comment.inc b/includes/comment.inc index 9bbc0c25969c82a7de82e00fe5a34fa5c6c3c765..dc5bbd48a75ec3f9af1104830d000784c2172712 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -87,7 +87,7 @@ function comment_reply($pid, $id) { $pid = 0; } - if (user_access($user, "post comments")) { + if (user_access("post comments")) { $theme->box(t("Reply"), comment_form(array(pid=>$pid, id=>$id))); } else { @@ -107,7 +107,7 @@ function comment_preview($edit) { function comment_post($edit) { global $theme, $user; - if (user_access($user, "post comments")) { + if (user_access("post comments")) { // check comment submission rate: throttle("post comment", variable_get(max_comment_rate, 60)); @@ -213,7 +213,7 @@ function comment_uri($args = 0) { else return ($mod) ? "module.php?mod=$mod" : "node.php"; } -function comment_link($comment, $return = 1) { +function comment_links($comment, $return = 1) { global $theme; if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("return") ."</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("reply to this comment") ."</FONT></A>"; else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("reply to this comment") ."</FONT></A>"; @@ -250,7 +250,7 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) { while ($comment = db_fetch_object($result)) { print "<UL>"; - comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); + comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1); print "</UL>"; } @@ -259,7 +259,7 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) { function comment_render($lid, $cid) { global $user, $theme, $REQUEST_URI; - if (user_access($user, "view comments")) { + if (user_access("access comments")) { // Pre-process variables: $lid = empty($lid) ? 0 : $lid; @@ -279,7 +279,7 @@ function comment_render($lid, $cid) { if ($cid > 0) { $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE cid = '$cid'"); if ($comment = db_fetch_object($result)) { - comment_view($comment, comment_link($comment)); + comment_view($comment, comment_links($comment)); } } else { @@ -297,7 +297,7 @@ function comment_render($lid, $cid) { else if ($mode == 2) { $result = comment_query($lid, $order); while ($comment = db_fetch_object($result)) { - comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); + comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); } } else if ($mode == 3) { @@ -310,7 +310,7 @@ function comment_render($lid, $cid) { else { $result = comment_query($lid, $order, 0); while ($comment = db_fetch_object($result)) { - comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); + comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); comment_thread_max($comment->cid, $mode, $threshold, $level + 1); } } diff --git a/includes/common.inc b/includes/common.inc index a5b82357cb2ed08348fbe5dec881284f2c291df4..9ef2da44f76823c8beda97969c9da61a2b53ca38 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -24,8 +24,7 @@ function watchdog($type, $message) { } function throttle($type, $rate) { - global $user; - if (!user_access($user, "access administration pages")) { + if (!user_access("access administration pages")) { if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) { watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type"); die(message_throttle()); @@ -135,8 +134,7 @@ function format_date($timestamp, $type = "medium", $format = "") { } function format_username($username) { - global $user; - if ($username) return (user_access($user, "add and edit user accounts") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">$username</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">$username</A>"); + if ($username) return (user_access("administer accounts") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">$username</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">$username</A>"); else return variable_get(anonymous, "Anonymous"); } @@ -209,6 +207,27 @@ function field_merge($a, $b) { return $a; } +function link_page() { + + $links[] = "<a href=\"index.php\">". t("home") ."</a>"; + $links[] = "<a href=\"search.php\">". t("search") ."</a>"; + $links[] = "<a href=\"submit.php\">". t("submit") ."</a>"; + $links[] = "<a href=\"account.php\">". t("account") ."</a>"; + + foreach (module_list() as $name) { + if (module_hook($name, "link")) { + $links = array_merge($links, module_invoke($name, "link", "page")); + } + } + + + return $links; +} + +function link_node($node) { + return module_invoke("node", "link", array("node", $node)); +} + function timer_start() { global $timer; $timer = explode(" ", microtime()); diff --git a/includes/module.inc b/includes/module.inc index 2843e55473fda64b000488d6afa08e97e237a4a5..cbbb1b18d58c1c1c54e9e0a45825b600ac38b98a 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -11,7 +11,7 @@ function module_iterate($function, $argument = "") { } // invoke hook $hook of module $name with optional arguments: -function module_invoke($name, $hook, $argument = "") { +function module_invoke($name, $hook, $argument = 0) { $function = $name ."_". $hook; return function_exists($function) ? $function($argument) : $argument; } diff --git a/includes/node.inc b/includes/node.inc index affb4437126f715df293acc23012dc05e7e261f0..47a317547dde6a5c64f00ba6ccf7eadf8cbb284e 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -236,20 +236,11 @@ function node_index($node) { function node_visible($node) { global $user, $status; - return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access($user, $node->type) || user_access($user, "add and edit nodes"); + return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access("administer nodes"); } function node_access($account, $node) { return strstr($node->moderate, $account->userid); } -function node_links(&$links, &$node, $main = 0) { - if ($main) { - if ($node->body) $_links[] = array("node.php?id=$node->nid", t("read more")); - if ($node->comment) $_links[] = array("node.php?id=$node->nid", format_plural(node_get_comments($node->nid), "comment", "comments")); - } - $links = ($links ? array_merge($_links, $links) : $_links); - return count($links) ? $links : 0; -} - ?> \ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index b01638d60654accbdbdbf89f435419c9040b1226..9530c60b145ebd3fb8a69ef5cb33eede454c0874 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1,16 +1,8 @@ <?php class BaseTheme { - function links(&$links, $state = 0) { - // $state = 0 : default behaviour - // $state = 1 : main page - // $state = 2 : theme_link() - // Subject to change coz its messy - foreach ($links as $link) { - if ($link[0]) $_links[] = count($link) == 2 ? "<A HREF=\"$link[0]\"><FONT COLOR=\"$theme->link\">". t($link[1]) ."</FONT></A>" : t($link[0]); - } - - return ($_links ? implode(" | ", $_links) : ""); + function links($links, $delimiter = " | ") { + return implode($delimiter, $links); } } @@ -26,21 +18,6 @@ function theme_init() { return new Theme(); } -function theme_link() { - global $user, $theme; - $links[] = array("index.php", t("home")); - $links[] = array("search.php", t("search")); - $links[] = array("submit.php", t("submit")); - $links[] = array("account.php", t("account")); - - foreach (module_list() as $name) { - if (module_hook($name, "page")) $links[] = array("module.php?mod=$name", t($name)); - } - - return $theme->links($links, 2); -} - - function theme_account($theme) { global $user; @@ -55,13 +32,14 @@ function theme_account($theme) { $content .= "<A HREF=\"account.php?op=edit&topic=content\">". t("edit your content") ."</A><BR>\n"; $content .= "<P>\n"; - if (user_access($user, "access administration pages")) { + if (user_access("access administration pages")) { $content .= "<A HREF=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</A><BR>\n"; $content .= "<P>\n"; } foreach (module_list() as $name) { - if ($links = module_invoke($name, "menu")) { + if (module_hook($name, "link")) { + $links = module_invoke($name, "link", "menu"); foreach ($links as $link) $content .= "$link<BR>\n"; } } @@ -119,29 +97,4 @@ function theme_moderation_results($theme, $node) { $theme->box(t("Moderation results"), ($output ? $output : t("This node has not been moderated yet."))); } -/* -// -// depricated -> new block strategy -// -function theme_new_headlines($theme, $num = 10) { - $result = db_query("SELECT nid, title FROM node WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num"); - while ($node = db_fetch_object($result)) $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n"; - $theme->box(t("Latest headlines"), $content); -} - -function theme_old_headlines($theme, $num = 10) { - global $user; - - $result = db_query("SELECT id, subject, timestamp FROM story WHERE status = 2 ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : $num) .", $num"); - while ($node = db_fetch_object($result)) { - if ($time != date("F jS", $node->timestamp)) { - $content .= "<P><B>". date("l, M jS", $node->timestamp) ."</B></P>\n"; - $time = date("F jS", $node->timestamp); - } - $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n"; - } - $theme->box(t("Older headlines"), $content); -} -*/ - ?> diff --git a/includes/user.inc b/includes/user.inc index 5e0bf22745c9ba485a6d8f7d006c2193c7c5ef84..9e1370f6b99a54d60440bc20dcdaa5e791003d01 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -52,12 +52,14 @@ function user_save($account, $array) { return user_load(($account->userid ? $account->userid : $array[userid])); } -function user_access($account, $perm) { - if ($account->id == 1) { +function user_access($perm) { + global $user; + + if ($user->id == 1) { return 1; } - else if ($account->perm) { - return strstr($account->perm, $perm); + else if ($user->perm) { + return strstr($user->perm, $perm); } else { return db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user' AND perm LIKE '%$perm%'")); diff --git a/index.php b/index.php index 9807560987073d210d9c0335b0b44bd47b38737a..25f02b1e7f0afc626edd8b23dc781e0b980c43c7 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ $theme->header(); -if (user_access($user, "view content")) { +if (user_access("view content")) { $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '". node_status("posted") ."' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10))); while ($node = db_fetch_object($result)) { node_view(node_get_object(array("nid" => $node->nid, "type" => $node->type)), 1); diff --git a/modules/access.module b/modules/access.module index 7126d4584baf778e75278a596adb539a164b29bc..9addd0732d297e6dafcf7dbd6f749eb4be08d56a 100644 --- a/modules/access.module +++ b/modules/access.module @@ -21,7 +21,15 @@ function access_help() { } function access_perm() { - return array("access administration pages", "view content", "search content", "post content", "edit roles and permissions"); + return array("access administration pages", "access content", "search content", "post content", "administer roles and permissions"); +} + +function access_link($type) { + if ($type == "admin" && user_access("administer roles and permissions")) { + $links[] = "<a href=\"admin.php?mod=access\">roles and permissions</a>"; + } + + return $links ? $links : array(); } function access_get_role($rid) { @@ -125,9 +133,9 @@ function access_init() { } function access_admin() { - global $user, $edit, $op, $id; + global $edit, $op, $id; - if (user_access($user, "edit roles and permissions")) { + if (user_access("administer roles and permissions")) { print "<SMALL><A HREF=\"admin.php?mod=access&op=add\">add new role</A> | <A HREF=\"admin.php?mod=access&op=role\">role overview</A> | <A HREF=\"admin.php?mod=access&op=perm\">permission overview</A> | <A HREF=\"admin.php?mod=access&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/account.module b/modules/account.module index db464623fec9b476da95c6658bf826257378db48..117c714334cae49b46a182297bf1c6b61e754269 100644 --- a/modules/account.module +++ b/modules/account.module @@ -33,7 +33,15 @@ function account_help() { } function account_perm() { - return array("add and edit user accounts"); + return array("administer users"); +} + +function account_link($type) { + if ($type == "admin" && user_access("administer users")) { + $links[] = "<a href=\"admin.php?mod=account\">user accounts</a>"; + } + + return $links ? $links : array(); } function account_conf_options() { @@ -42,10 +50,9 @@ function account_conf_options() { } function account_search($keys) { - global $user; $result = db_query("SELECT * FROM users WHERE userid LIKE '%$keys%' LIMIT 20"); while ($account = db_fetch_object($result)) { - $find[$i++] = array("title" => $account->userid, "link" => (user_access($user, "add and edit user accounts") ? "admin.php?mod=account&op=view&name=". urlencode($account->userid) : "account.php?op=view&name=". urlencode($account->userid)), "user" => $account->userid); + $find[$i++] = array("title" => $account->userid, "link" => (user_access("administer users") ? "admin.php?mod=account&op=view&name=". urlencode($account->userid) : "account.php?op=view&name=". urlencode($account->userid)), "user" => $account->userid); } return $find; } @@ -248,9 +255,9 @@ function account_query($type = "") { } function account_admin() { - global $user, $op, $edit, $id, $mod, $keys, $order, $name, $query; + global $op, $edit, $id, $mod, $keys, $order, $name, $query; - if (user_access($user, "add and edit user accounts")) { + if (user_access("administer users")) { print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=add\">add new account</A> | <A HREF=\"admin.php?mod=account&op=listing\">account listings</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>"; $query = $query ? $query : 0; diff --git a/modules/aggregator.module b/modules/aggregator.module index 447090738eca955e0df580e014d82bc3f697a4c6..44f0b480a9611055512e8cb0a2438ca38788cfaf 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -12,7 +12,15 @@ function import_help() { } function import_perm() { - return array("add and edit news feeds"); + return array("administer news feeds"); +} + +function import_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=import\">news feeds</a>"; + } + + return $links ? $links : array(); } function import_cron() { @@ -241,9 +249,9 @@ function import_view_item() { } function import_admin() { - global $user, $op, $id, $type, $edit; + global $op, $id, $type, $edit; - if (user_access($user, "add and edit news feeds")) { + if (user_access("administer news feeds")) { print "<SMALL><A HREF=\"admin.php?mod=import&type=bundle&op=add\">add new bundle</A> | <A HREF=\"admin.php?mod=import&type=feed&op=add\">add new feed</A> | <A HREF=\"admin.php?mod=import&type=bundle&op=view\">available bundles</A> | <A HREF=\"admin.php?mod=import&type=item&op=view\">available items</A> | <A HREF=\"admin.php?mod=import&op=view\">overview</A> | <A HREF=\"admin.php?mod=import&op=help\">help</A></SMALL><HR>"; diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 447090738eca955e0df580e014d82bc3f697a4c6..44f0b480a9611055512e8cb0a2438ca38788cfaf 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -12,7 +12,15 @@ function import_help() { } function import_perm() { - return array("add and edit news feeds"); + return array("administer news feeds"); +} + +function import_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=import\">news feeds</a>"; + } + + return $links ? $links : array(); } function import_cron() { @@ -241,9 +249,9 @@ function import_view_item() { } function import_admin() { - global $user, $op, $id, $type, $edit; + global $op, $id, $type, $edit; - if (user_access($user, "add and edit news feeds")) { + if (user_access("administer news feeds")) { print "<SMALL><A HREF=\"admin.php?mod=import&type=bundle&op=add\">add new bundle</A> | <A HREF=\"admin.php?mod=import&type=feed&op=add\">add new feed</A> | <A HREF=\"admin.php?mod=import&type=bundle&op=view\">available bundles</A> | <A HREF=\"admin.php?mod=import&type=item&op=view\">available items</A> | <A HREF=\"admin.php?mod=import&op=view\">overview</A> | <A HREF=\"admin.php?mod=import&op=help\">help</A></SMALL><HR>"; diff --git a/modules/block.module b/modules/block.module index 07b078dd72cb60bc22306c971bb44c10283a610c..97139035fc44fa42c40a0e9d576882a385bbd70a 100644 --- a/modules/block.module +++ b/modules/block.module @@ -10,7 +10,15 @@ function block_help() { } function block_perm() { - return array("add and edit blocks"); + return array("administer blocks"); +} + +function block_link($type) { + if ($type == "admin" && user_access("adminsiter blocks")) { + $links[] = "<a href=\"admin.php?mod=block\">blocks</a>"; + } + + return $links ? $links : array(); } function block_admin_save($edit) { @@ -114,9 +122,9 @@ function block_init() { } function block_admin() { - global $user, $op, $edit; + global $op, $edit; - if (user_access($user, "add and edit blocks")) { + if (user_access("administer blocks")) { print "<SMALL><A HREF=\"admin.php?mod=block\">configure</A> | <A HREF=\"admin.php?mod=block&op=preview\">preview</A> | <A HREF=\"admin.php?mod=block&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/block/block.module b/modules/block/block.module index 07b078dd72cb60bc22306c971bb44c10283a610c..97139035fc44fa42c40a0e9d576882a385bbd70a 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -10,7 +10,15 @@ function block_help() { } function block_perm() { - return array("add and edit blocks"); + return array("administer blocks"); +} + +function block_link($type) { + if ($type == "admin" && user_access("adminsiter blocks")) { + $links[] = "<a href=\"admin.php?mod=block\">blocks</a>"; + } + + return $links ? $links : array(); } function block_admin_save($edit) { @@ -114,9 +122,9 @@ function block_init() { } function block_admin() { - global $user, $op, $edit; + global $op, $edit; - if (user_access($user, "add and edit blocks")) { + if (user_access("administer blocks")) { print "<SMALL><A HREF=\"admin.php?mod=block\">configure</A> | <A HREF=\"admin.php?mod=block&op=preview\">preview</A> | <A HREF=\"admin.php?mod=block&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/book.module b/modules/book.module index 0365e9833b3051e29d268a4b20e6916e2bfbdc14..b8d3f9c81e06497ca8ee49f8bd70b718d865bf5d 100644 --- a/modules/book.module +++ b/modules/book.module @@ -10,7 +10,19 @@ function Book($book) { } function book_perm() { - return array("edit book"); + return array("administer book"); +} + +function book_link($type) { + if ($type == "admin" && user_access("administer book")) { + $links[] = "<a href=\"admin.php?mod=book\">". t("collaborative book") ."</a>"; + } + + if ($type == "page" && user_access("access content")) { + $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>"; + } + + return $links ? $links : array(); } function book_status() { @@ -70,10 +82,10 @@ function book_view($node, $main = 0) { } function book_search($keys) { - global $status, $user; + global $status; $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); } return $find; } @@ -90,13 +102,13 @@ function book_parent_query($parent) { } function book_toc($parent = "", $indent = "", $toc = array()) { - global $status, $user; + global $status; // select all child nodes: $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight"); // add root node: - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { $toc[0] = "<root>"; } @@ -125,7 +137,7 @@ function book_form($edit = array()) { $form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { $form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.")); } @@ -155,7 +167,7 @@ function book_save($edit) { if (!$edit[nid]) { node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { node_save($edit, array(body, log, parent, title, type => "book", weight)); } } @@ -207,8 +219,7 @@ function book_tree($parent = "", $depth = 0) { } function book_admin() { - global $user; - if (user_access($user, "edit book")) { + if (user_access("administer book")) { print book_tree(); } else { @@ -217,9 +228,9 @@ function book_admin() { } function book_page() { - global $user, $status, $theme; + global $status, $theme; - if (user_access($user, "view content")) { + if (user_access("access content")) { $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = 0 AND n.status = $status[posted] ORDER BY b.weight"); while ($node = db_fetch_object($result)) { diff --git a/modules/book/book.module b/modules/book/book.module index 0365e9833b3051e29d268a4b20e6916e2bfbdc14..b8d3f9c81e06497ca8ee49f8bd70b718d865bf5d 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -10,7 +10,19 @@ function Book($book) { } function book_perm() { - return array("edit book"); + return array("administer book"); +} + +function book_link($type) { + if ($type == "admin" && user_access("administer book")) { + $links[] = "<a href=\"admin.php?mod=book\">". t("collaborative book") ."</a>"; + } + + if ($type == "page" && user_access("access content")) { + $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>"; + } + + return $links ? $links : array(); } function book_status() { @@ -70,10 +82,10 @@ function book_view($node, $main = 0) { } function book_search($keys) { - global $status, $user; + global $status; $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); } return $find; } @@ -90,13 +102,13 @@ function book_parent_query($parent) { } function book_toc($parent = "", $indent = "", $toc = array()) { - global $status, $user; + global $status; // select all child nodes: $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight"); // add root node: - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { $toc[0] = "<root>"; } @@ -125,7 +137,7 @@ function book_form($edit = array()) { $form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { $form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.")); } @@ -155,7 +167,7 @@ function book_save($edit) { if (!$edit[nid]) { node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { node_save($edit, array(body, log, parent, title, type => "book", weight)); } } @@ -207,8 +219,7 @@ function book_tree($parent = "", $depth = 0) { } function book_admin() { - global $user; - if (user_access($user, "edit book")) { + if (user_access("administer book")) { print book_tree(); } else { @@ -217,9 +228,9 @@ function book_admin() { } function book_page() { - global $user, $status, $theme; + global $status, $theme; - if (user_access($user, "view content")) { + if (user_access("access content")) { $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = 0 AND n.status = $status[posted] ORDER BY b.weight"); while ($node = db_fetch_object($result)) { diff --git a/modules/box.module b/modules/box.module index c8e4330e282d6ad3a5e16acb80bffa6a2468842f..8bac561383f9a7f80b97dfe04caa0243fe32e536 100644 --- a/modules/box.module +++ b/modules/box.module @@ -30,7 +30,15 @@ function box_help() { } function box_perm() { - return array("add and edit boxes"); + return array("administer boxes"); +} + +function box_link($type) { + if ($type == "admin" && user_access("administer boxes")) { + $links[] = "<a href=\"admin.php?mod=box\">boxes</a>"; + } + + return $links ? $links : array(); } function box_block() { @@ -142,9 +150,9 @@ function box_admin_save($id, $subject, $content, $info, $link, $type) { } function box_admin() { - global $user, $op, $id, $subject, $content, $info, $link, $type; + global $op, $id, $subject, $content, $info, $link, $type; - if (user_access($user, "add and edit boxes")) { + if (user_access("administer boxes")) { print "<SMALL><A HREF=\"admin.php?mod=box&op=add\">add new box</A> | <A HREF=\"admin.php?mod=box\">overview</A> | <A HREF=\"admin.php?mod=box&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/comment.module b/modules/comment.module index ad9924603c7158bc9588c48b762dbf14c7028f91..5f4dd09fde61a2e2e5f4ad20b2bbf41345295d56 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -4,13 +4,21 @@ function comment_search($keys) { global $user; $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); while ($comment = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access($user, "edit user comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); + $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); } return $find; } function comment_perm() { - return array("view comments", "post comments", "edit comments"); + return array("access comments", "post comments", "administer comments"); +} + +function comment_link($type) { + if ($type == "admin" and user_access("administer comments")) { + $links[] = "<a href=\"admin.php?mod=comment\">comments</a>"; + } + + return $links ? $links : array(); } function comment_edit($id) { @@ -46,9 +54,9 @@ function comment_overview() { } function comment_admin() { - global $user, $op, $id, $edit, $mod, $keys, $order; + global $op, $id, $edit, $mod, $keys, $order; - if (user_access($user, "edit comments")) { + if (user_access("administer comments")) { print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n"; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index ad9924603c7158bc9588c48b762dbf14c7028f91..5f4dd09fde61a2e2e5f4ad20b2bbf41345295d56 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -4,13 +4,21 @@ function comment_search($keys) { global $user; $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); while ($comment = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access($user, "edit user comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); + $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); } return $find; } function comment_perm() { - return array("view comments", "post comments", "edit comments"); + return array("access comments", "post comments", "administer comments"); +} + +function comment_link($type) { + if ($type == "admin" and user_access("administer comments")) { + $links[] = "<a href=\"admin.php?mod=comment\">comments</a>"; + } + + return $links ? $links : array(); } function comment_edit($id) { @@ -46,9 +54,9 @@ function comment_overview() { } function comment_admin() { - global $user, $op, $id, $edit, $mod, $keys, $order; + global $op, $id, $edit, $mod, $keys, $order; - if (user_access($user, "edit comments")) { + if (user_access("administer comments")) { print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n"; diff --git a/modules/cvs.module b/modules/cvs.module index cc81a12e68ed115676cd39a5cc1a48cc024573a5..bc12068983bb6810ae73cf224b9019edb241d412 100644 --- a/modules/cvs.module +++ b/modules/cvs.module @@ -1,7 +1,15 @@ <?php function cvs_perm() { - return array("view CVS messages"); + return array("access cvs messages"); +} + +function cvs_link($type) { + if ($type == "page" && user_access("access cvs messages")) { + $links[] = "<a href=\"module.php?mod=cvs\">cvs messages</a>"; + } + + return $links ? $links : array(); } function cvs_cron() { @@ -14,7 +22,7 @@ function cvs_cron() { } $result = db_query("UPDATE cvs SET status = '1'"); - if ($body) mail(variable_get(cvs_mail, "root@localhost"), "CVS log messages", $body, "From: no-reply"); + if ($body) mail(variable_get(cvs_mail, "root@localhost"), "cvs log messages", $body, "From: no-reply"); } } @@ -26,9 +34,9 @@ function cvs_conf_options() { } function cvs_page() { - global $user, $theme; + global $theme; - if (user_access($user, "view CVS messages")) { + if (user_access("access cvs messages")) { $result = db_query("SELECT * FROM cvs ORDER BY timestamp DESC LIMIT 50"); while ($cvs = db_fetch_object($result)) { diff --git a/modules/diary.module b/modules/diary.module index a186161cee809f357c7d62cb22546c12f7b468dd..6008c344f76c006e197f7cb7839509edf21203ff 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -1,14 +1,13 @@ <?php function diary_perm() { - return array("view diary entries", "edit diary entries"); + return array("administer diary entries", "access diary entries", "post diary entries"); } function diary_search($keys) { - global $user; $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE d.text LIKE '%$keys%' ORDER BY d.timestamp DESC LIMIT 20"); while ($diary = db_fetch_object($result)) { - $find[$i++] = array("title" => "$diary->userid's diary", "link" => (user_access($user, "edit diary entries") ? "admin.php?mod=diary&op=edit&id=$diary->id" : "module.php?mod=diary&op=view&name=$diary->userid"), "user" => $diary->userid, "date" => $diary->timestamp); + $find[$i++] = array("title" => "$diary->userid's diary", "link" => (user_access("administer diary entries") ? "admin.php?mod=diary&op=edit&id=$diary->id" : "module.php?mod=diary&op=view&name=$diary->userid"), "user" => $diary->userid, "date" => $diary->timestamp); } return $find; @@ -17,7 +16,7 @@ function diary_search($keys) { function diary_page_overview($num = 20) { global $theme, $user; - if (user_access($user, "view diary entries")) { + if (user_access("access diary entries")) { $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY d.timestamp DESC LIMIT $num"); while ($diary = db_fetch_object($result)) { @@ -212,8 +211,22 @@ function diary_help() { <?php } -function diary_menu() { - return array("<A HREF=\"module.php?mod=diary&op=add\">". t("edit your diary") ."</A>", "<A HREF=\"module.php?mod=diary&op=view\">". t("view your diary") ."</A>"); +function diary_link($type) { + + if ($type == "admin" && user_access("adminsiter diary entries")) { + $links[] = "<a href=\"admin.php?mod=diary\">online diaries</a>"; + } + + if ($type == "page" && user_access("access diary entries")) { + $links[] = "<a href=\"module.php?mod=diary\">". t("online diaries") ."</a>"; + } + + if ($type == "menu" && user_access("post diary entries")) { + $links[] = "<a href=\"module.php?mod=diary&op=add\">". t("edit your diary") ."</a>"; + $links[] = "<a href=\"module.php?mod=diary&op=view\">". t("view your diary") ."</a>"; + } + + return $links ? $links : array(); } function diary_block() { @@ -309,9 +322,9 @@ function diary_admin_display($order = "date") { function diary_admin() { - global $user, $op, $id, $mod, $keys, $text, $order; + global $op, $id, $mod, $keys, $text, $order; - if (user_access($user, "edit diary entries")) { + if (user_access("administer diary entries")) { print "<SMALL><A HREF=\"admin.php?mod=diary\">overview</A> | <A HREF=\"admin.php?mod=diary&op=search\">search diary</A> | <A HREF=\"admin.php?mod=diary&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/forum.module b/modules/forum.module index cdbe9ce4f5c96f6200ab7f2558d5368a80710ffa..ecf0f52bd89a8b9afccb7b0d230d54dc0238fb0d 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -4,6 +4,15 @@ function forum_status() { return array(dumped, posted); } + +function forum_link($type) { + if ($type == "page" && user_access("access content")) { + $links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>"; + } + + return $links ? $links : array(); +} + function forum_view($node) { global $theme; $output .= "<P><A HREF=\"module.php?mod=forum\">". t("Forum") ."</A> / <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>:</P><P>". check_output($node->body) ."</P>"; @@ -38,9 +47,9 @@ function forum_last_comment($nid) { } function forum_page() { - global $user, $theme; + global $theme; - if (user_access($user, "view content")) { + if (user_access("access content")) { $result = db_query("SELECT nid FROM node WHERE type = 'forum' ORDER BY title"); $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index cdbe9ce4f5c96f6200ab7f2558d5368a80710ffa..ecf0f52bd89a8b9afccb7b0d230d54dc0238fb0d 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -4,6 +4,15 @@ function forum_status() { return array(dumped, posted); } + +function forum_link($type) { + if ($type == "page" && user_access("access content")) { + $links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>"; + } + + return $links ? $links : array(); +} + function forum_view($node) { global $theme; $output .= "<P><A HREF=\"module.php?mod=forum\">". t("Forum") ."</A> / <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>:</P><P>". check_output($node->body) ."</P>"; @@ -38,9 +47,9 @@ function forum_last_comment($nid) { } function forum_page() { - global $user, $theme; + global $theme; - if (user_access($user, "view content")) { + if (user_access("access content")) { $result = db_query("SELECT nid FROM node WHERE type = 'forum' ORDER BY title"); $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; diff --git a/modules/help.module b/modules/help.module index 254432a7bed523be41e37c7d464193989bcd7e63..1b26fd7ad03b800dc78379ead34ab8d7bf687ab7 100644 --- a/modules/help.module +++ b/modules/help.module @@ -1,5 +1,13 @@ <?php +function help_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=help\">help</a>"; + } + + return $links ? $links : array(); +} + function help_admin() { foreach (module_list() as $name) { if (module_hook($name, "help")) { diff --git a/modules/help/help.module b/modules/help/help.module index 254432a7bed523be41e37c7d464193989bcd7e63..1b26fd7ad03b800dc78379ead34ab8d7bf687ab7 100644 --- a/modules/help/help.module +++ b/modules/help/help.module @@ -1,5 +1,13 @@ <?php +function help_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=help\">help</a>"; + } + + return $links ? $links : array(); +} + function help_admin() { foreach (module_list() as $name) { if (module_hook($name, "help")) { diff --git a/modules/import.module b/modules/import.module index 447090738eca955e0df580e014d82bc3f697a4c6..44f0b480a9611055512e8cb0a2438ca38788cfaf 100644 --- a/modules/import.module +++ b/modules/import.module @@ -12,7 +12,15 @@ function import_help() { } function import_perm() { - return array("add and edit news feeds"); + return array("administer news feeds"); +} + +function import_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=import\">news feeds</a>"; + } + + return $links ? $links : array(); } function import_cron() { @@ -241,9 +249,9 @@ function import_view_item() { } function import_admin() { - global $user, $op, $id, $type, $edit; + global $op, $id, $type, $edit; - if (user_access($user, "add and edit news feeds")) { + if (user_access("administer news feeds")) { print "<SMALL><A HREF=\"admin.php?mod=import&type=bundle&op=add\">add new bundle</A> | <A HREF=\"admin.php?mod=import&type=feed&op=add\">add new feed</A> | <A HREF=\"admin.php?mod=import&type=bundle&op=view\">available bundles</A> | <A HREF=\"admin.php?mod=import&type=item&op=view\">available items</A> | <A HREF=\"admin.php?mod=import&op=view\">overview</A> | <A HREF=\"admin.php?mod=import&op=help\">help</A></SMALL><HR>"; diff --git a/modules/locale.module b/modules/locale.module index 8450746f597ffc78b73ace9af7560e54e9f26fe3..73d531c85d8dcb5f9cd5640ab0e46932d6c63bcc 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -35,7 +35,15 @@ function locale_help() { } function locale_perm() { - return array("add and edit locales"); + return array("administer locales"); +} + +function locale_link($type) { + if ($type == "admin" && user_access("administer locales")) { + $links[] = "<a href=\"admin.php?mod=locale\">locales</a>"; + } + + return $links ? $links : array(); } function locale_conf_options() { @@ -97,9 +105,9 @@ function locale_overview() { } function locale_admin() { - global $user, $id, $edit, $op; + global $id, $edit, $op; - if (user_access($user, "add and edit locales")) { + if (user_access("administer locales")) { print "<SMALL><A HREF=\"admin.php?mod=locale\">overview</A> | <A HREF=\"admin.php?mod=locale&op=help\">help</A></SMALL><HR>\n"; switch ($op) { diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 8450746f597ffc78b73ace9af7560e54e9f26fe3..73d531c85d8dcb5f9cd5640ab0e46932d6c63bcc 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -35,7 +35,15 @@ function locale_help() { } function locale_perm() { - return array("add and edit locales"); + return array("administer locales"); +} + +function locale_link($type) { + if ($type == "admin" && user_access("administer locales")) { + $links[] = "<a href=\"admin.php?mod=locale\">locales</a>"; + } + + return $links ? $links : array(); } function locale_conf_options() { @@ -97,9 +105,9 @@ function locale_overview() { } function locale_admin() { - global $user, $id, $edit, $op; + global $id, $edit, $op; - if (user_access($user, "add and edit locales")) { + if (user_access("administer locales")) { print "<SMALL><A HREF=\"admin.php?mod=locale\">overview</A> | <A HREF=\"admin.php?mod=locale&op=help\">help</A></SMALL><HR>\n"; switch ($op) { diff --git a/modules/meta.module b/modules/meta.module index 092bf1d4c7f2326272e7548898045c37b066ff57..207123b80a817050982e34cba6fec1fd9a1ac2d2 100644 --- a/modules/meta.module +++ b/modules/meta.module @@ -6,10 +6,19 @@ function meta_help() { <?php } -function meta_conf() { - return array("add and edit meta tags"); +function meta_perm() { + return array("administer meta tags"); } +function meta_link($type) { + if ($type == "admin" && user_access("administer meta tags")) { + $links[] = "<a href=\"admin.php?mod=meta\">meta tags</a>"; + } + + return $links ? $links : array(); +} + + function meta_form($type, $edit = array()) { $c = db_query("SELECT * FROM collection WHERE types LIKE '%". check_input($type) ."%'"); while ($collection = db_fetch_object($c)) { @@ -129,9 +138,9 @@ function meta_overview() { } function meta_admin() { - global $user, $edit, $type, $op, $id; + global $edit, $type, $op, $id; - if (user_access($user, "add and edit meta tags")) { + if (user_access("administer meta tags")) { print "<SMALL><A HREF=\"admin.php?mod=meta&type=collection&op=add\">add new collection</A> | <A HREF=\"admin.php?mod=meta&type=tag&op=add\">add new meta-tag</A> | <A HREF=\"admin.php?mod=meta&op=preview\">preview node forms</A> | <A HREF=\"admin.php?mod=meta\">overview</A> | <A HREF=\"admin.php?mod=meta&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/moderate.module b/modules/moderate.module index a75402c3a30de419333b8fc3388701cfef67f817..bbb3f948903c7277998d2f533d166ba61101e70b 100644 --- a/modules/moderate.module +++ b/modules/moderate.module @@ -4,6 +4,14 @@ function moderate_perm() { return array("access moderation pages"); } +function moderate_link($type) { + if ($type == "admin") { + $links[] = "<a href=\"admin.php?mod=moderate\">moderate content</a>"; + } + + return $links ? $links : array(); +} + 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%'")); @@ -72,9 +80,9 @@ function moderate_comment_save($id, $edit) { } function moderate_admin() { - global $user, $op, $id, $edit, $type; + global $op, $id, $edit, $type; - if (user_access($user, "access moderation pages")) { + if (user_access("access moderation pages")) { switch ($type) { case "comment": diff --git a/modules/node.module b/modules/node.module index 7bc148177a5acab638e2cb26724ffd0d17c18040..01642e76e72f32d1474134cd3564acd39a2b31ed 100644 --- a/modules/node.module +++ b/modules/node.module @@ -27,7 +27,7 @@ function node_help() { } function node_perm() { - return array("add and edit nodes"); + return array("administer nodes"); } function node_conf_options() { @@ -69,7 +69,26 @@ function node_cron() { db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } -function node_link($nid, $type) { +function node_link($context) { + + if ($context == "admin" && user_access("administer nodes")) { + $links[] = "<a href=\"admin.php?mod=node\">content</a>"; + } + + if ($context[0] && $context[1]) { + $node = $context[1]; + if ($node->body) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>"; + } + if ($node->comment) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>"; + } + } + + return $links ? $links : array(); +} + +function node_links($nid, $type) { global $op; $link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>"; @@ -97,7 +116,7 @@ function node_overview($query) { $bg = $color[$i++ % sizeof($color)]; $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; - $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_link($node->nid, $node->type)) ."</SMALL></TD>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_links($node->nid, $node->type)) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -110,7 +129,7 @@ function node_edit_option($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page."); $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); @@ -126,7 +145,7 @@ function node_edit_attribute($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'."); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); @@ -140,7 +159,7 @@ function node_edit_status($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Current status", "status", $node->status, node_status($node->type)); $form .= form_textfield("Automatically post document", "timestamp_posted", ($node->timestamp_posted ? format_date($node->timestamp_posted) : ""), 30, 55, "The date at which your document will be automatically posted. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_textfield("Automatically queue document", "timestamp_queued", ($node->timestamp_queued ? format_date($node->timestamp_queued) : ""), 30, 55, "The date at which your document will be automatically queued. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); @@ -259,14 +278,14 @@ function node_module_find() { function node_edit($node) { $output .= form_item("Title", $node->title); - $output .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); return $output; } function node_admin() { - global $user, $op, $id, $edit, $query, $type, $keys; + global $op, $id, $edit, $query, $type, $keys; - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { foreach (module_list() as $name) { if (module_hook($name, "status") && $name != "node") { diff --git a/modules/node/node.module b/modules/node/node.module index 7bc148177a5acab638e2cb26724ffd0d17c18040..01642e76e72f32d1474134cd3564acd39a2b31ed 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -27,7 +27,7 @@ function node_help() { } function node_perm() { - return array("add and edit nodes"); + return array("administer nodes"); } function node_conf_options() { @@ -69,7 +69,26 @@ function node_cron() { db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } -function node_link($nid, $type) { +function node_link($context) { + + if ($context == "admin" && user_access("administer nodes")) { + $links[] = "<a href=\"admin.php?mod=node\">content</a>"; + } + + if ($context[0] && $context[1]) { + $node = $context[1]; + if ($node->body) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>"; + } + if ($node->comment) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>"; + } + } + + return $links ? $links : array(); +} + +function node_links($nid, $type) { global $op; $link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>"; @@ -97,7 +116,7 @@ function node_overview($query) { $bg = $color[$i++ % sizeof($color)]; $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; - $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_link($node->nid, $node->type)) ."</SMALL></TD>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_links($node->nid, $node->type)) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -110,7 +129,7 @@ function node_edit_option($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page."); $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); @@ -126,7 +145,7 @@ function node_edit_attribute($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'."); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); @@ -140,7 +159,7 @@ function node_edit_status($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Current status", "status", $node->status, node_status($node->type)); $form .= form_textfield("Automatically post document", "timestamp_posted", ($node->timestamp_posted ? format_date($node->timestamp_posted) : ""), 30, 55, "The date at which your document will be automatically posted. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_textfield("Automatically queue document", "timestamp_queued", ($node->timestamp_queued ? format_date($node->timestamp_queued) : ""), 30, 55, "The date at which your document will be automatically queued. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); @@ -259,14 +278,14 @@ function node_module_find() { function node_edit($node) { $output .= form_item("Title", $node->title); - $output .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); return $output; } function node_admin() { - global $user, $op, $id, $edit, $query, $type, $keys; + global $op, $id, $edit, $query, $type, $keys; - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { foreach (module_list() as $name) { if (module_hook($name, "status") && $name != "node") { diff --git a/modules/poll.module b/modules/poll.module index af7f918f7fb6129b5deba933ade45efb1451687f..7d6be5461ed075605e97f73756af4d4cad5f38e6 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -75,10 +75,10 @@ function poll_status() { } function poll_search($keys) { - global $status, $user; + global $status; $result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20"); while ($poll = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); + $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); } return $find; } @@ -170,13 +170,10 @@ function poll_view($node, $main = 0, $block = 0) { function poll_form($edit = array(), $nocheck = 0) { global $REQUEST_URI, $user; - $duration = array(0 => t("Unlimited"), 86400 => t("1 day"), 172800 => t("2 days"), 345600 => t("4 days"), - 604800 => t("1 week"), 1209600 => t("2 weeks"), 2678400 => t("1 month"), 5356800 => t("2 months"), - 10713600 => t("4 months"), 31536000 => t("1 year")); - + $duration = array(0 => t("Unlimited"), 86400 => t("1 day"), 172800 => t("2 days"), 345600 => t("4 days"), 604800 => t("1 week"), 1209600 => t("2 weeks"), 2678400 => t("1 month"), 5356800 => t("2 months"), 10713600 => t("4 months"), 31536000 => t("1 year")); $active = array(0 => "Closed", 1 => "Active"); - $admin = ($edit[nid] && user_access($user, "add and edit nodes")) ? 1 : 0; + $admin = ($edit[nid] && user_access("administer nodes")) ? 1 : 0; if ($edit[title]) { $form .= poll_view(new Poll(node_preview($edit))); @@ -234,7 +231,7 @@ function poll_save($edit) { if (!$edit[nid]) { $nid = node_save($edit, array(active => 1, attributes => node_attributes_save("poll", $edit), author => $user->id, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), timestamp => time(), title, type => "poll", votes => 0, voters => "")); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { $nid = node_save($edit, array(active, attributes => node_attributes_save("poll", $edit), runtime, title, type => "poll")); db_query("DELETE FROM poll_choices WHERE nid='" . $nid . "'"); } diff --git a/modules/poll/poll.module b/modules/poll/poll.module index af7f918f7fb6129b5deba933ade45efb1451687f..7d6be5461ed075605e97f73756af4d4cad5f38e6 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -75,10 +75,10 @@ function poll_status() { } function poll_search($keys) { - global $status, $user; + global $status; $result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20"); while ($poll = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); + $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); } return $find; } @@ -170,13 +170,10 @@ function poll_view($node, $main = 0, $block = 0) { function poll_form($edit = array(), $nocheck = 0) { global $REQUEST_URI, $user; - $duration = array(0 => t("Unlimited"), 86400 => t("1 day"), 172800 => t("2 days"), 345600 => t("4 days"), - 604800 => t("1 week"), 1209600 => t("2 weeks"), 2678400 => t("1 month"), 5356800 => t("2 months"), - 10713600 => t("4 months"), 31536000 => t("1 year")); - + $duration = array(0 => t("Unlimited"), 86400 => t("1 day"), 172800 => t("2 days"), 345600 => t("4 days"), 604800 => t("1 week"), 1209600 => t("2 weeks"), 2678400 => t("1 month"), 5356800 => t("2 months"), 10713600 => t("4 months"), 31536000 => t("1 year")); $active = array(0 => "Closed", 1 => "Active"); - $admin = ($edit[nid] && user_access($user, "add and edit nodes")) ? 1 : 0; + $admin = ($edit[nid] && user_access("administer nodes")) ? 1 : 0; if ($edit[title]) { $form .= poll_view(new Poll(node_preview($edit))); @@ -234,7 +231,7 @@ function poll_save($edit) { if (!$edit[nid]) { $nid = node_save($edit, array(active => 1, attributes => node_attributes_save("poll", $edit), author => $user->id, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), timestamp => time(), title, type => "poll", votes => 0, voters => "")); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { $nid = node_save($edit, array(active, attributes => node_attributes_save("poll", $edit), runtime, title, type => "poll")); db_query("DELETE FROM poll_choices WHERE nid='" . $nid . "'"); } diff --git a/modules/queue.module b/modules/queue.module index 3776ee2a3c250a07c71b9898ad35bab47bce469e..4a42ec358a9d089820e02e7e3d46714ee6afb94d 100644 --- a/modules/queue.module +++ b/modules/queue.module @@ -2,11 +2,19 @@ function queue_conf_options() { $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); - $output .= form_select(t("Discard entries older than"), "queue_clear", variable_get("queue_clear", 604800), $period, t("The time nodes should be kept in the moderation queue. Older entries will be automatically discarded. Requires crontab.")); return $output; + $output .= form_select(t("Discard entries older than"), "queue_clear", variable_get("queue_clear", 604800), $period, t("The time nodes should be kept in the submission queue. Older entries will be automatically discarded. Requires crontab.")); return $output; } function queue_perm() { - return array("access moderation queue"); + return array("access submission queue"); +} + +function queue_link($type) { + if ($type == "menu" && user_access("access submission queue")) { + $links[] = "<a href=\"module.php?mod=queue\">". t("submission queue") ."</a> (<FONT COLOR=\"red\">". queue_count() ."</FONT>)"; + } + + return $links ? $links : array(); } function queue_cron() { @@ -14,10 +22,6 @@ function queue_cron() { db_query("UPDATE node SET status = '$status[dumped]' WHERE status = '$status[queued]' AND ". time() ." - timestamp > ". variable_get("queue_clear", 604800)); } -function queue_menu() { - return array("<A HREF=\"module.php?mod=queue\">". t("moderation queue") ."</A> (<FONT COLOR=\"red\">". queue_count() ."</FONT>)"); -} - function queue_count() { global $status; $result = db_query("SELECT COUNT(nid) FROM node WHERE status = '$status[queued]'"); @@ -112,9 +116,9 @@ function queue_node($id) { } function queue_page() { - global $id, $op, $theme, $user, $vote; + global $id, $op, $theme, $vote; - if ($user->id && user_access($user, "access moderation queue")) { + if ($user->id && user_access("access submission queue")) { switch($op) { case "Vote"; queue_vote(check_input($id), check_input($vote)); diff --git a/modules/rating.module b/modules/rating.module index 164b1eccaff04e4b174d4b3c455145a4c6fdc30f..4b9daa1a70bead70ba45acb5346dd01f72f5a8bd 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -1,7 +1,15 @@ <?php function rating_perm() { - return array("view user ratings"); + return array("access user ratings"); +} + +function rating_link($type) { + if ($type == "page" && user_access("access user ratings")) { + $links[] = "<a href=\"module.php?mod=rating\">". t("user ratings") ."</a>"; + } + + return $links ? $links : array(); } function rating_conf_options() { @@ -85,7 +93,7 @@ function rating_list($limit) { function rating_page() { global $user, $theme; - if (user_access($user, "view user ratings")) { + if (user_access($user, "access user ratings")) { $theme->header(); $theme->box(t("Top 100 users"), rating_list(100)); $theme->footer(); diff --git a/modules/statistics.module b/modules/statistics.module index 3cd41d06f21070b1eb0dca44656f97e1e7ec9f65..02fc75de1b6ba315283fc967c6ffd74821871285 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -14,6 +14,14 @@ function statistics_perm() { return array("access statistics"); } +function statistics_link($type) { + if ($type == "admin" && user_access("access statistics")) { + $links[] = "<a href=\"admin.php?mod=statistics\">statistics</a>"; + } + + return $links ? $links : array(); +} + function statistics_conf_options() { $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Track referers"), "referer", variable_get("referer", 0), array("Disabled", "Enabled"), "If enabled, Drupal will count how many times your website is referred to by other websites."); diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 3cd41d06f21070b1eb0dca44656f97e1e7ec9f65..02fc75de1b6ba315283fc967c6ffd74821871285 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -14,6 +14,14 @@ function statistics_perm() { return array("access statistics"); } +function statistics_link($type) { + if ($type == "admin" && user_access("access statistics")) { + $links[] = "<a href=\"admin.php?mod=statistics\">statistics</a>"; + } + + return $links ? $links : array(); +} + function statistics_conf_options() { $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Track referers"), "referer", variable_get("referer", 0), array("Disabled", "Enabled"), "If enabled, Drupal will count how many times your website is referred to by other websites."); diff --git a/modules/story.module b/modules/story.module index ee5b8cecf58aacfb932b34585f627ff835e42cbe..a941ff30765353cf5525d18c0ab806e113b28a18 100644 --- a/modules/story.module +++ b/modules/story.module @@ -16,7 +16,7 @@ function story_search($keys) { global $status, $user; $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($story = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($story->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); + $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); } return $find; } @@ -75,7 +75,7 @@ function story_save($edit) { if (!$edit[nid]) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story")); } } diff --git a/modules/story/story.module b/modules/story/story.module index ee5b8cecf58aacfb932b34585f627ff835e42cbe..a941ff30765353cf5525d18c0ab806e113b28a18 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -16,7 +16,7 @@ function story_search($keys) { global $status, $user; $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($story = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($story->title), "link" => (user_access($user, "add and edit nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); + $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); } return $find; } @@ -75,7 +75,7 @@ function story_save($edit) { if (!$edit[nid]) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); } - else if (user_access($user, "add and edit nodes")) { + else if (user_access("administer nodes")) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story")); } } diff --git a/modules/system.module b/modules/system.module index 6a2504d6a33cd384c6460d35441de62871c7bed3..b31a9dcad06c92a584270c69afeaa822b30afaae 100644 --- a/modules/system.module +++ b/modules/system.module @@ -13,7 +13,15 @@ function system_help() { } function system_perm() { - return array("edit configuration options"); + return array("administer site options"); +} + +function system_link($type) { + if ($type == "admin" && user_access("administer site options")) { + $links[] = "<a href=\"admin.php?mod=system\">configuration options</a>"; + } + + return $links ? $links : array(); } function system_view_options() { @@ -112,9 +120,9 @@ function system_modules() { } function system_admin() { - global $user, $edit, $op, $type; + global $edit, $op, $type; - if (user_access($user, "edit configuration options")) { + if (user_access("administer site options")) { print "<SMALL><A HREF=\"admin.php?mod=system&type=options\">site settings</A> | <A HREF=\"admin.php?mod=system&type=filter\">content filters</A> | <A HREF=\"admin.php?mod=system&op=modules\">modules</A> | <A HREF=\"admin.php?mod=system&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/system/system.module b/modules/system/system.module index 6a2504d6a33cd384c6460d35441de62871c7bed3..b31a9dcad06c92a584270c69afeaa822b30afaae 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -13,7 +13,15 @@ function system_help() { } function system_perm() { - return array("edit configuration options"); + return array("administer site options"); +} + +function system_link($type) { + if ($type == "admin" && user_access("administer site options")) { + $links[] = "<a href=\"admin.php?mod=system\">configuration options</a>"; + } + + return $links ? $links : array(); } function system_view_options() { @@ -112,9 +120,9 @@ function system_modules() { } function system_admin() { - global $user, $edit, $op, $type; + global $edit, $op, $type; - if (user_access($user, "edit configuration options")) { + if (user_access("administer site options")) { print "<SMALL><A HREF=\"admin.php?mod=system&type=options\">site settings</A> | <A HREF=\"admin.php?mod=system&type=filter\">content filters</A> | <A HREF=\"admin.php?mod=system&op=modules\">modules</A> | <A HREF=\"admin.php?mod=system&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/watchdog.module b/modules/watchdog.module index 23d4c8d28ddc0e016387865c204f692caf57c330..fb70530ee6f5bdb7af68e02791e2bb34ea56d10e 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -11,6 +11,14 @@ function watchdog_perm() { return array("access watchdog"); } +function watchdog_link($type) { + if ($type == "admin" && user_access("access watchdog")) { + $links[] = "<a href=\"admin.php?mod=watchdog\">watchdog</a>"; + } + + return $links ? $links : array(); +} + function watchdog_conf_options() { $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Discard entries older than"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); @@ -57,9 +65,9 @@ function watchdog_view($id) { } function watchdog_admin() { - global $user, $op, $id, $type, $order; + global $op, $id, $type, $order; - if (user_access($user, "access watchdog")) { + if (user_access("access watchdog")) { print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 23d4c8d28ddc0e016387865c204f692caf57c330..fb70530ee6f5bdb7af68e02791e2bb34ea56d10e 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -11,6 +11,14 @@ function watchdog_perm() { return array("access watchdog"); } +function watchdog_link($type) { + if ($type == "admin" && user_access("access watchdog")) { + $links[] = "<a href=\"admin.php?mod=watchdog\">watchdog</a>"; + } + + return $links ? $links : array(); +} + function watchdog_conf_options() { $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Discard entries older than"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); @@ -57,9 +65,9 @@ function watchdog_view($id) { } function watchdog_admin() { - global $user, $op, $id, $type, $order; + global $op, $id, $type, $order; - if (user_access($user, "access watchdog")) { + if (user_access("access watchdog")) { print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; diff --git a/node.php b/node.php index 09e9622e1dbcf048ab7cc4b58d87f058d8d7a1e8..45fd14162a3efded3a1516d5d77132a22c3df316 100644 --- a/node.php +++ b/node.php @@ -5,9 +5,9 @@ page_header(); function node_render($node) { - global $user, $id, $cid, $op, $moderate, $pid, $edit, $theme, $mode, $order, $threshold, $PHP_SELF; + global $id, $cid, $op, $moderate, $pid, $edit, $theme, $mode, $order, $threshold, $PHP_SELF; - if (user_access($user, "view content")) { + if (user_access("access content")) { if ($node->comment) { switch($op) { diff --git a/search.php b/search.php index 9d5b118e28a5afed250c3f494f395961f35e806a..c0c7f695b87f9c908a69ba31198a66d49614fd80 100644 --- a/search.php +++ b/search.php @@ -4,7 +4,7 @@ page_header(); -if (user_access($user, "search content")) { +if (user_access("search content")) { // verify input: $type = check_input($type); $keys = check_input($keys); diff --git a/submit.php b/submit.php index 02b6f89595d480a1564d0a55e31fcaa2dfa3f15c..b1cfaa32097dc815a6577777749e3141113ae1cf 100644 --- a/submit.php +++ b/submit.php @@ -6,7 +6,7 @@ $theme->header(); -if (user_access($user, "post content")) { +if (user_access("post content")) { if ($mod) { module_invoke($mod, "user"); } diff --git a/themes/example/example.theme b/themes/example/example.theme index e53496b6884c46ae2a149f719fbcb4937303d9cc..3f488968577c48dc422ee2ae13e7eaa065bb1e3d 100644 --- a/themes/example/example.theme +++ b/themes/example/example.theme @@ -30,7 +30,7 @@ function header() { <TD ALIGN="right" COLSPAN="2"> <?php - print theme_link(); + print $this->links(link_page()); ?> </TD> @@ -50,7 +50,7 @@ function header() { } // close header function - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { ?> <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="3" WIDTH="100%"> @@ -83,7 +83,7 @@ function node($node, $main = 0, $links = 0) { <TR> <TD COLSPAN="2"> <?php - if (node_links($links, $node, $main)) echo $this->links($links, $main); + if ($main) echo $this->links(link_node($node)); ?> </TD> @@ -178,7 +178,7 @@ function footer() { </TR> <TR> <TD ALIGN="center" COLSPAN="3"> - <P><?php print theme_link(" | "); ?></P> + <P><?php print $this->links(link_page()); ?></P> <P><SMALL><?php print variable_get(site_footer, ""); ?></SMALL></P> </TD> </TR> diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme index 9cb913975cbebb29fca6671a88db2650a10af067..9444db289614d405df929204426b17b69f7c2f2a 100644 --- a/themes/goofy/goofy.theme +++ b/themes/goofy/goofy.theme @@ -86,7 +86,7 @@ function linksbar() { // helper function to prevent double code </tr> <tr> <td class="lgl"><img src="themes/goofy/images/null.gif" alt=""></td> - <td class="lgcnt" width="100%" valign="top"><div align="center"><big><?php print theme_link(); ?></big></div></td> + <td class="lgcnt" width="100%" valign="top"><div align="center"><big><?php print $this->links(link_page()); ?></big></div></td> <td class="lgr"><img src="themes/goofy/images/null.gif" alt=""></td> </tr> <tr> @@ -99,12 +99,12 @@ function linksbar() { // helper function to prevent double code } // close linksbar function - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { echo "\n<!-- node: \"$node->title\" -->\n"; $title = check_output($node->title); $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid), "%b" => format_date($node->timestamp, "large"))); $subright = node_index($node); - $body = check_output($node->body, 1) . (node_links($links, $node, $main) ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links($links, $main) . " ]</div>" : ""); + $body = check_output($node->body, 1) . ($main ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>" : ""); print "<script language=\"JavaScript\"><!--\ns(\"". $this->stripbreaks(addslashes($title)) ."\",\"". $this->stripbreaks(addslashes($subleft)) ."\",\"". $this->stripbreaks(addslashes($subright)) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n"; } // close node function diff --git a/themes/jeroen/jeroen.theme b/themes/jeroen/jeroen.theme index c5685f3261d3b586b61e9acaf32423d00a78f361..739c7b16ef62b6c4ab16d2f3f5da09fce667779d 100644 --- a/themes/jeroen/jeroen.theme +++ b/themes/jeroen/jeroen.theme @@ -84,7 +84,7 @@ function header() { } // close header function - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { ?> @@ -138,8 +138,8 @@ function node($node, $main = 0, $links = 0) { <tr> <td colspan="2" align="right"> <?php - if (node_links($links, $node, $main)) - echo $this->links($links, $main); + if ($main) + echo $this->links(node_link($node)); ?> </td> @@ -310,7 +310,7 @@ function footer() { <tr> <td align="left" width="20" height="20" background="themes/jeroen/images/footerleft.gif" nowrap> </td> <td width="100%" background="themes/jeroen/images/footer.gif" align="center" valign="middle"> - <FONT COLOR="#E09226" SIZE="2">[ <?php print theme_link(); ?> ] </FONT> + <FONT COLOR="#E09226" SIZE="2">[ <?php print $this->links(link_page()); ?> ] </FONT> </td> <td align="right" width="20" background="themes/jeroen/images/footerright.gif" nowrap> </td> </tr> diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index c24cb68f34ab03b902b9ea9138299f294ff498e4..583011daf45cd6260f3134242fa57d28e56e594e 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -1,4 +1,4 @@ -<?php +<? /********************************************************************* @@ -41,7 +41,7 @@ function header() { <tr> <td align="right" colspan="2"> <?php - print "<small>". theme_link() ."</small>\n"; + print "<small>". $this->links(link_page()) ."</small>\n"; ?> </td> </tr> @@ -50,7 +50,7 @@ function header() { <?php } - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { print "\n<!-- node: \"$node->title\" -->\n"; print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">\n"; print " <tr><td colspan=\"2\"><img src=\"themes/marvin/images/drop.gif\" alt=\"\" /> <b>". check_output($node->title) ."</b></td></tr>\n"; @@ -59,9 +59,7 @@ function node($node, $main = 0, $links = 0) { print " <tr><td colspan=\"2\"> </td></tr>\n"; print " <tr><td colspan=\"2\"><p>". check_output($node->body, 1) ."</p></td></tr>\n"; print " <tr><td colspan=\"2\"> </tr></tr>\n"; - if (node_links($links, $node, $main)) { - print " <tr><td colspan=\"2\">". $this->links($links, $main) ."</td></tr>\n"; - } + if ($main) print " <tr><td colspan=\"2\">". $this->links(link_node($node)) ."</td></tr>\n"; print "</table>\n"; print "<br /><br />\n\n"; } @@ -145,7 +143,7 @@ function footer() { <tr> <td align="center" colspan="2"> <?php - print "<p><small>[ ". theme_link() ." ]</small></p><p>". variable_get("site_footer", "") ."</p>\n"; + print "<p><small>[ ". $this->links(link_page()) ." ]</small></p><p>". variable_get("site_footer", "") ."</p>\n"; ?> </td> </tr> diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme index a51f6222f81b53eeaeb39c8875cfde970c5bdfbe..0eeb72e7bb7c3439d246d1e256b2a2f4fa63b927 100644 --- a/themes/unconed/unconed.theme +++ b/themes/unconed/unconed.theme @@ -63,7 +63,7 @@ function header() { </TR> <TR> <TD COLSPAN="2" ALIGN="CENTER"> - <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(); ?></BIG></TD></TR></TABLE></TD></TR></TABLE> + <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print $this->links(link_page()); ?></BIG></TD></TR></TABLE></TD></TR></TABLE> </TD> </TR> <TR><TD COLSPAN="2"><?php @@ -79,7 +79,7 @@ function header() { <?php } - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { print "\n<!-- node: \"$node->title\" -->\n"; ?> @@ -101,8 +101,8 @@ function node($node, $main = 0, $links = 0) { </TD> </TR> <?php - if (node_links($links, $node, $main)) - echo "<TR BGCOLOR=\"". $this->bgcolor3 ."\"><TD BGCOLOR=\"". $this->bgcolor3 ."\" ALIGN=\"right\" COLSPAN=\"2\">[ ". $this->links($links, $main) ." ]</TD></TR>"; + if ($main) + echo "<TR BGCOLOR=\"". $this->bgcolor3 ."\"><TD BGCOLOR=\"". $this->bgcolor3 ."\" ALIGN=\"right\" COLSPAN=\"2\">[ ". $this->links(link_node($node)) ." ]</TD></TR>"; ?> </TABLE></TD></TR></TABLE><BR> <?php @@ -202,7 +202,7 @@ function footer() { ?></TD></TR> <TR> <TD COLSPAN="2"> - <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(); ?></BIG></TD></TR></TABLE></TD></TR></TABLE> + <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print $this->links(link_page()); ?></BIG></TD></TR></TABLE></TD></TR></TABLE> </TD> </TR> </TABLE> diff --git a/themes/yaroon/yaroon.theme b/themes/yaroon/yaroon.theme index 66280be8b8616bee5ad1bd6ed696eebbe5ef0fa9..f0dd622a5878843e36429d5a6f838f0ba435ef6c 100644 --- a/themes/yaroon/yaroon.theme +++ b/themes/yaroon/yaroon.theme @@ -112,7 +112,7 @@ function do_nav() { } // close header function - function node($node, $main = 0, $links = 0) { + function node($node, $main = 0) { switch ($node->tid) { case 0: $color = "#c4a2a2"; $img = "square2.gif"; break; @@ -145,8 +145,8 @@ function node($node, $main = 0, $links = 0) { <tr> <td align=\"right\"> <font color=\"". $color ."\">"; - if (node_links($links, $node, $main)) - echo $this->links($links, $main); + if ($main) + echo $this->links(node_link($node)); echo"</font>"; ?>