Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Extensions
form-processor
Commits
48ec3afb
Commit
48ec3afb
authored
Feb 23, 2021
by
ayduns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert tabs to spaces
Remove trailing spaces
parent
f4c43221
Changes
67
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
2544 additions
and
2544 deletions
+2544
-2544
CRM/Admin/Page/AutomationFormProcessor.php
CRM/Admin/Page/AutomationFormProcessor.php
+5
-5
CRM/FormProcessor/BAO/FormProcessorDefaultDataAction.php
CRM/FormProcessor/BAO/FormProcessorDefaultDataAction.php
+46
-46
CRM/FormProcessor/BAO/FormProcessorDefaultDataInput.php
CRM/FormProcessor/BAO/FormProcessorDefaultDataInput.php
+28
-28
CRM/FormProcessor/BAO/FormProcessorInput.php
CRM/FormProcessor/BAO/FormProcessorInput.php
+44
-44
CRM/FormProcessor/BAO/FormProcessorInstance.php
CRM/FormProcessor/BAO/FormProcessorInstance.php
+48
-48
CRM/FormProcessor/BAO/FormProcessorValidation.php
CRM/FormProcessor/BAO/FormProcessorValidation.php
+41
-41
CRM/FormProcessor/DAO/FormProcessorAction.php
CRM/FormProcessor/DAO/FormProcessorAction.php
+1
-1
CRM/FormProcessor/DAO/FormProcessorDefaultDataAction.php
CRM/FormProcessor/DAO/FormProcessorDefaultDataAction.php
+1
-1
CRM/FormProcessor/DAO/FormProcessorInput.php
CRM/FormProcessor/DAO/FormProcessorInput.php
+1
-1
CRM/FormProcessor/DAO/FormProcessorInstance.php
CRM/FormProcessor/DAO/FormProcessorInstance.php
+6
-6
CRM/FormProcessor/DAO/FormProcessorValidation.php
CRM/FormProcessor/DAO/FormProcessorValidation.php
+1
-1
CRM/FormProcessor/Status.php
CRM/FormProcessor/Status.php
+3
-3
CRM/FormProcessor/Upgrader.php
CRM/FormProcessor/Upgrader.php
+2
-2
Civi/FormProcessor/API/FormProcessor.php
Civi/FormProcessor/API/FormProcessor.php
+96
-96
Civi/FormProcessor/Config/ConfigurationBag.php
Civi/FormProcessor/Config/ConfigurationBag.php
+37
-37
Civi/FormProcessor/Config/Specification.php
Civi/FormProcessor/Config/Specification.php
+47
-47
Civi/FormProcessor/Config/SpecificationBag.php
Civi/FormProcessor/Config/SpecificationBag.php
+107
-107
Civi/FormProcessor/Config/SpecificationCollection.php
Civi/FormProcessor/Config/SpecificationCollection.php
+137
-137
Civi/FormProcessor/Config/SpecificationFields.php
Civi/FormProcessor/Config/SpecificationFields.php
+80
-80
Civi/FormProcessor/Config/SpecificationInterface.php
Civi/FormProcessor/Config/SpecificationInterface.php
+51
-51
Civi/FormProcessor/DataBag.php
Civi/FormProcessor/DataBag.php
+145
-145
Civi/FormProcessor/OutputHandler/AbstractOutputHandler.php
Civi/FormProcessor/OutputHandler/AbstractOutputHandler.php
+98
-98
Civi/FormProcessor/OutputHandler/Factory.php
Civi/FormProcessor/OutputHandler/Factory.php
+72
-72
Civi/FormProcessor/OutputHandler/FormatOutput.php
Civi/FormProcessor/OutputHandler/FormatOutput.php
+39
-39
Civi/FormProcessor/OutputHandler/OutputAllActionOutput.php
Civi/FormProcessor/OutputHandler/OutputAllActionOutput.php
+39
-39
Civi/FormProcessor/OutputHandler/OutputHandlerInterface.php
Civi/FormProcessor/OutputHandler/OutputHandlerInterface.php
+55
-55
Civi/FormProcessor/Type/DateType.php
Civi/FormProcessor/Type/DateType.php
+8
-8
Civi/FormProcessor/Type/TimeType.php
Civi/FormProcessor/Type/TimeType.php
+5
-5
Civi/FormProcessor/Validation/AbstractValidator.php
Civi/FormProcessor/Validation/AbstractValidator.php
+108
-108
Civi/FormProcessor/Validation/EmailValidator.php
Civi/FormProcessor/Validation/EmailValidator.php
+25
-25
Civi/FormProcessor/Validation/Factory.php
Civi/FormProcessor/Validation/Factory.php
+47
-47
Civi/FormProcessor/Validation/MaxValidator.php
Civi/FormProcessor/Validation/MaxValidator.php
+20
-20
Civi/FormProcessor/Validation/MinLengthValidator.php
Civi/FormProcessor/Validation/MinLengthValidator.php
+21
-21
Civi/FormProcessor/Validation/MinValidator.php
Civi/FormProcessor/Validation/MinValidator.php
+22
-22
ang/form_processor.ang.php
ang/form_processor.ang.php
+14
-14
api/v3/FormProcessorAction/Converttitletoname.php
api/v3/FormProcessorAction/Converttitletoname.php
+6
-6
api/v3/FormProcessorAction/Create.php
api/v3/FormProcessorAction/Create.php
+41
-41
api/v3/FormProcessorAction/Delete.php
api/v3/FormProcessorAction/Delete.php
+4
-4
api/v3/FormProcessorAction/Get.php
api/v3/FormProcessorAction/Get.php
+4
-4
api/v3/FormProcessorAction/Validatename.php
api/v3/FormProcessorAction/Validatename.php
+12
-12
api/v3/FormProcessorDefaultDataAction/Converttitletoname.php
api/v3/FormProcessorDefaultDataAction/Converttitletoname.php
+6
-6
api/v3/FormProcessorDefaultDataAction/Create.php
api/v3/FormProcessorDefaultDataAction/Create.php
+41
-41
api/v3/FormProcessorDefaultDataAction/Delete.php
api/v3/FormProcessorDefaultDataAction/Delete.php
+4
-4
api/v3/FormProcessorDefaultDataAction/Get.php
api/v3/FormProcessorDefaultDataAction/Get.php
+4
-4
api/v3/FormProcessorDefaultDataAction/Validatename.php
api/v3/FormProcessorDefaultDataAction/Validatename.php
+12
-12
api/v3/FormProcessorDefaultDataInput/Converttitletoname.php
api/v3/FormProcessorDefaultDataInput/Converttitletoname.php
+6
-6
api/v3/FormProcessorDefaultDataInput/Create.php
api/v3/FormProcessorDefaultDataInput/Create.php
+37
-37
api/v3/FormProcessorDefaultDataInput/Delete.php
api/v3/FormProcessorDefaultDataInput/Delete.php
+4
-4
api/v3/FormProcessorDefaultDataInput/Get.php
api/v3/FormProcessorDefaultDataInput/Get.php
+10
-10
api/v3/FormProcessorDefaultDataInput/Validatename.php
api/v3/FormProcessorDefaultDataInput/Validatename.php
+12
-12
api/v3/FormProcessorInput/Converttitletoname.php
api/v3/FormProcessorInput/Converttitletoname.php
+6
-6
api/v3/FormProcessorInput/Create.php
api/v3/FormProcessorInput/Create.php
+37
-37
api/v3/FormProcessorInput/Delete.php
api/v3/FormProcessorInput/Delete.php
+4
-4
api/v3/FormProcessorInput/Get.php
api/v3/FormProcessorInput/Get.php
+10
-10
api/v3/FormProcessorInput/Validatename.php
api/v3/FormProcessorInput/Validatename.php
+12
-12
api/v3/FormProcessorInstance/Create.php
api/v3/FormProcessorInstance/Create.php
+47
-47
api/v3/FormProcessorInstance/Delete.php
api/v3/FormProcessorInstance/Delete.php
+4
-4
api/v3/FormProcessorInstance/Get.php
api/v3/FormProcessorInstance/Get.php
+21
-21
api/v3/FormProcessorInstance/Import.mgd.php
api/v3/FormProcessorInstance/Import.mgd.php
+2
-2
api/v3/FormProcessorInstance/Validatename.php
api/v3/FormProcessorInstance/Validatename.php
+12
-12
api/v3/FormProcessorValidation/Create.php
api/v3/FormProcessorValidation/Create.php
+25
-25
api/v3/FormProcessorValidation/Delete.php
api/v3/FormProcessorValidation/Delete.php
+4
-4
api/v3/FormProcessorValidation/Get.php
api/v3/FormProcessorValidation/Get.php
+7
-7
form_processor.php
form_processor.php
+45
-45
tests/phpunit/Civi/FormProcessor/Type/ValidationTest.php
tests/phpunit/Civi/FormProcessor/Type/ValidationTest.php
+134
-134
tests/phpunit/UnitTestActionProvider.php
tests/phpunit/UnitTestActionProvider.php
+280
-280
tests/phpunit/api/v3/ApiPermissionTest.php
tests/phpunit/api/v3/ApiPermissionTest.php
+191
-191
No files found.
CRM/Admin/Page/AutomationFormProcessor.php
View file @
48ec3afb
...
...
@@ -5,15 +5,15 @@ class CRM_Admin_Page_AutomationFormProcessor extends CRM_Core_Page {
public
function
run
()
{
$loader
=
new
\
Civi\Angular\AngularLoader
();
$loader
->
setModules
(
array
(
'form_processor'
));
$loader
->
setPageName
(
'civicrm/admin/formprocessor'
);
\
Civi
::
resources
()
->
addSetting
(
array
(
$loader
->
setModules
(
array
(
'form_processor'
));
$loader
->
setPageName
(
'civicrm/admin/formprocessor'
);
\
Civi
::
resources
()
->
addSetting
(
array
(
'crmApp'
=>
array
(
'defaultRoute'
=>
'formprocessors'
,
),
));
$loader
->
load
();
parent
::
run
();
$loader
->
load
();
parent
::
run
();
}
}
CRM/FormProcessor/BAO/FormProcessorDefaultDataAction.php
View file @
48ec3afb
...
...
@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
extends
CRM_FormProcessor_DAO_FormProcessorDefaultDataAction
{
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
...
...
@@ -26,7 +26,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
}
$action
->
orderBy
(
'weight'
);
$action
->
orderBy
(
'weight'
);
$action
->
find
();
while
(
$action
->
fetch
())
{
$row
=
array
();
...
...
@@ -63,8 +63,8 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
/**
* Function to add or update form processor action
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
...
...
@@ -75,14 +75,14 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if
(
empty
(
$params
))
{
throw
new
Exception
(
'Params can not be empty when adding or updating a form processor action'
);
}
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
pre
(
'edit'
,
'FormProcessorDefaultDataAction'
,
$params
[
'id'
],
$params
);
}
else
{
CRM_Utils_Hook
::
pre
(
'create'
,
'FormProcessorDefaultDataAction'
,
NULL
,
$params
);
}
$action
=
new
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
();
$fields
=
self
::
fields
();
foreach
(
$params
as
$key
=>
$value
)
{
...
...
@@ -91,31 +91,31 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
if
(
is_array
(
$action
->
configuration
))
{
$action
->
configuration
=
json_encode
(
$action
->
configuration
);
}
if
(
is_array
(
$action
->
mapping
))
{
$action
->
mapping
=
json_encode
(
$action
->
mapping
);
}
if
(
is_array
(
$action
->
configuration
))
{
$action
->
configuration
=
json_encode
(
$action
->
configuration
);
}
if
(
is_array
(
$action
->
mapping
))
{
$action
->
mapping
=
json_encode
(
$action
->
mapping
);
}
if
(
is_array
(
$action
->
condition_configuration
))
{
$action
->
condition_configuration
=
json_encode
(
$action
->
condition_configuration
);
}
$action
->
save
();
self
::
storeValues
(
$action
,
$result
);
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
post
(
'edit'
,
'FormProcessorDefaultDataAction'
,
$action
->
id
,
$action
);
}
else
{
CRM_Utils_Hook
::
post
(
'create'
,
'FormProcessorDefaultDataAction'
,
$action
->
id
,
$action
);
}
return
$result
;
}
/**
* Function to delete a form processor action with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
...
...
@@ -125,21 +125,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if
(
empty
(
$id
))
{
throw
new
Exception
(
'id can not be empty when attempting to delete a form processor action'
);
}
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorDefaultDataAction'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorDefaultDataAction'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
$action
=
new
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
();
$action
->
id
=
$id
;
if
(
$action
->
find
(
true
))
{
$action
->
delete
();
}
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorDefaultDataAction'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorDefaultDataAction'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
return
;
}
/**
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorInstanceId
...
...
@@ -155,7 +155,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
/**
/**
* Public function to generate name from title
*
* @param $title
...
...
@@ -168,30 +168,30 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
$nameString
=
implode
(
'_'
,
$titleParts
);
return
substr
(
$nameString
,
0
,
80
);
}
/**
* Returns whether the name is valid or not
*
* @param string $name
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $form_processor_instance_id
* @param int $id optional
* @return bool
* @static
*/
public
static
function
isNameValid
(
$name
,
$form_processor_instance_id
,
$id
=
null
)
{
* @param int $id optional
* @return bool
* @static
*/
public
static
function
isNameValid
(
$name
,
$form_processor_instance_id
,
$id
=
null
)
{
if
(
empty
(
$form_processor_instance_id
))
{
return
true
;
}
$sql
=
"SELECT COUNT(*) FROM `civicrm_form_processor_default_data_action` WHERE `name` = %1 AND `form_processor_instance_id` = %2"
;
$params
[
1
]
=
[
$name
,
'String'
];
$params
[
2
]
=
[
$form_processor_instance_id
,
'Integer'
];
if
(
$id
)
{
$sql
.
=
" AND `id` != %3"
;
$params
[
3
]
=
array
(
$id
,
'Integer'
);
}
$count
=
CRM_Core_DAO
::
singleValueQuery
(
$sql
,
$params
);
return
(
$count
>
0
)
?
false
:
true
;
}
if
(
$id
)
{
$sql
.
=
" AND `id` != %3"
;
$params
[
3
]
=
array
(
$id
,
'Integer'
);
}
$count
=
CRM_Core_DAO
::
singleValueQuery
(
$sql
,
$params
);
return
(
$count
>
0
)
?
false
:
true
;
}
}
\ No newline at end of file
CRM/FormProcessor/BAO/FormProcessorDefaultDataInput.php
View file @
48ec3afb
...
...
@@ -8,7 +8,7 @@ use CRM_FormProcessor_ExtensionUtil as E;
*/
class
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
extends
CRM_FormProcessor_DAO_FormProcessorDefaultDataInput
{
/**
/**
* Function to get values
*
* @return array $result found rows with data
...
...
@@ -31,24 +31,24 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$row
=
array
();
self
::
storeValues
(
$input
,
$row
);
if
(
!
empty
(
$row
[
'form_processor_instance_id'
]))
{
$type
=
\
Civi
::
service
(
'form_processor_type_factory'
)
->
getTypeByName
(
$row
[
'type'
]);
if
(
$type
)
{
$configuration
=
$type
->
getDefaultConfiguration
();
if
(
isset
(
$row
[
'configuration'
])
&&
is_string
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
json_decode
(
$row
[
'configuration'
],
true
);
}
if
(
empty
(
$row
[
'configuration'
])
||
!
is_array
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
array
();
}
foreach
(
$row
[
'configuration'
]
as
$name
=>
$value
)
{
$configuration
->
set
(
$name
,
$value
);
}
$type
->
setConfiguration
(
$configuration
);
$row
[
'type'
]
=
$type
;
}
$row
[
'validators'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorValidation
::
getValues
(
array
(
'entity_id'
=>
$input
->
id
,
'entity'
=>
'FormProcessorDefaultDataInput'
)));
$type
=
\
Civi
::
service
(
'form_processor_type_factory'
)
->
getTypeByName
(
$row
[
'type'
]);
if
(
$type
)
{
$configuration
=
$type
->
getDefaultConfiguration
();
if
(
isset
(
$row
[
'configuration'
])
&&
is_string
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
json_decode
(
$row
[
'configuration'
],
true
);
}
if
(
empty
(
$row
[
'configuration'
])
||
!
is_array
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
array
();
}
foreach
(
$row
[
'configuration'
]
as
$name
=>
$value
)
{
$configuration
->
set
(
$name
,
$value
);
}
$type
->
setConfiguration
(
$configuration
);
$row
[
'type'
]
=
$type
;
}
$row
[
'validators'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorValidation
::
getValues
(
array
(
'entity_id'
=>
$input
->
id
,
'entity'
=>
'FormProcessorDefaultDataInput'
)));
$result
[
$row
[
'id'
]]
=
$row
;
}
else
{
...
...
@@ -74,7 +74,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
throw
new
Exception
(
'Params can not be empty when adding or updating a form processor input'
);
}
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
pre
(
'edit'
,
'FormProcessorDefaultDataInput'
,
$params
[
'id'
],
$params
);
}
else
{
...
...
@@ -88,13 +88,13 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$input
->
$key
=
$value
;
}
}
if
(
is_array
(
$input
->
configuration
))
{
$input
->
configuration
=
json_encode
(
$input
->
configuration
);
}
if
(
is_array
(
$input
->
configuration
))
{
$input
->
configuration
=
json_encode
(
$input
->
configuration
);
}
$input
->
save
();
self
::
storeValues
(
$input
,
$result
);
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
post
(
'edit'
,
'FormProcessorDefaultDataInput'
,
$input
->
id
,
$input
);
}
else
{
...
...
@@ -117,21 +117,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
throw
new
Exception
(
'id can not be empty when attempting to delete a form processor input'
);
}
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorDefaultDataInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorDefaultDataInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
$input
=
new
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
();
$input
->
id
=
$id
;
if
(
$input
->
find
(
true
))
{
CRM_FormProcessor_BAO_FormProcessorValidation
::
deleteWithEntityId
(
'FormProcessorDefaultDataInput'
,
$input
->
id
);
CRM_FormProcessor_BAO_FormProcessorValidation
::
deleteWithEntityId
(
'FormProcessorDefaultDataInput'
,
$input
->
id
);
$input
->
delete
();
}
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorDefaultDataInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorDefaultDataInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
return
;
}
/**
/**
* Function to delete all inputs with a form processor instance id
*
* @param int $formProcessorInstanceId
...
...
CRM/FormProcessor/BAO/FormProcessorInput.php
View file @
48ec3afb
...
...
@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class
CRM_FormProcessor_BAO_FormProcessorInput
extends
CRM_FormProcessor_DAO_FormProcessorInput
{
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
...
...
@@ -31,25 +31,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$row
=
array
();
self
::
storeValues
(
$input
,
$row
);
if
(
!
empty
(
$row
[
'form_processor_instance_id'
]))
{
$type
=
\
Civi
::
service
(
'form_processor_type_factory'
)
->
getTypeByName
(
$row
[
'type'
]);
if
(
$type
)
{
$configuration
=
$type
->
getDefaultConfiguration
();
if
(
isset
(
$row
[
'configuration'
])
&&
is_string
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
json_decode
(
$row
[
'configuration'
],
true
);
}
if
(
empty
(
$row
[
'configuration'
])
||
!
is_array
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
array
();
}
foreach
(
$row
[
'configuration'
]
as
$name
=>
$value
)
{
$configuration
->
set
(
$name
,
$value
);
}
$type
->
setConfiguration
(
$configuration
);
$row
[
'type'
]
=
$type
;
}
$row
[
'validators'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorValidation
::
getValues
(
array
(
'entity_id'
=>
$input
->
id
,
'entity'
=>
'FormProcessorInput'
)));
$type
=
\
Civi
::
service
(
'form_processor_type_factory'
)
->
getTypeByName
(
$row
[
'type'
]);
if
(
$type
)
{
$configuration
=
$type
->
getDefaultConfiguration
();
if
(
isset
(
$row
[
'configuration'
])
&&
is_string
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
json_decode
(
$row
[
'configuration'
],
true
);
}
if
(
empty
(
$row
[
'configuration'
])
||
!
is_array
(
$row
[
'configuration'
]))
{
$row
[
'configuration'
]
=
array
();
}
foreach
(
$row
[
'configuration'
]
as
$name
=>
$value
)
{
$configuration
->
set
(
$name
,
$value
);
}
$type
->
setConfiguration
(
$configuration
);
$row
[
'type'
]
=
$type
;
}
$row
[
'validators'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorValidation
::
getValues
(
array
(
'entity_id'
=>
$input
->
id
,
'entity'
=>
'FormProcessorInput'
)));
$result
[
$row
[
'id'
]]
=
$row
;
}
else
{
//invalid input because no there is no form processor
...
...
@@ -61,8 +61,8 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
/**
* Function to add or update form processor input
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
...
...
@@ -73,14 +73,14 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if
(
empty
(
$params
))
{
throw
new
Exception
(
'Params can not be empty when adding or updating a form processor input'
);
}
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
pre
(
'edit'
,
'FormProcessorInput'
,
$params
[
'id'
],
$params
);
}
else
{
CRM_Utils_Hook
::
pre
(
'create'
,
'FormProcessorInput'
,
NULL
,
$params
);
}
$input
=
new
CRM_FormProcessor_BAO_FormProcessorInput
();
$fields
=
self
::
fields
();
foreach
(
$params
as
$key
=>
$value
)
{
...
...
@@ -88,25 +88,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$input
->
$key
=
$value
;
}
}
if
(
is_array
(
$input
->
configuration
))
{
$input
->
configuration
=
json_encode
(
$input
->
configuration
);
}
if
(
is_array
(
$input
->
configuration
))
{
$input
->
configuration
=
json_encode
(
$input
->
configuration
);
}
$input
->
save
();
self
::
storeValues
(
$input
,
$result
);
if
(
!
empty
(
$params
[
'id'
]))
{
if
(
!
empty
(
$params
[
'id'
]))
{
CRM_Utils_Hook
::
post
(
'edit'
,
'FormProcessorInput'
,
$input
->
id
,
$input
);
}
else
{
CRM_Utils_Hook
::
post
(
'create'
,
'FormProcessorInput'
,
$input
->
id
,
$input
);
}
return
$result
;
}
/**
* Function to delete a form processor input with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
...
...
@@ -116,22 +116,22 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if
(
empty
(
$id
))
{
throw
new
Exception
(
'id can not be empty when attempting to delete a form processor input'
);
}
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
$input
=
new
CRM_FormProcessor_BAO_FormProcessorInput
();
$input
->
id
=
$id
;
if
(
$input
->
find
(
true
))
{
CRM_FormProcessor_BAO_FormProcessorValidation
::
deleteWithEntityId
(
'FormProcessorInput'
,
$input
->
id
);
CRM_FormProcessor_BAO_FormProcessorValidation
::
deleteWithEntityId
(
'FormProcessorInput'
,
$input
->
id
);
$input
->
delete
();
}
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
CRM_Utils_Hook
::
post
(
'delete'
,
'FormProcessorInput'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
return
;
}
/**
/**
* Function to delete all inputs with a form processor instance id
*
* @param int $formProcessorInstanceId
...
...
@@ -186,6 +186,6 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$count
=
CRM_Core_DAO
::
singleValueQuery
(
$sql
,
$params
);
return
(
$count
>
0
)
?
FALSE
:
TRUE
;
}
}
\ No newline at end of file
CRM/FormProcessor/BAO/FormProcessorInstance.php
View file @
48ec3afb
...
...
@@ -8,7 +8,7 @@
static
$importingFormProcessors
=
array
();
/**
/**
* Function to get values
*
* @return array $result found rows with data
...
...
@@ -30,10 +30,10 @@
while
(
$formProcessorInstance
->
fetch
())
{
$row
=
array
();
self
::
storeValues
(
$formProcessorInstance
,
$row
);
$row
[
'inputs'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorInput
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'actions'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorAction
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'default_data_inputs'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'default_data_actions'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'inputs'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorInput
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'actions'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorAction
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'default_data_inputs'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
$row
[
'default_data_actions'
]
=
array_values
(
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
::
getValues
(
array
(
'form_processor_instance_id'
=>
$formProcessorInstance
->
id
)));
if
(
isset
(
$row
[
'output_handler_configuration'
])
&&
is_string
(
$row
[
'output_handler_configuration'
]))
{
$row
[
'output_handler_configuration'
]
=
json_decode
(
$row
[
'output_handler_configuration'
],
true
);
}
...
...
@@ -54,19 +54,19 @@
}
}
if
(
isset
(
$row
[
'default_data_output_configuration'
])
&&
is_string
(
$row
[
'default_data_output_configuration'
]))
{
$row
[
'default_data_output_configuration'
]
=
json_decode
(
$row
[
'default_data_output_configuration'
],
true
);
}
if
(
empty
(
$row
[
'default_data_output_configuration'
])
||
!
is_array
(
$row
[
'default_data_output_configuration'
]))
{
$row
[
'default_data_output_configuration'
]
=
array
();
}
if
(
isset
(
$row
[
'default_data_output_configuration'
])
&&
is_string
(
$row
[
'default_data_output_configuration'
]))
{
$row
[
'default_data_output_configuration'
]
=
json_decode
(
$row
[
'default_data_output_configuration'
],
true
);
}
if
(
empty
(
$row
[
'default_data_output_configuration'
])
||
!
is_array
(
$row
[
'default_data_output_configuration'
]))
{
$row
[
'default_data_output_configuration'
]
=
array
();
}
$result
[
$row
[
'id'
]]
=
$row
;
}
return
$result
;
}
/**
/**
* Function to add or update a FormProcessorInstance
*
* @param array $params
...
...
@@ -103,12 +103,12 @@
$formProcessorInstance
->
name
=
CRM_FormProcessor_BAO_FormProcessorInstance
::
buildNameFromLabel
(
$formProcessorInstance
->
title
);
}
}
if
(
is_array
(
$formProcessorInstance
->
output_handler_configuration
))
{
$formProcessorInstance
->
output_handler_configuration
=
json_encode
(
$formProcessorInstance
->
output_handler_configuration
);
}
if
(
is_array
(
$formProcessorInstance
->
default_data_output_configuration
))
{
$formProcessorInstance
->
default_data_output_configuration
=
json_encode
(
$formProcessorInstance
->
default_data_output_configuration
);
}
if
(
is_array
(
$formProcessorInstance
->
output_handler_configuration
))
{
$formProcessorInstance
->
output_handler_configuration
=
json_encode
(
$formProcessorInstance
->
output_handler_configuration
);
}
if
(
is_array
(
$formProcessorInstance
->
default_data_output_configuration
))
{
$formProcessorInstance
->
default_data_output_configuration
=
json_encode
(
$formProcessorInstance
->
default_data_output_configuration
);
}
$formProcessorInstance
->
save
();
self
::
storeValues
(
$formProcessorInstance
,
$result
);
...
...
@@ -123,7 +123,7 @@
return
$result
;
}
/**
/**
* Function to delete a FormProcessorInstance with id
*
* @param int $id
...
...
@@ -138,12 +138,12 @@
CRM_Utils_Hook
::
pre
(
'delete'
,
'FormProcessorInstance'
,
$id
,
CRM_Core_DAO
::
$_nullArray
);
// First delete all inputs
CRM_FormProcessor_BAO_FormProcessorInput
::
deleteWithFormProcessorInstanceId
(
$id
);
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
::
deleteWithFormProcessorInstanceId
(
$id
);
// And all actions
CRM_FormProcessor_BAO_FormProcessorAction
::
deleteWithFormProcessorInstanceId
(
$id
);
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
::
deleteWithFormProcessorInstanceId
(
$id
);
// First delete all inputs
CRM_FormProcessor_BAO_FormProcessorInput
::
deleteWithFormProcessorInstanceId
(
$id
);
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput
::
deleteWithFormProcessorInstanceId
(
$id
);
// And all actions
CRM_FormProcessor_BAO_FormProcessorAction
::
deleteWithFormProcessorInstanceId
(
$id
);
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction
::
deleteWithFormProcessorInstanceId
(
$id
);
$formProcessorInstance
=
new
CRM_FormProcessor_BAO_FormProcessorInstance
();
$formProcessorInstance
->
id
=
$id
;
...
...
@@ -159,7 +159,7 @@
return
;
}
/**
/**
* Public function to generate name from label
*
* @param $label
...
...
@@ -173,28 +173,28 @@
return
substr
(
$nameString
,
0
,
80
);
}
/**
* Returns whether the name is valid or not