Index: trunk/bin/acl.cli.php
===================================================================
--- trunk/bin/acl.cli.php	(revision 173)
+++ trunk/bin/acl.cli.php	(revision 174)
@@ -14,4 +14,6 @@
 ********************************************************************/
 
+$this_script = basename($_SERVER['argv'][0]);
+
 // Give them a fighting chance. Show the help message. ;P
 if ($_SERVER['argc'] <= 1) {
@@ -23,9 +25,9 @@
 $db_quth_file = COMMON_BASE . '/global/db_auth.inc.php';
 if (!file_exists($db_quth_file)) {
-    die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the global/db_auth.inc.php file must exist.\n", $_SERVER['argv'][0]));
+    die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the global/db_auth.inc.php file must exist.\n", $this_script));
 }
 
 if (fileowner($db_quth_file) != getmyuid()) {
-    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $_SERVER['argv'][0]));
+    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script));
 }
 
@@ -55,6 +57,6 @@
     'display_errors' => true,
     'error_reporting' => E_ALL,
-    'log_file_priority' => LOG_DEBUG,
-    'log_screen_priority' => LOG_NOTICE,
+    'log_file_priority' => LOG_INFO,
+    'log_screen_priority' => LOG_ERR,
     'log_directory' => COMMON_BASE . '/log',
     'log_filename' => 'site_log',
@@ -82,17 +84,22 @@
 switch ($op) {
 case 'list' :
-$type = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null;
-if (isset($type)) {
-    listACL('root', $type);
-} else {
-
-    echo "\n_______________________Access Request Objects________________________\n\n";
-    listACL('root', 'aro');                               
-    echo "\n_______________________Access Control Objects________________________\n\n";
-    listACL('root', 'aco');                               
-    echo "\n______________________Access eXtension Objects_______________________\n\n";
-    listACL('root', 'axo');
-}
-break;
+    $type = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null;
+    switch ($type) {
+    case 'aro' :
+    case 'aco' :
+    case 'axo' :
+        listObjects('root', $type);
+        break;
+    case 'all' :
+        listObjects('root', 'aro');                               
+        listObjects('root', 'aco');                               
+        listObjects('root', 'axo');
+        break;
+    case 'perms' :
+        default :
+        listPerms();
+        break;
+    }
+    break;
 
 case 'addaro' :
@@ -107,4 +114,15 @@
     break;
 
+case 'mvaro' :
+case 'mvaco' :
+case 'mvaxo' :
+    $object = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null;
+    $parent = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : null;
+    if (!isset($object)) {
+        echo "'mv*' commands require at least one argument. Try 'help' if you are lost.\n";
+    }
+    echo $acl->move($object, $parent, str_replace('mv', '', $op)) ? "Ok\n" : "Error!\n";
+    break;
+
 case 'rmaro' :
 case 'rmaco' :
@@ -167,4 +185,6 @@
 function help()
 {
+    global $this_script;
+
     ?>
 Access Control List command line tool.
@@ -176,5 +196,5 @@
 
 Three types of objects are managed by this interface: ARO - Access
-Request Objects, ACO - Access Control Objects, and AXO - Access eXtention
+Request Objects, ACO - Access Control Objects, and AXO - Access Xtra
 Objects. These are most often used as a USER -> ACTION -> OBJECT model,
 but can just as easily be SPICES -> CUISINES -> DISHES A privilege is
@@ -190,19 +210,23 @@
 "anything" since it is at the top of all branches.
 
-Usage: <?php echo $_SERVER['argv'][0]; ?> <command> [args]
-
-
-<?php echo $_SERVER['argv'][0]; ?> initdb
-<?php echo $_SERVER['argv'][0]; ?> list [aro | aco | axo]
-<?php echo $_SERVER['argv'][0]; ?> addaro <aro_object> [parent]
-<?php echo $_SERVER['argv'][0]; ?> addaco <aco_object> [parent]
-<?php echo $_SERVER['argv'][0]; ?> addaxo <axo_object> [parent]
-<?php echo $_SERVER['argv'][0]; ?> rmaro <aro_object>
-<?php echo $_SERVER['argv'][0]; ?> rmaco <aco_object>
-<?php echo $_SERVER['argv'][0]; ?> rmaxo <axo_object>
-<?php echo $_SERVER['argv'][0]; ?> grant <aro_object> [aco_object] [axo_object]
-<?php echo $_SERVER['argv'][0]; ?> revoke <aro_object> [aco_object] [axo_object]
-
-For the add*, grant, and revoke commands, if any of the optional 
+Usage: <?php echo $this_script; ?> <command> [args]
+
+Where <command> is any of the following (with arguments):
+    
+    initdb
+    list [aro | aco | axo | all | perms]
+    addaro <aro_object> [parent]
+    addaco <aco_object> [parent]
+    addaxo <axo_object> [parent]
+    mvaro <aro_object> [parent]
+    mvaco <aco_object> [parent]
+    mvaxo <axo_object> [parent]
+    rmaro <aro_object>
+    rmaco <aco_object>
+    rmaxo <axo_object>
+    grant <aro_object> [aco_object] [axo_object]
+    revoke <aro_object> [aco_object] [axo_object]
+
+For the add*, mv*, grant, and revoke commands if any of the optional 
 args are not provided, 'root' is assumed.
 
@@ -213,18 +237,35 @@
 
 
-function listACL($root, $type)
+/*
+* Print the tree structure of a specified table (aro_tbl, aco_tbl, or axo_tbl).
+*
+* @access   public
+* @param    string $root Root node from which to begin calculating.
+* @param    string $type Table to call, one of: aro, aco, or axo.
+* @return   bool Returns false on error.
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    17 Jun 2006 23:41:22
+*/
+function listObjects($root, $type)
 {
     $app =& App::getInstance();
     $db =& DB::getInstance();
-    
+    global $this_script;
+    
+    echo "\n";
+
     switch ($type) {
     case 'aro' :
         $tbl = 'aro_tbl';
+        printf("%-35s %-5s %-5s %s\n", 'Request objects', 'lft', 'rgt', 'Added');
         break;
     case 'aco' :
         $tbl = 'aco_tbl';
+        printf("%-35s %-5s %-5s %s\n", 'Control objects', 'lft', 'rgt', 'Added');
         break;
     case 'axo' :
         $tbl = 'axo_tbl';
+        printf("%-35s %-5s %-5s %s\n", 'Xtra objects', 'lft', 'rgt', 'Added');
         break;
     default :
@@ -233,5 +274,7 @@
         break;
     }
-    
+
+    echo "-----------------------------------------------------------\n";
+
     // Retrieve the left and right value of the $root node.
     $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'");
@@ -249,5 +292,5 @@
     
         // Display indented node title.
-        printf("%-20s %-5s %-5s %s\n", str_repeat('    ', sizeof($depth)) . $name, $lft, $rgt, $added_datetime);
+        printf("%-35s %-5s %-5s %s\n", str_repeat('    ', sizeof($depth)) . $name, $lft, $rgt, date($app->getParam('date_format'), strtotime($added_datetime)));
         
         // Add this node to the stack.
@@ -256,4 +299,35 @@
 }
 
+/*
+* List all entries in the acl_tbl.
+*
+* @access   public
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    17 Jun 2006 15:11:53
+*/
+function listPerms()
+{
+    $app =& App::getInstance();
+    $db =& DB::getInstance();
+    global $this_script;
+    
+    // Retreive access value from db.
+    $qid = $db->query("
+        SELECT aro_tbl.name AS aro, aco_tbl.name AS aco, axo_tbl.name AS axo, acl_tbl.access, acl_tbl.added_datetime
+        FROM acl_tbl
+        LEFT JOIN aro_tbl ON (acl_tbl.aro_id = aro_tbl.aro_id)
+        LEFT JOIN aco_tbl ON (acl_tbl.aco_id = aco_tbl.aco_id)
+        LEFT JOIN axo_tbl ON (acl_tbl.axo_id = axo_tbl.axo_id)
+        ORDER BY aro_tbl.aro_id ASC, aco_tbl.aco_id ASC, axo_tbl.axo_id ASC
+    ");
+    echo "\n";
+    printf("%-25s %-25s %-25s %-6s %-10s\n", 'Request objects', 'Control objects', 'Xtra objects', '', 'Added');
+    echo "------------------------------------------------------------------------------------------------\n";
+    while ($p = mysql_fetch_assoc($qid)) {
+        printf("%-25s %-25s %-25s \033[0;%sm%-6s\033[0m %-10s\n", $p['aro'], $p['aco'], $p['axo'], ('allow' == $p['access'] ? '32' : '31'), $p['access'], date($app->getParam('date_format'), strtotime($p['added_datetime'])));
+    }    
+}
+
 
 ?>
