Skip to content

Commit

Permalink
ENH #16378: New Plugin Event: beforeTokenImport
Browse files Browse the repository at this point in the history
Adding importDone as new parameter.
  • Loading branch information
gabrieljenik committed Jul 23, 2020
1 parent 645db58 commit 9b57c8a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions application/controllers/admin/tokens.php
Expand Up @@ -2164,8 +2164,11 @@ public function import($iSurveyId)
$event->set('params', $params);
$event->set('recordCount', $iRecordCount);
$event->set('token', $aWriteArray);
$event->set('importDone', false);
$event->set('importValid', true);
App()->getPluginManager()->dispatchEvent($event);
$bPluginReportedError = !is_null($event->get('importValid')) && !$event->get('importValid');
$bImportDone = $event->get('importDone');

if ($bPluginReportedError) {
// If plugin says import is not valid, append the error
Expand All @@ -2183,7 +2186,7 @@ public function import($iSurveyId)
$aWriteArray = $event->get('token');
}

if (!$bDuplicateFound && !$bInvalidEmail && !$bInvalidToken && !$bPluginReportedError) {
if (!$bDuplicateFound && !$bInvalidEmail && !$bInvalidToken && !$bPluginReportedError && !$bImportDone) {
// unset all empty value
foreach ($aWriteArray as $key => $value) {
if ($aWriteArray[$key] == "") {
Expand All @@ -2207,9 +2210,10 @@ public function import($iSurveyId)
$errors = ($oToken->getErrors());
$aModelErrorList[] = sprintf(gT("Line %s : %s"), $iRecordCount, print_r($errors, true));
} else {
$iRecordImported++;
$bImportDone = true;
}
}
if ($bImportDone) $iRecordImported++;
$iRecordOk++;
}
$iRecordCount++;
Expand Down

0 comments on commit 9b57c8a

Please sign in to comment.