Skip to content

feat: add country support#742

Open
anonymoususer72041 wants to merge 6 commits into
opencats:masterfrom
anonymoususer72041:feat/country-support
Open

feat: add country support#742
anonymoususer72041 wants to merge 6 commits into
opencats:masterfrom
anonymoususer72041:feat/country-support

Conversation

@anonymoususer72041

Copy link
Copy Markdown
Contributor

Summary

This PR adds country support to the core address-bearing entities in OpenCATS by introducing a country field for companies, contacts, candidates and job orders across the schema, legacy data layer, UI forms, AJAX location helpers and the newer entity/repository coverage where applicable.

It also adds country selection support to the Career Portal, including the shipped default apply template and candidate profile handling, so candidate address data can be captured and preserved consistently instead of assuming a single-country setup.

In addition, this PR updates Career Portal job location rendering to use a unified <location> placeholder so locations can include country information cleanly. The default Job Details templates are updated accordingly, and a schema migration upgrades stored default templates that still use the legacy <city> / <state> pattern.

Note: Custom Career Portal templates that still reference <city> and/or <state> will no longer render a location and must be updated to use <location>

Motivation

The main goal of this change is to make OpenCATS usable for recruiters and staffing agencies that operate across national borders by introducing an explicit way to distinguish and store country information.

It also serves as groundwork for restoring zip lookup on top of country-aware location data, so future improvements can avoid relying on a fixed country assumption such as the current US-based behavior.

@anonymoususer72041 anonymoususer72041 force-pushed the feat/country-support branch 3 times, most recently from 87e5e60 to 261c9ee Compare April 15, 2026 12:05
@anonymoususer72041

Copy link
Copy Markdown
Contributor Author

Please merge #743 first.

In order to keep the country fixture semantically correct, I changed

(40001, 1, 30001, 20002, 1, 1, 1, '', 'OpenCATS Tester', '', '', 'H', '', '', '', 'Active', 0, 1, 'London', 'United Kingdom', NULL, '2016-08-10 14:48:21', '2016-08-10 15:03:11', 0, 0, 0, 1, NULL);

to

(40001, 1, 30001, 20002, 1, 1, 1, '', 'OpenCATS Tester', '', '', 'H', '', '', '', 'Active', 0, 1, 'London', NULL, 'GB', NULL, '2016-08-10 14:48:21', '2016-08-10 15:03:11', 0, 0, 0, 1, NULL);

Without #743, this branch still needs a workaround in test/data/securityTests.sql because joborder.state is not nullable at the schema level.

@RussH

RussH commented Apr 24, 2026

Copy link
Copy Markdown
Member

My main concern here is that he google geocoding in /lib/ZipLookup.php is not broken. Google lookup currently returns the country long name, while the new country select appears to expect the ISO-style country code. Could you please make sure the zip/geocode lookup is also amended so it maps Google’s country component using short_name rather than long_name, and stores the values like "US" rather than "United States"?

@anonymoususer72041 anonymoususer72041 requested a review from RussH May 2, 2026 14:37
@anonymoususer72041 anonymoususer72041 added this to the 1.0.0 milestone May 4, 2026
@anonymoususer72041 anonymoususer72041 force-pushed the feat/country-support branch 3 times, most recently from 618c0cb to 5c80c52 Compare May 24, 2026 16:44

@RussH RussH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I’d like checked before merge: please re-check the final argument ordering in the CareersUI::onApplyToJobOrder() calls to Candidates::add() and Candidates::update().

Candidates::add() now has $skipHistory = false, $country = '' at the end, while Candidates::update() now has $country = false at the end. The careers portal calls appear to add $country in a way that may not line up with those signatures, especially the update call where an extra false is passed before $country. That could cause issues?

Minor maintainability point: there are also a few new direct htmlspecialchars() calls when building the country dropdown. These should ideally reuse the existing OpenCATS escaping/helper approach rather than introducing more inline escaping logic.

If you can fix the candidate add/update argument ordering and fix the merge conflict I’m happy with the rest of the direction.

* Remove legacy `<city>` / `<state>` placeholder handling from the public Career Portal template rendering and rely on `<location>` only

* Update the shipped default Job Details template to use `<location>` and add a safe schema migration that upgrades stored default Job Details templates

* Note: Custom Career Portal templates that still reference `<city>` and/or `<state>` will no longer render a location and must be updated to use `<location>`

@RussH RussH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to double-check?

Can you re-check the argument order for the candidate add/update calls, especially in the career portal apply/update flow? Since Candidates::add() and Candidates::update() have slightly different trailing args, I want to make sure $country is not getting passed into the wrong slot or skipped in one path.

For the country dropdown output, can we use the existing OpenCATS functions  instead of direct htmlspecialchars() calls? For normal HTML text output, Template::escapeHtml($value) is the helper I’d expect?

@anonymoususer72041

Copy link
Copy Markdown
Contributor Author

Thanks @RussH. I believe this should already be addressed in the follow-up changes from last month: https://github.com/opencats/OpenCATS/compare/5c80c52ed7411a4331cd2320aaa5241188031c75..cd1c227d2785515aaeeb87994f8d324e6f269670

I re-checked the current branch and the career portal calls now pass the candidate country in the expected position. For Candidates::add(), the extra false before $country is intentional because it maps to $skipHistory. For Candidates::update(), $country is passed as the final argument.

The country dropdown is also generated through TemplateUtility::getCountrySelectHTML() now, which uses the existing template escaping helpers rather than inline htmlspecialchars() calls.

That is why I requested another re-review last month after pushing those changes. Please let me know if I missed a remaining case or if you had a different spot in mind.

@anonymoususer72041 anonymoususer72041 requested a review from RussH June 24, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants