Fix PHP notice when validating profile forms with action "delete"
This commit is contained in:
parent
08e9418766
commit
f746a3fe06
1 changed files with 47 additions and 45 deletions
|
@ -364,58 +364,60 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
|
|
||||||
// Validate custom field mapping.
|
// Validate custom field mapping.
|
||||||
try {
|
try {
|
||||||
$custom_field_mapping = preg_split('/\r\n|\r|\n/', $values['custom_field_mapping'], -1, PREG_SPLIT_NO_EMPTY);
|
if (isset($values['custom_field_mapping'])) {
|
||||||
if (!is_array($custom_field_mapping)) {
|
$custom_field_mapping = preg_split('/\r\n|\r|\n/', $values['custom_field_mapping'], -1, PREG_SPLIT_NO_EMPTY);
|
||||||
throw new Exception(
|
if (!is_array($custom_field_mapping)) {
|
||||||
E::ts('Could not parse custom field mapping.')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
foreach ($custom_field_mapping as $custom_field_map) {
|
|
||||||
$custom_field_map = explode("=", $custom_field_map);
|
|
||||||
if (count($custom_field_map) !== 2) {
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
E::ts('Could not parse custom field mapping.')
|
E::ts('Could not parse custom field mapping.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
list($twingle_field_name, $custom_field_name) = $custom_field_map;
|
foreach ($custom_field_mapping as $custom_field_map) {
|
||||||
$custom_field_id = substr($custom_field_name, strlen('custom_'));
|
$custom_field_map = explode("=", $custom_field_map);
|
||||||
|
if (count($custom_field_map) !== 2) {
|
||||||
|
throw new Exception(
|
||||||
|
E::ts('Could not parse custom field mapping.')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
list($twingle_field_name, $custom_field_name) = $custom_field_map;
|
||||||
|
$custom_field_id = substr($custom_field_name, strlen('custom_'));
|
||||||
|
|
||||||
// Check for custom field existence
|
// Check for custom field existence
|
||||||
try {
|
try {
|
||||||
$custom_field = civicrm_api3('CustomField', 'getsingle', array(
|
$custom_field = civicrm_api3('CustomField', 'getsingle', array(
|
||||||
'id' => $custom_field_id,
|
'id' => $custom_field_id,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
catch (CiviCRM_API3_Exception $exception) {
|
catch (CiviCRM_API3_Exception $exception) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
E::ts(
|
E::ts(
|
||||||
'Custom field custom_%1 does not exist.',
|
'Custom field custom_%1 does not exist.',
|
||||||
array(1 => $custom_field_id)
|
array(1 => $custom_field_id)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only allow custom fields on relevant entities.
|
// Only allow custom fields on relevant entities.
|
||||||
try {
|
try {
|
||||||
$custom_group = civicrm_api3('CustomGroup', 'getsingle', array(
|
$custom_group = civicrm_api3('CustomGroup', 'getsingle', array(
|
||||||
'id' => $custom_field['custom_group_id'],
|
'id' => $custom_field['custom_group_id'],
|
||||||
'extends' => array(
|
'extends' => array(
|
||||||
'IN' => array(
|
'IN' => array(
|
||||||
'Contact',
|
'Contact',
|
||||||
'Individual',
|
'Individual',
|
||||||
'Organization',
|
'Organization',
|
||||||
'Contribution',
|
'Contribution',
|
||||||
'ContributionRecur',
|
'ContributionRecur',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
));
|
||||||
));
|
} catch (CiviCRM_API3_Exception $exception) {
|
||||||
} catch (CiviCRM_API3_Exception $exception) {
|
throw new Exception(
|
||||||
throw new Exception(
|
E::ts(
|
||||||
E::ts(
|
'Custom field custom_%1 is not in a CustomGroup that extends one of the supported CiviCRM entities.',
|
||||||
'Custom field custom_%1 is not in a CustomGroup that extends one of the supported CiviCRM entities.',
|
array(1 => $custom_field['id'])
|
||||||
array(1 => $custom_field['id'])
|
)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue