Skip to content

Commit

Permalink
ENH #16378: New Plugin Event: beforeTokenImport
Browse files Browse the repository at this point in the history
Code review
  • Loading branch information
gabrieljenik committed Jul 24, 2020
1 parent 9b57c8a commit 5592e59
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions application/controllers/admin/tokens.php
Expand Up @@ -2167,13 +2167,15 @@ public function import($iSurveyId)
$event->set('importDone', false);
$event->set('importValid', true);
App()->getPluginManager()->dispatchEvent($event);
$bPluginReportedError = !is_null($event->get('importValid')) && !$event->get('importValid');
$bPluginReportedError = !$event->get('importValid');
$bImportDone = $event->get('importDone');

if ($bPluginReportedError) {
// If plugin says import is not valid, append the error
$sErrorMessage = $event->get('errorMessage');
if (empty($sErrorMessage)) $sErrorMessage = gT("%s records with other errors");
if (empty($sErrorMessage)) {
$sErrorMessage = gT("%s records with other errors");
}

$sTokenSpecificErrorMessage = $event->get('tokenSpecificErrorMessage');
if (!empty($sTokenSpecificErrorMessage)) {
Expand Down Expand Up @@ -2213,7 +2215,9 @@ public function import($iSurveyId)
$bImportDone = true;
}
}
if ($bImportDone) $iRecordImported++;
if ($bImportDone) {
$iRecordImported++;
}
$iRecordOk++;
}
$iRecordCount++;
Expand Down

0 comments on commit 5592e59

Please sign in to comment.