show privileges on views, functions, sequences, database and schemas. make grant...
authorchriskl <chriskl>
Sun, 9 Feb 2003 10:22:38 +0000 (10:22 +0000)
committerchriskl <chriskl>
Sun, 9 Feb 2003 10:22:38 +0000 (10:22 +0000)
classes/database/BaseDB.php
classes/database/Postgres.php
classes/database/Postgres74.php
database.php
functions.php
lang/english.php
lang/recoded/english.php
privileges.php
sequences.php
views.php

index 1c9e971cda774b716c234cae7713602b2b1791d8..f48cc283446df47ea3afb85d8f969818b6c4b05e 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: BaseDB.php,v 1.9 2003/01/27 15:18:03 chriskl Exp $
+ * $Id: BaseDB.php,v 1.10 2003/02/09 10:22:38 chriskl Exp $
  */
 
 include_once('classes/database/ADODB_base.php');
@@ -158,6 +158,7 @@ class BaseDB extends ADODB_base {
        function hasLanguages() { return false; }
        function hasSchemas() { return false; }
        function hasConversions() { return false; }
+       function hasGrantOption() { return false; }
 
 }
 
index ad2f78603b35dc6e0f85d26ba23521175619cec5..97809937b9f640b36a0548cc9d2393e23c94076a 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.50 2003/02/09 09:23:39 chriskl Exp $
+ * $Id: Postgres.php,v 1.51 2003/02/09 10:22:39 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1529,7 +1529,7 @@ class Postgres extends BaseDB {
                                $sql = "SELECT datacl AS acl FROM pg_database WHERE datname = '{$object}'";
                                break;
                        case 'function':
-                               $sql = "SELECT proacl AS acl FROM pg_proc WHERE proname = '{$object}'";
+                               $sql = "SELECT proacl AS acl FROM pg_proc WHERE oid = '{$object}'";
                                break;
                        case 'language':
                                $sql = "SELECT lanacl AS acl FROM pg_language WHERE lanname = '{$object}'";
index 793bfe73d96c1a2a8d4fa54dffea20ba4cb2a42b..bbbe82f820c14c0a6e41c9f92dbd64fccc450d99 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres74.php,v 1.2 2003/01/18 06:38:37 chriskl Exp $
+ * $Id: Postgres74.php,v 1.3 2003/02/09 10:22:39 chriskl Exp $
  */
 
 include_once('classes/database/Postgres73.php');
@@ -50,6 +50,9 @@ class Postgres74 extends Postgres73 {
                return $this->selectSet($sql);
        }
 
+       // Capabilities
+       function hasGrantOption() { return true; }
+       
 }
 
 ?>
index 3051e123a6ecd7e8518494cc1a8c375e98ced482..9080320ef37ccafe20ebe150fa15d84bb8eb4a90 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.3 2003/02/07 17:34:34 xzilla Exp $
+        * $Id: database.php,v 1.4 2003/02/09 10:22:38 chriskl Exp $
         */
 
        // Include application functions
         */
        function doDefault($msg = '') {
                global $data, $localData, $misc;
-               global $PHP_SELF, $strName, $strOwner, $strSchemas, $strDrop, $strActions, $strCreateSchema, $strNoSchemas;
+               global $PHP_SELF, $strName, $strOwner, $strSchemas, $strDrop, $strActions;
+               global $strCreateSchema, $strNoSchemas, $strPrivileges;
                
                $misc->printDatabaseNav();
                echo "<h2>", htmlspecialchars($_REQUEST['database']), ": {$strSchemas}</h2>\n";
 
                        if ($schemas->recordCount() > 0) {
                                echo "<table>\n";
-                               echo "<tr><th class=data>{$strName}</th><th class=data>{$strOwner}</th><th class=data>{$strActions}</th>\n";
+                               echo "<tr><th class=data>{$strName}</th><th class=data>{$strOwner}</th><th colspan=\"2\" class=data>{$strActions}</th>\n";
                                $i = 0;
                                while (!$schemas->EOF) {
                                        $id = (($i % 2) == 0 ? '1' : '2');
                                        echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&database=",
                                                htmlspecialchars($_REQUEST['database']), "&schema=",
                                                htmlspecialchars($schemas->f[$data->nspFields['nspname']]), "\">{$strDrop}</a></td>\n";
+                                       echo "<td class=opbutton{$id}><a href=\"privileges.php?database=",
+                                               htmlspecialchars($_REQUEST['database']), "&object=",
+                                               htmlspecialchars($schemas->f[$data->nspFields['nspname']]), "&type=schema\">{$strPrivileges}</a></td>\n";
                                        echo "</tr>\n";
                                        $schemas->moveNext();
                                        $i++;
index bb786de8bcaa0ddb980d24dd38c2492fb7ba0e7c..8fbd5a23ec93f6397565bcb23de42aa0eb51cc7d 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage functions in a database
         *
-        * $Id: functions.php,v 1.2 2003/02/07 17:34:34 xzilla Exp $
+        * $Id: functions.php,v 1.3 2003/02/09 10:22:38 chriskl Exp $
         */
 
        // Include application functions
        function doDefault($msg = '') {
                global $data, $localData, $misc, $database, $func;
                global $PHP_SELF, $strFunctions, $strArguments, $strReturns, $strActions, $strNoFunctions;
+               global $strCreateFunction, $strProperties, $strEdit, $strDrop, $strPrivileges;
                
                echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Functions</h2>\n";
                $misc->printMsg($msg);
 
                if ($funcs->recordCount() > 0) {
                        echo "<table>\n";
-                       echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strArguments}</th><th colspan=3 class=data>{$strActions}</th>\n";
+                       echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strArguments}</th><th colspan=\"4\" class=data>{$strActions}</th>\n";
                        $i = 0;
                        while (!$funcs->EOF) {
                                $func_full = $funcs->f[$data->fnFields['fnname']] . "(". $funcs->f[$data->fnFields['fnarguments']] .")";
                                echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnreturns']]), "</td>\n";
                                echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnarguments']]), "</td>\n";
                                echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=properties&{$misc->href}&function=", 
-                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Properties</a></td>\n";
+                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">{$strProperties}</a></td>\n";
                                echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=edit&{$misc->href}&function=", 
-                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Edit</a></td>\n";
-                               echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&function=", 
-                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Drop</a></td>\n";
+                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">{$strEdit}</a></td>\n";
+                               echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&function=",
+                                       urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">{$strDrop}</a></td>\n";
+                               echo "<td class=opbutton{$id}><a href=\"privileges.php?{$misc->href}&function=", 
+                                       urlencode($func_full), "&object=",
+                                       $funcs->f[$data->fnFields['fnoid']], "&type=function\">{$strPrivileges}</a></td>\n";
                                echo "</tr>\n";
                                $funcs->moveNext();
                                $i++;
                        echo "<p>{$strNoFunctions}</p>\n";
                }
                
-               echo "<p><a class=navlink href=\"$PHP_SELF?action=create&{$misc->href}\">Create Function</a></p>\n";
+               echo "<p><a class=navlink href=\"$PHP_SELF?action=create&{$misc->href}\">{$strCreateFunction}</a></p>\n";
 
        }
        
index 175bfa0ca4acdb12d8bac075e8c0e2a7e7b48cfc..7f4b26a036f33c2aebd91069b4825b51dc2e4da3 100755 (executable)
@@ -4,7 +4,7 @@
         * Language template file for WebDB. Use this to base language
         * files.
         *
-        * $Id: english.php,v 1.49 2003/01/27 15:18:03 chriskl Exp $
+        * $Id: english.php,v 1.50 2003/02/09 10:22:39 chriskl Exp $
         */
 
        // Language and character set
 
        // Privilges
        $strPrivileges = 'Privileges';
+       $strNoPrivileges = 'This object has no privileges.';
        $strGrant = 'Grant';
        $strRevoke = 'Revoke';
 
index b1037dcd0bb5beaad9d9474ecb06b829ce3f5235..931c6674ec68b159c0bbc1721d787f26da6ee6f5 100644 (file)
@@ -4,7 +4,7 @@
         * Language template file for WebDB. Use this to base language
         * files.
         *
-        * $Id: english.php,v 1.5 2003/01/27 15:19:49 chriskl Exp $
+        * $Id: english.php,v 1.6 2003/02/09 10:22:39 chriskl Exp $
         */
 
        // Language and character set
 
        // Privilges
        $strPrivileges = 'Privileges';
+       $strNoPrivileges = 'This object has no privileges.';
        $strGrant = 'Grant';
        $strRevoke = 'Revoke';
 
index a32e294c6d70128984de362bf2de1e59e3d79bd5..2400067dd1b6adac72c17b28986d81d55574a550 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage privileges in a database
         *
-        * $Id: privileges.php,v 1.4 2003/02/09 09:23:37 chriskl Exp $
+        * $Id: privileges.php,v 1.5 2003/02/09 10:22:38 chriskl Exp $
         */
 
        // Include application functions
        function doDefault($msg = '') {
                global $data, $localData, $misc, $database;
                global $PHP_SELF, $strPrivileges, $strGrant, $strRevoke;
-               global $strUser, $strGroup, $strSelect, $strInsert, $strUpdate, $strDelete, $strRule;
-               global $strReferences, $strTrigger, $strAction, $strYes, $strNo, $strType;
+               global $strUser, $strGroup, $strYes, $strNo, $strType;
+               global $strShowAllViews, $strShowAllSequences, $strShowAllFunctions, $strNoPrivileges;
+               global $strShowAllSchemas;
 
                switch ($_REQUEST['type']) {
                        case 'database':
                                $misc->printDatabaseNav();
+                               $name = $_REQUEST['object'];
                                break;
                        case 'table':
                                $misc->printTableNav();
+                               $name = $_REQUEST['object'];
                                break;
+                       case 'function':
+                               $name = $_REQUEST['function'];
+                               break;
+                       default:
+                               $name = $_REQUEST['object'];
                }
-               echo "<h2>$strPrivileges: ", htmlspecialchars($_REQUEST['object']), "</h2>\n";
+               echo "<h2>$strPrivileges: ", htmlspecialchars($name), "</h2>\n";
                $misc->printMsg($msg);
 
                // Get the privileges on the object, given its type
                $privileges = $localData->getPrivileges($_REQUEST['object'], $_REQUEST['type']);
 
-               echo "<table>\n";
-               echo "<tr><th class=\"data\">{$strType}</th><th class=\"data\">User/Group</th><th class=\"data\">",
-                       join('</th><th class="data">', $data->privlist[$_REQUEST['type']]), "</th>";
-               echo "<th class=\"data\">Grant Option?</th><th class=\"data\">Grantor</th></tr>\n";
-
-               // Loop over privileges, outputting them
-               $i = 0;
-               foreach ($privileges as $v) {
-                       $id = (($i % 2) == 0 ? '1' : '2');
-                       echo "<tr>\n";
-                       echo "<td class=\"data{$id}\">", htmlspecialchars($v[0]), "</td>\n";
-                       echo "<td class=\"data{$id}\">", htmlspecialchars($v[1]), "</td>\n";
+               if (sizeof($privileges) > 0) {
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$strType}</th><th class=\"data\">{$strUser}/{$strGroup}</th>";
                        foreach ($data->privlist[$_REQUEST['type']] as $v2) {
-                               if (in_array($v2, $v[2]))
-                                       echo "<td class=\"data{$id}\">$strYes</td>\n";
-                               else
-                                       echo "<td class=\"data{$id}\">$strNo</td>\n";
+                               // Skip over ALL PRIVILEGES
+                               if ($v2 == 'ALL PRIVILEGES') continue;
+                               echo "<th class=\"data\">{$v2}</th>\n";
+                       }
+                       if ($data->hasGrantOption()) {
+                               echo "<th class=\"data\">Grant Option?</th><th class=\"data\">Grantor</th>";
                        }
-                       echo "<td class=\"data{$id}\">", ($v[3]) ? $strYes : $strNo, "</td>\n";
-                       echo "<td class=\"data{$id}\">", htmlspecialchars($v[4]), "</td>\n";
                        echo "</tr>\n";
-                       $i++;
+
+                       // Loop over privileges, outputting them
+                       $i = 0;
+                       foreach ($privileges as $v) {
+                               $id = (($i % 2) == 0 ? '1' : '2');
+                               echo "<tr>\n";
+                               echo "<td class=\"data{$id}\">", htmlspecialchars($v[0]), "</td>\n";
+                               echo "<td class=\"data{$id}\">", htmlspecialchars($v[1]), "</td>\n";
+                               foreach ($data->privlist[$_REQUEST['type']] as $v2) {
+                                       // Skip over ALL PRIVILEGES
+                                       if ($v2 == 'ALL PRIVILEGES') continue;
+                                       if (in_array($v2, $v[2]))
+                                               echo "<td class=\"data{$id}\">$strYes</td>\n";
+                                       else
+                                               echo "<td class=\"data{$id}\">$strNo</td>\n";
+                               }
+                               if ($data->hasGrantOption()) {
+                                       echo "<td class=\"data{$id}\">", ($v[3]) ? $strYes : $strNo, "</td>\n";
+                                       echo "<td class=\"data{$id}\">", htmlspecialchars($v[4]), "</td>\n";
+                               }
+                               echo "</tr>\n";
+                               $i++;
+                       }
+
+                       echo "</table>";
+               }
+               else {
+                       echo "<p>{$strNoPrivileges}</p>\n";
                }
 
-               echo "</table>";
+               switch ($_REQUEST['type']) {
+                       case 'view':
+                               echo "<p><a class=\"navlink\" href=\"views.php?{$misc->href}\">{$strShowAllViews}</a></p>\n";
+                               break;
+                       case 'sequence':
+                               echo "<p><a class=\"navlink\" href=\"sequences.php?{$misc->href}\">{$strShowAllSequences}</a></p>\n";
+                               break;
+                       case 'function':
+                               echo "<p><a class=\"navlink\" href=\"functions.php?{$misc->href}\">$strShowAllFunctions</a></p>\n";
+                               break;
+                       case 'schema':
+                               echo "<p><a class=\"navlink\" href=\"database.php?database=", htmlspecialchars($_REQUEST['database']),
+                                       "\">$strShowAllSchemas</a></p>\n";
+                               break;          
+               }
        }
 
        $misc->printHeader($strPrivileges);
index feeb87356f743afed17f9623cce78829974cf6c7..0d43c0f73461c6f81b4616ba490da200ced41384 100644 (file)
@@ -2,7 +2,7 @@
 /**
  *  FILENAME:   sequence.php
  *
- *  $Id: sequences.php,v 1.2 2003/02/07 17:34:35 xzilla Exp $
+ *  $Id: sequences.php,v 1.3 2003/02/09 10:22:38 chriskl Exp $
  */
 
 include_once( 'libraries/lib.inc.php' );
@@ -44,7 +44,8 @@ function doDefault($msg='')
                        echo "<td class=\"data{$id}\">";
                                echo "<a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&sequence=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "\">$strDrop</td>\n"; 
                        echo "<td class=\"data{$id}\">";
-                               echo "<a href=\"privileges.php?action=priviledges&{$misc->href}&sequence=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "\">$strPrivileges</td></tr>\n"; 
+                               echo "<a href=\"privileges.php?{$misc->href}&object=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]),
+                                       "&type=sequence\">$strPrivileges</td></tr>\n";
 
                        $sequences->movenext();
                        $i++;
index 34a4cf8a5297f912d6079097803cfc93814eec86..20f9461c7234c34f589ccf0f0b056ba13f734529 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.2 2003/02/07 17:34:35 xzilla Exp $
+        * $Id: views.php,v 1.3 2003/02/09 10:22:38 chriskl Exp $
         */
 
        // Include application functions
                global $data, $localData, $misc;
                global $PHP_SELF, $strView, $strOwner, $strActions, $strNoViews, $strViews;
                global $strBrowse, $strProperties, $strDrop, $strCreateView, $strBack;
+               global $strPrivileges;
                
                echo "<h2>", htmlspecialchars($_REQUEST['database']), ": {$strViews}</h2>\n";
                $misc->printMsg($msg);
                
                if ($views->recordCount() > 0) {
                        echo "<table>\n";
-                       echo "<tr><th class=data>{$strView}</th><th class=data>{$strOwner}</th><th colspan=4 class=data>{$strActions}</th>\n";
+                       echo "<tr><th class=data>{$strView}</th><th class=data>{$strOwner}</th><th colspan=\"5\" class=data>{$strActions}</th>\n";
                        $i = 0;
                        while (!$views->EOF) {
                                // @@@@@@@@@ FIX THIS!!!!!
                                echo "<td class=opbutton{$id}><a href=\"display.php?{$misc->href}&query={$query}&count={$count}&return_url={$return_url}&return_desc={$strBack}\">{$strBrowse}</a></td>\n";
                                echo "<td class=opbutton{$id}>Select</td>\n";
                                echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=properties&{$misc->href}&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">{$strProperties}</a></td>\n"; 
-                               echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">{$strDrop}</a></td>\n"; 
+                               echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">{$strDrop}</a></td>\n";
+                               echo "<td class=opbutton{$id}><a href=\"privileges.php?{$misc->href}&object=", urlencode($views->f[$data->vwFields['vwname']]),
+                                       "&type=view\">{$strPrivileges}</a></td>\n";
                                echo "</tr>\n";
                                $views->moveNext();
                                $i++;