From 99cfa872fb82c5939be1dc8d4bc2ab0bd5c220cd Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 13 Mar 2020 16:36:52 +0000 Subject: [PATCH 001/695] Fixed timesheet approval workflow. --- WEB-INF/templates/footer.tpl | 2 +- timesheet_view.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index b00f04392..e2fee92b3 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.14.5180 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5181 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/timesheet_view.php b/timesheet_view.php index c8d7048a4..a1ee74d26 100644 --- a/timesheet_view.php +++ b/timesheet_view.php @@ -65,7 +65,7 @@ $showApprovers = count($approvers) >= 1; } $canApprove = $user->can('approve_timesheets') || $user->can('approve_own_timesheets'); -$showApprove = $timesheet['submit_status'] && $timesheet['approve_status'] == null; +$showApprove = $timesheet['submit_status'] && $timesheet['approve_status'] == null && $canApprove; // Add a form with controls. $form = new Form('timesheetForm'); From 789503c8ec404352b316cf4302e29f9d729d67e4 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 17 Mar 2020 18:05:54 +0000 Subject: [PATCH 002/695] Removed a PHP warning condition. --- WEB-INF/templates/footer.tpl | 2 +- reports.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e2fee92b3..1da155dcb 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5181 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5182 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/reports.php b/reports.php index 84d8bde08..253652b94 100644 --- a/reports.php +++ b/reports.php @@ -391,7 +391,7 @@ if ($request->isGet() && !$bean->isSaved()) { // No previous form data were found in session. Use the following default values. - $form->setValueByElement('users_active', array_keys($user_list_active)); + $form->setValueByElement('users_active', array_keys((array)$user_list_active)); $period = new Period(INTERVAL_THIS_MONTH, new DateAndTime($user->getDateFormat())); $form->setValueByElement('start_date', $period->getStartDate()); $form->setValueByElement('end_date', $period->getEndDate()); From 8762873a1eb28de2d927fad1a5906a6541b2a3c0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 17 Mar 2020 18:31:48 +0000 Subject: [PATCH 003/695] Got rid of another PHP warning. --- WEB-INF/lib/ttUser.class.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 89a1973fb..1bdb1c19f 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -571,7 +571,7 @@ function addGroupToDropdown(&$groups, $group_id, $subgroup_level) { $groups[] = array('id'=>$group_id, 'name'=>$name); - $subgroups = $this->getSubgroups($group_id); + $subgroups = (array) $this->getSubgroups($group_id); foreach($subgroups as $subgroup) { $this->addGroupToDropdown($groups, $subgroup['id'], $subgroup_level+1); } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1da155dcb..6a17b0185 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5182 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5183 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From a5e16a489f2021c9d709f59b34fa2ab611540d2f Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 17 Mar 2020 18:37:16 +0000 Subject: [PATCH 004/695] Got rid of another PHP warning. --- WEB-INF/lib/ttGroupHelper.class.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 48e4de724..83ffe648c 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -157,7 +157,7 @@ static function markGroupDeleted($group_id) { // Keep the logic simple by returning false on first error. // Obtain subgroups and call self recursively on them. - $subgroups = $user->getSubgroups($group_id); + $subgroups = (array) $user->getSubgroups($group_id); foreach($subgroups as $subgroup) { if (!ttGroupHelper::markGroupDeleted($subgroup['id'])) return false; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6a17b0185..f682fe618 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5183 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5184 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From 402edebfaefcf41f70e3c9e9b8223a32e5575416 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 17 Mar 2020 23:49:40 +0000 Subject: [PATCH 005/695] Eliminated one more PHP warning. --- WEB-INF/templates/footer.tpl | 2 +- charts.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f682fe618..e49e3ff34 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5184 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5185 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/charts.php b/charts.php index 862a2fad6..4ca91a151 100644 --- a/charts.php +++ b/charts.php @@ -205,7 +205,7 @@ $file_name = $img_dir.$file_name; // Full file name. // Clean up the file system from older images. -$img_files = glob($img_dir.'chart_*.png'); +$img_files = (array) glob($img_dir.'chart_*.png'); foreach($img_files as $file) { // If the create time of file is older than 1 minute, delete it. if (filemtime($file) < (time() - 60)) { From 5a1c585bdc0633e871a1c2af81df22dfb28f314e Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 18 Mar 2020 01:36:13 +0000 Subject: [PATCH 006/695] Got rid of one more PHP warning. --- WEB-INF/templates/footer.tpl | 2 +- charts.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e49e3ff34..94fc6e34f 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5185 | Copyright © Anuko | +  Anuko Time Tracker 1.19.15.5186 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/charts.php b/charts.php index 4ca91a151..942b5ce7b 100644 --- a/charts.php +++ b/charts.php @@ -205,11 +205,13 @@ $file_name = $img_dir.$file_name; // Full file name. // Clean up the file system from older images. -$img_files = (array) glob($img_dir.'chart_*.png'); -foreach($img_files as $file) { - // If the create time of file is older than 1 minute, delete it. - if (filemtime($file) < (time() - 60)) { - unlink($file); +$img_files = glob($img_dir.'chart_*.png'); +if (is_array($img_files)) { + foreach($img_files as $file) { + // If file creation time is older than 1 minute, delete it. + if (filemtime($file) < (time() - 60)) { + unlink($file); + } } } From 93e14dc4da46515c90b86d0330f1d3588f3c4ac0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 13 May 2020 18:10:26 +0000 Subject: [PATCH 007/695] Fixed ttValidDate function to handle DD-MM-YYYY date format. --- WEB-INF/lib/common.lib.php | 3 ++- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index b19feacdc..1f2829442 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -245,9 +245,10 @@ function ttValidDate($val) if (strlen($val) == 0) return false; - // This should accept a string in format 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD.MM.YYYY', or 'DD.MM.YYYY whatever'. + // This should accept a string in format 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD-MM-YYYY', 'DD.MM.YYYY', or 'DD.MM.YYYY whatever'. if (!preg_match('/^\d\d\d\d-\d\d-\d\d$/', $val) && !preg_match('/^\d\d\/\d\d\/\d\d\d\d$/', $val) && + !preg_match('/^\d\d\-\d\d\-\d\d\d\d$/', $val) && !preg_match('/^\d\d\.\d\d\.\d\d\d\d$/', $val) && !preg_match('/^\d\d\.\d\d\.\d\d\d\d .+$/', $val)) return false; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 94fc6e34f..9af4352eb 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.15.5186 | Copyright © Anuko | +  Anuko Time Tracker 1.19.16.5187 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From 355dfcff28334a24ab0d6f02535072a152ccf592 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 2 Jun 2020 17:51:50 +0000 Subject: [PATCH 008/695] Improved bot protection slightly. --- WEB-INF/lib/ttRegistrator.class.php | 10 +++++----- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index e054fe001..936bb4ffd 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -217,7 +217,7 @@ private function setCreatedBy($user_id) { // registeredRecently determines if we already have successful recent registration(s) from user IP. // "recent" means the following: - // - 2 or more registrations during last 10 minutes, or + // - 2 or more registrations during last 15 minutes, or // - 1 registration during last minute. // // This offers some level of protection from bot registrations. @@ -225,17 +225,17 @@ function registeredRecently() { $mdb2 = getConnection(); $ip_part = ' created_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']); - $sql = 'select count(*) as cnt from tt_groups where '.$ip_part.' and created > now() - interval 10 minute'; + $sql = 'select count(*) as cnt from tt_groups where '.$ip_part.' and created > now() - interval 15 minute'; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; $val = $res->fetchRow(); if ($val['cnt'] == 0) - return false; // No registrations in last 10 minutes. + return false; // No registrations in last 15 minutes. if ($val['cnt'] >= 2) - return true; // 2 or more registrations in last 10 mintes. + return true; // 2 or more registrations in last 15 mintes. - // If we are here, there was exactly one registration during last 10 minutes. + // If we are here, there was exactly one registration during last 15 minutes. // Determine if it occurred within the last minute in a separate query. $sql = 'select created from tt_groups where '.$ip_part.' and created > now() - interval 1 minute'; $res = $mdb2->query($sql); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9af4352eb..72e375036 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.16.5187 | Copyright © Anuko | +  Anuko Time Tracker 1.19.16.5188 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From 3540c71810375d32fbddfdcd40ba90f87d423bec Mon Sep 17 00:00:00 2001 From: Juergen Neumann Date: Thu, 11 Jun 2020 22:23:51 +0200 Subject: [PATCH 009/695] patched openldap to work with member_of groups (#90) Co-authored-by: Juergen Neumann --- WEB-INF/lib/auth/Auth_ldap.class.php | 45 +++++++++++++++++----------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index 5fb3dcf3d..b2138e67c 100644 --- a/WEB-INF/lib/auth/Auth_ldap.class.php +++ b/WEB-INF/lib/auth/Auth_ldap.class.php @@ -199,12 +199,6 @@ function authenticate($login, $password) echo '$login_oldap='; var_dump($login_oldap); echo '
'; } - // check if the user specified full login - if (strpos($login, '@') === false) { - // append default domain - $login .= '@' . $this->params['default_domain']; - } - $lb = @ldap_bind($lc, $login_oldap, $password); if (isTrue('DEBUG')) { @@ -221,11 +215,18 @@ function authenticate($login, $password) // TODO: Fix this for OpenLDAP, as samaccountname has nothing to do with it. // get groups - $filter = 'samaccountname='.Auth_ldap::ldap_escape($login_oldap); - $fields = array('samaccountname', 'mail', 'memberof', 'department', 'displayname', 'telephonenumber', 'primarygroupid'); + if (isTrue('DEBUG')) { + echo '$member_of : '; var_dump($member_of); echo '
'; + } + + $filter = 'uid='.$login; // ldap search filter + $fields = array('memberof'); // ldap search attributes + // $fields = 'uid'; $sr = @ldap_search($lc, $this->params['base_dn'], $filter, $fields); if (isTrue('DEBUG')) { + echo '$filter='; var_dump($filter); echo '
'; + echo '$fields='; var_dump($fields); echo '
'; echo '$sr='; var_dump($sr); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -248,24 +249,28 @@ function authenticate($login, $password) return false; } - $groups = array(); + $groups = array(); // existing ldap group memberships - // extract group names from - // assuming the groups are in format: CN=,... for ($i = 0; $i < @$entries[0]['memberof']['count']; $i++) { - $grp = $entries[0]['memberof'][$i]; - $grp_fields = explode(',', $grp); - $groups[] = substr($grp_fields[0], 3); - } + $grp = $entries[0]['memberof'][$i]; + $groups[] = $grp; // append group to array + if (isTrue('DEBUG')) { + var_dump($grp); echo ' appended to $groups
'; + }; - if (isTrue('DEBUG')) { - echo '$member_of'; var_dump($member_of); echo '
'; } + // check for group membership foreach ($member_of as $check_grp) { + if (isTrue('DEBUG')) { + echo '$check_grp:'; var_dump($check_grp); echo '
'; + }; if (!in_array($check_grp, $groups)) { ldap_unbind($lc); + if (isTrue('DEBUG')) { + echo '=> '.$login.' is not a member of '.$check_grp.'
'; + }; return false; } } @@ -273,6 +278,12 @@ function authenticate($login, $password) ldap_unbind($lc); + // check if the user specified full login + if (strpos($login, '@') === false) { + // append default domain + $login .= '@' . $this->params['default_domain']; + } + return array('login' => $login, 'data' => $entries, 'member_of' => $groups); } From cf6afd523f46b24e4b08fd50ec2e6c3fc849bcf0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 11 Jun 2020 20:38:13 +0000 Subject: [PATCH 010/695] Cleaned up some comments and styles, hopefully without breaking stuff. --- WEB-INF/lib/auth/Auth_ldap.class.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index b2138e67c..59a539389 100644 --- a/WEB-INF/lib/auth/Auth_ldap.class.php +++ b/WEB-INF/lib/auth/Auth_ldap.class.php @@ -38,10 +38,6 @@ // In April 2012, a previously mandatory search for group membership was put in a conditional block (if ($member_of) - // when mandatory membership in groups is actually defined in config.php). // This made the module work with Sun Directory Server when NO GROUP MEMBERSHIP is specified. -// Note 1: search is likely to fail with Sun DS if 'member_of' => array()); is used in config.php. -// Note 2: search is likely to not work properly with OpenLDAP as well because of Windows specific filtering code in there -// (we are looking for matches for Windows-specific samaccountname property). Search needs to be redone during the next -// refactoring effort. /** @@ -212,8 +208,6 @@ function authenticate($login, $password) } if ($member_of) { - // TODO: Fix this for OpenLDAP, as samaccountname has nothing to do with it. - // get groups if (isTrue('DEBUG')) { echo '$member_of : '; var_dump($member_of); echo '
'; @@ -221,7 +215,6 @@ function authenticate($login, $password) $filter = 'uid='.$login; // ldap search filter $fields = array('memberof'); // ldap search attributes - // $fields = 'uid'; $sr = @ldap_search($lc, $this->params['base_dn'], $filter, $fields); if (isTrue('DEBUG')) { @@ -256,21 +249,19 @@ function authenticate($login, $password) $groups[] = $grp; // append group to array if (isTrue('DEBUG')) { var_dump($grp); echo ' appended to $groups
'; - }; - + } } - // check for group membership foreach ($member_of as $check_grp) { if (isTrue('DEBUG')) { echo '$check_grp:'; var_dump($check_grp); echo '
'; - }; + } if (!in_array($check_grp, $groups)) { ldap_unbind($lc); if (isTrue('DEBUG')) { - echo '=> '.$login.' is not a member of '.$check_grp.'
'; - }; + echo '=> '.$login.' is not a member of '.$check_grp.'
'; + } return false; } } From a1cd3a3e2d443a0aaca4109d64cbb2665bfb386d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 13 Jun 2020 14:32:16 +0000 Subject: [PATCH 011/695] Included an improvement as per issue #89. --- WEB-INF/templates/footer.tpl | 2 +- initialize.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 72e375036..36c85f355 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.16.5188 | Copyright © Anuko | +  Anuko Time Tracker 1.19.16.5189 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/initialize.php b/initialize.php index 241d72334..404872936 100644 --- a/initialize.php +++ b/initialize.php @@ -85,8 +85,8 @@ // Set lifetime for garbage collection. ini_set('session.gc_maxlifetime', $phpsessid_ttl); // Set PHP session path, if defined to avoid garbage collection interference from other scripts. -if (defined('PHP_SESSION_PATH')) { - ini_set('session.save_path', PHP_SESSION_PATH); +if (defined('PHP_SESSION_PATH') && realpath(PHP_SESSION_PATH)) { + ini_set('session.save_path', realpath(PHP_SESSION_PATH)); ini_set('session.gc_probability', 1); } From 908e119d978dcfd26b126036ce4514c39a00c8a4 Mon Sep 17 00:00:00 2001 From: BTR Naidu Date: Tue, 16 Jun 2020 16:25:28 +0200 Subject: [PATCH 012/695] File permission error while loading the landing page (#92) --- dockerfile-tt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dockerfile-tt b/dockerfile-tt index 8902cbf7e..2b102f1ff 100644 --- a/dockerfile-tt +++ b/dockerfile-tt @@ -34,3 +34,5 @@ RUN cp /var/www/html/WEB-INF/config.php.dist /var/www/html/WEB-INF/config.php RUN sed -i "s|mysqli://root:no@localhost/dbname|mysqli://anuko_user:anuko_pw@anuko_db/timetracker|g" /var/www/html/WEB-INF/config.php # Note that db is defined as anuko_db/timetracker where anuko_db is service name and timetracker is db name. # See docker-compose.yml for details. + +RUN chown -R www-data /var/www/html/ From 88a5ef90c0a639efa0b9b140325beb3dd9f6a01f Mon Sep 17 00:00:00 2001 From: Juergen Neumann Date: Tue, 16 Jun 2020 16:59:16 +0200 Subject: [PATCH 013/695] Applying .Auth_ldap::ldap_escape($login) to openldap. (#93) * Applying .Auth_ldap::ldap_escape($login) to openldap. * added $user_login_attribute to config for openldap authentication Co-authored-by: Juergen Neumann --- WEB-INF/config.php.dist | 3 ++- WEB-INF/lib/auth/Auth_ldap.class.php | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index 6ffdff08e..a288ec0bf 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -150,7 +150,8 @@ define('AUTH_MODULE', 'db'); // 'server' => '127.0.0.1', // OpenLDAP server address or name. For secure LDAP use ldaps://hostname:port here. // 'type' => 'openldap', // Type of server. openldap type should also work with Sun Directory Server when member_of is empty. // It may work with other (non Windows AD) LDAP servers. For Windows AD use the 'ad' type. -// 'base_dn' => 'ou=People,dc=example,dc=com', // Base distinguished name in LDAP catalog. +// 'base_dn' => 'ou=People,dc=example,dc=com', // Path of user's base distinguished name in LDAP catalog. +// 'user_login_attribute' => 'uid', // LDAP attribute used for login // 'default_domain' => 'example.com', // Default domain. // 'member_of' => array()); // List of groups, membership in which is required for user to be authenticated. diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index 59a539389..3c43fd3a3 100644 --- a/WEB-INF/lib/auth/Auth_ldap.class.php +++ b/WEB-INF/lib/auth/Auth_ldap.class.php @@ -189,7 +189,15 @@ function authenticate($login, $password) if ($this->params['type'] == 'openldap') { // Assuming OpenLDAP server. - $login_oldap = 'uid='.$login.','.$this->params['base_dn']; + + if (empty($this->params['user_login_attribute'])) { + $user_login_attribute = 'uid'; + } else { + $user_login_attribute = @$this->params['user_login_attribute']; + + } + + $login_oldap = $user_login_attribute.'='.Auth_ldap::ldap_escape($login).','.$this->params['base_dn']; if (isTrue('DEBUG')) { echo '$login_oldap='; var_dump($login_oldap); echo '
'; @@ -213,8 +221,8 @@ function authenticate($login, $password) echo '$member_of : '; var_dump($member_of); echo '
'; } - $filter = 'uid='.$login; // ldap search filter - $fields = array('memberof'); // ldap search attributes + $filter = $user_login_attribute.'='.Auth_ldap::ldap_escape($login); // ldap search filter + $fields = array('memberof'); // ldap search attributes $sr = @ldap_search($lc, $this->params['base_dn'], $filter, $fields); if (isTrue('DEBUG')) { From fe25e6cf65c4cfda4ec5726a71c48ce7e7b36dde Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 16 Jun 2020 15:11:34 +0000 Subject: [PATCH 014/695] Some cleanup after pr #93 merge. --- WEB-INF/lib/auth/Auth_ldap.class.php | 3 +-- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index 3c43fd3a3..7f3495737 100644 --- a/WEB-INF/lib/auth/Auth_ldap.class.php +++ b/WEB-INF/lib/auth/Auth_ldap.class.php @@ -193,8 +193,7 @@ function authenticate($login, $password) if (empty($this->params['user_login_attribute'])) { $user_login_attribute = 'uid'; } else { - $user_login_attribute = @$this->params['user_login_attribute']; - + $user_login_attribute = $this->params['user_login_attribute']; } $login_oldap = $user_login_attribute.'='.Auth_ldap::ldap_escape($login).','.$this->params['base_dn']; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 36c85f355..fc42d9df4 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.16.5189 | Copyright © Anuko | +  Anuko Time Tracker 1.19.16.5190 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From 74c23e14f9c755aef8139a0e7f01ac9c67500532 Mon Sep 17 00:00:00 2001 From: BTR Naidu Date: Sat, 20 Jun 2020 17:24:22 +0200 Subject: [PATCH 015/695] missing freetype library causes chart from loading (#95) --- dockerfile-tt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dockerfile-tt b/dockerfile-tt index 2b102f1ff..9c79f4786 100644 --- a/dockerfile-tt +++ b/dockerfile-tt @@ -11,8 +11,9 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" RUN docker-php-ext-install mysqli # Install gd extension. -RUN apt-get update && apt-get install libpng-dev -y \ - && docker-php-ext-install gd +RUN apt-get update && apt-get install libpng-dev libfreetype6-dev -y \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \ + && docker-php-ext-install gd # Install ldap extension. RUN apt-get install libldap2-dev -y \ From b525c77813327c06b2d005e00b81dbfa8231e740 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 29 Jun 2020 20:55:36 +0000 Subject: [PATCH 016/695] Started to work on binding templates to projects. --- WEB-INF/templates/footer.tpl | 2 +- dbinstall.php | 14 ++++++++++---- mysql.sql | 18 +++++++++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index fc42d9df4..05c0feed6 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - - + +
 Anuko Time Tracker 1.19.16.5190 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5191 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index ea476d403..f596a05e6 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -1161,7 +1161,7 @@ function ttGenerateKeys() { ttExecute("UPDATE `tt_site_config` SET param_value = '1.19.0', modified = now() where param_name = 'version_db' and param_value = '1.18.61'"); } - if ($_POST["convert11900to11914"]) { + if ($_POST["convert11900to11917"]) { ttExecute("CREATE TABLE `tt_work_currencies` (`id` int(10) unsigned NOT NULL,`name` varchar(10) NOT NULL,PRIMARY KEY (`id`))"); ttExecute("create unique index currency_idx on tt_work_currencies(`name`)"); ttExecute("INSERT INTO `tt_work_currencies` (`id`, `name`) VALUES ('1', 'USD'), ('2', 'CAD'), ('3', 'AUD'), ('4', 'EUR'), ('5', 'NZD')"); @@ -1183,6 +1183,11 @@ function ttGenerateKeys() { ttExecute("ALTER TABLE `tt_fav_reports` drop `cf_1_option_id`"); ttExecute("ALTER TABLE `tt_fav_reports` drop `show_custom_field_1`"); ttExecute("UPDATE `tt_site_config` SET param_value = '1.19.14', modified = now() where param_name = 'version_db' and param_value = '1.19.7'"); + ttExecute("CREATE TABLE `tt_project_template_binds` (`project_id` int(10) unsigned NOT NULL,`template_id` int(10) unsigned NOT NULL,`group_id` int(10) unsigned NOT NULL,`org_id` int(10) unsigned NOT NULL)"); + ttExecute("create index project_idx on tt_project_template_binds(project_id);"); + ttExecute("create index template_idx on tt_project_template_binds(template_id)"); + ttExecute("create unique index project_template_idx on tt_project_template_binds(project_id, template_id)"); + ttExecute("UPDATE `tt_site_config` SET param_value = '1.19.17', modified = now() where param_name = 'version_db' and param_value = '1.19.14'"); } if ($_POST["cleanup"]) { @@ -1210,6 +1215,7 @@ function ttGenerateKeys() { ttExecute("OPTIMIZE TABLE tt_log"); ttExecute("OPTIMIZE TABLE tt_monthly_quotas"); ttExecute("OPTIMIZE TABLE tt_templates"); + ttExecute("OPTIMIZE TABLE tt_project_template_binds"); ttExecute("OPTIMIZE TABLE tt_predefined_expenses"); ttExecute("OPTIMIZE TABLE tt_project_task_binds"); ttExecute("OPTIMIZE TABLE tt_projects"); @@ -1232,7 +1238,7 @@ function ttGenerateKeys() {

DB Install

-
Create database structure (v1.19.14) + Create database structure (v1.19.17)
(applies only to new installations, do not execute when updating)
@@ -1281,8 +1287,8 @@ function ttGenerateKeys() {
Update database structure (v1.19 to v1.19.14)Update database structure (v1.19 to v1.19.17)
diff --git a/mysql.sql b/mysql.sql index 3e9df4a1b..ae31890b5 100644 --- a/mysql.sql +++ b/mysql.sql @@ -565,6 +565,22 @@ CREATE TABLE `tt_templates` ( ); +# +# Structure for table tt_project_template_binds. This table maps projects to templates. +# +CREATE TABLE `tt_project_template_binds` ( + `project_id` int(10) unsigned NOT NULL, # project id + `template_id` int(10) unsigned NOT NULL, # template id + `group_id` int(10) unsigned NOT NULL, # group id + `org_id` int(10) unsigned NOT NULL # organization id +); + +# Indexes for tt_project_template_binds. +create index project_idx on tt_project_template_binds(project_id); +create index template_idx on tt_project_template_binds(template_id); +create unique index project_template_idx on tt_project_template_binds(project_id, template_id); + + # # Structure for table tt_files. # This table keeps file attachment information. @@ -639,4 +655,4 @@ CREATE TABLE `tt_site_config` ( PRIMARY KEY (`param_name`) ); -INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.19.14', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.19.17', now()); # TODO: change when structure changes. From 625b4e3d69fe52e2b5affd9ed2d6ae616020053d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 30 Jun 2020 14:30:38 +0000 Subject: [PATCH 017/695] Work in progress on associating templates with projects. --- WEB-INF/lib/ttOrgHelper.class.php | 1 + WEB-INF/lib/ttTemplateHelper.class.php | 23 +++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- template_edit.php | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/WEB-INF/lib/ttOrgHelper.class.php b/WEB-INF/lib/ttOrgHelper.class.php index 60126420a..ffb39beb4 100644 --- a/WEB-INF/lib/ttOrgHelper.class.php +++ b/WEB-INF/lib/ttOrgHelper.class.php @@ -98,6 +98,7 @@ static function deleteOrg($org_id) { 'tt_config', 'tt_cron', 'tt_fav_reports', + 'tt_project_template_binds', 'tt_templates', 'tt_monthly_quotas', 'tt_predefined_expenses', diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index e3a935646..e963877cc 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -118,4 +118,27 @@ static function update($fields) { $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } + + // getAssignedProjects - returns an array of projects associatied with a template. + static function getAssignedProjects($template_id) + { + global $user; + + $result = array(); + $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + // Do a query with inner join to get assigned projects. + $sql = "select p.id, p.name from tt_projects p + inner join tt_project_template_binds ptb on (ptb.project_id = p.id and ptb.template_id = $template_id) + where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by p.name"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 05c0feed6..cbfce2f69 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.17.5191 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5192 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/template_edit.php b/template_edit.php index 90e5f5655..568d9dbbb 100644 --- a/template_edit.php +++ b/template_edit.php @@ -47,16 +47,22 @@ } // End of access checks. +$projects = ttGroupHelper::getActiveProjects(); + if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); $cl_description = trim($request->getParameter('description')); $cl_content = trim($request->getParameter('content')); $cl_status = $request->getParameter('status'); + $cl_projects = $request->getParameter('projects'); } else { $cl_name = $template['name']; $cl_description = $template['description']; $cl_content = $template['content']; $cl_status = $template['status']; + $assigned_projects = ttTemplateHelper::getAssignedProjects($cl_template_id); + foreach ($assigned_projects as $project_item) + $cl_projects[] = $project_item['id']; } $form = new Form('templateForm'); From dcfe5eb3b0e95d80cd4854d5244c16a8ef9e0ddb Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 30 Jun 2020 15:37:59 +0000 Subject: [PATCH 018/695] Added project selector on template_edit.php. --- WEB-INF/lib/ttTemplateHelper.class.php | 20 +++++++++++++++++++- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/task_add.tpl | 2 +- WEB-INF/templates/task_edit.tpl | 2 +- WEB-INF/templates/template_edit.tpl | 7 +++++++ template_edit.php | 5 ++++- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index e963877cc..33839d58e 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -109,6 +109,7 @@ static function update($fields) { $content = $fields['content']; $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$user->id; $status = (int) $fields['status']; + $projects = $fields['projects']; $sql = "update tt_templates set name = ".$mdb2->quote($name). ", description = ".$mdb2->quote($description). @@ -116,7 +117,24 @@ static function update($fields) { ", status = ".$status. " where id = $template_id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); - return (!is_a($affected, 'PEAR_Error')); + if (is_a($affected, 'PEAR_Error')) + die($affected->getMessage()); + + // Insert project binds into tt_project_template_binds table. + $sql = "delete from tt_project_template_binds where template_id = $template_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + die($affected->getMessage()); + if (count($projects) > 0) + foreach ($projects as $p_id) { + $sql = "insert into tt_project_template_binds (project_id, template_id, group_id, org_id)". + " values($p_id, $template_id, $group_id, $org_id)"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + die($affected->getMessage()); + } + + return true; } // getAssignedProjects - returns an array of projects associatied with a template. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index cbfce2f69..903c257ac 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {if $show_projects} - + diff --git a/WEB-INF/templates/task_edit.tpl b/WEB-INF/templates/task_edit.tpl index 0bf189bba..0c2b1a555 100644 --- a/WEB-INF/templates/task_edit.tpl +++ b/WEB-INF/templates/task_edit.tpl @@ -17,7 +17,7 @@ {if $show_projects} - + diff --git a/WEB-INF/templates/template_edit.tpl b/WEB-INF/templates/template_edit.tpl index 6f3e406f8..f4db77878 100644 --- a/WEB-INF/templates/template_edit.tpl +++ b/WEB-INF/templates/template_edit.tpl @@ -19,6 +19,13 @@ +{if $show_projects} + + + + + +{/if} diff --git a/template_edit.php b/template_edit.php index 568d9dbbb..1bff1a3bf 100644 --- a/template_edit.php +++ b/template_edit.php @@ -72,6 +72,7 @@ $form->addInput(array('type'=>'textarea','name'=>'content','style'=>'width: 250px; height: 80px;','value'=>$cl_content)); $form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status, 'data'=>array(ACTIVE=>$i18n->get('dropdown.status_active'),INACTIVE=>$i18n->get('dropdown.status_inactive')))); +$form->addInput(array('type'=>'checkboxgroup','name'=>'projects','layout'=>'H','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_projects)); $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.submit'))); if ($request->isPost()) { @@ -87,7 +88,8 @@ 'name' => $cl_name, 'description' => $cl_description, 'content' => $cl_content, - 'status' => $cl_status))) { + 'status' => $cl_status, + 'projects' => $cl_projects))) { header('Location: templates.php'); exit(); } else @@ -96,6 +98,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('show_projects', count($projects) > 0 && defined('TEMPLATES_DEBUG')); $smarty->assign('title', $i18n->get('title.edit_template')); $smarty->assign('content_page_name', 'template_edit.tpl'); $smarty->display('index.tpl'); From 6942f78f7bfe309b368e8243f715d4381e6ccd9d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 30 Jun 2020 16:13:15 +0000 Subject: [PATCH 019/695] Added project selector on template_add.php. --- WEB-INF/lib/ttTemplateHelper.class.php | 16 +++++++++++++++- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/template_add.tpl | 7 +++++++ WEB-INF/templates/templates.tpl | 2 +- template_add.php | 11 ++++++++++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index 33839d58e..6aec08c73 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -81,6 +81,7 @@ static function insert($fields) { $name = $fields['name']; $description = $fields['description']; $content = $fields['content']; + $projects = $fields['projects']; $created_part = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$user->id; @@ -89,10 +90,23 @@ static function insert($fields) { " values ($group_id, $org_id, ".$mdb2->quote($name). ", ".$mdb2->quote($description).", ".$mdb2->quote($content).$created_part.")"; $affected = $mdb2->exec($sql); + $last_id = 0; if (is_a($affected, 'PEAR_Error')) return false; - return true; + $last_id = $mdb2->lastInsertID('tt_templates', 'id'); + + if (is_array($projects)) { + foreach ($projects as $p_id) { + // Insert project binds into tt_project_template_binds table. + $sql = "insert into tt_project_template_binds (project_id, template_id, group_id, org_id)". + " values($p_id, $last_id, $group_id, $org_id)"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + } + } + return $last_id; } // update function - updates a template in database. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 903c257ac..a232aa149 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.17.5192 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5193 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/task_add.tpl b/WEB-INF/templates/task_add.tpl index 8e7f7882f..d1892709a 100644 --- a/WEB-INF/templates/task_add.tpl +++ b/WEB-INF/templates/task_add.tpl @@ -13,7 +13,7 @@
 
{$i18n.label.projects}: {$forms.taskForm.projects.control}
 
{$i18n.label.projects}: {$forms.taskForm.projects.control}
{$i18n.label.status}: {$forms.templateForm.status.control}
 
{$i18n.label.projects}:{$forms.templateForm.projects.control}
{$i18n.label.required_fields}
- +{if $show_projects} + + + + + +{/if} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index 2e388b491..c0a74422d 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -26,7 +26,7 @@
 Anuko Time Tracker 1.19.17.5193 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5194 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/template_add.tpl b/WEB-INF/templates/template_add.tpl index 2a52cec32..bfd624028 100644 --- a/WEB-INF/templates/template_add.tpl +++ b/WEB-INF/templates/template_add.tpl @@ -15,6 +15,13 @@ {$i18n.label.template} (*): {$forms.templateForm.content.control}
 
{$i18n.label.projects}:{$forms.templateForm.projects.control}
{$i18n.label.required_fields}
{if $inactive_templates} - + diff --git a/template_add.php b/template_add.php index 6fb0238e4..e7e828444 100644 --- a/template_add.php +++ b/template_add.php @@ -41,16 +41,23 @@ } // End of access checks. +$projects = ttGroupHelper::getActiveProjects(); + if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); $cl_description = trim($request->getParameter('description')); $cl_content = trim($request->getParameter('content')); + $cl_projects = $request->getParameter('projects'); +} else { + foreach ($projects as $project_item) + $cl_projects[] = $project_item['id']; } $form = new Form('templateForm'); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','style'=>'width: 250px;','value'=>$cl_name)); $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); $form->addInput(array('type'=>'textarea','name'=>'content','style'=>'width: 250px; height: 80px;','value'=>$cl_content)); +$form->addInput(array('type'=>'checkboxgroup','name'=>'projects','layout'=>'H','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_projects)); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); if ($request->isPost()) { @@ -64,7 +71,8 @@ if (ttTemplateHelper::insert(array( 'name' => $cl_name, 'description' => $cl_description, - 'content' => $cl_content))) { + 'content' => $cl_content, + 'projects' => $cl_projects))) { header('Location: templates.php'); exit(); } else @@ -73,6 +81,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('show_projects', count($projects) > 0 && defined('TEMPLATES_DEBUG')); $smarty->assign('title', $i18n->get('title.add_template')); $smarty->assign('content_page_name', 'template_add.tpl'); $smarty->display('index.tpl'); From 9fbacfa36e86370d8c71ef7a282c769e4d7d6710 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 30 Jun 2020 21:42:05 +0000 Subject: [PATCH 020/695] More progress towards associating templates with projects. --- WEB-INF/lib/ttProjectHelper.class.php | 6 ++++++ WEB-INF/lib/ttTemplateHelper.class.php | 28 ++++++++++++++++++++++++++ WEB-INF/lib/ttUser.class.php | 11 ++++++++-- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time.tpl | 4 ++-- WEB-INF/templates/time_script.tpl | 1 + projects.php | 6 ++++-- time.php | 20 +++++++++++------- 8 files changed, 64 insertions(+), 14 deletions(-) diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index 399cba2d2..d456c3110 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -204,6 +204,12 @@ static function delete($id) { if (is_a($affected, 'PEAR_Error')) return false; + // Delete template binds to this project. + $sql = "delete from tt_project_template_binds where project_id = $id and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + // Finally, delete the project from the projects field in tt_clients table. $result = ttClientHelper::deleteProject($id); return $result; diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index 6aec08c73..cedda1671 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -67,6 +67,12 @@ static function delete($id) { if (is_a($affected, 'PEAR_Error')) return false; + // Delete project binds to this template. + $sql = "delete from tt_project_template_binds where template_id = $id and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + return true; } @@ -173,4 +179,26 @@ static function getAssignedProjects($template_id) } return $result; } + + // getAssignedTemplates - returns a comma-separated list of template ids assigned to a project. + static function getAssignedTemplates($project_id) + { + global $user; + + $result = array(); + $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select template_id from tt_project_template_binds + where project_id = $project_id and group_id = $group_id and org_id = $org_id" ; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val['template_id']; + } + } + $comma_separated = implode(',', $result); // This is a comma-separated list of associated template ids. + return $comma_separated; + } } diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 1bdb1c19f..42f9b0d90 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -32,6 +32,7 @@ import('ttGroup'); import('form.Form'); import('form.ActionForm'); +import('ttTemplateHelper'); class ttUser { var $login = null; // User login. @@ -333,7 +334,7 @@ function setOption($option, $enable = true) } // getAssignedProjects - returns an array of assigned projects. - function getAssignedProjects($includeFiles = false) + function getAssignedProjects($options = null) { $result = array(); $mdb2 = getConnection(); @@ -342,7 +343,7 @@ function getAssignedProjects($includeFiles = false) $group_id = $this->getGroup(); $org_id = $this->org_id; - if ($includeFiles) { + if ($options['include_files']) { $filePart = ', if(Sub1.entity_id is null, 0, 1) as has_files'; $fileJoin = " left join (select distinct entity_id from tt_files". " where entity_type = 'project' and group_id = $group_id and org_id = $org_id and status = 1) Sub1". @@ -356,6 +357,12 @@ function getAssignedProjects($includeFiles = false) $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { + // If we have to include templates, get them in a separate query for each project. + // Although, theoretically, we could use mysql group_concat, but this requires grouping by, which makes + // maintenance of this code more complex. + if ($options['include_templates']) { + $val['templates'] = ttTemplateHelper::getAssignedTemplates($val['id']); + } $result[] = $val; } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index a232aa149..4ec458529 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
{$i18n.form.tasks.inactive_tasks}
{$i18n.form.templates.inactive_templates}
{$i18n.label.thing_name} {$i18n.label.description}
- {/if} -{if $user->isPluginEnabled('iv')} +{if $show_billable} @@ -81,7 +81,7 @@ {/if} -{if $template_dropdown} +{if $show_templates} diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 3e8a02024..529acfe5a 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -13,6 +13,7 @@ // project_names[325] = "Time Tracker"; // Project name. // task_ids[325] = "100,101,302,303,304"; // Comma-separated list ot task ids for project. // task_names[100] = "Coding"; // Task name. +// template_ids[325] = "17,21"; // Comma-separated list ot template ids for project. NOT YET IMPLEMENTED. // Prepare an array of project ids for clients. var project_ids = new Array(); diff --git a/projects.php b/projects.php index 1b137895e..0075c038f 100644 --- a/projects.php +++ b/projects.php @@ -45,8 +45,10 @@ if($user->can('manage_projects')) { $active_projects = ttGroupHelper::getActiveProjects($showFiles); $inactive_projects = ttGroupHelper::getInactiveProjects($showFiles); -} else - $active_projects = $user->getAssignedProjects($showFiles); +} else { + $options['include_files'] = $showFiles; + $active_projects = $user->getAssignedProjects($options); +} $smarty->assign('active_projects', $active_projects); $smarty->assign('inactive_projects', $inactive_projects); diff --git a/time.php b/time.php index 8b1c0926f..5e24904a5 100644 --- a/time.php +++ b/time.php @@ -69,6 +69,7 @@ $group_id = $user->getGroup(); $showClient = $user->isPluginEnabled('cl'); +$showBillable = $user->isPluginEnabled('iv'); $trackingMode = $user->getTrackingMode(); $showProject = MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode; $showTask = MODE_PROJECTS_AND_TASKS == $trackingMode; @@ -76,6 +77,7 @@ $showStart = TYPE_START_FINISH == $recordType || TYPE_ALL == $recordType; $showFinish = $showStart; $showDuration = TYPE_DURATION == $recordType || TYPE_ALL == $recordType; +$showTemplates = $user->isPluginEnabled('tp'); $showFiles = $user->isPluginEnabled('at'); // Initialize and store date in session. @@ -206,7 +208,8 @@ if ($showProject) { // Dropdown for projects assigned to user. - $project_list = $user->getAssignedProjects(); + $options['include_templates'] = $showTemplates; + $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillTaskDropdown(this.value);', 'name'=>'project', @@ -245,6 +248,9 @@ } } +if ($showBillable) + $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable)); + if ($showTask) { $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', @@ -277,9 +283,7 @@ -// TODO: refactoring ongoing down from here. Use $showBillable, perhaps? -if ($user->isPluginEnabled('iv')) - $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable)); +// TODO: refactoring ongoing down from here. $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click. $form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->get('button.submit'))); @@ -300,7 +304,7 @@ } // If we have templates, add a dropdown to select one. -if ($user->isPluginEnabled('tp')){ +if ($showTemplates){ $templates = ttGroupHelper::getActiveTemplates(); if (count($templates) >= 1) { $form->addInput(array('type'=>'combobox', @@ -310,7 +314,7 @@ 'data'=>$templates, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); - $smarty->assign('template_dropdown', 1); + $smarty->assign('show_templates', 1); $smarty->assign('templates', $templates); } } @@ -358,7 +362,7 @@ $err->add($i18n->get('error.field'), $i18n->get('label.duration')); } if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); - if ($user->isPluginEnabled('tp') && !ttValidTemplateText($cl_note)) { + if ($showTemplates && !ttValidTemplateText($cl_note)) { $err->add($i18n->get('error.field'), $i18n->get('label.note')); } if (!ttTimeHelper::canAdd()) $err->add($i18n->get('error.expired')); @@ -465,11 +469,13 @@ $smarty->assign('time_records', $timeRecords); $smarty->assign('show_navigation', $user->isPluginEnabled('wv') && !$user->isOptionEnabled('week_menu')); $smarty->assign('show_client', $showClient); +$smarty->assign('show_billable', $showBillable); $smarty->assign('show_project', $showProject); $smarty->assign('show_task', $showTask); $smarty->assign('show_start', $showStart); $smarty->assign('show_finish', $showFinish); $smarty->assign('show_duration', $showDuration); +$smarty->assign('show_templates', $showTemplates); $smarty->assign('show_note_column', $showNoteColumn); $smarty->assign('show_note_row', $showNoteRow); $smarty->assign('show_files', $showFiles); From 4128cf13931abaa84cbe57ca1d094a183124ca1d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 30 Jun 2020 21:57:04 +0000 Subject: [PATCH 021/695] Fixed template content population - broken in previous commit. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time.tpl | 2 +- time.php | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4ec458529..3794de8f5 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.17.5194 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5195 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index 94be028b3..5663d89b7 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -30,7 +30,7 @@ {$forms.timeRecordForm.client.control}
  {$forms.timeRecordForm.newfile.control}
{$i18n.label.template}: {$forms.timeRecordForm.template.control}
- {/if} -{if $show_templates} +{if $template_dropdown} diff --git a/time.php b/time.php index 5e24904a5..3a9e582aa 100644 --- a/time.php +++ b/time.php @@ -77,7 +77,6 @@ $showStart = TYPE_START_FINISH == $recordType || TYPE_ALL == $recordType; $showFinish = $showStart; $showDuration = TYPE_DURATION == $recordType || TYPE_ALL == $recordType; -$showTemplates = $user->isPluginEnabled('tp'); $showFiles = $user->isPluginEnabled('at'); // Initialize and store date in session. @@ -304,7 +303,7 @@ } // If we have templates, add a dropdown to select one. -if ($showTemplates){ +if ($user->isPluginEnabled('tp')){ $templates = ttGroupHelper::getActiveTemplates(); if (count($templates) >= 1) { $form->addInput(array('type'=>'combobox', @@ -314,7 +313,7 @@ 'data'=>$templates, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); - $smarty->assign('show_templates', 1); + $smarty->assign('template_dropdown', 1); $smarty->assign('templates', $templates); } } @@ -362,7 +361,7 @@ $err->add($i18n->get('error.field'), $i18n->get('label.duration')); } if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); - if ($showTemplates && !ttValidTemplateText($cl_note)) { + if ($user->isPluginEnabled('tp') && !ttValidTemplateText($cl_note)) { $err->add($i18n->get('error.field'), $i18n->get('label.note')); } if (!ttTimeHelper::canAdd()) $err->add($i18n->get('error.expired')); From df5542ddf3de5aa8051f551a8a05ec88cd8d6aad Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 2 Jul 2020 17:51:19 +0000 Subject: [PATCH 022/695] Work in progress adding bind templates with projects option. --- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 1 + WEB-INF/resources/de.lang.php | 1 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 1 + WEB-INF/resources/fa.lang.php | 1 + WEB-INF/resources/fi.lang.php | 1 + WEB-INF/resources/fr.lang.php | 1 + WEB-INF/resources/gr.lang.php | 1 + WEB-INF/resources/he.lang.php | 1 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 1 + WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 2 ++ WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 1 + WEB-INF/resources/pt-br.lang.php | 1 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 1 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 1 + WEB-INF/resources/sv.lang.php | 1 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 6 ++++++ templates.php | 10 ++++++++++ 33 files changed, 48 insertions(+), 1 deletion(-) diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index f49ce3025..658a19318 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -276,6 +276,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 6459cc953..4ec5d0093 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -286,6 +286,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index e03d73d43..3905d8950 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -266,6 +266,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index b4663d1b3..b0e8c4af5 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -256,6 +256,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 0c1b8e0a9..b52195d6b 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -250,6 +250,7 @@ 'label.approval' => 'Report approval', 'label.mark_approved' => 'Mark approved', 'label.template' => 'Template', +'label.bind_templates_with_projects' => 'Bind templates with projects', 'label.attachments' => 'Attachments', 'label.files' => 'Files', 'label.file' => 'File', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index a8faaf364..30fb2803d 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -279,6 +279,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index ecb4a1e20..1539d26e3 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -273,6 +273,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 33776560a..eb5f095e5 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -277,6 +277,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index d8d477d15..1b0f0bc9a 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -270,6 +270,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 39755c50c..e84e6f9fc 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -264,6 +264,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 16baaf28c..46a18d53e 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -260,6 +260,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 706be9cae..c1697904a 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -285,6 +285,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 8176a45c8..b136dc1fd 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -282,6 +282,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 7f667b445..0805dcbe3 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -264,6 +264,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index fb0fd6fcb..5826460b8 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -286,6 +286,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 8414edb52..0b2b51b1d 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -286,6 +286,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index fc7aeb361..29826bcd2 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -255,6 +255,8 @@ 'label.approval' => 'Rapport goedkeuring', 'label.mark_approved' => 'Markeer goedkeuring', 'label.template' => 'Sjabloon', +// TODO: translate the following. +// 'label.bind_templates_with_projects' => 'Bind templates with projects', 'label.attachments' => 'Bijlagen', 'label.files' => 'Bestanden', 'label.file' => 'Bestand', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index b0dc2ead0..c1696fc11 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -283,6 +283,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index de6ded99a..046fa922c 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -271,6 +271,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index fafb843bb..5e97cf7ac 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -268,6 +268,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 3c6ecefd9..01751f8e5 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -271,6 +271,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 9b6fc1750..9756a1cea 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -283,6 +283,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index a08157191..48795ca22 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -241,6 +241,7 @@ 'label.approval' => 'Одобрение отчётов', 'label.mark_approved' => 'Отметить одобрение', 'label.template' => 'Шаблон', +'label.bind_templates_with_projects' => 'Связать шаблоны с проектамиЫ', 'label.attachments' => 'Приложения', 'label.files' => 'Файлы', 'label.file' => 'Файл', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 88d310e12..159b6ce45 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -275,6 +275,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index ae9d8ab8c..6ffa74b57 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -266,6 +266,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index b29f81bca..523277b32 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -269,6 +269,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 41dea480e..4112465f2 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -266,6 +266,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 4ac00f1c1..ab1d51bae 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -290,6 +290,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index 8d96b36ee..7b6dbef6d 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -275,6 +275,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 77acaecad..454b000c1 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -281,6 +281,7 @@ // 'label.approval' => 'Report approval', // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', +// 'label.bind_templates_with_projects' => 'Bind templates with projects', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3794de8f5..fdcbd866b 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.17.5195 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5196 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index 5663d89b7..d153dc96d 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -81,7 +81,7 @@ {$forms.timeRecordForm.newfile.control}
{$i18n.label.template}: {$forms.timeRecordForm.template.control}
-
 Anuko Time Tracker 1.19.17.5196 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5197 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index c0a74422d..80991537e 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -3,6 +3,12 @@
+{if defined('TEMPLATES_DEBUG')} + + + + +{/if} {if $inactive_templates} {/if} diff --git a/templates.php b/templates.php index 6bf6ae393..0b1f312fb 100644 --- a/templates.php +++ b/templates.php @@ -41,7 +41,17 @@ } // End of access checks. +$config = $user->getConfigHelper(); + +if ($request->isPost()) { + $cl_bind_templates_with_projects = $request->getParameter('bind_templates_with_projects'); +} else { + $cl_bind_templates_with_projects = $config->getDefinedValue('bind_templates_with_projects'); +} + + $form = new Form('templatesForm'); +$form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); if ($request->isPost()) { if ($request->getParameter('btn_add')) { From 70a998d4a2a235a44e64dda3d96b0cda71e5df1c Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 2 Jul 2020 20:51:50 +0000 Subject: [PATCH 023/695] Some more work in progress on binding templates with projects. --- WEB-INF/lib/ttUser.class.php | 3 ++- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 3 +++ template_edit.php | 18 ++++++++++++------ templates.php | 17 ++++++++++++----- time.php | 2 +- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 42f9b0d90..4ef5d26e0 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -356,11 +356,12 @@ function getAssignedProjects($options = null) " where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { + $bindTemplatesWithProjects = $options['include_templates']; while ($val = $res->fetchRow()) { // If we have to include templates, get them in a separate query for each project. // Although, theoretically, we could use mysql group_concat, but this requires grouping by, which makes // maintenance of this code more complex. - if ($options['include_templates']) { + if ($bindTemplatesWithProjects) { $val['templates'] = ttTemplateHelper::getAssignedTemplates($val['id']); } $result[] = $val; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index fdcbd866b..9580c3c07 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
{$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$i18n.form.templates.active_templates}
- + + + {/if} {if $inactive_templates} diff --git a/template_edit.php b/template_edit.php index 1bff1a3bf..da8485047 100644 --- a/template_edit.php +++ b/template_edit.php @@ -47,22 +47,28 @@ } // End of access checks. -$projects = ttGroupHelper::getActiveProjects(); +$config = $user->getConfigHelper(); +$bindTemplatesWithProjects = $config->getDefinedValue('bind_templates_with_projects'); +if ($bindTemplatesWithProjects) + $projects = ttGroupHelper::getActiveProjects(); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); $cl_description = trim($request->getParameter('description')); $cl_content = trim($request->getParameter('content')); $cl_status = $request->getParameter('status'); - $cl_projects = $request->getParameter('projects'); + if ($bindTemplatesWithProjects) + $cl_projects = $request->getParameter('projects'); } else { $cl_name = $template['name']; $cl_description = $template['description']; $cl_content = $template['content']; $cl_status = $template['status']; - $assigned_projects = ttTemplateHelper::getAssignedProjects($cl_template_id); - foreach ($assigned_projects as $project_item) - $cl_projects[] = $project_item['id']; + if ($bindTemplatesWithProjects) { + $assigned_projects = ttTemplateHelper::getAssignedProjects($cl_template_id); + foreach ($assigned_projects as $project_item) + $cl_projects[] = $project_item['id']; + } } $form = new Form('templateForm'); @@ -98,7 +104,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_projects', count($projects) > 0 && defined('TEMPLATES_DEBUG')); +$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0 && defined('TEMPLATES_DEBUG')); $smarty->assign('title', $i18n->get('title.edit_template')); $smarty->assign('content_page_name', 'template_edit.tpl'); $smarty->display('index.tpl'); diff --git a/templates.php b/templates.php index 0b1f312fb..cf315d085 100644 --- a/templates.php +++ b/templates.php @@ -49,20 +49,27 @@ $cl_bind_templates_with_projects = $config->getDefinedValue('bind_templates_with_projects'); } - $form = new Form('templatesForm'); $form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); +$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); +$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); +$activeTemplates = ttGroupHelper::getActiveTemplates(); +$inactiveTemplates = ttGroupHelper::getInactiveTemplates(); if ($request->isPost()) { + if ($request->getParameter('btn_save')) { + // Save button clicked. Update config. + $config->setDefinedValue('bind_templates_with_projects', $cl_bind_templates_with_projects); + if (!$user->updateGroup(array('config' => $config->getConfig()))) { + $err->add($i18n->get('error.db')); + } + } + if ($request->getParameter('btn_add')) { // The Add button clicked. Redirect to template_add.php page. header('Location: template_add.php'); exit(); } -} else { - $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); - $activeTemplates = ttGroupHelper::getActiveTemplates(); - $inactiveTemplates = ttGroupHelper::getInactiveTemplates(); } $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/time.php b/time.php index 3a9e582aa..a48458add 100644 --- a/time.php +++ b/time.php @@ -207,7 +207,7 @@ if ($showProject) { // Dropdown for projects assigned to user. - $options['include_templates'] = $showTemplates; + $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillTaskDropdown(this.value);', From 9cbb307079829d2c3660fd7900a71b7b1eb9f62e Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 3 Jul 2020 16:28:48 +0000 Subject: [PATCH 024/695] Initial implementation of template binds to projects. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 19 ++++---- WEB-INF/templates/time_script.tpl | 75 ++++++++++++++++++++++++++++--- mobile/time.php | 16 ++++--- mobile/time_edit.php | 16 ++++--- template_add.php | 3 +- template_edit.php | 2 +- time.php | 13 +++--- time_edit.php | 16 ++++--- 9 files changed, 119 insertions(+), 43 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9580c3c07..930618e50 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.17.5197 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5199 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index 80991537e..3a7da2b7e 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -8,6 +8,9 @@ {$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$forms.templatesForm.btn_save.control}
{$i18n.form.templates.active_templates}
-
 Anuko Time Tracker 1.19.17.5199 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5200 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index 3a7da2b7e..d4532873d 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -3,15 +3,6 @@
-{if defined('TEMPLATES_DEBUG')} - - - - - - - -{/if} {if $inactive_templates} {/if} @@ -55,6 +46,16 @@
{$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$forms.templatesForm.btn_save.control}
{$i18n.form.templates.active_templates}

{$forms.templatesForm.btn_add.control}
{/if} +
+ + + + + + + + +
{$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$forms.templatesForm.btn_save.control}
diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 529acfe5a..495a16aee 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -44,32 +44,47 @@ var task_names = new Array(); task_names[{$task.id}] = "{$task.name|escape:'javascript'}"; {/foreach} -{if $template_dropdown} -var templates = new Array(); -{foreach $templates as $template} - templates[{$template.id}] = "{$template.content|escape:'javascript'}"; +// Prepare an array of template ids for projects. +var template_ids = new Array(); +{if $bind_templates_with_projects} + {foreach $project_list as $project} + template_ids[{$project.id}] = "{$project.templates}"; + {/foreach} +{/if} +// Prepare an array of template names. +var template_names = new Array(); +{if $bind_templates_with_projects} + {foreach $template_list as $template} + template_names[{$template.id}] = "{$template.name|escape:'javascript'}"; + {/foreach} +{/if} +// Prepare an array of template bodies. +var template_bodies = new Array(); +{foreach $template_list as $template} + template_bodies[{$template.id}] = "{$template.content|escape:'javascript'}"; {/foreach} // The fillNote function populates the Note field with a selected template body. function fillNote(id) { if (!id) return; // Do nothing. - var template_body = templates[id]; + var template_body = template_bodies[id]; var note = document.getElementById("note"); note.value = template_body; } -{/if} // Mandatory top options for project and task dropdowns. var empty_label_project = "{$i18n.dropdown.select|escape:'javascript'}"; var empty_label_task = "{$i18n.dropdown.select|escape:'javascript'}"; +var empty_label_template = "{$i18n.dropdown.select|escape:'javascript'}"; -// The fillDropdowns function populates the "project" and "task" dropdown controls +// The fillDropdowns function populates the "project", "task", and "template" dropdown controls // with relevant values. function fillDropdowns() { if(document.body.contains(document.timeRecordForm.client)) fillProjectDropdown(document.timeRecordForm.client.value); fillTaskDropdown(document.timeRecordForm.project.value); + fillTemplateDropdown(document.timeRecordForm.project.value); } // The fillProjectDropdown function populates the project combo box with @@ -167,6 +182,52 @@ function fillTaskDropdown(id) { } } +// The fillTemplateDropdown function populates the template combo box with +// templates associated with a selected project (project id is passed here as id). +function fillTemplateDropdown(id) { +{if !$bind_templates_with_projects} + return; // Do nothing if we are not binding templates with projects, +{/if} + + var str_ids = template_ids[id]; + + var dropdown = document.getElementById("template"); + if (dropdown == null) return; // Nothing to do. + + // Determine previously selected item. + var selected_item = dropdown.options[dropdown.selectedIndex].value; + + // Remove existing content. + dropdown.length = 0; + // Add mandatory top option. + dropdown.options[0] = new Option(empty_label_template, '', true); + + // Populate the dropdown from the template_names array. + if (str_ids) { + var ids = new Array(); + ids = str_ids.split(","); + var len = ids.length; + + var idx = 1; + for (var i = 0; i < len; i++) { + var t_id = ids[i]; + if (template_names[t_id]) { + dropdown.options[idx] = new Option(template_names[t_id], t_id); + idx++; + } + } + + // If a previously selected item is still in dropdown - select it. + if (dropdown.options.length > 0) { + for (var i = 0; i < dropdown.options.length; i++) { + if (dropdown.options[i].value == selected_item) { + dropdown.options[i].selected = true; + } + } + } + } +} + // The formDisable function disables some fields depending on what we have in other fields. function formDisable(formField) { var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); diff --git a/mobile/time.php b/mobile/time.php index c5fb0ea75..b37a0a959 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -31,6 +31,7 @@ import('ttUserHelper'); import('ttGroupHelper'); import('ttClientHelper'); +import('ttConfigHelper'); import('ttTimeHelper'); import('DateAndTime'); @@ -65,6 +66,7 @@ } $group_id = $user->getGroup(); +$config = new ttConfigHelper($user->getConfig()); // Initialize and store date in session. $cl_date = $request->getParameter('date', @$_SESSION['date']); @@ -161,9 +163,10 @@ if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { // Dropdown for projects assigned to user. - $project_list = $user->getAssignedProjects(); + $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); + $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, @@ -245,17 +248,18 @@ // If we have templates, add a dropdown to select one. if ($user->isPluginEnabled('tp')){ - $templates = ttGroupHelper::getActiveTemplates(); - if (count($templates) >= 1) { + $template_list = ttGroupHelper::getActiveTemplates(); + if (count($template_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'fillNote(this.value);', 'name'=>'template', 'style'=>'width: 250px;', - 'data'=>$templates, + 'data'=>$template_list, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); - $smarty->assign('templates', $templates); + $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('template_list', $template_list); } } diff --git a/mobile/time_edit.php b/mobile/time_edit.php index bce156661..18acb98b4 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -32,6 +32,7 @@ import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); +import('ttConfigHelper'); import('DateAndTime'); // Access checks. @@ -49,6 +50,7 @@ // End of access checks. $user_id = $user->getUser(); +$config = new ttConfigHelper($user->getConfig()); // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { @@ -138,9 +140,10 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { // Dropdown for projects assigned to user. - $project_list = $user->getAssignedProjects(); + $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); + $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, @@ -221,17 +224,18 @@ // If we have templates, add a dropdown to select one. if ($user->isPluginEnabled('tp')){ - $templates = ttGroupHelper::getActiveTemplates(); - if (count($templates) >= 1) { + $template_list = ttGroupHelper::getActiveTemplates(); + if (count($template_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'fillNote(this.value);', 'name'=>'template', 'style'=>'width: 250px;', - 'data'=>$templates, + 'data'=>$template_list, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); - $smarty->assign('templates', $templates); + $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('template_list', $template_list); } } diff --git a/template_add.php b/template_add.php index e7e828444..98dd41430 100644 --- a/template_add.php +++ b/template_add.php @@ -41,6 +41,7 @@ } // End of access checks. +$config = new ttConfigHelper($user->getConfig()); $projects = ttGroupHelper::getActiveProjects(); if ($request->isPost()) { @@ -81,7 +82,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_projects', count($projects) > 0 && defined('TEMPLATES_DEBUG')); +$smarty->assign('show_projects', count($projects) > 0 && $config->getDefinedValue('bind_templates_with_projects')); $smarty->assign('title', $i18n->get('title.add_template')); $smarty->assign('content_page_name', 'template_add.tpl'); $smarty->display('index.tpl'); diff --git a/template_edit.php b/template_edit.php index da8485047..7619e7378 100644 --- a/template_edit.php +++ b/template_edit.php @@ -104,7 +104,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0 && defined('TEMPLATES_DEBUG')); +$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0 && $bindTemplatesWithProjects); $smarty->assign('title', $i18n->get('title.edit_template')); $smarty->assign('content_page_name', 'template_edit.tpl'); $smarty->display('index.tpl'); diff --git a/time.php b/time.php index a48458add..823cd8287 100644 --- a/time.php +++ b/time.php @@ -67,6 +67,7 @@ } $group_id = $user->getGroup(); +$config = new ttConfigHelper($user->getConfig()); $showClient = $user->isPluginEnabled('cl'); $showBillable = $user->isPluginEnabled('iv'); @@ -95,7 +96,6 @@ $smarty->assign('custom_fields', $custom_fields); } -$config = new ttConfigHelper($user->getConfig()); $showNoteColumn = !$config->getDefinedValue('time_note_on_separate_row'); $showNoteRow = $config->getDefinedValue('time_note_on_separate_row'); if ($showNoteRow) { @@ -210,7 +210,7 @@ $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, @@ -304,17 +304,18 @@ // If we have templates, add a dropdown to select one. if ($user->isPluginEnabled('tp')){ - $templates = ttGroupHelper::getActiveTemplates(); - if (count($templates) >= 1) { + $template_list = ttGroupHelper::getActiveTemplates(); + if (count($template_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'fillNote(this.value);', 'name'=>'template', 'style'=>'width: 250px;', - 'data'=>$templates, + 'data'=>$template_list, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); - $smarty->assign('templates', $templates); + $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('template_list', $template_list); } } diff --git a/time_edit.php b/time_edit.php index f6ee7de1e..8734d2ab8 100644 --- a/time_edit.php +++ b/time_edit.php @@ -32,6 +32,7 @@ import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); +import('ttConfigHelper'); import('DateAndTime'); // Access checks. @@ -49,6 +50,7 @@ // End of access checks. $user_id = $user->getUser(); +$config = new ttConfigHelper($user->getConfig()); // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { @@ -141,9 +143,10 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { // Dropdown for projects assigned to user. - $project_list = $user->getAssignedProjects(); + $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); + $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, @@ -224,17 +227,18 @@ // If we have templates, add a dropdown to select one. if ($user->isPluginEnabled('tp')){ - $templates = ttGroupHelper::getActiveTemplates(); - if (count($templates) >= 1) { + $template_list = ttGroupHelper::getActiveTemplates(); + if (count($template_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'fillNote(this.value);', 'name'=>'template', 'style'=>'width: 250px;', - 'data'=>$templates, + 'data'=>$template_list, 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); - $smarty->assign('templates', $templates); + $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('template_list', $template_list); } } From 3deb102003dcfb43b1594d713fd942eb782c6ca6 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 4 Jul 2020 13:05:25 +0000 Subject: [PATCH 025/695] Introduced label.prepopulate_empty_note string in translation files. --- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 1 + WEB-INF/resources/de.lang.php | 1 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 1 + WEB-INF/resources/fa.lang.php | 1 + WEB-INF/resources/fi.lang.php | 1 + WEB-INF/resources/fr.lang.php | 1 + WEB-INF/resources/gr.lang.php | 1 + WEB-INF/resources/he.lang.php | 1 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 1 + WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 1 + WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 1 + WEB-INF/resources/pt-br.lang.php | 1 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 3 ++- WEB-INF/resources/sk.lang.php | 1 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 1 + WEB-INF/resources/sv.lang.php | 1 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- 31 files changed, 32 insertions(+), 2 deletions(-) diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 658a19318..63bc3123f 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -277,6 +277,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 4ec5d0093..d79763485 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -287,6 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index 3905d8950..53e73200c 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -267,6 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index b0e8c4af5..b7e3b2efd 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -257,6 +257,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index b52195d6b..b7f3a21f2 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -251,6 +251,7 @@ 'label.mark_approved' => 'Mark approved', 'label.template' => 'Template', 'label.bind_templates_with_projects' => 'Bind templates with projects', +'label.prepopulate_empty_note' => 'Prepopulate empty Note field', 'label.attachments' => 'Attachments', 'label.files' => 'Files', 'label.file' => 'File', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 30fb2803d..9867273e3 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -280,6 +280,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 1539d26e3..573689a57 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -274,6 +274,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index eb5f095e5..de9fefe1d 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -278,6 +278,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 1b0f0bc9a..3f45c2752 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -271,6 +271,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index e84e6f9fc..769006928 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -265,6 +265,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 46a18d53e..661a31697 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -261,6 +261,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index c1697904a..8e72b7c93 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -286,6 +286,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index b136dc1fd..03d54e4f2 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -283,6 +283,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 0805dcbe3..d9c6023e9 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -265,6 +265,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 5826460b8..afc001282 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -287,6 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 0b2b51b1d..23ba28957 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -287,6 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 29826bcd2..5c9516b2e 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -257,6 +257,7 @@ 'label.template' => 'Sjabloon', // TODO: translate the following. // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', 'label.attachments' => 'Bijlagen', 'label.files' => 'Bestanden', 'label.file' => 'Bestand', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index c1696fc11..6059ed09c 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -284,6 +284,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 046fa922c..6c7adf0f6 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -272,6 +272,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index 5e97cf7ac..daf8fc1d3 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -269,6 +269,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 01751f8e5..204a72e31 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -272,6 +272,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 9756a1cea..01a0f37f4 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -284,6 +284,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 48795ca22..f40becac9 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -241,7 +241,8 @@ 'label.approval' => 'Одобрение отчётов', 'label.mark_approved' => 'Отметить одобрение', 'label.template' => 'Шаблон', -'label.bind_templates_with_projects' => 'Связать шаблоны с проектамиЫ', +'label.bind_templates_with_projects' => 'Связать шаблоны с проектами', +'label.prepopulate_empty_note' => 'Подставлять шаблон в пустое поле', 'label.attachments' => 'Приложения', 'label.files' => 'Файлы', 'label.file' => 'Файл', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 159b6ce45..313fcfd2d 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -276,6 +276,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 6ffa74b57..19cceabca 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -267,6 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 523277b32..19f6d345e 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -270,6 +270,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 4112465f2..72113f964 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -267,6 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index ab1d51bae..2d509b658 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -291,6 +291,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index 7b6dbef6d..9dccc6b25 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -276,6 +276,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 454b000c1..0d0ad29f8 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -282,6 +282,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', +// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 930618e50..e3d6cad82 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.17.5200 | Copyright © Anuko | +  Anuko Time Tracker 1.19.17.5201 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} From 0b1455a77e7fd2d543b843edf2f6dcc863699118 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 4 Jul 2020 13:43:56 +0000 Subject: [PATCH 026/695] Introduced a handler for prepopulate_empty_note option. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 4 ++++ WEB-INF/templates/time_script.tpl | 10 ++++++++++ mobile/time.php | 1 + templates.php | 4 ++++ time.php | 1 + 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e3d6cad82..96a499dd4 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- + + + + diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 495a16aee..d6c48a833 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -226,6 +226,16 @@ function fillTemplateDropdown(id) { } } } + + // Do things for prepopulate_empty_note. + if ({$prepopulate_empty_note} && dropdown.options.length >= 2) { // 2 because of mandatory top option. + var note = document.getElementById("note"); + if (note.value == "") { + // We have an empty Note field. + dropdown.options[1].selected = true; // Select first template. + note.value = template_bodies[dropdown.options[1].value]; // Pre-polulate note with first template body. + } + } } // The formDisable function disables some fields depending on what we have in other fields. diff --git a/mobile/time.php b/mobile/time.php index b37a0a959..0293574dc 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -259,6 +259,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('prepopulate_empty_note', $config->getDefinedValue('prepopulate_empty_note')); $smarty->assign('template_list', $template_list); } } diff --git a/templates.php b/templates.php index cf315d085..1a643e8f3 100644 --- a/templates.php +++ b/templates.php @@ -45,12 +45,15 @@ if ($request->isPost()) { $cl_bind_templates_with_projects = $request->getParameter('bind_templates_with_projects'); + $cl_prepopulate_empty_note = $request->getParameter('prepopulate_empty_note'); } else { $cl_bind_templates_with_projects = $config->getDefinedValue('bind_templates_with_projects'); + $cl_prepopulate_empty_note = $config->getDefinedValue('prepopulate_empty_note'); } $form = new Form('templatesForm'); $form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); +$form->addInput(array('type'=>'checkbox','name'=>'prepopulate_empty_note','value'=>$cl_prepopulate_empty_note)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); $activeTemplates = ttGroupHelper::getActiveTemplates(); @@ -60,6 +63,7 @@ if ($request->getParameter('btn_save')) { // Save button clicked. Update config. $config->setDefinedValue('bind_templates_with_projects', $cl_bind_templates_with_projects); + $config->setDefinedValue('prepopulate_empty_note', $cl_prepopulate_empty_note); if (!$user->updateGroup(array('config' => $config->getConfig()))) { $err->add($i18n->get('error.db')); } diff --git a/time.php b/time.php index 823cd8287..44d895a5b 100644 --- a/time.php +++ b/time.php @@ -315,6 +315,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('prepopulate_empty_note', $config->getDefinedValue('prepopulate_empty_note')); $smarty->assign('template_list', $template_list); } } From da251bb9b537cdf266ba905493c96d8a20690d5b Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 5 Jul 2020 15:03:23 +0000 Subject: [PATCH 027/695] Changed prepopulate_empty_note to prepopulate_note logic. --- WEB-INF/resources/ca.lang.php | 2 +- WEB-INF/resources/cs.lang.php | 2 +- WEB-INF/resources/da.lang.php | 2 +- WEB-INF/resources/de.lang.php | 2 +- WEB-INF/resources/en.lang.php | 2 +- WEB-INF/resources/es.lang.php | 2 +- WEB-INF/resources/et.lang.php | 2 +- WEB-INF/resources/fa.lang.php | 2 +- WEB-INF/resources/fi.lang.php | 2 +- WEB-INF/resources/fr.lang.php | 2 +- WEB-INF/resources/gr.lang.php | 2 +- WEB-INF/resources/he.lang.php | 2 +- WEB-INF/resources/hu.lang.php | 2 +- WEB-INF/resources/it.lang.php | 2 +- WEB-INF/resources/ja.lang.php | 2 +- WEB-INF/resources/ko.lang.php | 2 +- WEB-INF/resources/nl.lang.php | 2 +- WEB-INF/resources/no.lang.php | 2 +- WEB-INF/resources/pl.lang.php | 2 +- WEB-INF/resources/pt-br.lang.php | 2 +- WEB-INF/resources/pt.lang.php | 2 +- WEB-INF/resources/ro.lang.php | 2 +- WEB-INF/resources/ru.lang.php | 2 +- WEB-INF/resources/sk.lang.php | 2 +- WEB-INF/resources/sl.lang.php | 2 +- WEB-INF/resources/sr.lang.php | 2 +- WEB-INF/resources/sv.lang.php | 2 +- WEB-INF/resources/tr.lang.php | 2 +- WEB-INF/resources/zh-cn.lang.php | 2 +- WEB-INF/resources/zh-tw.lang.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 4 ++-- WEB-INF/templates/time_script.tpl | 11 ++++------- mobile/time.php | 2 +- mobile/time_edit.php | 1 + templates.php | 8 ++++---- time.php | 2 +- time_edit.php | 1 + 38 files changed, 45 insertions(+), 46 deletions(-) diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 63bc3123f..9893ad523 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -277,7 +277,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index d79763485..59756d1b5 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -287,7 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index 53e73200c..a8a14b53d 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -267,7 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index b7e3b2efd..a8f1d165a 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -257,7 +257,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index b7f3a21f2..2beefaa1c 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -251,7 +251,7 @@ 'label.mark_approved' => 'Mark approved', 'label.template' => 'Template', 'label.bind_templates_with_projects' => 'Bind templates with projects', -'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +'label.prepopulate_note' => 'Prepopulate Note field', 'label.attachments' => 'Attachments', 'label.files' => 'Files', 'label.file' => 'File', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 9867273e3..1cf3ce768 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -280,7 +280,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 573689a57..5e2e78caa 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -274,7 +274,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index de9fefe1d..e078a0a34 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -278,7 +278,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 3f45c2752..575dc04f6 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -271,7 +271,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 769006928..5fe0f76d7 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -265,7 +265,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 661a31697..5d0dd6bde 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -261,7 +261,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 8e72b7c93..199e26533 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -286,7 +286,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 03d54e4f2..a4a4dd005 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -283,7 +283,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index d9c6023e9..b10575302 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -265,7 +265,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index afc001282..8ebec5955 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -287,7 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 23ba28957..76c159472 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -287,7 +287,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 5c9516b2e..06f764d4c 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -257,7 +257,7 @@ 'label.template' => 'Sjabloon', // TODO: translate the following. // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', 'label.attachments' => 'Bijlagen', 'label.files' => 'Bestanden', 'label.file' => 'Bestand', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index 6059ed09c..ad95bd7e3 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -284,7 +284,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 6c7adf0f6..f988df4a4 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -272,7 +272,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index daf8fc1d3..5c9d89a32 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -269,7 +269,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 204a72e31..3043e8bba 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -272,7 +272,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 01a0f37f4..add70a4ea 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -284,7 +284,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index f40becac9..fb050a1a0 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -242,7 +242,7 @@ 'label.mark_approved' => 'Отметить одобрение', 'label.template' => 'Шаблон', 'label.bind_templates_with_projects' => 'Связать шаблоны с проектами', -'label.prepopulate_empty_note' => 'Подставлять шаблон в пустое поле', +'label.prepopulate_note' => 'Подставлять шаблон в поле', 'label.attachments' => 'Приложения', 'label.files' => 'Файлы', 'label.file' => 'Файл', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 313fcfd2d..cf0b8432b 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -276,7 +276,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 19cceabca..f4aa21b58 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -267,7 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 19f6d345e..be5739b6e 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -270,7 +270,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 72113f964..43b0d92b6 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -267,7 +267,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 2d509b658..e241cace8 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -291,7 +291,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index 9dccc6b25..b1d81418b 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -276,7 +276,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 0d0ad29f8..05615586d 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -282,7 +282,7 @@ // 'label.mark_approved' => 'Mark approved', // 'label.template' => 'Template', // 'label.bind_templates_with_projects' => 'Bind templates with projects', -// 'label.prepopulate_empty_note' => 'Prepopulate empty Note field', +// 'label.prepopulate_note' => 'Prepopulate Note field', // 'label.attachments' => 'Attachments', // 'label.files' => 'Files', // 'label.file' => 'File', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 96a499dd4..6743bb1ee 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.17.5201 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5202 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index d4532873d..eb1b2027f 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -52,6 +52,10 @@ {$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$forms.templatesForm.prepopulate_empty_note.control} {$i18n.label.what_is_it}
{$forms.templatesForm.btn_save.control}
- - - + + diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index d6c48a833..14157a932 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -227,14 +227,11 @@ function fillTemplateDropdown(id) { } } - // Do things for prepopulate_empty_note. - if ({$prepopulate_empty_note} && dropdown.options.length >= 2) { // 2 because of mandatory top option. + // Prepopulate note if we have to. + if ({$prepopulate_note} && dropdown.options.length >= 2) { // 2 because of mandatory top option. var note = document.getElementById("note"); - if (note.value == "") { - // We have an empty Note field. - dropdown.options[1].selected = true; // Select first template. - note.value = template_bodies[dropdown.options[1].value]; // Pre-polulate note with first template body. - } + dropdown.options[1].selected = true; // Select first template. + note.value = template_bodies[dropdown.options[1].value]; // Pre-polulate note with first template body. } } diff --git a/mobile/time.php b/mobile/time.php index 0293574dc..427d22aa3 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -259,7 +259,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); - $smarty->assign('prepopulate_empty_note', $config->getDefinedValue('prepopulate_empty_note')); + $smarty->assign('prepopulate_note', $config->getDefinedValue('prepopulate_note')); $smarty->assign('template_list', $template_list); } } diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 18acb98b4..f901952cf 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -235,6 +235,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('prepopulate_note', $config->getDefinedValue('prepopulate_note')); $smarty->assign('template_list', $template_list); } } diff --git a/templates.php b/templates.php index 1a643e8f3..fec66b599 100644 --- a/templates.php +++ b/templates.php @@ -45,15 +45,15 @@ if ($request->isPost()) { $cl_bind_templates_with_projects = $request->getParameter('bind_templates_with_projects'); - $cl_prepopulate_empty_note = $request->getParameter('prepopulate_empty_note'); + $cl_prepopulate_note = $request->getParameter('prepopulate_note'); } else { $cl_bind_templates_with_projects = $config->getDefinedValue('bind_templates_with_projects'); - $cl_prepopulate_empty_note = $config->getDefinedValue('prepopulate_empty_note'); + $cl_prepopulate_note = $config->getDefinedValue('prepopulate_note'); } $form = new Form('templatesForm'); $form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); -$form->addInput(array('type'=>'checkbox','name'=>'prepopulate_empty_note','value'=>$cl_prepopulate_empty_note)); +$form->addInput(array('type'=>'checkbox','name'=>'prepopulate_note','value'=>$cl_prepopulate_note)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); $activeTemplates = ttGroupHelper::getActiveTemplates(); @@ -63,7 +63,7 @@ if ($request->getParameter('btn_save')) { // Save button clicked. Update config. $config->setDefinedValue('bind_templates_with_projects', $cl_bind_templates_with_projects); - $config->setDefinedValue('prepopulate_empty_note', $cl_prepopulate_empty_note); + $config->setDefinedValue('prepopulate_note', $cl_prepopulate_note); if (!$user->updateGroup(array('config' => $config->getConfig()))) { $err->add($i18n->get('error.db')); } diff --git a/time.php b/time.php index 44d895a5b..1a9a07b4c 100644 --- a/time.php +++ b/time.php @@ -315,7 +315,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); - $smarty->assign('prepopulate_empty_note', $config->getDefinedValue('prepopulate_empty_note')); + $smarty->assign('prepopulate_note', $config->getDefinedValue('prepopulate_note')); $smarty->assign('template_list', $template_list); } } diff --git a/time_edit.php b/time_edit.php index 8734d2ab8..bbf55d086 100644 --- a/time_edit.php +++ b/time_edit.php @@ -238,6 +238,7 @@ 'empty'=>array(''=>$i18n->get('dropdown.select')))); $smarty->assign('template_dropdown', 1); $smarty->assign('bind_templates_with_projects', $config->getDefinedValue('bind_templates_with_projects')); + $smarty->assign('prepopulate_note', $config->getDefinedValue('prepopulate_note')); $smarty->assign('template_list', $template_list); } } From 0d1cbcf045d46d6fac66bed2a141c72620bd7651 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 5 Jul 2020 15:57:14 +0000 Subject: [PATCH 028/695] Implemented prepopulateNote as a separate function. --- WEB-INF/templates/time_script.tpl | 18 ++++++++++++------ mobile/time.php | 2 +- mobile/time_edit.php | 2 +- time.php | 2 +- time_edit.php | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 14157a932..c64131d5e 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -85,6 +85,7 @@ function fillDropdowns() { fillTaskDropdown(document.timeRecordForm.project.value); fillTemplateDropdown(document.timeRecordForm.project.value); + prepopulateNote(); } // The fillProjectDropdown function populates the project combo box with @@ -226,13 +227,18 @@ function fillTemplateDropdown(id) { } } } +} - // Prepopulate note if we have to. - if ({$prepopulate_note} && dropdown.options.length >= 2) { // 2 because of mandatory top option. - var note = document.getElementById("note"); - dropdown.options[1].selected = true; // Select first template. - note.value = template_bodies[dropdown.options[1].value]; // Pre-polulate note with first template body. - } +// The prepopulateNote function populates the note field with first found template body in Template dropdown. +function prepopulateNote() { + var dropdown = document.getElementById("template"); + if (dropdown == null) return; // Nothing to do. + + if (!{$prepopulate_note} || dropdown.options.length <= 1) return ; // 1 because of mandatory top option. + + dropdown.options[1].selected = true; // Select first template. + var note = document.getElementById("note"); + note.value = template_bodies[dropdown.options[1].value]; // Prepolulate note with first template body. } // The formDisable function disables some fields depending on what we have in other fields. diff --git a/mobile/time.php b/mobile/time.php index 427d22aa3..c361fbe0d 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -166,7 +166,7 @@ $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);prepopulateNote();', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, diff --git a/mobile/time_edit.php b/mobile/time_edit.php index f901952cf..e6e790827 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -143,7 +143,7 @@ $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);prepopulateNote();', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, diff --git a/time.php b/time.php index 1a9a07b4c..0f30eac7c 100644 --- a/time.php +++ b/time.php @@ -210,7 +210,7 @@ $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);prepopulateNote();', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, diff --git a/time_edit.php b/time_edit.php index bbf55d086..2a0a02357 100644 --- a/time_edit.php +++ b/time_edit.php @@ -146,7 +146,7 @@ $options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects'); $project_list = $user->getAssignedProjects($options); $form->addInput(array('type'=>'combobox', - 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);', + 'onchange'=>'fillTaskDropdown(this.value);fillTemplateDropdown(this.value);prepopulateNote();', 'name'=>'project', 'style'=>'width: 250px;', 'value'=>$cl_project, From c44d8fd50bf6211a266df402fb979a7e5aefcf86 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 6 Jul 2020 01:04:30 +0000 Subject: [PATCH 029/695] Fixed the script for Now buttons to work again. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time_script.tpl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6743bb1ee..0571b5a74 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 Anuko Time Tracker 1.19.18.5202 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5203 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index eb1b2027f..71b7daebc 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -53,8 +53,8 @@ {$i18n.label.what_is_it}
{$forms.templatesForm.prepopulate_empty_note.control} {$i18n.label.what_is_it}{$forms.templatesForm.prepopulate_note.control} {$i18n.label.what_is_it}
{$forms.templatesForm.btn_save.control}
-
 Anuko Time Tracker 1.19.18.5203 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5204 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index c64131d5e..707121128 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -231,10 +231,13 @@ function fillTemplateDropdown(id) { // The prepopulateNote function populates the note field with first found template body in Template dropdown. function prepopulateNote() { + {if !prepopulate_note} + return; + {/if} var dropdown = document.getElementById("template"); if (dropdown == null) return; // Nothing to do. - if (!{$prepopulate_note} || dropdown.options.length <= 1) return ; // 1 because of mandatory top option. + if (dropdown.options.length <= 1) return ; // 1 because of mandatory top option. dropdown.options[1].selected = true; // Select first template. var note = document.getElementById("note"); From b4de969043705a34ebf68e0af33a23a8c71dbce7 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 6 Jul 2020 01:07:54 +0000 Subject: [PATCH 030/695] A better fix for previous commit. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time_script.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 0571b5a74..e5f70cfbd 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.18.5204 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5205 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 707121128..84ff653d2 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -231,7 +231,7 @@ function fillTemplateDropdown(id) { // The prepopulateNote function populates the note field with first found template body in Template dropdown. function prepopulateNote() { - {if !prepopulate_note} + {if !$prepopulate_note} return; {/if} var dropdown = document.getElementById("template"); From 014dcc496cb0e4385213a6d3a9f75d6fa77c4fcc Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 7 Jul 2020 17:51:54 +0000 Subject: [PATCH 031/695] Cosmetic improvements in comments. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time_script.tpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e5f70cfbd..9a047ba35 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.18.5205 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5206 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 84ff653d2..709a7cff7 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -78,7 +78,7 @@ var empty_label_task = "{$i18n.dropdown.select|escape:'javascript'}"; var empty_label_template = "{$i18n.dropdown.select|escape:'javascript'}"; // The fillDropdowns function populates the "project", "task", and "template" dropdown controls -// with relevant values. +// with relevant values, and also prepopulates the Note field, if required. function fillDropdowns() { if(document.body.contains(document.timeRecordForm.client)) fillProjectDropdown(document.timeRecordForm.client.value); @@ -239,9 +239,9 @@ function prepopulateNote() { if (dropdown.options.length <= 1) return ; // 1 because of mandatory top option. - dropdown.options[1].selected = true; // Select first template. + dropdown.options[1].selected = true; // Select first available template. var note = document.getElementById("note"); - note.value = template_bodies[dropdown.options[1].value]; // Prepolulate note with first template body. + note.value = template_bodies[dropdown.options[1].value]; // Prepolulate the Note field with first template body. } // The formDisable function disables some fields depending on what we have in other fields. From 531fba94204370984d817fa7f7543d7d59e3fbfe Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 7 Jul 2020 18:09:47 +0000 Subject: [PATCH 032/695] Made coding of template_add.php and template_edit.php more consistent. --- WEB-INF/templates/footer.tpl | 2 +- template_add.php | 12 ++++++++---- template_edit.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9a047ba35..3cdabc241 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.18.5206 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5207 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/template_add.php b/template_add.php index 98dd41430..cc2dc83b6 100644 --- a/template_add.php +++ b/template_add.php @@ -42,7 +42,9 @@ // End of access checks. $config = new ttConfigHelper($user->getConfig()); -$projects = ttGroupHelper::getActiveProjects(); +$bindTemplatesWithProjects = $config->getDefinedValue('bind_templates_with_projects'); +if ($bindTemplatesWithProjects) + $projects = ttGroupHelper::getActiveProjects(); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -50,8 +52,10 @@ $cl_content = trim($request->getParameter('content')); $cl_projects = $request->getParameter('projects'); } else { - foreach ($projects as $project_item) - $cl_projects[] = $project_item['id']; + if ($bindTemplatesWithProjects) { + foreach ($projects as $project_item) + $cl_projects[] = $project_item['id']; + } } $form = new Form('templateForm'); @@ -82,7 +86,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_projects', count($projects) > 0 && $config->getDefinedValue('bind_templates_with_projects')); +$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0); $smarty->assign('title', $i18n->get('title.add_template')); $smarty->assign('content_page_name', 'template_add.tpl'); $smarty->display('index.tpl'); diff --git a/template_edit.php b/template_edit.php index 7619e7378..ef2b38cf1 100644 --- a/template_edit.php +++ b/template_edit.php @@ -104,7 +104,7 @@ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0 && $bindTemplatesWithProjects); +$smarty->assign('show_projects', $bindTemplatesWithProjects && count($projects) > 0); $smarty->assign('title', $i18n->get('title.edit_template')); $smarty->assign('content_page_name', 'template_edit.tpl'); $smarty->display('index.tpl'); From c7fb55551bd14b7d9f649a085c7fff11d18de768 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 7 Jul 2020 20:00:46 +0000 Subject: [PATCH 033/695] Some usability fixes for templates plugin. --- WEB-INF/lib/ttGroupHelper.class.php | 5 +++-- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 7 +++++-- WEB-INF/templates/time_script.tpl | 6 ++++-- templates.php | 5 ++++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 83ffe648c..af8d55345 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -174,7 +174,8 @@ static function markGroupDeleted($group_id) { 'tt_config', 'tt_predefined_expenses', 'tt_client_project_binds', - 'tt_project_task_binds' + 'tt_project_task_binds', + 'tt_project_template_binds' ); foreach($tables_to_delete_from as $table) { if (!ttGroupHelper::deleteGroupEntriesFromTable($group_id, $table)) @@ -187,7 +188,7 @@ static function markGroupDeleted($group_id) { // // 1) Users may mark some of them deleted during their work. // If we mark all of them deleted here, we can't recover nicely - // as we'll lose track of what was accidentally deleted by user. + // as we'll lose track of what was deleted by users. // // 2) DB maintenance script (Clean up DB from inactive groups) should // get rid of these items permanently eventually. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3cdabc241..25f44c0e6 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.18.5207 | Copyright © Anuko | +  Anuko Time Tracker 1.19.18.5208 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index 71b7daebc..a22325788 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -48,12 +48,15 @@ {/if}
+ +{if $show_bind_with_projects_checkbox} - + +{/if} - + diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 709a7cff7..2c6364305 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -83,8 +83,10 @@ function fillDropdowns() { if(document.body.contains(document.timeRecordForm.client)) fillProjectDropdown(document.timeRecordForm.client.value); - fillTaskDropdown(document.timeRecordForm.project.value); - fillTemplateDropdown(document.timeRecordForm.project.value); + if(document.body.contains(document.timeRecordForm.project)) { + fillTaskDropdown(document.timeRecordForm.project.value); + fillTemplateDropdown(document.timeRecordForm.project.value); + } prepopulateNote(); } diff --git a/templates.php b/templates.php index fec66b599..45ea2e477 100644 --- a/templates.php +++ b/templates.php @@ -42,6 +42,8 @@ // End of access checks. $config = $user->getConfigHelper(); +$trackingMode = $user->getTrackingMode(); +$showBindWithProjectsCheckbox = $trackingMode != MODE_TIME; if ($request->isPost()) { $cl_bind_templates_with_projects = $request->getParameter('bind_templates_with_projects'); @@ -52,7 +54,7 @@ } $form = new Form('templatesForm'); -$form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); +if ($showBindWithProjectsCheckbox) $form->addInput(array('type'=>'checkbox','name'=>'bind_templates_with_projects','value'=>$cl_bind_templates_with_projects)); $form->addInput(array('type'=>'checkbox','name'=>'prepopulate_note','value'=>$cl_prepopulate_note)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); @@ -79,6 +81,7 @@ $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('active_templates', $activeTemplates); $smarty->assign('inactive_templates', $inactiveTemplates); +$smarty->assign('show_bind_with_projects_checkbox', $showBindWithProjectsCheckbox); $smarty->assign('title', $i18n->get('title.templates')); $smarty->assign('content_page_name', 'templates.tpl'); $smarty->display('index.tpl'); From 79d5bdaa98570c812069ff57bfe185e5d74a73ef Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 7 Jul 2020 20:58:44 +0000 Subject: [PATCH 034/695] Cosmetic. --- WEB-INF/lib/ttGroupExportHelper.class.php | 2 +- WEB-INF/templates/templates.tpl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/WEB-INF/lib/ttGroupExportHelper.class.php b/WEB-INF/lib/ttGroupExportHelper.class.php index 91d463542..9b23edbee 100644 --- a/WEB-INF/lib/ttGroupExportHelper.class.php +++ b/WEB-INF/lib/ttGroupExportHelper.class.php @@ -470,7 +470,7 @@ function writeData() { } fwrite($this->file, $this->indentation." \n"); - // Write expense otems. + // Write expense items. // We use getRecordsChunkFromTable here to avoid out of memory condition for large tables. fwrite($this->file, $this->indentation." \n"); $offset = 0; diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index a22325788..c1ffff729 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -48,7 +48,6 @@ {/if}
{$forms.templatesForm.bind_templates_with_projects.control}{$forms.templatesForm.bind_templates_with_projects.control} {$i18n.label.what_is_it}
{$forms.templatesForm.prepopulate_note.control}{$forms.templatesForm.prepopulate_note.control} {$i18n.label.what_is_it}
- {if $show_bind_with_projects_checkbox} From c72ff82cccba42b7a4fcaea557db86b5068228bc Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 9 Jul 2020 15:47:10 +0000 Subject: [PATCH 035/695] Added project to template binds to export. --- WEB-INF/lib/ttGroupExportHelper.class.php | 27 +++++++++++++++++++++-- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/WEB-INF/lib/ttGroupExportHelper.class.php b/WEB-INF/lib/ttGroupExportHelper.class.php index 9b23edbee..843fe84f4 100644 --- a/WEB-INF/lib/ttGroupExportHelper.class.php +++ b/WEB-INF/lib/ttGroupExportHelper.class.php @@ -48,6 +48,7 @@ class ttGroupExportHelper { var $customFieldMap = array(); var $customFieldOptionMap = array(); var $favReportMap = array(); + var $templateMap = array(); // Constructor. function __construct($group_id, $file, $indentation) { @@ -218,6 +219,11 @@ function writeData() { foreach ($fav_reports as $key=>$fav_report) $this->favReportMap[$fav_report['id']] = $key + 1; + // Prepare template map. + $templates = $this->getRecordsFromTable('tt_templates'); + foreach ($templates as $key=>$template) + $this->templateMap[$template['id']] = $key + 1; + // Write roles. fwrite($this->file, $this->indentation." \n"); foreach ($roles as $role) { @@ -511,11 +517,11 @@ function writeData() { } // Write templates. - $templates = $this->getRecordsFromTable('tt_templates'); if (count($templates) > 0) { fwrite($this->file, $this->indentation." \n"); foreach ($templates as $template) { - $template_part = $this->indentation.' '."
{$forms.templatesForm.bind_templates_with_projects.control}