Kunden-Status wird benutzt / lastlogin eingeführt.
bernd

bernd commited on 2007-07-04 17:20:39
Zeige 4 geänderte Dateien mit 20 Einfügungen und 1 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@534 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -28,6 +28,8 @@ if (isset($_REQUEST['customerno']) and isset($_REQUEST['token']))
28 28
         logger("modules/index/validate_token.php", "pwrecovery", "customer »{$customerno}« set a new password");
29 29
         set_customer_password($customerno, $_POST['password']);
30 30
         success_msg('Das Passwort wurde gesetzt!');
31
+        set_customer_verified($customerno);
32
+        set_customer_lastlogin($customerno);
31 33
         invalidate_customer_token($customerno);
32 34
         $_SESSION['role'] = ROLE_CUSTOMER;
33 35
         $_SESSION['customerinfo'] = get_customer_info($customerno);
... ...
@@ -40,7 +40,7 @@ function create_customer($data)
40 40
   $nachname = maybe_null($nachname);
41 41
 
42 42
   db_query("BEGIN");
43
-  db_query("INSERT INTO kundendaten.kunden (firma, nachname, vorname, anrede, erstellungsdatum) VALUES ({$firma}, {$nachname}, {$vorname}, {$anrede}, CURDATE())");
43
+  db_query("INSERT INTO kundendaten.kunden (firma, nachname, vorname, anrede, erstellungsdatum,status) VALUES ({$firma}, {$nachname}, {$vorname}, {$anrede}, CURDATE(), 3)");
44 44
   $customerno = mysql_insert_id();
45 45
   db_query("INSERT INTO kundendaten.kundenkontakt (typ, comment, wert, name, kundennr) VALUES ('email', 'extern', '{$email}', {$realname}, {$customerno})");
46 46
   db_query("COMMIT");
... ...
@@ -81,7 +81,10 @@ function get_user_info($username)
81 81
   $result = db_query("SELECT kunde AS customerno, username, uid, homedir, name
82 82
                       FROM system.v_useraccounts WHERE username='{$username}' OR uid='{$username}' LIMIT 1");
83 83
   if (mysql_num_rows($result) < 1)
84
+  {
85
+    logger("session/checkuser.php", "login", "error reading user's data: »{$username}«");
84 86
     system_failure('Das Auslesen Ihrer Benutzerdaten ist fehlgeschlagen. Bitte melden Sie dies einem Administrator');
87
+  }
85 88
   $val = @mysql_fetch_object($result);
86 89
   return array(
87 90
           'username'      => $val->username,
... ...
@@ -92,6 +95,19 @@ function get_user_info($username)
92 95
           );
93 96
 }
94 97
 
98
+function set_customer_verified($customerno)
99
+{
100
+  $customerno = (int) $customerno;
101
+  db_query("UPDATE kundendaten.kunden SET status=0 WHERE id={$customerno};");
102
+  logger("session/checkuser.php", "register", "set customer's status to 0.");
103
+}
104
+
105
+function set_customer_lastlogin($customerno)
106
+{
107
+  $customerno = (int) $customerno;
108
+  db_query("UPDATE kundendaten.kunden SET lastlogin=NOW() WHERE id={$customerno};");
109
+}
110
+
95 111
 function set_customer_password($customerno, $newpass)
96 112
 {
97 113
   $customerno = (int) $customerno;
... ...
@@ -43,6 +43,7 @@ if (isset($_POST['username']) && isset($_POST['password']))
43 43
     case ROLE_CUSTOMER:
44 44
       $info = get_customer_info($_POST['username']);
45 45
       $_SESSION['customerinfo'] = $info;
46
+      set_customer_lastlogin($info['customerno']);
46 47
       logger("session/start.php", "login", "logged in customer no »{$info['customerno']}«");
47 48
       break;
48 49
     }
49 50