From 0f567be0ed1de29ecf213a19c96ebdc6611d196b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 10 Apr 2001 20:07:27 +0000 Subject: - 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 --- modules/account.module | 41 ++++++++++++++++++++--------------------- modules/book.module | 38 ++++++++++++++++++++++++++++---------- modules/book/book.module | 38 ++++++++++++++++++++++++++++---------- modules/node.module | 28 ++++++++++++++++++++++++---- modules/node/node.module | 28 ++++++++++++++++++++++++---- modules/story.module | 34 ++++++++++++++++++++++++++-------- modules/story/story.module | 34 ++++++++++++++++++++++++++-------- 7 files changed, 176 insertions(+), 65 deletions(-) (limited to 'modules') diff --git a/modules/account.module b/modules/account.module index 7008bd7ec..88c75b494 100644 --- a/modules/account.module +++ b/modules/account.module @@ -4,12 +4,6 @@ $module = array("help" => "account_help", "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() { ?>

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.

@@ -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 .= "\n"; $output .= " \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 .= "
  • $array[0]
  • \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 .= "
  • $array[0]
  • \n"; } return "
      $output
    \n"; } function account_admin() { - global $op, $edit, $id, $mod, $keys, $order, $name, $query; + global $op, $edit, $id, $mod, $keys, $order, $name, $type; - print "access control | account queries | search account | overview | help
    "; + print "access control | account listings | search account | overview | help
    "; + + $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)); } } diff --git a/modules/book.module b/modules/book.module index 85f69d059..daf314d1c 100644 --- a/modules/book.module +++ b/modules/book.module @@ -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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \n"; +} + + function book_admin() { - global $op, $id, $edit, $mod, $keys, $user; + global $op, $id, $edit, $mod, $keys, $type, $user; + + print "add new page | book listing | search book | list overview | tree overview
    \n"; - print "add new page | search book | list overview | tree overview
    \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)); } } diff --git a/modules/book/book.module b/modules/book/book.module index 85f69d059..daf314d1c 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \n"; +} + + function book_admin() { - global $op, $id, $edit, $mod, $keys, $user; + global $op, $id, $edit, $mod, $keys, $type, $user; + + print "add new page | book listing | search book | list overview | tree overview
    \n"; - print "add new page | search book | list overview | tree overview
    \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)); } } diff --git a/modules/node.module b/modules/node.module index 48f680aa0..cbb0d5013 100644 --- a/modules/node.module +++ b/modules/node.module @@ -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 .= "
    usernamelast accessoperations
    \n"; $output .= " \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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \n"; +} + function node_admin() { - global $op, $id, $edit; + global $op, $id, $edit, $type; + + print "node listings | overview
    \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)); } } diff --git a/modules/node/node.module b/modules/node/node.module index 48f680aa0..cbb0d5013 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -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 .= "
    titletypestatusauthordateoperations
    \n"; $output .= " \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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \n"; +} + function node_admin() { - global $op, $id, $edit; + global $op, $id, $edit, $type; + + print "node listings | overview
    \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)); } } diff --git a/modules/story.module b/modules/story.module index 1ab6f6da5..0a90490b6 100644 --- a/modules/story.module +++ b/modules/story.module @@ -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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \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 "add new story | story listing | search story | overview | help
    \n"; - print "add new story | overview | search story | help
    \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)); } } diff --git a/modules/story/story.module b/modules/story/story.module index 1ab6f6da5..0a90490b6 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -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 .= "
  • $array[0]
  • \n"; + } + return "
      $output
    \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 "add new story | story listing | search story | overview | help
    \n"; - print "add new story | overview | search story | help
    \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)); } } -- cgit v1.2.3
    titletypestatusauthordateoperations