Skip to content

Commit

Permalink
[#977 CountryRestriction] Update execution order + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed Feb 13, 2022
1 parent bcc92ec commit 39c0c7c
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ public function __construct(string $sTable)

$this->sTable = $sTable;
$oUserModel = new UserCoreModel;

// First, clear everything
$oUserModel->clearCountries($this->sTable);

// Then, reindex the table
$aCountries = (array)$this->httpRequest->post('countries');

// Validation: Make sure at least one country has been selected
if ($this->areCountriesNotSet($aCountries)) {
\PFBC\Form::setError('form_country_restriction', t('You need to select at least one country.'));
return;
}

// Firstly, clear everything
$oUserModel->clearCountries($this->sTable);

// Secondly, reindex the table
foreach ($aCountries as $sCountry) {
if ($this->isEligibleToAdd($sCountry)) {
$oUserModel->addCountry($sCountry, $this->sTable);
Expand Down

0 comments on commit 39c0c7c

Please sign in to comment.