class ttOrgImportHelper {
var $errors = null; // Errors go here. Set in constructor by reference.
var $schema_version = null; // Database schema version from XML file we import from.
+ var $num_users = 0; // A number of active and inactive users we are importing.
var $conflicting_logins = null; // A comma-separated list of logins we cannot import.
var $canImport = true; // False if we cannot import data due to a conflict such as login collision.
var $firstPass = true; // True during first pass through the file.
// In first pass we check user logins for potential collisions with existing.
if ($name == 'USER' && $this->canImport) {
$login = $attrs['LOGIN'];
+ if ('' != $attrs['STATUS']) $this->num_users++;
if ('' != $attrs['STATUS'] && $this->loginExists($login)) {
// We have a login collision. Append colliding login to a list of things we cannot import.
$this->conflicting_logins .= ($this->conflicting_logins ? ", $login" : $login);
$this->errors->add($i18n->get('error.user_exists'));
$this->errors->add(sprintf($i18n->get('error.cannot_import'), $this->conflicting_logins));
}
+ if (!ttUserHelper::canAdd($this->num_users)) {
+ $this->canImport = false;
+ $this->errors->add($i18n->get('error.user_count'));
+ }
$this->firstPass = false; // We are done with 1st pass.
xml_parser_free($parser);
}
// canAdd determines if we can add a user in case there is a limit.
- static function canAdd() {
+ static function canAdd($num_users = 1) {
$mdb2 = getConnection();
$sql = "select param_value from tt_site_config where param_name = 'max_users'";
$res = $mdb2->query($sql);
$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)
+ if ($val['user_count'] < $max_count - $num_users) // TODO: test this.
return true; // Limit not reached.
return false;
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.36.4688 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.36.4689 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
$err->add($i18n->get('error.not_equal'), $i18n->get('label.password'), $i18n->get('label.confirm_password'));
if (!ttValidEmail($cl_manager_email, true))
$err->add($i18n->get('error.field'), $i18n->get('label.email'));
+ if (!ttUserHelper::canAdd())
+ $err->add($i18n->get('error.user_count'));
if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$');