Feature: Add configurable default phone country calling code #686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces support for a configurable default phone country calling code and updates phone number handling to normalize numbers to E.164 where possible.
The changes include:
Backend support for E.164 normalization
StringUtility::extractPhoneNumberE164($string)to normalize phone numbers:00to+(e.g.0049...→+49...).+.+, it is treated as an E.164-style number and returned as-is (after normalization).+, the default phone country calling code is applied and the number is converted to E.164.StringUtility::extractPhoneNumber($string)to delegate toextractPhoneNumberE164($string), while keeping the previous NANP-based implementation as commented legacy code for future refactoring.Site configuration for default phone country calling code
default_phone_country_code(VARCHAR(8), default'+1') to thesitetable in the schema and schema migration.Session::getDefaultPhoneCountryCode()/Session::setDefaultPhoneCountryCode()andSite::setDefaultPhoneCountryCode()).Installer support (new installations)
+prefixed text input (defaultPhoneCountryCodeDigits) that only accepts digits on the client side.+<digits>in thesite.default_phone_country_codecolumn when the installer completes.+1as part of the schema migration and can then adjust it via the Admin UI.Admin UI (Localization settings)
+49→49).+<digits>viaSite::setDefaultPhoneCountryCode().Motivation
Historically, OpenCATS relied on a NANP-centric phone number format and hard-coded assumptions such as the country code
+1. This causes several issues for non-US/Canadian users:By introducing a configurable default phone country calling code and moving phone number handling toward E.164, this Pull Request:
+1for existing databases (through the schema default),extractPhoneNumber()logic as commented legacy code to make a future refactor easier to understand,Overall, this is a first, backward-compatible step toward better internationalized phone number handling, while still fitting cleanly into existing OpenCATS patterns for configuration, schema updates, and settings UI.