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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
ayduns
civirules
Commits
b0f0d1eb
Commit
b0f0d1eb
authored
10 years ago
by
Erik Hommel
Browse files
Options
Downloads
Patches
Plain Diff
cleanup Engine and EditEntity
parent
af4383db
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/Engine.php
+45
-3
45 additions, 3 deletions
CRM/Civirules/Engine.php
CRM/Civirules/Event/EditEntity.php
+59
-9
59 additions, 9 deletions
CRM/Civirules/Event/EditEntity.php
with
104 additions
and
12 deletions
CRM/Civirules/Engine.php
+
45
−
3
View file @
b0f0d1eb
<?php
/**
* Class for CiviRules engine
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
class
CRM_Civirules_Engine
{
...
...
@@ -7,9 +13,11 @@ class CRM_Civirules_Engine {
*
* The trigger will check the conditions and if conditions are valid then the actions are executed
*
* @param CRM_Civirules_EventData_EventData $eventData
* @param $ruleId
* @param $eventId
* @param object CRM_Civirules_EventData_EventData $eventData
* @param int $ruleId
* @param int $eventId
* @access public
* @static
*/
public
static
function
triggerRule
(
CRM_Civirules_EventData_EventData
$eventData
,
$ruleId
,
$eventId
)
{
$eventData
->
setEventId
(
$eventId
);
...
...
@@ -22,6 +30,14 @@ class CRM_Civirules_Engine {
}
}
/**
* Method to execute the actions
*
* @param object CRM_Civirules_EventData_EventData $eventData
* @param int $ruleId
* @access protected
* @static
*/
protected
static
function
executeActions
(
CRM_Civirules_EventData_EventData
$eventData
,
$ruleId
)
{
$actionParams
=
array
(
'rule_id'
=>
$ruleId
...
...
@@ -32,6 +48,14 @@ class CRM_Civirules_Engine {
}
}
/**
* Method to execute a single action
*
* @param object CRM_Civirules_EventData_EventData $eventData
* @param array $ruleAction
* @access protected
* @static
*/
protected
static
function
executeAction
(
CRM_Civirules_EventData_EventData
$eventData
,
$ruleAction
)
{
$object
=
CRM_Civirules_BAO_Action
::
getActionObjectById
(
$ruleAction
[
'action_id'
],
true
);
if
(
!
$object
)
{
...
...
@@ -42,6 +66,15 @@ class CRM_Civirules_Engine {
$object
->
processAction
(
$eventData
);
}
/**
* Method to check if all conditions are valid
*
* @param object CRM_Civirules_EventData_EventData $eventData
* @param int $ruleId
* @return bool
* @access protected
* @static
*/
protected
static
function
areConditionsValid
(
CRM_Civirules_EventData_EventData
$eventData
,
$ruleId
)
{
$isValid
=
true
;
$firstCondition
=
true
;
...
...
@@ -74,6 +107,15 @@ class CRM_Civirules_Engine {
return
$isValid
;
}
/**
* Method to check condition
*
* @param array $ruleCondition
* @param object CRM_Civirules_EventData_EventData $eventData
* @return bool
* @access protected
* @static
*/
protected
static
function
checkCondition
(
$ruleCondition
,
CRM_Civirules_EventData_EventData
$eventData
)
{
$condition
=
CRM_Civirules_BAO_Condition
::
getConditionObjectById
(
$ruleCondition
[
'condition_id'
],
false
);
if
(
!
$condition
)
{
...
...
This diff is collapsed.
Click to expand it.
CRM/Civirules/Event/EditEntity.php
+
59
−
9
View file @
b0f0d1eb
<?php
/**
* The post event handler
* Class for CiviRules post event handling
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
class
CRM_Civirules_Event_EditEntity
{
/**
* Data set in pre and used for compare which field is changed
*
* @var array
* @var array
$preData
*/
protected
static
$preData
=
array
();
/**
* Method pre to store the entity data before the data in the database is changed
* for the edit operation
*
* @param string $op
* @param string $objectName
* @param int $objectId
* @param array $params
* @access public
* @static
*
*/
public
static
function
pre
(
$op
,
$objectName
,
$objectId
,
$params
)
{
if
(
$op
!=
'edit'
)
{
return
;
...
...
@@ -24,6 +38,16 @@ class CRM_Civirules_Event_EditEntity {
self
::
setPreData
(
$entity
,
$objectId
,
$data
);
}
/**
* Method post
*
* @param string $op
* @param string $objectName
* @param int $objectId
* @param object $objectRef
* @access public
* @static
*/
public
static
function
post
(
$op
,
$objectName
,
$objectId
,
&
$objectRef
)
{
$extensionConfig
=
CRM_Civirules_Config
::
singleton
();
if
(
!
in_array
(
$op
,
$extensionConfig
->
getValidEventOperations
()))
{
...
...
@@ -55,17 +79,43 @@ class CRM_Civirules_Event_EditEntity {
}
}
protected
static
function
setPreData
(
$entity
,
$entity_id
,
$data
)
{
self
::
$preData
[
$entity
][
$entity_id
]
=
$data
;
/**
* Method to set the pre operation data
*
* @param string $entity
* @param int $entityId
* @param array $data
* @access protected
* @static
*/
protected
static
function
setPreData
(
$entity
,
$entityId
,
$data
)
{
self
::
$preData
[
$entity
][
$entityId
]
=
$data
;
}
protected
static
function
getPreData
(
$entity
,
$entity_id
)
{
if
(
isset
(
self
::
$preData
[
$entity
][
$entity_id
]))
{
return
self
::
$preData
[
$entity
][
$entity_id
];
/**
* Method to get the pre operation data
*
* @param string $entity
* @param id $entityId
* @return array
* @access protected
* @static
*/
protected
static
function
getPreData
(
$entity
,
$entityId
)
{
if
(
isset
(
self
::
$preData
[
$entity
][
$entityId
]))
{
return
self
::
$preData
[
$entity
][
$entityId
];
}
return
array
();
}
/**
* Method to convert the object name to the entity for contacts
*
* @param string $objectName
* @return string $entity
* @access public
* @static
*/
public
static
function
convertObjectNameToEntity
(
$objectName
)
{
$entity
=
$objectName
;
switch
(
$objectName
)
{
...
...
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