Commit 0f567be0 authored by Dries's avatar Dries

- 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 @@
"find" => "account_find",
"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() {
?>
<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() {
return $output;
}
function account_overview($query = 0) {
global $queries;
function account_overview($query = array()) {
$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 .= " <TR><TH>username</TH><TH>last access</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($account = db_fetch_object($result)) {
......@@ -227,18 +220,24 @@ function account_view($name) {
}
}
function account_query() {
global $queries;
foreach ($queries as $key=>$array) {
$output .= "<LI><A HREF=\"admin.php?mod=account&query=$key\">$array[0]</A></LI>\n";
function account_query($type = "") {
$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"));
return ($queries[$type] ? $queries[$type] : $queries);
}
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";
}
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) {
case "access":
......@@ -259,7 +258,7 @@ function account_admin() {
case "Delete account":
case "delete":
print status(account_delete(check_input($name)));
print account_overview();
print account_overview(account_query($type));
break;
case "Edit account":
case "edit":
......@@ -268,6 +267,9 @@ function account_admin() {
case "help":
print account_help();
break;
case "listing":
print account_listing();
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
......@@ -280,11 +282,8 @@ function account_admin() {
case "view":
print account_view($name);
break;
case "query":
print account_query();
break;
default:
print account_overview($query);
print account_overview(account_query($type));
}
}
......
......@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) {
return $output;
}
function book_list() {
return node_overview("type = 'book'");
function book_list($query = array()) {
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() {
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) {
case "add":
print book_form();
break;
case "list":
print book_list();
break;
case "edit":
print book_form(node_get_array(nid, $id));
break;
case "listing":
print book_listing();
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
break;
case "tree":
print book_tree();
break;
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);
print book_form($edit);
break;
case t("Submit"):
book_save($edit);
print book_tree();
break;
// fall through:
default:
print book_tree();
print book_list(book_query($type));
}
}
......
......@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) {
return $output;
}
function book_list() {
return node_overview("type = 'book'");
function book_list($query = array()) {
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() {
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) {
case "add":
print book_form();
break;
case "list":
print book_list();
break;
case "edit":
print book_form(node_get_array(nid, $id));
break;
case "listing":
print book_listing();
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
break;
case "tree":
print book_tree();
break;
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);
print book_form($edit);
break;
case t("Submit"):
book_save($edit);
print book_tree();
break;
// fall through:
default:
print book_tree();
print book_list(book_query($type));
}
}
......
......@@ -2,11 +2,12 @@
$module = array("admin" => "node_admin");
function node_overview($query = 0) {
function node_overview($query = array()) {
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 .= " <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)) {
......@@ -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.");
}
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() {
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);
$type = ($type ? $type : 0);
switch ($op) {
case "Edit node":
......@@ -74,6 +91,9 @@ function node_admin() {
print status(node_delete($id));
print node_overview();
break;
case "listing":
print node_listing();
break;
case "Save node":
print status(node_save($edit));
print node_admin_view($id);
......@@ -83,7 +103,7 @@ function node_admin() {
print node_admin_view($id);
break;
default:
print node_overview();
print node_overview(node_query($type));
}
}
......
......@@ -2,11 +2,12 @@
$module = array("admin" => "node_admin");
function node_overview($query = 0) {
function node_overview($query = array()) {
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 .= " <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)) {
......@@ -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.");
}
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() {
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);
$type = ($type ? $type : 0);
switch ($op) {
case "Edit node":
......@@ -74,6 +91,9 @@ function node_admin() {
print status(node_delete($id));
print node_overview();
break;
case "listing":
print node_listing();
break;
case "Save node":
print status(node_save($edit));
print node_admin_view($id);
......@@ -83,7 +103,7 @@ function node_admin() {
print node_admin_view($id);
break;
default:
print node_overview();
print node_overview(node_query($type));
}
}
......
......@@ -199,14 +199,30 @@ function story_block() {
*/
}
function story_overview() {
return node_overview("type = 'story'");
function story_query($type = "") {
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() {
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) {
case "add":
......@@ -214,7 +230,7 @@ function story_admin() {
break;
case "delete":
print story_delete($id);
print story_overview();
print story_overview(story_query($type));
break;
case "edit":
print story_form(node_get_array("nid", check_input($id)));
......@@ -222,6 +238,9 @@ function story_admin() {
case "help":
story_help();
break;
case "listing":
print story_listing();
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
......@@ -232,10 +251,9 @@ function story_admin() {
break;
case t("Submit"):
story_save($edit);
print story_overview();
break;
// fall through:
default:
print story_overview();
print story_overview(story_query($type));
}
}
......
......@@ -199,14 +199,30 @@ function story_block() {
*/
}
function story_overview() {
return node_overview("type = 'story'");
function story_query($type = "") {
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() {
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) {
case "add":
......@@ -214,7 +230,7 @@ function story_admin() {
break;
case "delete":
print story_delete($id);
print story_overview();
print story_overview(story_query($type));
break;
case "edit":
print story_form(node_get_array("nid", check_input($id)));
......@@ -222,6 +238,9 @@ function story_admin() {
case "help":
story_help();
break;
case "listing":
print story_listing();
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
......@@ -232,10 +251,9 @@ function story_admin() {
break;
case t("Submit"):
story_save($edit);
print story_overview();
break;
// fall through:
default:
print story_overview();
print story_overview(story_query($type));
}
}
......
......@@ -48,7 +48,7 @@ function header() {
<?php
$mybox = 1;
$mybox = 1;
$this->box("Drop where?", "<td align=\"left\" valign=\"top\">
<a href=\"index.php\">home</a><br />
<a href=\"module.php?mod=book\">handbook</a><br />
......@@ -263,8 +263,8 @@ function box($subject, $content, $options = "") {
<?php
if ($mybox == 1) {
echo $content;
if ($mybox == 1) {
echo $content;
$mybox = 0;
}
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment