Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
civirules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
civirules
Commits
4072fc73
Commit
4072fc73
authored
9 years ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
fixed a few errors
parent
14452a35
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Civirules/TriggerData/TriggerData.php
+3
-2
3 additions, 2 deletions
CRM/Civirules/TriggerData/TriggerData.php
CRM/CivirulesPostTrigger/Case.php
+48
-3
48 additions, 3 deletions
CRM/CivirulesPostTrigger/Case.php
with
51 additions
and
5 deletions
CRM/Civirules/TriggerData/TriggerData.php
+
3
−
2
View file @
4072fc73
...
...
@@ -48,14 +48,15 @@ abstract class CRM_Civirules_TriggerData_TriggerData {
* @return int
*/
public
function
getContactId
()
{
if
(
$this
->
contact_id
)
{
if
(
!
empty
(
$this
->
contact_id
)
)
{
return
$this
->
contact_id
;
}
foreach
(
$this
->
entity_data
as
$data
)
{
foreach
(
$this
->
entity_data
as
$entity
=>
$data
)
{
if
(
!
empty
(
$data
[
'contact_id'
]))
{
return
$data
[
'contact_id'
];
}
}
return
null
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
CRM/CivirulesPostTrigger/Case.php
+
48
−
3
View file @
4072fc73
...
...
@@ -29,19 +29,19 @@ class CRM_CivirulesPostTrigger_Case extends CRM_Civirules_Trigger_Post {
* @param $objectRef
*/
public
function
triggerTrigger
(
$op
,
$objectName
,
$objectId
,
$objectRef
)
{
$t
riggerData
=
$this
->
getTriggerDataFromPost
(
$op
,
$objectName
,
$objectId
,
$objectRef
);
$t
=
$this
->
getTriggerDataFromPost
(
$op
,
$objectName
,
$objectId
,
$objectRef
);
//trigger for each client
$clients
=
CRM_Case_BAO_Case
::
getCaseClients
(
$objectId
);
foreach
(
$clients
as
$client
)
{
$triggerData
=
clone
$t
;
$roleData
=
array
();
$roleData
[
'contact_id'
]
=
$client
;
$roleData
[
'is_client'
]
=
true
;
$triggerData
->
setEntityData
(
'CaseRole'
,
$roleData
);
$triggerData
->
setEntityData
(
'Relationship'
,
null
);
CRM_Civirules_Engine
::
triggerRule
(
$this
,
clone
$triggerData
);
CRM_Civirules_Engine
::
triggerRule
(
$this
,
$triggerData
);
}
//trigger for each case role
...
...
@@ -78,4 +78,49 @@ class CRM_CivirulesPostTrigger_Case extends CRM_Civirules_Trigger_Post {
return
$entities
;
}
/**
* Get trigger data belonging to this specific post event
*
* Sub classes could override this method. E.g. a post on GroupContact doesn't give on object of GroupContact
* it rather gives an array with contact Id's
*
* @param $op
* @param $objectName
* @param $objectId
* @param $objectRef
* @return CRM_Civirules_TriggerData_Edit|CRM_Civirules_TriggerData_Post
*/
protected
function
getTriggerDataFromPost
(
$op
,
$objectName
,
$objectId
,
$objectRef
)
{
$entity
=
CRM_Civirules_Utils_ObjectName
::
convertToEntity
(
$objectName
);
//set data
$data
=
array
();
if
(
is_object
(
$objectRef
))
{
CRM_Core_DAO
::
storeValues
(
$objectRef
,
$data
);
}
elseif
(
is_array
(
$objectRef
))
{
$data
=
$objectRef
;
}
//retrieve extra data from the database because the objectRef does not contain all
//data from the case
$case_data
=
civicrm_api3
(
'Case'
,
'getsingle'
,
array
(
'id'
=>
$objectId
));
foreach
(
$case_data
as
$key
=>
$value
)
{
if
(
!
isset
(
$data
[
$key
]))
{
$data
[
$key
]
=
$value
;
}
}
//unset contact_id
unset
(
$data
[
'contact_id'
]);
if
(
$op
==
'edit'
)
{
//set also original data with an edit event
$oldData
=
CRM_Civirules_Utils_PreData
::
getPreData
(
$entity
,
$objectId
);
$triggerData
=
new
CRM_Civirules_TriggerData_Edit
(
$entity
,
$objectId
,
$data
,
$oldData
);
}
else
{
$triggerData
=
new
CRM_Civirules_TriggerData_Post
(
$entity
,
$objectId
,
$data
);
}
return
$triggerData
;
}
}
\ No newline at end of file
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