[geeklog-cvs] geeklog: User editor no longer loses changes when an error occur...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Aug 28 11:08:58 EDT 2011


changeset 8376:c7dcfeb6a59c
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/c7dcfeb6a59c
user: Dirk Haun <dirk at haun-online.de>
date: Thu Jun 23 21:26:48 2011 +0200
description:
User editor no longer loses changes when an error occured (cf. bug #0000653)

diffstat:

 public_html/admin/user.php |  43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diffs (71 lines):

diff -r bac1b9f47e00 -r c7dcfeb6a59c public_html/admin/user.php
--- a/public_html/admin/user.php	Thu Jun 23 20:32:16 2011 +0200
+++ b/public_html/admin/user.php	Thu Jun 23 21:26:48 2011 +0200
@@ -119,26 +119,27 @@
     } else {
         $A['uid'] = '';
         $uid = '';
-        $curtime =  COM_getUserDateTimeFormat();
+        $curtime = COM_getUserDateTimeFormat();
         $lastlogin = '';
         $lasttime = '';
         $A['status'] = USER_ACCOUNT_ACTIVE;
+    }
 
-        if (isset($_POST['username'])) {
-            $A['username'] = strip_tags($_POST['username']);
-        }
-        if (isset($_POST['fullname'])) {
-            $A['fullname'] = strip_tags($_POST['fullname']);
-        }
-        if (isset($_POST['email'])) {
-            $A['email'] = strip_tags($_POST['email']);
-        }
-        if (isset($_POST['homepage'])) {
-            $A['homepage'] = strip_tags($_POST['homepage']);
-        }
-        if (isset($_POST['userstatus'])) {
-            $A['status'] = COM_applyFilter($_POST['userstatus'], true);
-        }
+    // POST data can override, in case there was an error while editing a user
+    if (isset($_POST['username'])) {
+        $A['username'] = strip_tags($_POST['username']);
+    }
+    if (isset($_POST['fullname'])) {
+        $A['fullname'] = strip_tags($_POST['fullname']);
+    }
+    if (isset($_POST['email'])) {
+        $A['email'] = strip_tags($_POST['email']);
+    }
+    if (isset($_POST['homepage'])) {
+        $A['homepage'] = strip_tags($_POST['homepage']);
+    }
+    if (isset($_POST['userstatus'])) {
+        $A['status'] = COM_applyFilter($_POST['userstatus'], true);
     }
 
     $token = SEC_createToken();
@@ -317,6 +318,13 @@
                 $selected .= ' ' . $def_grp;
             }
         }
+
+        // in case of an error we may have previously selected a different
+        // mix of groups already - reconstruct those from the POST data
+        if (isset($_POST['groups']) && (count($_POST['groups']) > 0)) {
+            $selected = implode(' ', $_POST['groups']);
+        }
+
         $thisUsersGroups = SEC_getUserGroups();
         $remoteGroup = DB_getItem($_TABLES['groups'], 'grp_id',
                                   "grp_name = 'Remote Users'");
@@ -707,7 +715,8 @@
     } else {
         $retval = COM_siteHeader('menu', $LANG28[1]);
         $retval .= COM_showMessageText($LANG28[10]);
-        if (DB_count($_TABLES['users'], 'uid', $uid) > 0) {
+        if (!empty($uid) && ($uid > 1) &&
+                DB_count($_TABLES['users'], 'uid', $uid) > 0) {
             $retval .= edituser($uid);
         } else {
             $retval .= edituser();



More information about the geeklog-cvs mailing list