r2022 + working on the "my account"
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 1 Jul 2008 20:43:36 +0000 (20:43 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 1 Jul 2008 20:43:36 +0000 (20:43 +0000)
ChangeLog
inc/interface.php
inc/navigation.php
inc/ophandlers.php

index 4a8a74f584c2908a3a47ecb5af54a27a60d183c3..ff9f3ecd5b015e6e4a62cb17763f7c8dc83416f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,8 @@
        new feature: tag roller
        new feature: taggable user accounts
        new feature: RackCode configuration
-       new feature: account password changer
+       new feature: "my account" page
+       update: page layout fixes and improvements
 0.15.1 2008-06-05
        bugfix: fix auth headers in upgrade script (broken in 0.15.0)
        new feature: fetch switch serial number via SNMP (by killsystem)
index 6a1914c1d231ff8f6decaffdaf4fc3a6640bc6d8..85ad43a72ed73cacc515d9451df5cd85b9cf82ca 100644 (file)
@@ -5137,15 +5137,13 @@ function renderUser ($user_id)
        echo '</table>';
 }
 
-function renderUserPasswordEditor ($user_id)
+function renderMyPasswordEditor ()
 {
        global $root, $pageno, $tabno, $remote_username, $accounts;
        showMessageOrError();
-       echo "<form method=post action='${root}process.php?page=${pageno}&tab=${tabno}&op=changePassword'>";
-       echo "<input type=hidden name=user_id value='${user_id}'>";
+       echo "<form method=post action='${root}process.php?page=${pageno}&tab=${tabno}&op=changeMyPassword'>";
        echo '<table border=0 align=center>';
-       if ($accounts[$remote_username]['user_id'] != 1)
-               echo "<tr><th class=tdright>Current password (*):</th><td><input type=password name=oldpassword tabindex=1></td></tr>";
+       echo "<tr><th class=tdright>Current password (*):</th><td><input type=password name=oldpassword tabindex=1></td></tr>";
        echo "<tr><th class=tdright>New password (*):</th><td><input type=password name=newpassword1 tabindex=2></td></tr>";
        echo "<tr><th class=tdright>New password again (*):</th><td><input type=password name=newpassword2 tabindex=3></td></tr>";
        echo "<tr><td colspan=2 align=center><input type=submit value='Change' tabindex=4></td></tr>";
index b20f69870be756bef46fae8c38f814de01879fea..e8f71bae22ea30777a88b977a027582c3678298a 100644 (file)
@@ -288,13 +288,10 @@ $page['user']['bypass_type'] = 'uint';
 $page['user']['tagloader'] = 'loadUserTags';
 $page['user']['autotagloader'] = 'getUserAutoTags';
 $tab['user']['default'] = 'View';
-$tab['user']['password'] = 'Change password';
 $tab['user']['tags'] = 'Tags';
 $tabhandler['user']['default'] = 'renderUser';
-$tabhandler['user']['password'] = 'renderUserPasswordEditor';
 $tabhandler['user']['tags'] = 'renderUserTags';
 $ophandler['user']['tags']['saveTags'] = 'saveUserTags';
-$ophandler['user']['password']['changePassword'] = 'changePassword';
 
 $page['perms']['title'] = 'Permissions';
 $page['perms']['parent'] = 'config';
@@ -362,6 +359,15 @@ $ophandler['tagtree']['edit']['destroyTag'] = 'destroyTag';
 $ophandler['tagtree']['edit']['createTag'] = 'createTag';
 $ophandler['tagtree']['edit']['updateTag'] = 'updateTag';
 
+$page['myaccount']['title'] = 'My account';
+$page['myaccount']['parent'] = 'config';
+$tab['myaccount']['default'] = 'Info';
+$tab['myaccount']['mypassword'] = 'Password';
+$tab['myaccount']['myrealname'] = 'Real name';
+$tabhandler['myaccount']['default'] = 'renderMyAccount';
+$tabhandler['myaccount']['mypassword'] = 'renderMyPasswordEditor';
+$ophandler['myaccount']['mypassword']['changeMyPassword'] = 'changeMyPassword';
+
 $page['reports']['title'] = 'Reports';
 $page['reports']['parent'] = 'index';
 $page['reports']['handler'] = 'renderReportSummary';
index 16f32eb1b28ec118ae2f1bceeb05154acec14dec..17cf96283a2ace1a4b46f8f0005ef5b7623b554f 100644 (file)
@@ -1323,26 +1323,22 @@ function rollTags ()
        return "${root}?page=${pageno}&tab=${tabno}&row_id=${row_id}&message=" . urlencode ("${nnew} new records done, ${ndupes} already existed");
 }
 
-function changePassword ()
+function changeMyPassword ()
 {
-       assertUIntArg ('user_id');
-       $user_id = $_REQUEST['user_id'];
-       $username = getUsernameByID ($user_id);
        global $accounts, $root, $pageno, $tabno, $remote_username;
-       if ($accounts[$remote_username]['user_id'] != 1)
-       {
-               assertStringArg ('oldpassword');
-               if ($accounts[$username]['user_password_hash'] != $_REQUEST['oldpassword'])
-                       return "${root}?page=${pageno}&tab=${tabno}&user_id=${user_id}&error=" . urlencode ('Old password doesn\'t match!');
-       }
+       if (getConfigVar ('USER_AUTH_SRC') != 'database')
+               return buildRedirectURL_ERR ('Can only change password under DB authentication.');
+       assertStringArg ('oldpassword');
        assertStringArg ('newpassword1');
        assertStringArg ('newpassword2');
+       if ($accounts[$remote_username]['user_password_hash'] != $_REQUEST['oldpassword'])
+               return buildRedirectURL_ERR ('Old password doesn\'t match.');
        if ($_REQUEST['newpassword1'] != $_REQUEST['newpassword2'])
-               return "${root}?page=${pageno}&tab=${tabno}&user_id=${user_id}&error=" . urlencode ('New passwords don\'t match!');
-       if (commitUpdateUserAccount ($user_id, $accounts[$username]['user_name'], $accounts[$username]['user_realname'], hash (PASSWORD_HASH, $_REQUEST['newpassword1'])))
-               return "${root}?page=${pageno}&tab=${tabno}&user_id=${user_id}&message=" . urlencode ('Password changed successfully.');
+               return buildRedirectURL_ERR ('New passwords don\'t match.');
+       if (commitUpdateUserAccount ($accounts[$remote_username]['user_id'], $accounts[$remote_username]['user_name'], $accounts[$username]['user_realname'], hash (PASSWORD_HASH, $_REQUEST['newpassword1'])))
+               return buildRedirectURL_OK ('Password changed successfully.');
        else
-               return "${root}?page=${pageno}&tab=${tabno}&user_id=${user_id}&error=" . urlencode ('DB update failed');
+               return buildRedirectURL_ERR ('Password change failed.');
 }
 
 function saveRackCode ()