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
Development
Core
Commits
10114f2d
Commit
10114f2d
authored
Apr 30, 2014
by
Eileen McNaughton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CRM-14449 activity api fix enotice to pass test, tidy up
parent
e34ab426
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
api/v3/Activity.php
api/v3/Activity.php
+18
-17
No files found.
api/v3/Activity.php
View file @
10114f2d
...
...
@@ -64,8 +64,6 @@ function civicrm_api3_activity_create($params) {
);
}
$errors
=
array
();
// check for various error and required conditions
// note that almost all the processing in there should be managed by the wrapper layer
// & should be removed - needs testing
...
...
@@ -79,7 +77,7 @@ function civicrm_api3_activity_create($params) {
// processing for custom data
$values
=
array
();
$values
=
$activityArray
=
array
();
_civicrm_api3_custom_format_params
(
$params
,
$values
,
'Activity'
);
if
(
!
empty
(
$values
[
'custom'
]))
{
...
...
@@ -104,7 +102,7 @@ function civicrm_api3_activity_create($params) {
CRM_Activity_BAO_Activity
::
retrieve
(
$oldActivityParams
,
$oldActivityValues
);
}
if
(
empty
(
$oldActivityValues
))
{
return
civicrm_api3_create_error
(
ts
(
"Unable to locate existing activity."
));
throw
new
API_Exception
(
ts
(
"Unable to locate existing activity."
));
}
else
{
$activityDAO
=
new
CRM_Activity_DAO_Activity
();
...
...
@@ -114,7 +112,7 @@ function civicrm_api3_activity_create($params) {
if
(
is_object
(
$activityDAO
))
{
$activityDAO
->
free
();
}
return
civicrm_api3_create_error
(
ts
(
"Unable to revision existing case activity."
));
throw
new
API_Exception
(
ts
(
"Unable to revision existing case activity."
));
}
$createRevision
=
TRUE
;
}
...
...
@@ -157,7 +155,7 @@ function civicrm_api3_activity_create($params) {
$params
[
'original_id'
]
=
empty
(
$oldActivityValues
[
'original_id'
])
?
$oldActivityValues
[
'id'
]
:
$oldActivityValues
[
'original_id'
];
}
else
{
return
civicrm_api3_create_error
(
ts
(
"Unable to create new revision of case activity."
));
throw
new
API_Exception
(
ts
(
"Unable to create new revision of case activity."
));
}
}
...
...
@@ -294,9 +292,9 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
}
if
(
!
empty
(
$activities
)
&&
(
!
empty
(
$returnProperties
)
||
!
empty
(
$params
[
'contact_id'
])))
{
foreach
(
$activities
as
$activityId
=>
$values
)
{
_civicrm_api3_custom_data_get
(
$activities
[
$activityId
],
'Activity'
,
$activityId
,
NULL
,
$values
[
'activity_type_id'
]);
//@todo - should possibly load activity type id if not loaded (update with id)
_civicrm_api3_custom_data_get
(
$activities
[
$activityId
],
'Activity'
,
$activityId
,
NULL
,
CRM_Utils_Array
::
value
(
'activity_type_id'
,
$values
));
}
return
$activities
;
}
return
$activities
;
}
...
...
@@ -308,6 +306,7 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
* @param array $params array holding 'id' of activity to be deleted
* {@getfields activity_delete}
*
* @throws API_Exception
* @return void|CRM_Core_Error An error if 'activityName or ID' is invalid,
* permissions are insufficient, etc. or CiviCRM success array
*
...
...
@@ -315,7 +314,6 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
*
* @example ActivityDelete.php Standard Delete Example
*
*
*/
function
civicrm_api3_activity_delete
(
$params
)
{
...
...
@@ -323,15 +321,18 @@ function civicrm_api3_activity_delete($params) {
return
civicrm_api3_create_success
(
1
,
$params
,
'activity'
,
'delete'
);
}
else
{
return
civicrm_api3_create_error
(
'Could not delete activity'
);
throw
new
API_Exception
(
'Could not delete activity'
);
}
}
/**
* Function to check for required params
*
* @param array $params associated array of fields
* @param boolean $addMode true for add mode
* @param array $params associated array of fields
*
* @throws API_Exception
* @throws Exception
* @internal param bool $addMode true for add mode
*
* @return array $error array with errors
*/
...
...
@@ -370,7 +371,7 @@ SELECT count(*)
FROM civicrm_contact
WHERE id IN ('
.
implode
(
', '
,
$contactIds
)
.
' )'
;
if
(
count
(
$contactIds
)
!=
CRM_Core_DAO
::
singleValueQuery
(
$sql
))
{
return
civicrm_api3_create_error
(
'Invalid '
.
' Contact Id'
);
throw
new
API_Exception
(
'Invalid '
.
' Contact Id'
);
}
}
...
...
@@ -384,7 +385,7 @@ SELECT count(*)
if
(
$value
&&
!
CRM_Core_DAO
::
getFieldValue
(
'CRM_Activity_DAO_Activity'
,
$value
,
'id'
)
)
{
return
civicrm_api3_create_error
(
'Invalid '
.
ucfirst
(
$id
)
.
' Id'
);
throw
new
API_Exception
(
'Invalid '
.
ucfirst
(
$id
)
.
' Id'
);
}
}
// this should be handled by wrapper layer & probably the api would already manage it
...
...
@@ -408,21 +409,21 @@ SELECT count(*)
throw
new
Exception
(
$errorString
);
}
elseif
(
$activityTypeId
&&
(
$activityTypeId
!=
$activityTypeIdInList
))
{
return
civicrm_api3_create_error
(
'Mismatch in Activity'
);
throw
new
API_Exception
(
'Mismatch in Activity'
);
}
$params
[
'activity_type_id'
]
=
$activityTypeIdInList
;
}
elseif
(
$activityTypeId
&&
!
array_key_exists
(
$activityTypeId
,
$activityTypes
)
)
{
return
civicrm_api3_create_error
(
'Invalid Activity Type ID'
);
throw
new
API_Exception
(
'Invalid Activity Type ID'
);
}
// check for activity duration minutes
// this should be validated @ the wrapper layer not here
// needs testing
if
(
isset
(
$params
[
'duration_minutes'
])
&&
!
is_numeric
(
$params
[
'duration_minutes'
]))
{
return
civicrm_api3_create_error
(
'Invalid Activity Duration (in minutes)'
);
throw
new
API_Exception
(
'Invalid Activity Duration (in minutes)'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment