diff options
Diffstat (limited to 'modules')
36 files changed, 423 insertions, 142 deletions
diff --git a/modules/access.module b/modules/access.module index 7126d4584..9addd0732 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 db464623f..117c71433 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 447090738..44f0b480a 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 447090738..44f0b480a 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 07b078dd7..97139035f 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 07b078dd7..97139035f 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 0365e9833..b8d3f9c81 100644 --- a/modules/book.module +++ b/modules/book.module @@ -10,7 +10,19 @@ class 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 0365e9833..b8d3f9c81 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -10,7 +10,19 @@ class 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 c8e4330e2..8bac56138 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 ad9924603..5f4dd09fd 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 ad9924603..5f4dd09fd 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 cc81a12e6..bc1206898 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 a186161ce..6008c344f 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 cdbe9ce4f..ecf0f52bd 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 cdbe9ce4f..ecf0f52bd 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 254432a7b..1b26fd7ad 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 254432a7b..1b26fd7ad 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 447090738..44f0b480a 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 8450746f5..73d531c85 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 8450746f5..73d531c85 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 092bf1d4c..207123b80 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 a75402c3a..bbb3f9489 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 7bc148177..01642e76e 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 7bc148177..01642e76e 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 af7f918f7..7d6be5461 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 af7f918f7..7d6be5461 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 3776ee2a3..4a42ec358 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 164b1ecca..4b9daa1a7 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 3cd41d06f..02fc75de1 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 3cd41d06f..02fc75de1 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 ee5b8cecf..a941ff307 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 ee5b8cecf..a941ff307 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 6a2504d6a..b31a9dcad 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 6a2504d6a..b31a9dcad 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 23d4c8d28..fb70530ee 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 23d4c8d28..fb70530ee 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"; |