/** * @see LinkedToMappingRuleDataAnalyzerInterface::runAndMakeMessages() */ public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName, $mappingRuleType, $mappingRuleData) { assert('is_string($columnName)'); assert('is_string($mappingRuleType)'); assert('is_array($mappingRuleData)'); assert('is_int($mappingRuleData["type"])'); assert('$mappingRuleData["type"] == UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID || $mappingRuleData["type"] == UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID || $mappingRuleData["type"] == UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME'); $this->type = $mappingRuleData["type"]; if ($mappingRuleData['type'] == UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID) { $this->acceptableValues = UserValueTypeSanitizerUtil::getUserIds(); } elseif ($mappingRuleData['type'] == UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID) { $this->acceptableValues = UserValueTypeSanitizerUtil::getUserExternalSystemIds(); } else { $acceptableValues = UserValueTypeSanitizerUtil::getUsernames(); $this->acceptableValues = ArrayUtil::resolveArrayToLowerCase($acceptableValues); } $this->processAndMakeMessage($dataProvider, $columnName); }
protected function getAcceptableValues() { if ($this->mappingRuleData['type'] == UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID) { return UserValueTypeSanitizerUtil::getUserIds(); } elseif ($this->mappingRuleData['type'] == UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID) { return UserValueTypeSanitizerUtil::getUserExternalSystemIds(); } else { $acceptableValues = UserValueTypeSanitizerUtil::getUsernames(); return ArrayUtil::resolveArrayToLowerCase($acceptableValues); } }
/** * Check whether the value is a valid external system id. * @param object $dataProvider * @param string $columnName */ protected function resolveForTypeExternalSystemId(AnalyzerSupportedDataProvider $dataProvider, $columnName) { assert('is_string($columnName)'); $userIds = UserValueTypeSanitizerUtil::getUserExternalSystemIds(); $data = $dataProvider->getCountDataByGroupByColumnName($columnName); $count = 0; foreach ($data as $valueCountData) { if ($valueCountData[$columnName] == null) { continue; } if (!in_array($valueCountData[$columnName], $userIds)) { $count++; } } if ($count > 0) { $label = '{count} external system user id(s) specified were not found. '; $label .= 'These values will not be used during the import.'; $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count))); } }