finish off account management screen. fix bugs in displaying empty groups. bump...
authorchriskl <chriskl>
Thu, 8 May 2003 15:14:14 +0000 (15:14 +0000)
committerchriskl <chriskl>
Thu, 8 May 2003 15:14:14 +0000 (15:14 +0000)
classes/database/Postgres.php
conf/config.inc.php-dist
groups.php
lang/english.php
lang/recoded/english.php
libraries/lib.inc.php
topbar.php
users.php

index 71a9fac7eac21a6051273708a062522c8c16a568..e1fdf715177fe30aa60b659cdd2641b94a66dac4 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.97 2003/05/08 14:15:57 chriskl Exp $
+ * $Id: Postgres.php,v 1.98 2003/05/08 15:14:14 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1452,6 +1452,21 @@ class Postgres extends BaseDB {
        
        // User functions
        
+       /**
+        * Changes a user's password
+        * @param $username The username
+        * @param $password The new password
+        * @return 0 success
+        */
+       function changePassword($username, $password) {
+               $this->fieldClean($username);
+               $this->clean($password);
+               
+               $sql = "ALTER USER \"{$username}\" WITH PASSWORD '{$password}'";
+               
+               return $this->execute($sql);
+       }
+       
        /**
         * Returns all users in the database cluster
         * @return All users
@@ -1575,11 +1590,14 @@ class Postgres extends BaseDB {
                $sql = "SELECT grolist FROM pg_group WHERE groname = '{$groname}'";
       
                $grodata = $this->selectSet($sql);
-               $members = $grodata->f['grolist'];
-               $members = ereg_replace("\{|\}","",$members);
-               $this->clean($members);
+               if ($grodata->f['grolist'] !== null && $grodata->f['grolist'] != '{}') {
+                       $members = $grodata->f['grolist'];
+                       $members = ereg_replace("\{|\}","",$members);
+                       $this->clean($members);
 
-               $sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
+                       $sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
+               }
+               else $sql = "SELECT usename FROM pg_user WHERE false";
 
                return $this->selectSet($sql);
        }
index c6da4c446fbdbca13d7e223eb7453acaa09f38b7..f96ff50528eba49fb3725d920e335f9815b9a5ee 100644 (file)
@@ -4,7 +4,7 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.19 2003/05/08 14:15:58 chriskl Exp $
+        * $Id: config.inc.php-dist,v 1.20 2003/05/08 15:14:15 chriskl Exp $
         */
 
        // An example server.  Create as many of these as you wish,
@@ -37,6 +37,9 @@
        // means.
        $conf['owned_reports_only'] = false;
 
+       // Minimum length users can set their password to.
+       $conf['min_password_length'] = 1;
+
        // Width of the left frame in pixels (object browser)
        $conf['left_width'] = 200;
        
@@ -56,6 +59,6 @@
         * Don't modify anything below this line *
         *****************************************/
 
-       $conf['version'] = 6;
+       $conf['version'] = 7;
 
 ?>
index 86cb249c551c415002fa8bc2817b994a2b40d609..5962203ac1b0baa54f4ec786ac09ee2a883890b2 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage groups in a database cluster
         *
-        * $Id: groups.php,v 1.7 2003/04/18 11:08:26 chriskl Exp $
+        * $Id: groups.php,v 1.8 2003/05/08 15:14:14 chriskl Exp $
         */
 
        // Include application functions
@@ -35,7 +35,7 @@
                        echo "</table>\n";
 
                }
-               else echo "<p>{$lang['strinvalidparam']}</p>\n";
+               else echo "<p>{$lang['strnousers']}</p>\n";
                
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF\">{$lang['strshowallgroups']}</a></p>\n";
        }
index 1bb113179c61599c047ac0cb946485825f78bca2..85d052434b1829b0ee956c9c3c80454d6b3afb8e 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.75 2003/05/08 14:15:58 chriskl Exp $
+        * $Id: english.php,v 1.76 2003/05/08 15:14:15 chriskl Exp $
         */
 
        // Language and character set
@@ -66,6 +66,7 @@
        $lang['strunique'] = 'Unique';
        $lang['strprimary'] = 'Primary';
        $lang['strexport'] = 'Export';
+       $lang['strimport'] = 'Import';
        $lang['strsql'] = 'SQL';
        $lang['strgo'] = 'Go';
        $lang['stradmin'] = 'Admin';
@@ -80,6 +81,8 @@
        $lang['strinstead'] = 'Do Instead';
        $lang['strwhen'] = 'When';
        $lang['strformat'] = 'Format';
+       $lang['strdata'] = 'Data';
+       $lang['strconfirm'] = 'Confirm';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strcreatedb'] = 'Create DB?';
        $lang['strexpires'] = 'Expires';
        $lang['strnousers'] = 'No users found.';
-        $lang['struserupdated'] = 'User updated.';
+       $lang['struserupdated'] = 'User updated.';
        $lang['struserupdatedbad'] = 'User update failed.';
        $lang['strshowallusers'] = 'Show All Users';
        $lang['strcreateuser'] = 'Create User';
        $lang['struserdroppedbad'] = 'Failed to drop user.';
        $lang['straccount'] = 'Account';
        $lang['strchangepassword'] = 'Change Password';
-               
+       $lang['strpasswordchanged'] = 'Password changed.';
+       $lang['strpasswordchangedbad'] = 'Failed to change password.';
+       $lang['strpasswordshort'] = 'Password is too short.';
+       $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
+       
        // Groups
        $lang['strgroupadmin'] = 'Group Admin';
        $lang['strgroup'] = 'Group';
index 6a14774a72e9f33c0d0c6df19942b3cd2f970b6f..fd32b25ab89a0b814140f57f4cc0130b65035470 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.27 2003/05/08 14:15:59 chriskl Exp $
+        * $Id: english.php,v 1.28 2003/05/08 15:14:15 chriskl Exp $
         */
 
        // Language and character set
@@ -66,6 +66,7 @@
        $lang['strunique'] = 'Unique';
        $lang['strprimary'] = 'Primary';
        $lang['strexport'] = 'Export';
+       $lang['strimport'] = 'Import';
        $lang['strsql'] = 'SQL';
        $lang['strgo'] = 'Go';
        $lang['stradmin'] = 'Admin';
@@ -80,6 +81,8 @@
        $lang['strinstead'] = 'Do Instead';
        $lang['strwhen'] = 'When';
        $lang['strformat'] = 'Format';
+       $lang['strdata'] = 'Data';
+       $lang['strconfirm'] = 'Confirm';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strcreatedb'] = 'Create DB?';
        $lang['strexpires'] = 'Expires';
        $lang['strnousers'] = 'No users found.';
-        $lang['struserupdated'] = 'User updated.';
+       $lang['struserupdated'] = 'User updated.';
        $lang['struserupdatedbad'] = 'User update failed.';
        $lang['strshowallusers'] = 'Show All Users';
        $lang['strcreateuser'] = 'Create User';
        $lang['struserdroppedbad'] = 'Failed to drop user.';
        $lang['straccount'] = 'Account';
        $lang['strchangepassword'] = 'Change Password';
-               
+       $lang['strpasswordchanged'] = 'Password changed.';
+       $lang['strpasswordchangedbad'] = 'Failed to change password.';
+       $lang['strpasswordshort'] = 'Password is too short.';
+       $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
+       
        // Groups
        $lang['strgroupadmin'] = 'Group Admin';
        $lang['strgroup'] = 'Group';
index e4f232be77e8f127eb43c51c28a74fe035629524..dd3be6c2398f86132e6f3d271cd0a3026175d186 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.44 2003/05/08 14:15:59 chriskl Exp $
+        * $Id: lib.inc.php,v 1.45 2003/05/08 15:14:15 chriskl Exp $
         */
        
        // Set error reporting level to max
@@ -29,7 +29,7 @@
        // Configuration file version.  If this is greater than that in config.inc.php, then
        // the app will refuse to run.  This and $conf['version'] should be incremented whenever
        // backwards incompatible changes are made to config.inc.php-dist.
-       $conf['base_version'] = 6;
+       $conf['base_version'] = 7;
 
        // List of available language files
        $appLangFiles = array(
index 1b76b0b8df62be0232c9f18af0181d1498d4d7e9..5c4d213be658c50518a2255115fa17adc1b7883e 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Top menu for phpPgAdmin
         *
-        * $Id: topbar.php,v 1.10 2003/05/08 14:15:55 chriskl Exp $
+        * $Id: topbar.php,v 1.11 2003/05/08 15:14:14 chriskl Exp $
         */
 
        // Include application functions
 ?>
                        <a class="toplink" href="users.php" target="detail"><?php echo $lang['struseradmin'] ?></a> | 
                        <a class="toplink" href="groups.php" target="detail"><?php echo $lang['strgroupadmin'] ?></a> |
-<?php
-       else :
-?>
-                       <a class="toplink" href="users.php?action=account" target="detail"><?php echo $lang['straccount'] ?></a> |
 <?php
        endif;
 ?>
+                       <a class="toplink" href="users.php?action=account" target="detail"><?php echo $lang['straccount'] ?></a> |
 <?php if ($conf['show_reports']) : ?>
                        <a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
 <?php endif; ?>
index 067b3d8452e815b0cf832fd8c3196fe10931f28e..5c219328cb10c6b3d6f7b30ad5e24d104e3718f4 100644 (file)
--- a/users.php
+++ b/users.php
@@ -3,7 +3,7 @@
        /**
         * Manage users in a database cluster
         *
-        * $Id: users.php,v 1.9 2003/05/08 14:15:56 chriskl Exp $
+        * $Id: users.php,v 1.10 2003/05/08 15:14:14 chriskl Exp $
         */
 
        // Include application functions
                $userdata = &$data->getUser($_SESSION['webdbUsername']);
                
                if ($userdata->recordCount() > 0) {
+                       $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]);
+                       $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]);
                        echo "<table>\n";
                        echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th></tr>\n";
                        echo "<tr><td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uname']]), "</td>\n";
-                       echo "<td class=\"data1\">", $userdata->f[$data->uFields['usuper']], "</td>\n";
-                       echo "<td class=\"data1\">", $userdata->f[$data->uFields['ucreatedb']], "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
                        echo "<td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
                        echo "</table>\n";
                }
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=confchangepassword\">{$lang['strchangepassword']}</a></p>\n";
        }
        
+       /**
+        * Show confirmation of change password and actually change password
+        */
+       function doChangePassword($confirm, $msg = '') {
+               global $data, $misc;
+               global $PHP_SELF, $lang, $conf;
+
+               if ($confirm) { 
+                       echo "<h2>{$lang['strusers']}: ", htmlspecialchars($_SESSION['webdbUsername']), ": {$lang['strchangepassword']}</h2>\n";
+                       $misc->printMsg($msg);
+                                               
+                       if (!isset($_POST['password'])) $_POST['password'] = '';
+                       if (!isset($_POST['confirm'])) $_POST['confirm'] = '';
+                       
+                       
+                       echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                       echo $lang['strpassword'], "<br />\n";
+                       echo "<input type=\"password\" name=\"password\" size=\"32\" value=\"", 
+                               htmlspecialchars($_POST['password']), "\" /><br /><br />\n";
+                       echo $lang['strconfirm'], "<br />\n";
+                       echo "<input type=\"password\" name=\"confirm\" size=\"32\" value=\"", 
+                               htmlspecialchars($_POST['confirm']), "\" /><br /><br />\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"changepassword\" />\n";
+                       echo "<input type=\"submit\" name=\"ok\" value=\"{$lang['strok']}\" />\n";
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "</form>\n";
+               }
+               else {
+                       // Check that password is minimum length
+                       if (strlen($_POST['password']) < $conf['min_password_length'])
+                               doChangePassword(true, $lang['strpasswordshort']);
+                       // Check that password matches confirmation password
+                       elseif ($_POST['password'] != $_POST['confirm'])
+                               doChangePassword(true, $lang['strpasswordconfirm']);
+                       else {
+                               $status = $data->changePassword($_SESSION['webdbUsername'], 
+                                       $_POST['password']);
+                               if ($status == 0)
+                                       doAccount($lang['strpasswordchanged']);
+                               else
+                                       doAccount($lang['strpasswordchangedbad']);
+                       }
+               }               
+       }
+
        /** 
         * Function to save after editing a user
         */
                $userdata = &$data->getUser($_REQUEST['username']);
                
                if ($userdata->recordCount() > 0) {
+                       $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]);
+                       $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]);
                        echo "<table>\n";
                        echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th></tr>\n";
                        echo "<tr><td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uname']]), "</td>\n";
-                       echo "<td class=\"data1\">", $userdata->f[$data->uFields['usuper']], "</td>\n";
-                       echo "<td class=\"data1\">", $userdata->f[$data->uFields['ucreatedb']], "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
                        echo "<td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
                        echo "</table>\n";
                }
        $misc->printBody();
 
        switch ($action) {
+               case 'changepassword':
+                       if (isset($_REQUEST['ok'])) doChangePassword(false);
+                       else doAccount();
+                       break;
+               case 'confchangepassword':
+                       doChangePassword(true);
+                       break;                  
                case 'account':
                        doAccount();
                        break;