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
1110735d
Commit
1110735d
authored
10 years ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
added validation of condition
parent
2c14ef5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Civirules/Condition.php
+9
-0
9 additions, 0 deletions
CRM/Civirules/Condition.php
CRM/Civirules/Event/EditEntity.php
+1
-1
1 addition, 1 deletion
CRM/Civirules/Event/EditEntity.php
CRM/Civirules/Form/RuleCondition.php
+33
-0
33 additions, 0 deletions
CRM/Civirules/Form/RuleCondition.php
with
43 additions
and
1 deletion
CRM/Civirules/Condition.php
+
9
−
0
View file @
1110735d
...
@@ -39,6 +39,15 @@ abstract class CRM_Civirules_Condition {
...
@@ -39,6 +39,15 @@ abstract class CRM_Civirules_Condition {
return
''
;
return
''
;
}
}
/**
* Returns an array with required entity names
*
* @return array
*/
public
function
requiredEntities
()
{
return
array
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
CRM/Civirules/Event/EditEntity.php
+
1
−
1
View file @
1110735d
...
@@ -65,7 +65,7 @@ class CRM_Civirules_Event_EditEntity {
...
@@ -65,7 +65,7 @@ class CRM_Civirules_Event_EditEntity {
return
array
();
return
array
();
}
}
p
rotected
static
function
convertObjectNameToEntity
(
$objectName
)
{
p
ublic
static
function
convertObjectNameToEntity
(
$objectName
)
{
$entity
=
$objectName
;
$entity
=
$objectName
;
switch
(
$objectName
)
{
switch
(
$objectName
)
{
case
'Individual'
:
case
'Individual'
:
...
...
This diff is collapsed.
Click to expand it.
CRM/Civirules/Form/RuleCondition.php
+
33
−
0
View file @
1110735d
...
@@ -113,6 +113,39 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form {
...
@@ -113,6 +113,39 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form {
*/
*/
public
function
addRules
()
{
public
function
addRules
()
{
$this
->
addFormRule
(
array
(
'CRM_Civirules_Form_RuleCondition'
,
'validateRuleCondition'
));
$this
->
addFormRule
(
array
(
'CRM_Civirules_Form_RuleCondition'
,
'validateRuleCondition'
));
$this
->
addFormRule
(
array
(
'CRM_Civirules_Form_RuleCondition'
,
'validateConditionEntities'
));
}
/**
* @param $fields
*/
static
function
validateConditionEntities
(
$fields
)
{
$conditionClass
=
CRM_Civirules_BAO_Condition
::
getConditionObjectById
(
$fields
[
'rule_condition_select'
],
false
);
if
(
!
$conditionClass
)
{
$errors
[
'rule_condition_select'
]
=
ts
(
'Not a valid condition, condition class is missing'
);
return
$errors
;
}
$requiredEntities
=
$conditionClass
->
requiredEntities
();
$rule
=
new
CRM_Civirules_BAO_Rule
();
$rule
->
id
=
$fields
[
'rule_id'
];
$rule
->
find
(
true
);
$event
=
new
CRM_Civirules_BAO_Event
();
$event
->
id
=
$rule
->
event_id
;
$event
->
find
(
true
);
$eventEntities
=
array
(
'contact'
);
$eventEntities
[]
=
$event
->
object_name
;
if
(
CRM_Civirules_Event_EditEntity
::
convertObjectNameToEntity
(
$event
->
object_name
)
!=
$event
->
object_name
)
{
$eventEntities
[]
=
CRM_Civirules_Event_EditEntity
::
convertObjectNameToEntity
(
$event
->
object_name
);
}
foreach
(
$requiredEntities
as
$entity
)
{
if
(
!
in_array
(
strtolower
(
$entity
),
$eventEntities
))
{
$errors
[
'rule_condition_select'
]
=
ts
(
'This condition is not available with event %1'
,
array
(
1
=>
$event
->
label
));
return
$errors
;
}
}
return
true
;
}
}
/**
/**
...
...
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