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
c7f46de7
Commit
c7f46de7
authored
10 years ago
by
Erik Hommel
Browse files
Options
Downloads
Patches
Plain Diff
updated validation of api Event Create
parent
8b90f68b
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/BAO/Event.php
+26
-0
26 additions, 0 deletions
CRM/Civirules/BAO/Event.php
api/v3/CiviRuleEvent/Create.php
+11
-0
11 additions, 0 deletions
api/v3/CiviRuleEvent/Create.php
with
37 additions
and
0 deletions
CRM/Civirules/BAO/Event.php
+
26
−
0
View file @
c7f46de7
...
...
@@ -134,4 +134,30 @@ class CRM_Civirules_BAO_Event extends CRM_Civirules_DAO_Event {
$event
->
find
(
true
);
return
$event
->
label
;
}
/**
* Function to check if an event exists with class_name or object_name/op
*
* @param array $params
* @return bool
* @access public
* @static
*/
public
static
function
eventExists
(
$params
)
{
if
(
isset
(
$params
[
'class_name'
])
&&
!
empty
(
$params
[
'class_name'
]))
{
$checkParams
[
'class_name'
]
=
$params
[
'class_name'
];
}
else
{
if
(
isset
(
$params
[
'object_name'
])
&&
isset
(
$params
[
'op'
])
&&
!
empty
(
$params
[
'object_name'
])
&&
!
empty
(
$params
[
'op'
]))
{
$checkParams
[
'object_name'
]
=
$params
[
'object_name'
];
$checkParams
[
'op'
]
=
$params
[
'op'
];
}
}
if
(
!
empty
(
$checkParams
))
{
$foundEvents
=
self
::
getValues
(
$checkParams
);
if
(
!
empty
(
$foundEvents
))
{
return
TRUE
;
}
}
return
FALSE
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/v3/CiviRuleEvent/Create.php
+
11
−
0
View file @
c7f46de7
...
...
@@ -55,6 +55,13 @@ function _validateParams($params) {
if
(
_checkClassNameObjectNameOperation
(
$params
)
==
FALSE
)
{
return
ts
(
'Either class_name or a combination of object_name and op is mandatory'
);
}
if
(
isset
(
$params
[
'cron'
])
&&
$params
[
'cron'
]
==
1
)
{
$params
[
'object_name'
]
=
null
;
$params
[
'op'
]
=
null
;
if
(
!
isset
(
$params
[
'class_name'
])
||
empty
(
$params
[
'class_name'
]))
{
return
ts
(
'For a cron type event the class_name is mandatory'
);
}
}
if
(
isset
(
$params
[
'object_name'
])
&&
!
empty
(
$params
[
'object_name'
]))
{
$extensionConfig
=
CRM_Civirules_Config
::
singleton
();
if
(
!
in_array
(
$params
[
'object_name'
],
$extensionConfig
->
getValidEventObjectNames
()))
{
...
...
@@ -69,6 +76,10 @@ function _validateParams($params) {
.
')is not a valid operation for a CiviRule Event'
);
}
}
if
(
CRM_Civirules_BAO_Event
::
eventExists
(
$params
)
==
TRUE
)
{
return
ts
(
'There is already an event for this class_name or combination of object_name and op'
);
}
return
$errorMessage
;
}
...
...
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