X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/11cef71c5608efdf93d400622140ef48f08b18f6..367baa10353d5f679e6e3c795ae9d35a275a24d9:/WEB-INF/lib/ttUserHelper.class.php diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 26ced938..b3a5e360 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -386,4 +386,22 @@ class ttUserHelper { $sql = "update tt_users set accessed = now(), accessed_ip = $accessed_ip where id = $user->id"; $mdb2->exec($sql); } + + // canAdd determines if we can add a user in case there is a limit. + static function canAdd() { + $mdb2 = getConnection(); + $sql = "select param_value from tt_site_config where param_name = 'max_users'"; + $res = $mdb2->query($sql); + $val = $res->fetchRow(); + if (!$val) return true; // No limit. + + $max_count = $val['param_value']; + $sql = "select count(*) as user_count from tt_users where status is not null"; + $res = $mdb2->query($sql); + $val = $res->fetchRow(); + if ($val['user_count'] < $max_count) + return true; // Limit not reached. + + return false; + } }