Commit 0f567be0 authored by Dries's avatar Dries
Browse files

- improved administrator interface of account, node, story and book
  by (1) adding a few extra features to "easify" navigation and (b)
  to start using "status messages" as once suggested on the mailing
  list by Jeroen
parent 94d6b63f
...@@ -4,12 +4,6 @@ ...@@ -4,12 +4,6 @@
"find" => "account_find", "find" => "account_find",
"admin" => "account_admin"); "admin" => "account_admin");
$queries = array(0 => array("users recently visiting", "ORDER BY last_access DESC"),
1 => array("users recently joining", "ORDER BY id DESC"),
2 => array("users with access rights", "WHERE access != '' ORDER BY last_access DESC"),
3 => array("users with pending accounts", "WHERE status = 1 ORDER BY last_access DESC"),
4 => array("users with blocked accounts", "WHERE status = 0 ORDER BY last_access DESC"));
function account_help() { function account_help() {
?> ?>
<P>The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access control, password retrieval, user settings and much more.</P> <P>The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access control, password retrieval, user settings and much more.</P>
...@@ -90,12 +84,11 @@ function account_ac() { ...@@ -90,12 +84,11 @@ function account_ac() {
return $output; return $output;
} }
function account_overview($query = 0) { function account_overview($query = array()) {
global $queries;
$result = db_query("SELECT id, userid, last_access FROM users ". $queries[$query][1] ." LIMIT 50"); $result = db_query("SELECT id, userid, last_access FROM users $query[1] LIMIT 50");
$output .= status($queries[$query][0]); $output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>username</TH><TH>last access</TH><TH COLSPAN=\"2\">operations</TH></TR>\n"; $output .= " <TR><TH>username</TH><TH>last access</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($account = db_fetch_object($result)) { while ($account = db_fetch_object($result)) {
...@@ -227,18 +220,24 @@ function account_view($name) { ...@@ -227,18 +220,24 @@ function account_view($name) {
} }
} }
function account_query() { function account_query($type = "") {
global $queries; $queries = array(0 => array("users recently visiting", "ORDER BY last_access DESC"), 1 => array("users recently joining", "ORDER BY id DESC"), 2 => array("users with access rights", "WHERE access != '' ORDER BY last_access DESC"), 3 => array("users with pending accounts", "WHERE status = 1 ORDER BY last_access DESC"), 4 => array("users with blocked accounts", "WHERE status = 0 ORDER BY last_access DESC"));
foreach ($queries as $key=>$array) { return ($queries[$type] ? $queries[$type] : $queries);
$output .= "<LI><A HREF=\"admin.php?mod=account&query=$key\">$array[0]</A></LI>\n"; }
function account_listing() {
foreach (account_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=account&type=$key\">$array[0]</A></LI>\n";
} }
return "<OL>$output</OL>\n"; return "<OL>$output</OL>\n";
} }
function account_admin() { function account_admin() {
global $op, $edit, $id, $mod, $keys, $order, $name, $query; global $op, $edit, $id, $mod, $keys, $order, $name, $type;
print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=query\">account queries</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>"; print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</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>";
$type = ($type ? $type : 1);
switch ($op) { switch ($op) {
case "access": case "access":
...@@ -259,7 +258,7 @@ function account_admin() { ...@@ -259,7 +258,7 @@ function account_admin() {
case "Delete account": case "Delete account":
case "delete": case "delete":
print status(account_delete(check_input($name))); print status(account_delete(check_input($name)));
print account_overview(); print account_overview(account_query($type));
break; break;
case "Edit account": case "Edit account":
case "edit": case "edit":
...@@ -268,6 +267,9 @@ function account_admin() { ...@@ -268,6 +267,9 @@ function account_admin() {
case "help": case "help":
print account_help(); print account_help();
break; break;
case "listing":
print account_listing();
break;
case "search": case "search":
print search_form($keys); print search_form($keys);
print search_data($keys, $mod); print search_data($keys, $mod);
...@@ -280,11 +282,8 @@ function account_admin() { ...@@ -280,11 +282,8 @@ function account_admin() {
case "view": case "view":
print account_view($name); print account_view($name);
break; break;
case "query":
print account_query();
break;
default: default:
print account_overview($query); print account_overview(account_query($type));
} }
} }
......
...@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) { ...@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) {
return $output; return $output;
} }
function book_list() { function book_list($query = array()) {
return node_overview("type = 'book'"); return node_overview($query);
} }
function book_query($type = "") {
global $status;
$queries = array(0 => array("active book pages", "WHERE n.type = 'book' ORDER BY n.timestamp DESC"), 1 => array("posted book pages", "WHERE n.type = 'book' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued book pages", "WHERE n.type = 'book' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped book pages", "WHERE n.type = 'book' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function book_listing() {
foreach (book_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=book&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function book_admin() { function book_admin() {
global $op, $id, $edit, $mod, $keys, $user; global $op, $id, $edit, $mod, $keys, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=listing\">book listing</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book\">list overview</A> | <A HREF=\"admin.php?mod=book&op=tree\">tree overview</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book&op=list\">list overview</A> | <A HREF=\"admin.php?mod=book\">tree overview</A></SMALL><HR>\n"; $type = $type ? $type : 0;
switch ($op) { switch ($op) {
case "add": case "add":
print book_form(); print book_form();
break; break;
case "list":
print book_list();
break;
case "edit": case "edit":
print book_form(node_get_array(nid, $id)); print book_form(node_get_array(nid, $id));
break; break;
case "listing":
print book_listing();
break;
case "search": case "search":
print search_form($keys); print search_form($keys);
print search_data($keys, $mod); print search_data($keys, $mod);
break; break;
case "tree":
print book_tree();
break;
case t("Preview"): case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0); book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
print book_form($edit); print book_form($edit);
break; break;
case t("Submit"): case t("Submit"):
book_save($edit); book_save($edit);
print book_tree(); // fall through:
break;
default: default:
print book_tree(); print book_list(book_query($type));
} }
} }
......
...@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) { ...@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) {
return $output; return $output;
} }
function book_list() { function book_list($query = array()) {
return node_overview("type = 'book'"); return node_overview($query);
} }
function book_query($type = "") {
global $status;
$queries = array(0 => array("active book pages", "WHERE n.type = 'book' ORDER BY n.timestamp DESC"), 1 => array("posted book pages", "WHERE n.type = 'book' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued book pages", "WHERE n.type = 'book' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped book pages", "WHERE n.type = 'book' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function book_listing() {
foreach (book_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=book&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function book_admin() { function book_admin() {
global $op, $id, $edit, $mod, $keys, $user; global $op, $id, $edit, $mod, $keys, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=listing\">book listing</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book\">list overview</A> | <A HREF=\"admin.php?mod=book&op=tree\">tree overview</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book&op=list\">list overview</A> | <A HREF=\"admin.php?mod=book\">tree overview</A></SMALL><HR>\n"; $type = $type ? $type : 0;
switch ($op) { switch ($op) {
case "add": case "add":
print book_form(); print book_form();
break; break;
case "list":
print book_list();
break;
case "edit": case "edit":
print book_form(node_get_array(nid, $id)); print book_form(node_get_array(nid, $id));
break; break;
case "listing":
print book_listing();
break;
case "search": case "search":
print search_form($keys); print search_form($keys);
print search_data($keys, $mod); print search_data($keys, $mod);
break; break;
case "tree":
print book_tree();
break;
case t("Preview"): case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0); book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
print book_form($edit); print book_form($edit);
break; break;
case t("Submit"): case t("Submit"):
book_save($edit); book_save($edit);
print book_tree(); // fall through:
break;
default: default:
print book_tree(); print book_list(book_query($type));
} }
} }
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
$module = array("admin" => "node_admin"); $module = array("admin" => "node_admin");
function node_overview($query = 0) { function node_overview($query = array()) {
global $user, $rstatus; global $user, $rstatus;
$result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id ". ($query ? "WHERE $query" : "") ." ORDER BY n.timestamp DESC"); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n"; $output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
...@@ -60,10 +61,26 @@ function node_delete($id) { ...@@ -60,10 +61,26 @@ function node_delete($id) {
return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first."); return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
} }
function node_query($type = "") {
global $status;
$queries = array(0 => array("active nodes", "ORDER BY n.timestamp DESC"), 1 => array("posted nodes", "WHERE n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued nodes", "WHERE n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped nodes", "WHERE n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function node_listing() {
foreach (node_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=node&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function node_admin() { function node_admin() {
global $op, $id, $edit; global $op, $id, $edit, $type;
print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
$id = check_input($edit[nid] ? $edit[nid] : $id); $id = check_input($edit[nid] ? $edit[nid] : $id);
$type = ($type ? $type : 0);
switch ($op) { switch ($op) {
case "Edit node": case "Edit node":
...@@ -74,6 +91,9 @@ function node_admin() { ...@@ -74,6 +91,9 @@ function node_admin() {
print status(node_delete($id)); print status(node_delete($id));
print node_overview(); print node_overview();
break; break;
case "listing":
print node_listing();
break;
case "Save node": case "Save node":
print status(node_save($edit)); print status(node_save($edit));
print node_admin_view($id); print node_admin_view($id);
...@@ -83,7 +103,7 @@ function node_admin() { ...@@ -83,7 +103,7 @@ function node_admin() {
print node_admin_view($id); print node_admin_view($id);
break; break;
default: default:
print node_overview(); print node_overview(node_query($type));
} }
} }
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
$module = array("admin" => "node_admin"); $module = array("admin" => "node_admin");
function node_overview($query = 0) { function node_overview($query = array()) {
global $user, $rstatus; global $user, $rstatus;
$result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id ". ($query ? "WHERE $query" : "") ." ORDER BY n.timestamp DESC"); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n"; $output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
...@@ -60,10 +61,26 @@ function node_delete($id) { ...@@ -60,10 +61,26 @@ function node_delete($id) {
return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first."); return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
} }
function node_query($type = "") {
global $status;
$queries = array(0 => array("active nodes", "ORDER BY n.timestamp DESC"), 1 => array("posted nodes", "WHERE n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued nodes", "WHERE n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped nodes", "WHERE n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function node_listing() {
foreach (node_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=node&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function node_admin() { function node_admin() {
global $op, $id, $edit; global $op, $id, $edit, $type;
print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
$id = check_input($edit[nid] ? $edit[nid] : $id); $id = check_input($edit[nid] ? $edit[nid] : $id);
$type = ($type ? $type : 0);
switch ($op) { switch ($op) {
case "Edit node": case "Edit node":
...@@ -74,6 +91,9 @@ function node_admin() { ...@@ -74,6 +91,9 @@ function node_admin() {
print status(node_delete($id)); print status(node_delete($id));
print node_overview(); print node_overview();
break; break;
case "listing":
print node_listing();
break;
case "Save node": case "Save node":
print status(node_save($edit)); print status(node_save($edit));
print node_admin_view($id); print node_admin_view($id);
...@@ -83,7 +103,7 @@ function node_admin() { ...@@ -83,7 +103,7 @@ function node_admin() {
print node_admin_view($id); print node_admin_view($id);
break; break;
default: default:
print node_overview(); print node_overview(node_query($type));
} }
} }
......
...@@ -199,14 +199,30 @@ function story_block() { ...@@ -199,14 +199,30 @@ function story_block() {
*/ */
} }
function story_overview() { function story_query($type = "") {
return node_overview("type = 'story'"); global $status;
$queries = array(0 => array("active stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), 1 => array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function story_listing() {
foreach (story_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=story&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function story_overview($query = array()) {
return node_overview($query);
} }
function story_admin() { function story_admin() {
global $id, $edit, $mod, $keys, $op, $theme, $user; global $id, $edit, $mod, $keys, $op, $theme, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n"; $type = ($type ? $type : 0);
switch ($op) { switch ($op) {
case "add": case "add":
...@@ -214,7 +230,7 @@ function story_admin() { ...@@ -214,7 +230,7 @@ function story_admin() {
break; break;
case "delete": case "delete":
print story_delete($id); print story_delete($id);
print story_overview(); print story_overview(story_query($type));
break; break;
case "edit": case "edit":
print story_form(node_get_array("nid", check_input($id))); print story_form(node_get_array("nid", check_input($id)));
...@@ -222,6 +238,9 @@ function story_admin() { ...@@ -222,6 +238,9 @@ function story_admin() {
case "help": case "help":
story_help(); story_help();
break; break;
case "listing":
print story_listing();
break;
case "search": case "search":
print search_form($keys); print search_form($keys);
print search_data($keys, $mod); print search_data($keys, $mod);
...@@ -232,10 +251,9 @@ function story_admin() { ...@@ -232,10 +251,9 @@ function story_admin() {
break; break;
case t("Submit"): case t("Submit"):
story_save($edit); story_save($edit);
print story_overview(); // fall through:
break;
default: default:
print story_overview(); print story_overview(story_query($type));
} }
} }
......
...@@ -199,14 +199,30 @@ function story_block() { ...@@ -199,14 +199,30 @@ function story_block() {
*/ */
} }
function story_overview() { function story_query($type = "") {
return node_overview("type = 'story'"); global $status;
$queries = array(0 => array("active stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), 1 => array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function story_listing() {
foreach (story_query() as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=story&type=$key\">$array[0]</A></LI>\n";
}
return "<OL>$output</OL>\n";
}
function story_overview($query = array()) {
return node_overview($query);
} }
function story_admin() { function story_admin() {
global $id, $edit, $mod, $keys, $op, $theme, $user; global $id, $edit, $mod, $keys, $op, $theme, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n"; $type = ($type ? $type : 0);
switch ($op) { switch ($op) {
case "add": case "add":
...@@ -214,7 +230,7 @@ function story_admin() { ...@@ -214,7 +230,7 @@ function story_admin() {
break;