Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
1e40fc23
Commit
1e40fc23
authored
2 months ago
by
colemanw
Browse files
Options
Downloads
Patches
Plain Diff
[REF] Relationship - Refactor out uses of deprecated CRM_Utils_Array::value
parent
310ff81a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Contact/BAO/Relationship.php
+8
-8
8 additions, 8 deletions
CRM/Contact/BAO/Relationship.php
CRM/Contact/Form/Relationship.php
+1
-1
1 addition, 1 deletion
CRM/Contact/Form/Relationship.php
CRM/Contact/Page/View/Relationship.php
+1
-1
1 addition, 1 deletion
CRM/Contact/Page/View/Relationship.php
with
10 additions
and
10 deletions
CRM/Contact/BAO/Relationship.php
+
8
−
8
View file @
1e40fc23
...
...
@@ -54,7 +54,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship implemen
$extendedParams
=
self
::
loadExistingRelationshipDetails
(
$params
);
// When id is specified we always want to update, so we don't need to check for duplicate relations.
if
(
!
isset
(
$params
[
'id'
])
&&
self
::
checkDuplicateRelationship
(
$extendedParams
,
(
int
)
$extendedParams
[
'contact_id_a'
],
(
int
)
$extendedParams
[
'contact_id_b'
],
CRM_Utils_Array
::
value
(
'id'
,
$extendedParams
,
0
))
)
{
if
(
!
isset
(
$params
[
'id'
])
&&
self
::
checkDuplicateRelationship
(
$extendedParams
,
(
int
)
$extendedParams
[
'contact_id_a'
],
(
int
)
$extendedParams
[
'contact_id_b'
],
$extendedParams
[
'id'
]
??
0
))
{
throw
new
CRM_Core_Exception
(
'Duplicate Relationship'
);
}
$params
=
$extendedParams
;
...
...
@@ -219,7 +219,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship implemen
foreach
(
self
::
getdefaults
()
as
$defaultField
=>
$defaultValue
)
{
if
(
isset
(
$params
[
$defaultField
]))
{
if
(
in_array
(
$defaultField
,
$dateFields
))
{
$relationship
->
$defaultField
=
CRM_Utils_Date
::
format
(
CRM_Utils_Array
::
value
(
$defaultField
,
$params
)
);
$relationship
->
$defaultField
=
CRM_Utils_Date
::
format
(
$params
[
$defaultField
]
??
NULL
);
if
(
!
$relationship
->
$defaultField
)
{
$relationship
->
$defaultField
=
'NULL'
;
}
...
...
@@ -271,7 +271,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship implemen
if
((
$session
->
get
(
'userID'
)
==
$relationship
->
contact_id_a
)
||
CRM_Contact_BAO_Contact_Permission
::
allow
(
$relationship
->
contact_id_a
,
CRM_Core_Permission
::
EDIT
)
)
{
$rType
=
substr
(
CRM_Utils_Array
::
value
(
'relationship_type_id'
,
$params
)
,
-
3
);
$rType
=
substr
(
$params
[
'relationship_type_id'
]
,
-
3
);
$recentOther
=
[
'editUrl'
=>
CRM_Utils_System
::
url
(
'civicrm/contact/view/rel'
,
"action=update&reset=1&id=
{
$relationship
->
id
}
&cid=
{
$relationship
->
contact_id_a
}
&rtype=
{
$rType
}
&context=home"
...
...
@@ -875,7 +875,7 @@ WHERE is_active = 1 AND relationship_type_id = ' . CRM_Utils_Type::escape($type
]);
if
(
is_array
(
$result
)
&&
!
empty
(
$result
[
'is_error'
])
&&
$result
[
'error_message'
]
!=
'Duplicate Relationship'
)
{
throw
new
CRM_Core_Exception
(
$result
[
'error_message'
],
CRM_Utils_Array
::
value
(
'error_code'
,
$result
,
'undefined'
)
,
$result
);
throw
new
CRM_Core_Exception
(
$result
[
'error_message'
],
$result
[
'error_code'
]
??
'undefined'
,
$result
);
}
return
TRUE
;
...
...
@@ -1427,7 +1427,7 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
$relTypeValues
=
[];
CRM_Contact_BAO_RelationshipType
::
retrieve
(
$relTypeParams
,
$relTypeValues
);
if
((
$relTypeValues
[
'name_a_b'
]
??
NULL
)
==
CRM_Utils_Array
::
v
alue
(
'name_b_a'
,
$relTypeValues
))
{
if
((
$relTypeValues
[
'name_a_b'
]
??
NULL
)
==
(
$relTypeV
alue
s
[
'name_b_a'
]
??
NULL
))
{
$values
[
$cid
][
'relationshipTypeDirection'
]
=
'_a_b'
;
}
else
{
...
...
@@ -1440,7 +1440,7 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
$relationshipProcessor
=
new
CRM_Member_Utils_RelationshipProcessor
(
array_keys
(
$values
),
$active
);
foreach
(
$values
as
$cid
=>
$details
)
{
$relatedContacts
=
array_keys
(
CRM_Utils_Array
::
value
(
'relatedContacts'
,
$details
,
[])
)
;
$relatedContacts
=
array_keys
(
$details
[
'relatedContacts'
]
??
[]);
$mainRelatedContactId
=
reset
(
$relatedContacts
);
foreach
(
$relationshipProcessor
->
getRelationshipMembershipsForContact
((
int
)
$cid
)
as
$membershipId
=>
$membershipValues
)
{
...
...
@@ -1879,7 +1879,7 @@ AND cc.sort_name LIKE '%$name%'";
'civicrm/contact/view'
,
"reset=1&cid=
{
$values
[
'cid'
]
}
"
);
$relationship
[
'relation'
]
=
CRM_Utils_Array
::
value
(
'case'
,
$values
,
''
)
.
CRM_Utils_System
::
href
(
$relationship
[
'relation'
]
=
(
$
value
s
[
'case'
]
??
''
)
.
CRM_Utils_System
::
href
(
$values
[
'relation'
],
'civicrm/contact/view/rel'
,
"action=view&reset=1&cid=
{
$values
[
'cid'
]
}
&id=
{
$values
[
'id'
]
}
&rtype=
{
$values
[
'rtype'
]
}
"
);
...
...
@@ -2184,7 +2184,7 @@ SELECT count(*)
AND owner_membership_id =
{
$membershipValues
[
'owner_membership_id'
]
}
AND is_current_member = 1"
;
$result
=
CRM_Core_DAO
::
singleValueQuery
(
$query
);
if
(
$result
<
CRM_Utils_Array
::
v
alue
(
'max_related'
,
$membershipValues
,
PHP_INT_MAX
))
{
if
(
$result
<
(
$membershipV
alue
s
[
'max_related'
]
??
PHP_INT_MAX
))
{
// Convert custom_xx_id fields to custom_xx
// See https://lab.civicrm.org/dev/membership/-/issues/37
// This makes sure the value is copied and not the looked up value.
...
...
This diff is collapsed.
Click to expand it.
CRM/Contact/Form/Relationship.php
+
1
−
1
View file @
1e40fc23
...
...
@@ -517,7 +517,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form {
$jsData
[
$id
]
=
array_filter
(
array_intersect_key
(
$allRelationshipNames
[
$id
],
$whatWeWant
));
// Add user-friendly placeholder
foreach
([
'a'
,
'b'
]
as
$x
)
{
$type
=
!
empty
(
$jsData
[
$id
][
"contact_sub_type_
$x
"
])
?
$jsData
[
$id
][
"contact_sub_type_
$x
"
]
:
(
CRM_Utils_Array
::
value
(
"contact_type_
$x
"
,
$jsData
[
$id
])
);
$type
=
!
empty
(
$jsData
[
$id
][
"contact_sub_type_
$x
"
])
?
$jsData
[
$id
][
"contact_sub_type_
$x
"
]
:
(
$jsData
[
$id
][
"contact_type_
$x
"
]
??
NULL
);
$jsData
[
$id
][
"placeholder_
$x
"
]
=
$type
?
ts
(
'- select %1 -'
,
[
strtolower
(
$contactTypes
[
$type
][
'label'
])])
:
ts
(
'- select contact -'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Contact/Page/View/Relationship.php
+
1
−
1
View file @
1e40fc23
...
...
@@ -100,7 +100,7 @@ class CRM_Contact_Page_View_Relationship extends CRM_Core_Page {
NULL
,
TRUE
,
NULL
,
FALSE
,
CRM_Core_Permission
::
VIEW
);
CRM_Core_BAO_CustomGroup
::
buildCustomDataView
(
$this
,
$groupTree
,
FALSE
,
NULL
,
NULL
,
NULL
,
$this
->
getEntityId
());
$rType
=
CRM_Utils_Array
::
value
(
'rtype'
,
$viewRelationship
[
$this
->
getEntityId
()]
)
;
$rType
=
$viewRelationship
[
$this
->
getEntityId
()]
[
'rtype'
]
;
// add viewed contribution to recent items list
$url
=
CRM_Utils_System
::
url
(
'civicrm/contact/view/rel'
,
"action=view&reset=1&id=
{
$viewRelationship
[
$this
->
getEntityId
()][
'id'
]
}
&cid=
{
$this
->
getContactId
()
}
&context=home"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment