From 0825270a9b1a47a73e08f00ecd9191c227fbdd8c Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 31 Mar 2019 13:36:49 +0000 Subject: [PATCH] Changed required template elements to 3 stop sign emojis for visibility. --- WEB-INF/lib/common.lib.php | 9 +++++++++ WEB-INF/templates/footer.tpl | 2 +- mobile/time.php | 3 +-- mobile/time_edit.php | 3 +-- time.php | 3 +-- time_edit.php | 3 +-- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index e09a943f..e2950753 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -182,6 +182,15 @@ function ttValidString($val, $emptyValid = false) return true; } +// ttValidTemplateText is used to check template-based user input. +// When templates are used, required input parts must be filled by user. +// We identify these parts by 3 "stop sign" emojis (aka "octagonal sign" U+1F6D1). +function ttValidTemplateText($val) +{ + $valid = strpos($val, '🛑🛑🛑') === false; // no 3 "stop sign" emojis in a row. + return $valid; +} + // ttValidEmail is used to check user input to validate an email string. function ttValidEmail($val, $emptyValid = false) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3f192b30..52aa91c5 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.61.4900 | Copyright © Anuko | +  Anuko Time Tracker 1.18.62.4901 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/time.php b/mobile/time.php index b9ee3bce..15069db2 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -283,8 +283,7 @@ if ($request->isPost()) { $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') && strpos($cl_note, '%req%') !== false) { - // A %req% element is found in note. They have to be replaced by user. + 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')); diff --git a/mobile/time_edit.php b/mobile/time_edit.php index c3699d53..b33b0991 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -271,8 +271,7 @@ if ($request->isPost()) { } if (!ttValidDate($cl_date)) $err->add($i18n->get('error.field'), $i18n->get('label.date')); if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); - if ($user->isPluginEnabled('tp') && strpos($cl_note, '%req%') !== false) { - // A %req% element is found in note. They have to be replaced by user. + 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')); diff --git a/time.php b/time.php index 4f0d5918..9b76587b 100644 --- a/time.php +++ b/time.php @@ -304,8 +304,7 @@ if ($request->isPost()) { $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') && strpos($cl_note, '%req%') !== false) { - // A %req% element is found in note. They have to be replaced by user. + 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')); diff --git a/time_edit.php b/time_edit.php index e6ca12ad..bbc95ead 100644 --- a/time_edit.php +++ b/time_edit.php @@ -276,8 +276,7 @@ if ($request->isPost()) { } if (!ttValidDate($cl_date)) $err->add($i18n->get('error.field'), $i18n->get('label.date')); if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); - if ($user->isPluginEnabled('tp') && strpos($cl_note, '%req%') !== false) { - // A %req% element is found in note. They have to be replaced by user. + 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')); -- 2.20.1