diff --git a/module/Application/language/en.po b/module/Application/language/en.po index 284738abf..2469a5fa6 100644 --- a/module/Application/language/en.po +++ b/module/Application/language/en.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-19 14:18+0200\n" +"POT-Creation-Date: 2024-09-02 15:08+0200\n" "PO-Revision-Date: \n" "Last-Translator: Rink Pieters \n" "Language-Team: \n" @@ -11,7 +11,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.4.4\n" +"X-Generator: Poedit 3.5\n" msgid "# Decisions" msgstr "# Decisions" @@ -1552,6 +1552,15 @@ msgstr "You have to consent to processing your data" msgid "Your API token is \"%s\". This value will NOT be shown again!" msgstr "Your API token is \"%s\". This value will NOT be shown again!" +msgid "" +"Your TU/e-username appears to be incorrect. Ensure that it starts with a " +"valid year and looks like: YYYYxxxx. If you believe your TU/e-username is " +"correct, please contact the secretary." +msgstr "" +"Your TU/e-username appears to be incorrect. Ensure that it starts with a " +"valid year and looks like: YYYYxxxx. If you believe your TU/e-username is " +"correct, please contact the secretary." + msgid "Your TU/e-username should look like sYYxxxx or YYYYxxxx." msgstr "Your TU/e-username should look like sYYxxxx or YYYYxxxx." diff --git a/module/Application/language/gewisdb.pot b/module/Application/language/gewisdb.pot index 0f0e7298f..586869abe 100644 --- a/module/Application/language/gewisdb.pot +++ b/module/Application/language/gewisdb.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: GEWISdb v2.0.0-570-g4b9a5a8f-dirty\n" +"Project-Id-Version: GEWISdb v2.0.0-590-g07dc9e8e-dirty\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-19 14:18+0200\n" +"POT-Creation-Date: 2024-09-02 15:08+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1427,6 +1427,12 @@ msgstr "" msgid "Your API token is \"%s\". This value will NOT be shown again!" msgstr "" +msgid "" +"Your TU/e-username appears to be incorrect. Ensure that it starts with a " +"valid year and looks like: YYYYxxxx. If you believe your TU/e-username is " +"correct, please contact the secretary." +msgstr "" + msgid "Your TU/e-username should look like sYYxxxx or YYYYxxxx." msgstr "" diff --git a/module/Application/language/nl.po b/module/Application/language/nl.po index 624225d58..e0c3fe5c3 100644 --- a/module/Application/language/nl.po +++ b/module/Application/language/nl.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-19 14:18+0200\n" +"POT-Creation-Date: 2024-09-02 15:08+0200\n" "PO-Revision-Date: \n" "Last-Translator: Rink Pieters \n" "Language-Team: \n" @@ -11,7 +11,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.4.4\n" +"X-Generator: Poedit 3.5\n" msgid "# Decisions" msgstr "# besluiten" @@ -390,7 +390,7 @@ msgid "Controller" msgstr "Controller" msgid "Copy Decision" -msgstr "Besluit kopiëren" +msgstr "Besluit kopiëren" #, php-format msgid "Could not add new %s!" @@ -1574,6 +1574,15 @@ msgid "Your API token is \"%s\". This value will NOT be shown again!" msgstr "" "Jouw API-sleutel is \"%s\". Deze sleutel wordt NIET opnieuw weergegeven!" +msgid "" +"Your TU/e-username appears to be incorrect. Ensure that it starts with a " +"valid year and looks like: YYYYxxxx. If you believe your TU/e-username is " +"correct, please contact the secretary." +msgstr "" +"Jouw TU/e-gebruikersnaam lijkt onjuist te zijn. Zorg ervoor dat deze begint " +"met een geldig jaartal en eruitziet als: YYYYxxxx. Als je denkt dat jouw TU/" +"e-gebruikersnaam correct is, neem dan contact op met de secretaris." + msgid "Your TU/e-username should look like sYYxxxx or YYYYxxxx." msgstr "Jouw TU/e-gebruikersnaam moet lijken op sYYxxxx of YYYYxxxx." diff --git a/module/Database/src/Form/Member.php b/module/Database/src/Form/Member.php index 570a97ba8..121adf8f5 100644 --- a/module/Database/src/Form/Member.php +++ b/module/Database/src/Form/Member.php @@ -29,7 +29,10 @@ use Laminas\Validator\StringLength; use Throwable; +use function date; +use function preg_match; use function str_ends_with; +use function substr; class Member extends Form implements InputFilterProviderInterface { @@ -399,6 +402,20 @@ public function getInputFilterSpecification(): array ], ], ], + [ + 'name' => Callback::class, + 'options' => [ + 'callback' => function ($value) { + return $this->isNewTueUsernameValid($value); + }, + 'messages' => [ + Callback::INVALID_VALUE => $this->translator->translate( + // phpcs:ignore -- user-visible strings should not be split + 'Your TU/e-username appears to be incorrect. Ensure that it starts with a valid year and looks like: YYYYxxxx. If you believe your TU/e-username is correct, please contact the secretary.', + ), + ], + ], + ], ], 'filters' => [ ['name' => ToNull::class], @@ -407,6 +424,25 @@ public function getInputFilterSpecification(): array ]; } + private function isNewTueUsernameValid(string $value): bool + { + try { + // Only check for YYYYABCD TU/e usernames. + if (preg_match('/^s\d{6}$/', $value)) { + return true; + } + + $year = substr($value, 0, 4); + $currentYear = date('Y'); + + // Check if the year is within the valid range, the assumption being that you can never have a number + // starting with a year that is higher than the current year. + return $year >= 2000 && $year <= $currentYear; + } catch (Throwable) { + return false; + } + } + private function isOldEnough(string $value): bool { try {