Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
justinfreeman (Agileware)
Core
Commits
f0fc26a5
Commit
f0fc26a5
authored
11 years ago
by
lobo
Browse files
Options
Downloads
Patches
Plain Diff
fix formatting
parent
28be3fb1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Contact/BAO/Relationship.php
+28
-16
28 additions, 16 deletions
CRM/Contact/BAO/Relationship.php
with
28 additions
and
16 deletions
CRM/Contact/BAO/Relationship.php
+
28
−
16
View file @
f0fc26a5
...
@@ -113,9 +113,11 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
...
@@ -113,9 +113,11 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
}
}
else
{
else
{
// check for duplicate relationship
// check for duplicate relationship
//@todo this code doesn't cope well with updates - causes e-Notices. API has a lot of code to work around
// @todo this code doesn't cope well with updates - causes e-Notices.
// API has a lot of code to work around
// this but should review this code & remove the extra handling from the api
// this but should review this code & remove the extra handling from the api
// it seems doubtful any of this is relevant if the contact fields & relationship type fields are not set
// it seems doubtful any of this is relevant if the contact fields & relationship
// type fields are not set
if
(
if
(
self
::
checkDuplicateRelationship
(
self
::
checkDuplicateRelationship
(
$params
,
$params
,
...
@@ -199,7 +201,9 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
...
@@ -199,7 +201,9 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
* @static
* @static
*/
*/
static
function
add
(
&
$params
,
$ids
=
array
(),
$contactId
=
NULL
)
{
static
function
add
(
&
$params
,
$ids
=
array
(),
$contactId
=
NULL
)
{
$relationshipId
=
CRM_Utils_Array
::
value
(
'relationship'
,
$ids
,
CRM_Utils_Array
::
value
(
'id'
,
$params
));
$relationshipId
=
CRM_Utils_Array
::
value
(
'relationship'
,
$ids
,
CRM_Utils_Array
::
value
(
'id'
,
$params
));
$hook
=
'create'
;
$hook
=
'create'
;
if
(
$relationshipId
)
{
if
(
$relationshipId
)
{
$hook
=
'edit'
;
$hook
=
'edit'
;
...
@@ -209,14 +213,16 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
...
@@ -209,14 +213,16 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
$relationshipTypes
=
CRM_Utils_Array
::
value
(
'relationship_type_id'
,
$params
);
$relationshipTypes
=
CRM_Utils_Array
::
value
(
'relationship_type_id'
,
$params
);
// expolode the string with _ to get the relationship type id and to know which contact has to be inserted in
// explode the string with _ to get the relationship type id
// and to know which contact has to be inserted in
// contact_id_a and which one in contact_id_b
// contact_id_a and which one in contact_id_b
list
(
$type
,
$first
,
$second
)
=
explode
(
'_'
,
$relationshipTypes
);
list
(
$type
,
$first
,
$second
)
=
explode
(
'_'
,
$relationshipTypes
);
$
{
'contact_'
.
$first
}
=
CRM_Utils_Array
::
value
(
'contact'
,
$ids
);
$
{
'contact_'
.
$first
}
=
CRM_Utils_Array
::
value
(
'contact'
,
$ids
);
$
{
'contact_'
.
$second
}
=
$contactId
;
$
{
'contact_'
.
$second
}
=
$contactId
;
//check if the relationship type is Head of Household then update the household's primary contact with this contact.
// check if the relationship type is Head of Household then update the
// household's primary contact with this contact.
if
(
$type
==
6
)
{
if
(
$type
==
6
)
{
CRM_Contact_BAO_Household
::
updatePrimaryContact
(
$contact_b
,
$contact_a
);
CRM_Contact_BAO_Household
::
updatePrimaryContact
(
$contact_b
,
$contact_a
);
}
}
...
@@ -664,14 +670,16 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
...
@@ -664,14 +670,16 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
$relationshipTypeId
=
CRM_Utils_Array
::
value
(
'relationship_type_id'
,
$params
);
$relationshipTypeId
=
CRM_Utils_Array
::
value
(
'relationship_type_id'
,
$params
);
list
(
$type
,
$first
,
$second
)
=
explode
(
'_'
,
$relationshipTypeId
);
list
(
$type
,
$first
,
$second
)
=
explode
(
'_'
,
$relationshipTypeId
);
$queryString
=
" SELECT id
$queryString
=
"
FROM civicrm_relationship
SELECT id
WHERE relationship_type_id = "
.
CRM_Utils_Type
::
escape
(
$type
,
'Integer'
);
FROM civicrm_relationship
WHERE relationship_type_id = "
.
CRM_Utils_Type
::
escape
(
$type
,
'Integer'
);
/*
/*
* CRM-11792 - date fields from API are in ISO format, but this function supports date arrays
* CRM-11792 - date fields from API are in ISO format, but this function
* BAO has increasingly standardised to ISO format so I believe this function should support
* supports date arrays BAO has increasingly standardised to ISO format
* ISO rather than make API format it - however, need to support array format for now to avoid breakage
* so I believe this function should support ISO rather than make API
* format it - however, need to support array format for now to avoid breakage
* @ time of writing this function is called from Relationship::create (twice)
* @ time of writing this function is called from Relationship::create (twice)
* CRM_BAO_Contact_Utils::clearCurrentEmployer (seemingly without dates)
* CRM_BAO_Contact_Utils::clearCurrentEmployer (seemingly without dates)
* CRM_Contact_Form_Task_AddToOrganization::postProcess &
* CRM_Contact_Form_Task_AddToOrganization::postProcess &
...
@@ -683,16 +691,20 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
...
@@ -683,16 +691,20 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
foreach
(
$dateFields
as
$dateField
){
foreach
(
$dateFields
as
$dateField
){
if
(
array_key_exists
(
$dateField
,
$params
))
{
if
(
array_key_exists
(
$dateField
,
$params
))
{
if
(
empty
(
$params
[
$dateField
])
||
$params
[
$dateField
]
==
'null'
){
if
(
empty
(
$params
[
$dateField
])
||
$params
[
$dateField
]
==
'null'
){
//this is most likely coming from an api call & probably loaded from the DB to deal with some of the
//this is most likely coming from an api call & probably loaded
//other myriad of excessive checks still in place both in the api & the create functions
// from the DB to deal with some of the
// other myriad of excessive checks still in place both in
// the api & the create functions
$queryString
.
=
" AND
$dateField
IS NULL"
;
$queryString
.
=
" AND
$dateField
IS NULL"
;
continue
;
continue
;
}
}
elseif
(
is_array
(
$params
[
$dateField
])){
elseif
(
is_array
(
$params
[
$dateField
])){
$queryString
.
=
" AND
$dateField
= "
.
CRM_Utils_Type
::
escape
(
CRM_Utils_Date
::
format
(
$params
[
$dateField
]),
'Date'
);
$queryString
.
=
" AND
$dateField
= "
.
CRM_Utils_Type
::
escape
(
CRM_Utils_Date
::
format
(
$params
[
$dateField
]),
'Date'
);
}
}
else
{
else
{
$queryString
.
=
" AND
$dateField
= "
.
CRM_Utils_Type
::
escape
(
$params
[
$dateField
],
'Date'
);
$queryString
.
=
" AND
$dateField
= "
.
CRM_Utils_Type
::
escape
(
$params
[
$dateField
],
'Date'
);
}
}
}
}
}
}
...
...
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