From: Nik Okuntseff Date: Mon, 24 Dec 2018 15:01:49 +0000 (+0000) Subject: Introduced handling of max user count. X-Git-Tag: timetracker_1.19-1~379 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=367baa10353d5f679e6e3c795ae9d35a275a24d9;p=timetracker.git Introduced handling of max user count. --- 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; + } } diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index b4d86993..f38bcabd 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index d12be155..baf085b5 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -118,6 +118,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index c4974513..051b6f8c 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index eab807e8..6c75c7e3 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -104,6 +104,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index aadf6f5a..687f19da 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -101,6 +101,7 @@ $i18n_key_words = array( 'error.xml' => 'Error in XML file at line %d: %s.', 'error.cannot_import' => 'Cannot import: %s.', 'error.format' => 'Invalid file format.', +'error.user_count' => 'Limit on user count.', // Warning messages. 'warn.sure' => 'Are you sure?', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index cc4fe034..fbf7076a 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -114,6 +114,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index a29929af..860b8cd9 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index f1a37b4f..3ec01e23 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 065f71c1..4895713b 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -112,6 +112,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 4c6d7674..5e003665 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 6be29a04..6e7b32ef 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -105,6 +105,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index d27edb8c..daedb00b 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -127,6 +127,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 27642b47..fcd4c256 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 8f35a78e..36f8ab3d 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -109,6 +109,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index ea158793..4cb224fb 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -120,6 +120,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 27cbe669..2c0a898e 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index b0ada311..d98188f4 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -101,6 +101,8 @@ $i18n_key_words = array( 'error.xml' => 'Fout in XML bestand in regel line %d: %s.', 'error.cannot_import' => 'Kan het volgende niet importeren: %s.', 'error.format' => 'Bestandsformaat niet valide.', +// TODO: translate the following. +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index 34f4f6d3..650957ed 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index a9220c4e..11b6c4b4 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -114,6 +114,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index ee699e11..3e36200e 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -111,6 +111,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 8a96bc88..c3ef6c5c 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -113,6 +113,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 4f027f6b..01ecded5 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -120,6 +120,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 466f7cd1..f68e0631 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -100,6 +100,7 @@ $i18n_key_words = array( 'error.xml' => 'Ошибка в файле XML на строке %d: %s.', 'error.cannot_import' => 'Невозможно импортировать: %s.', 'error.format' => 'Неверный формат файла.', +'error.user_count' => 'Ограничение на количество пользователей.', // Warning messages. 'warn.sure' => 'Вы уверены?', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 0077e713..33622c99 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 9be563c4..6b3881a1 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 270984d4..3b12961d 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -111,6 +111,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 815ad80e..5ddd55d1 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -109,6 +109,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 720475be..fafeeaaf 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -123,6 +123,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index aa9e7dea..656eb451 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -111,6 +111,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 7346c9ad..0bdb2e05 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( // 'error.xml' => 'Error in XML file at line %d: %s.', // 'error.cannot_import' => 'Cannot import: %s.', // 'error.format' => 'Invalid file format.', +// 'error.user_count' => 'Limit on user count.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 57e94258..d163b71d 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.36.4686 | Copyright © Anuko | +  Anuko Time Tracker 1.18.36.4687 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/user_add.php b/mobile/user_add.php index b1d155aa..c821c7d4 100644 --- a/mobile/user_add.php +++ b/mobile/user_add.php @@ -149,6 +149,7 @@ if ($request->isPost()) { if (!ttValidEmail($cl_email, true)) $err->add($i18n->get('error.field'), $i18n->get('label.email')); if (!ttValidFloat($cl_rate, true)) $err->add($i18n->get('error.field'), $i18n->get('form.users.default_rate')); if (!ttValidFloat($cl_quota_percent, true)) $err->add($i18n->get('error.field'), $i18n->get('label.quota')); + if (!ttUserHelper::canAdd()) $err->add($i18n->get('error.user_count')); if ($err->no()) { if (!ttUserHelper::getUserByLogin($cl_login)) { diff --git a/user_add.php b/user_add.php index a9995191..cf233d5b 100644 --- a/user_add.php +++ b/user_add.php @@ -152,6 +152,7 @@ if ($request->isPost()) { if ($user->isPluginEnabled('cl') && ttRoleHelper::isClientRole($cl_role_id) && !$cl_client_id) $err->add($i18n->get('error.client')); if (!ttValidFloat($cl_rate, true)) $err->add($i18n->get('error.field'), $i18n->get('form.users.default_rate')); if (!ttValidFloat($cl_quota_percent, true)) $err->add($i18n->get('error.field'), $i18n->get('label.quota')); + if (!ttUserHelper::canAdd()) $err->add($i18n->get('error.user_count')); if ($err->no()) { if (!ttUserHelper::getUserByLogin($cl_login)) {