From fee0416f26c839936f63dc36694bfbd2ff7541de Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Fri, 20 Jul 2018 15:09:06 -0400 Subject: [PATCH] Relationship permissions: move icons to template, change to stacked on squares --- CRM/Contact/BAO/Relationship.php | 60 +++++++++---------- templates/CRM/Contact/Form/Relationship.tpl | 16 ++--- .../Contact/Page/View/RelationshipPerm.tpl | 43 +++++++++++++ 3 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 templates/CRM/Contact/Page/View/RelationshipPerm.tpl diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index b1f74bd693..df64ddcbba 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -2130,36 +2130,36 @@ AND cc.sort_name LIKE '%$name%'"; } if ($params['context'] == 'current') { - if (($params['contact_id'] == $values['contact_id_a'] and $values['is_permission_a_b'] == CRM_Contact_BAO_Relationship::EDIT) or - ($params['contact_id'] == $values['contact_id_b'] and $values['is_permission_b_a'] == CRM_Contact_BAO_Relationship::EDIT) - ) { - $relationship['sort_name'] .= << -HEREDOC; - } - - if (($params['contact_id'] == $values['contact_id_a'] and $values['is_permission_a_b'] == CRM_Contact_BAO_Relationship::VIEW) or - ($params['contact_id'] == $values['contact_id_b'] and $values['is_permission_b_a'] == CRM_Contact_BAO_Relationship::VIEW) - ) { - $relationship['sort_name'] .= << -HEREDOC; - } - - if (($values['cid'] == $values['contact_id_a'] and $values['is_permission_a_b'] == CRM_Contact_BAO_Relationship::EDIT) or - ($values['cid'] == $values['contact_id_b'] and $values['is_permission_b_a'] == CRM_Contact_BAO_Relationship::EDIT) - ) { - $relationship['relation'] .= << -HEREDOC; - } - - if (($values['cid'] == $values['contact_id_a'] and $values['is_permission_a_b'] == CRM_Contact_BAO_Relationship::VIEW) or - ($values['cid'] == $values['contact_id_b'] and $values['is_permission_b_a'] == CRM_Contact_BAO_Relationship::VIEW) - ) { - $relationship['relation'] .= << -HEREDOC; + $smarty = CRM_Core_Smarty::singleton(); + + $contactCombos = [ + [ + 'permContact' => $params['contact_id'], + 'permDisplayName' => $displayName, + 'otherContact' => $values['cid'], + 'otherDisplayName' => $values['display_name'], + 'columnKey' => 'sort_name', + ], + [ + 'permContact' => $values['cid'], + 'permDisplayName' => $values['display_name'], + 'otherContact' => $params['contact_id'], + 'otherDisplayName' => $displayName, + 'columnKey' => 'relation', + ], + ]; + + foreach ($contactCombos as $combo) { + foreach ([CRM_Contact_BAO_Relationship::EDIT, CRM_Contact_BAO_Relationship::VIEW] as $permType) { + $smarty->assign('permType', $permType); + if (($combo['permContact'] == $values['contact_id_a'] and $values['is_permission_a_b'] == $permType) + || ($combo['permContact'] == $values['contact_id_b'] and $values['is_permission_b_a'] == $permType) + ) { + $smarty->assign('permDisplayName', $combo['permDisplayName']); + $smarty->assign('otherDisplayName', $combo['otherDisplayName']); + $relationship[$combo['columnKey']] .= $smarty->fetch('CRM/Contact/Page/View/RelationshipPerm.tpl'); + } + } } } diff --git a/templates/CRM/Contact/Form/Relationship.tpl b/templates/CRM/Contact/Form/Relationship.tpl index 55bb4060ff..cfc33721af 100644 --- a/templates/CRM/Contact/Form/Relationship.tpl +++ b/templates/CRM/Contact/Form/Relationship.tpl @@ -58,15 +58,15 @@
{if $row.rtype EQ 'a_b' AND $is_contact_id_a} {if $row.is_permission_a_b == 1} - {ts 1=$displayName 2=$row.display_name}%1 can view and update information about %2{/ts} + {ts 1=$displayName 2=$row.display_name}%1 can view and update information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=1 permDisplayName=$displayName otherDisplayName=$row.display_name} {else} - {ts 1=$displayName 2=$row.display_name}%1 can view information about %2{/ts} + {ts 1=$displayName 2=$row.display_name}%1 can view information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=2 permDisplayName=$displayName otherDisplayName=$row.display_name} {/if} {else} {if $row.is_permission_a_b == 1} - {ts 1=$row.display_name 2=$displayName}%1 can view and update information about %2{/ts} + {ts 1=$row.display_name 2=$displayName}%1 can view and update information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=1 otherDisplayName=$displayName permDisplayName=$row.display_name} {else} - {ts 1=$row.display_name 2=$displayName}%1 can view information about %2{/ts} + {ts 1=$row.display_name 2=$displayName}%1 can view information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=2 otherDisplayName=$displayName permDisplayName=$row.display_name} {/if} {/if}
@@ -75,15 +75,15 @@
{if $row.rtype EQ 'a_b' AND $is_contact_id_a} {if $row.is_permission_b_a == 1} - {ts 1=$row.display_name 2=$displayName}%1 can view and update information about %2{/ts} + {ts 1=$row.display_name 2=$displayName}%1 can view and update information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=1 otherDisplayName=$displayName permDisplayName=$row.display_name} {else} - {ts 1=$row.display_name 2=$displayName}%1 can view information about %2{/ts} + {ts 1=$row.display_name 2=$displayName}%1 can view information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=2 otherDisplayName=$displayName permDisplayName=$row.display_name} {/if} {else} {if $row.is_permission_b_a == 1} - {ts 1=$displayName 2=$row.display_name}%1 can view and update information about %2{/ts} + {ts 1=$displayName 2=$row.display_name}%1 can view and update information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=1 permDisplayName=$displayName otherDisplayName=$row.display_name} {else} - {ts 1=$displayName 2=$row.display_name}%1 can view information about %2{/ts} + {ts 1=$displayName 2=$row.display_name}%1 can view information about %2{/ts} {include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=2 permDisplayName=$displayName otherDisplayName=$row.display_name} {/if} {/if}
diff --git a/templates/CRM/Contact/Page/View/RelationshipPerm.tpl b/templates/CRM/Contact/Page/View/RelationshipPerm.tpl new file mode 100644 index 0000000000..691bc7834d --- /dev/null +++ b/templates/CRM/Contact/Page/View/RelationshipPerm.tpl @@ -0,0 +1,43 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 5 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2018 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* Partial for displaying permissions associated with a relationship *} + +{if $permType eq 1} +{include file="CRM/Contact/Page/View/RelationshipPerm.tpl" permType=2} +{/if} + +{capture assign="permText"} +{if $permType eq 1} +{ts 1=$permDisplayName 2=$otherDisplayName}%2 can be edited by %1{/ts} +{else} +{ts 1=$permDisplayName 2=$otherDisplayName}%2 can be viewed by %1{/ts} +{/if} +{/capture} + + + + + -- 2.25.1