From 99041558bf625b082fc5058a93e1bd2634c2c9d2 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 19 Jul 2018 23:53:58 +0000 Subject: [PATCH] A bit more progress on Work units plugin, made its config page working. --- WEB-INF/lib/ttConfigHelper.class.php | 98 ++++++++++++++++++++++++++++ WEB-INF/resources/ca.lang.php | 5 ++ WEB-INF/resources/cs.lang.php | 5 ++ WEB-INF/resources/da.lang.php | 5 ++ WEB-INF/resources/de.lang.php | 5 ++ WEB-INF/resources/en.lang.php | 4 ++ WEB-INF/resources/es.lang.php | 5 ++ WEB-INF/resources/et.lang.php | 5 ++ WEB-INF/resources/fa.lang.php | 5 ++ WEB-INF/resources/fi.lang.php | 5 ++ WEB-INF/resources/fr.lang.php | 5 ++ WEB-INF/resources/gr.lang.php | 5 ++ WEB-INF/resources/he.lang.php | 5 ++ WEB-INF/resources/hu.lang.php | 5 ++ WEB-INF/resources/it.lang.php | 5 ++ WEB-INF/resources/ja.lang.php | 5 ++ WEB-INF/resources/ko.lang.php | 5 ++ WEB-INF/resources/nl.lang.php | 5 ++ WEB-INF/resources/no.lang.php | 5 ++ WEB-INF/resources/pl.lang.php | 5 ++ WEB-INF/resources/pt-br.lang.php | 5 ++ WEB-INF/resources/pt.lang.php | 5 ++ WEB-INF/resources/ro.lang.php | 5 ++ WEB-INF/resources/ru.lang.php | 4 ++ WEB-INF/resources/sk.lang.php | 5 ++ WEB-INF/resources/sl.lang.php | 5 ++ WEB-INF/resources/sr.lang.php | 5 ++ WEB-INF/resources/sv.lang.php | 5 ++ WEB-INF/resources/tr.lang.php | 5 ++ WEB-INF/resources/zh-cn.lang.php | 5 ++ WEB-INF/resources/zh-tw.lang.php | 5 ++ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/group_edit.tpl | 2 +- WEB-INF/templates/work_units.tpl | 18 +++++ group_edit.php | 2 + work_units.php | 76 +++++++++++++++++++++ 36 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 WEB-INF/lib/ttConfigHelper.class.php create mode 100644 WEB-INF/templates/work_units.tpl create mode 100644 work_units.php diff --git a/WEB-INF/lib/ttConfigHelper.class.php b/WEB-INF/lib/ttConfigHelper.class.php new file mode 100644 index 00000000..95cd1218 --- /dev/null +++ b/WEB-INF/lib/ttConfigHelper.class.php @@ -0,0 +1,98 @@ +config = $config; + $this->config_array = explode(',', $this->config); + } + + // getDefinedValue determines if a value identified by name is defined. + function getDefinedValue($name) { + return in_array($name, $this->$config_array); + } + + // The getIntValue parses an integer value from the source config string. + function getIntValue($name) { + $name_with_colon = $name.':'; + $len = strlen($name_with_colon); + + foreach ($this->config_array as $unparsed_value) { + if (substr($unparsed_value, 0, $len) === $name_with_colon) { + // Found value. + $unparsed_len = strlen($unparsed_value); + $int_value = (int) substr($unparsed_value, -($unparsed_len - $len)); + return $int_value; + } + + } + return false; + } + + // The setIntValue sets an integer value into config array. + function setIntValue($name, $value) { + // Try to find and replace an already existing value. + $name_with_colon = $name.':'; + $len = strlen($name_with_colon); + + foreach ($this->config_array as $key => $unparsed_value) { + if (substr($unparsed_value, 0, $len) === $name_with_colon) { + // Found an already existing value. + // Remove value if our new value is NULL. + if ($value !== null) { + // Replace value. + $this->config_array[$key] = $name.':'.$value; + } else { + // Remove value. + unset($this->config_array[$key]); + } + $this->config = implode(',', $this->config_array); + return; + } + } + // If we get here, the value was not found, so add it. + $this->config_array[] = $name.':'.$value; + $this->config = implode(',', $this->config_array); + return; + } + + // The getConfig returns the config string. + function getConfig() { + return $this->config; + } +} diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 74f299cc..6f499dd6 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -544,6 +544,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 7e30f0e5..21e16a6f 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -558,6 +558,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index c461cc37..3b6487ed 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -502,6 +502,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index 23b13c1c..cf112e99 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -500,6 +500,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 55c158e8..7e57b2fe 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -475,6 +475,10 @@ $i18n_key_words = array( 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +'form.work_units.minutes_in_unit' => 'Minutes in unit', +'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. 'role.user.label' => 'User', 'role.user.low_case_label' => 'user', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index a665fabd..d3ab0e8c 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -559,6 +559,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index e1aa2e38..8547caf7 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -554,6 +554,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 7d99e4d3..9b06bb13 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -530,6 +530,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index a7920c7f..cf4d0b83 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -510,6 +510,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 46eb3f33..010d6792 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -498,6 +498,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index ec6fdf8a..42b7986d 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -481,6 +481,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. 'role.user.label' => 'Χρήστης', 'role.user.low_case_label' => 'χρήστης', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 599826e3..646e12a2 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -536,6 +536,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index fb64b80c..74c3bd2f 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -547,6 +547,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 09fe6b72..ed335fe4 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -497,6 +497,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 6386d5f2..7902decf 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -550,6 +550,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 4bc1ec8d..4128eb67 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -548,6 +548,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index db0e1907..25b8148f 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -474,6 +474,11 @@ $i18n_key_words = array( 'form.swap.hint' => 'Degradeer jezelf naar een lagere rol door een rol te verruilen met iemand anders. Dit kan niet ongedaan worden gemaakt.', 'form.swap.swap_with' => 'Verruil rol met', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. 'role.user.label' => 'Gebruiker', 'role.user.low_case_label' => 'gebruiker', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index a2074315..3bd4cc24 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -547,6 +547,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 42c75f27..5a6150eb 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -512,6 +512,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index dff07897..c4f9f6a7 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -507,6 +507,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 9520d3eb..5e43040d 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -531,6 +531,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index a86a3640..002a38c9 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -553,6 +553,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 718f3246..804d9cd5 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -472,6 +472,10 @@ $i18n_key_words = array( 'form.swap.hint' => 'Уменьшите свою роль, обменявшись с другим пользователем. Роль не может восстановлена.', 'form.swap.swap_with' => 'Обменять роль с', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +'form.work_units.minutes_in_unit' => 'Минут в единице работы', +'form.work_units.1st_unit_threshold' => 'Порог для 1-й единицы', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. 'role.user.label' => 'Пользователь', 'role.user.low_case_label' => 'пользователь', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 7ed5339e..45d16c83 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -527,6 +527,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index ab858b90..8dc9a6d0 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -527,6 +527,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 4dc9e58e..648f26e2 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -511,6 +511,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index e47f8939..1e056716 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -505,6 +505,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 665b23e1..6449a7cd 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -566,6 +566,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index eb571ead..cbd7de32 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -534,6 +534,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 50a0960b..6a77cff5 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -542,6 +542,11 @@ $i18n_key_words = array( // 'form.swap.hint' => 'Demote yourself to a lower role by swapping roles with someone else. This cannot be undone.', // 'form.swap.swap_with' => 'Swap roles with', +// Work Units configuration form. See example at https://timetracker.anuko.com/work_units.php after enabling Work units plugin. +// TODO: translate the following. +// 'form.work_units.minutes_in_unit' => 'Minutes in unit', +// 'form.work_units.1st_unit_threshold' => '1st unit threshold', + // Roles and rights. These strings are used in multiple places. Grouped here to provide consistent translations. // TODO: translate the following. // 'role.user.label' => 'User', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9ed4365f..3f71f0ef 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - + {/if} {/if} diff --git a/WEB-INF/templates/work_units.tpl b/WEB-INF/templates/work_units.tpl new file mode 100644 index 00000000..9c2e64da --- /dev/null +++ b/WEB-INF/templates/work_units.tpl @@ -0,0 +1,18 @@ +{$forms.workUnitsForm.open} +
 Anuko Time Tracker 1.17.91.4274 | Copyright © Anuko | +  Anuko Time Tracker 1.17.91.4275 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/group_edit.tpl b/WEB-INF/templates/group_edit.tpl index a8f56a2d..dd059114 100644 --- a/WEB-INF/templates/group_edit.tpl +++ b/WEB-INF/templates/group_edit.tpl @@ -250,7 +250,7 @@ function handlePluginCheckboxes() { {if defined('WORK_UNITS_DEBUG')}
{$forms.groupForm.work_units.control} {$i18n.label.configure} {$i18n.label.configure}
+ + + + + + + + + + + + + + +
{$i18n.form.work_units.minutes_in_unit}:{$forms.workUnitsForm.minutes_in_unit.control} {$i18n.label.what_is_it}
{$i18n.form.work_units.1st_unit_threshold}:{$forms.workUnitsForm.1st_unit_threshold.control} {$i18n.label.what_is_it}
 
{$forms.workUnitsForm.btn_save.control}
+{$forms.weekViewForm.close} diff --git a/group_edit.php b/group_edit.php index 676a4d77..a5a85d1d 100644 --- a/group_edit.php +++ b/group_edit.php @@ -259,6 +259,8 @@ if ($request->isPost()) { $plugins .= ',mq'; if ($cl_week_view) $plugins .= ',wv'; + if ($cl_work_units) + $plugins .= ',wu'; // Recycle week view plugin options as they are not configured on this page. $existing_plugins = explode(',', $user->plugins); diff --git a/work_units.php b/work_units.php new file mode 100644 index 00000000..3340ec15 --- /dev/null +++ b/work_units.php @@ -0,0 +1,76 @@ +isPluginEnabled('wu')) { + header('Location: feature_disabled.php'); + exit(); +} + +$config = new ttConfigHelper($user->config); + +if ($request->isPost()) { + $cl_minutes_in_unit = $request->getParameter('minutes_in_unit'); + $cl_1st_unit_threshold = $request->getParameter('1st_unit_threshold'); +} else { + $cl_minutes_in_unit = $config->getIntValue('minutes_in_unit'); + $cl_1st_unit_threshold = $config->getIntValue('1st_unit_threshold'); +} + +$form = new Form('workUnitsForm'); +$form->addInput(array('type'=>'text', 'name'=>'minutes_in_unit', 'value'=>$cl_minutes_in_unit, 'style'=>'width:40px')); +$form->addInput(array('type'=>'text', 'name'=>'1st_unit_threshold', 'value'=>$cl_1st_unit_threshold, 'style'=>'width:40px')); +$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); + +if ($request->isPost()){ + // Validate user input. + if (!ttValidInteger($cl_minutes_in_unit)) $err->add($i18n->get('error.field'), $i18n->get('form.work_units.minutes_in_unit')); + if (!ttValidInteger($cl_1st_unit_threshold, true) ||($cl_minutes_in_unit && $cl_1st_unit_threshold > $cl_minutes_in_unit)) $err->add($i18n->get('error.field'), $i18n->get('form.work_units.1st_unit_threshold')); + // Finished validating user input. + + if ($err->no()) { + $config->setIntValue('minutes_in_unit', $cl_minutes_in_unit); + $config->setIntValue('1st_unit_threshold', $cl_1st_unit_threshold); + if (!$user->updateGroup(array('config' => $config->getConfig()))) { + $err->add($i18n->get('error.db')); + } + } +} + +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('title', $i18n->get('title.work_units')); +$smarty->assign('content_page_name', 'work_units.tpl'); +$smarty->display('index.tpl'); -- 2.20.1