Unverified Commit 97a941af authored by eileen's avatar eileen 🎱 Committed by GitHub

Merge pull request #12865 from civicrm/5.6

5.6
parents 65ae4215 96e1e3f1
......@@ -227,7 +227,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form {
$defaults['description'] = CRM_Utils_Array::value('description', $this->_values);
$defaults['is_active'] = CRM_Utils_Array::value('is_active', $this->_values);
// The javascript on the form will swap these fields if it is a b_a relationship, so we compensate here
// The postprocess function will swap these fields if it is a b_a relationship, so we compensate here
$defaults['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_' . $this->_rtype, $this->_values);
$defaults['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_' . strrev($this->_rtype), $this->_values);
......@@ -578,22 +578,23 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form {
/**
* Prepares parameters to be used for create/update actions
*
* @param array $params
* @param array $values
*
* @return array
*/
private function preparePostProcessParameters($params) {
$relationshipTypeParts = explode('_', $params['relationship_type_id']);
private function preparePostProcessParameters($values) {
$params = $values;
list($relationshipTypeId, $a, $b) = explode('_', $params['relationship_type_id']);
$params['relationship_type_id'] = $relationshipTypeParts[0];
$params['contact_id_' . $relationshipTypeParts[1]] = $this->_contactId;
$params['relationship_type_id'] = $relationshipTypeId;
$params['contact_id_' . $a] = $this->_contactId;
if (empty($this->_relationshipId)) {
$params['contact_id_' . $relationshipTypeParts[2]] = explode(',', $params['related_contact_id']);
$params['contact_id_' . $b] = explode(',', $params['related_contact_id']);
}
else {
$params['id'] = $this->_relationshipId;
$params['contact_id_' . $relationshipTypeParts[2]] = $params['related_contact_id'];
$params['contact_id_' . $b] = $params['related_contact_id'];
foreach (array('start_date', 'end_date') as $dateParam) {
if (!empty($params[$dateParam])) {
......@@ -602,11 +603,11 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form {
}
}
// CRM-14612 - Don't use adv-checkbox as it interferes with the form js
$params['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_a_b', $params, 0);
$params['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_b_a', $params, 0);
// If this is a b_a relationship these form elements are flipped
$params['is_permission_a_b'] = CRM_Utils_Array::value("is_permission_{$a}_{$b}", $values, 0);
$params['is_permission_b_a'] = CRM_Utils_Array::value("is_permission_{$b}_{$a}", $values, 0);
return array($params, $relationshipTypeParts[1]);
return array($params, $a);
}
/**
......
......@@ -121,7 +121,7 @@
</td>
</tr>
<tr class="crm-relationship-form-block-is_permission_b_a">
<td class="label"></td>
<td class="label"> </td>
<td>
{ts 1=$contact_b|ucfirst 2=$display_name_a}Permission for <strong>%1</strong> to access information about <strong>%2</strong>{/ts}<br />
{$form.is_permission_b_a.html}
......@@ -262,10 +262,6 @@
// Show/hide employer field
$('.crm-relationship-form-block-is_current_employer', $form).toggle(rType === {/literal}'{$employmentRelationship}'{literal});
// Swap the permission checkboxes to match selected relationship direction
$('#is_permission_a_b', $form).attr('name', 'is_permission_' + source + '_' + target);
$('#is_permission_b_a', $form).attr('name', 'is_permission_' + target + '_' + source);
CRM.buildCustomData('Relationship', rType);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment