X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/496cfee4721ea6f3dca65ec57a2845ef059c5b1d..15684e556a6829fbea1511e99ee5bf8053d69295:/WEB-INF/lib/ttRegistrator.class.php diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 0e51ce39..ea76f3a2 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -122,8 +122,10 @@ class ttRegistrator { $name = $mdb2->quote($this->group_name); $currency = $mdb2->quote($this->currency); $lang = $mdb2->quote($this->lang); + $created = 'now()'; + $created_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']); - $sql = "insert into tt_teams (name, currency, lang) values($name, $currency, $lang)"; + $sql = "insert into tt_teams (name, currency, lang, created, created_ip) values($name, $currency, $lang, $created, $created_ip)"; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { @@ -149,6 +151,15 @@ class ttRegistrator { $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { $user_id = $mdb2->lastInsertID('tt_users', 'id'); + + // Update created_by field for the team with user id, now that we have it. + $sql = "update tt_teams set created_by = $user_id where id = $this->group_id and created_by is null"; + $affected = $mdb2->exec($sql); + + // Update created_by field for user by setting to self. + $sql = "update tt_users set created_by = $user_id where id = $user_id and team_id = $this->group_id and created_by is null"; + $affected = $mdb2->exec($sql); + return $user_id; } return false;