$this->buildVersion = $buildVersion;
if ($verbose) {
- echo "Parsing schema description " . $schemaPath . "\n";
+ echo 'Parsing schema description ' . $schemaPath . "\n";
}
$dbXML = CRM_Core_CodeGen_Util_Xml::parse($schemaPath);
// add archive tables here
foreach ($this->tables as $name => $table) {
- if ($table['archive'] == 'true') {
+ if ($table['archive'] === 'true') {
$name = 'archive_' . $table['name'];
$table['name'] = $name;
$table['archive'] = 'false';
if (isset($table['foreignKey'])) {
foreach ($table['foreignKey'] as $fkName => $fkValue) {
- if ($this->tables[$fkValue['table']]['archive'] == 'true') {
+ if ($this->tables[$fkValue['table']]['archive'] === 'true') {
$table['foreignKey'][$fkName]['table'] = 'archive_' . $table['foreignKey'][$fkName]['table'];
$table['foreignKey'][$fkName]['uniqName']
= str_replace('FK_', 'FK_archive_', $table['foreignKey'][$fkName]['uniqName']);
default:
$field['sqlType'] = $type;
- if ($type == 'int unsigned' || $type == 'tinyint') {
+ if ($type === 'int unsigned' || $type === 'tinyint') {
$field['crmType'] = 'CRM_Utils_Type::T_INT';
}
else {
$field['comment'] = $this->value('comment', $fieldXML);
$field['deprecated'] = $this->value('deprecated', $fieldXML, FALSE);
$field['default'] = $this->value('default', $fieldXML);
- $field['import'] = $this->value('import', $fieldXML);
- if ($this->value('export', $fieldXML)) {
- $field['export'] = $this->value('export', $fieldXML);
+ $import = $this->value('import', $fieldXML) ? strtoupper($this->value('import', $fieldXML)) : 'FALSE';
+ $export = $this->value('export', $fieldXML) ? strtoupper($this->value('export', $fieldXML)) : NULL;
+ if (!isset($fieldXML->usage)) {
+ $usage = [
+ 'import' => $import,
+ 'export' => $export ?? $import,
+ ];
}
else {
- $field['export'] = $this->value('import', $fieldXML);
- }
+ $usage = [];
+ foreach ($fieldXML->usage->children() as $usedFor => $isUsed) {
+ $usage[$usedFor] = strtoupper((string) $isUsed);
+ }
+ $import = $usage['import'] ?? $import;
+ }
+ // Ensure all keys are populated. Import is the historical de-facto default.
+ $field['usage'] = array_merge(array_fill_keys(['import', 'export', 'duplicate_matching'], $import), $usage);
+ // Usage for tokens has not historically been in the metadata so we can default to FALSE.
+ // historically hard-coded lists have been used.
+ $field['usage']['token'] = $field['usage']['token'] ?? 'FALSE';
+ $field['import'] = $field['usage']['import'];
+ $field['export'] = $export ?? $import;
$field['rule'] = $this->value('rule', $fieldXML);
$field['title'] = $this->value('title', $fieldXML);
if (!$field['title']) {
* @param $object
* @param null $default
*
- * @return null|string
+ * @return null|string|\SimpleXMLElement
*/
protected function value($key, &$object, $default = NULL) {
if (isset($object->$key)) {
*
* Generated from xml/schema/CRM/Core/Address.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d528ca80d405aaf51c9868b4a491329d)
+ * (GenCodeChecksum:93cff77485ca748e88906bcb5d61bf22)
*/
/**
'title' => ts('Address ID'),
'description' => ts('Unique Address ID'),
'required' => TRUE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.id',
'export' => TRUE,
'table_name' => 'civicrm_address',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Contact ID'),
'description' => ts('FK to Contact ID'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.contact_id',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Address Location Type'),
'description' => ts('Which Location does this address belong to.'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.location_type_id',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'title' => ts('Is Primary'),
'description' => ts('Is this the primary address.'),
'required' => TRUE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.is_primary',
'default' => '0',
'table_name' => 'civicrm_address',
'title' => ts('Is Billing Address'),
'description' => ts('Is this the billing address.'),
'required' => TRUE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.is_billing',
'default' => '0',
'table_name' => 'civicrm_address',
delivery, etc.).'),
'maxlength' => 96,
'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.street_address',
'headerPattern' => '/(street|address)/i',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Street Number'),
'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_number',
'export' => TRUE,
'table_name' => 'civicrm_address',
'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
'maxlength' => 8,
'size' => CRM_Utils_Type::EIGHT,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_number_suffix',
'export' => TRUE,
'table_name' => 'civicrm_address',
'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
'maxlength' => 8,
'size' => CRM_Utils_Type::EIGHT,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_number_predirectional',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_name',
'export' => TRUE,
'table_name' => 'civicrm_address',
'description' => ts('St, Rd, Dr, etc.'),
'maxlength' => 8,
'size' => CRM_Utils_Type::EIGHT,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_type',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
'maxlength' => 8,
'size' => CRM_Utils_Type::EIGHT,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_number_postdirectional',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
'maxlength' => 16,
'size' => CRM_Utils_Type::TWELVE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.street_unit',
'export' => TRUE,
'table_name' => 'civicrm_address',
'description' => ts('Supplemental Address Information, Line 1'),
'maxlength' => 96,
'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.supplemental_address_1',
'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
'description' => ts('Supplemental Address Information, Line 2'),
'maxlength' => 96,
'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.supplemental_address_2',
'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
'description' => ts('Supplemental Address Information, Line 3'),
'maxlength' => 96,
'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.supplemental_address_3',
'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
'description' => ts('City, Town or Village Name.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.city',
'headerPattern' => '/city/i',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('County ID'),
'description' => ts('Which County does this address belong to.'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.county_id',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('State/Province ID'),
'description' => ts('Which State_Province does this address belong to.'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.state_province_id',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
'maxlength' => 12,
'size' => 3,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.postal_code_suffix',
'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
'maxlength' => 64,
'size' => 6,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.postal_code',
'headerPattern' => '/postal|zip/i',
'description' => ts('USPS Bulk mailing code.'),
'maxlength' => 32,
'size' => CRM_Utils_Type::MEDIUM,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.usps_adc',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Country ID'),
'description' => ts('Which Country does this address belong to.'),
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.country_id',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'type' => CRM_Utils_Type::T_FLOAT,
'title' => ts('Latitude'),
'description' => ts('Latitude'),
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.geo_code_1',
'headerPattern' => '/geo/i',
'type' => CRM_Utils_Type::T_FLOAT,
'title' => ts('Longitude'),
'description' => ts('Longitude'),
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.geo_code_2',
'headerPattern' => '/geo/i',
'title' => ts('Is Manually Geocoded'),
'description' => ts('Is this a manually entered geo code'),
'required' => TRUE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => TRUE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.manual_geo_code',
'export' => TRUE,
'default' => '0',
'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
'maxlength' => 8,
'size' => CRM_Utils_Type::EIGHT,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
'where' => 'civicrm_address.timezone',
'table_name' => 'civicrm_address',
'entity' => 'Address',
'title' => ts('Address Name'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.name',
'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Master Address ID'),
'description' => ts('FK to Address ID'),
+ 'usage' => [
+ 'import' => TRUE,
+ 'export' => TRUE,
+ 'duplicate_matching' => TRUE,
+ 'token' => FALSE,
+ ],
'import' => TRUE,
'where' => 'civicrm_address.master_id',
'export' => TRUE,