Skip to content

Commit

Permalink
Merge pull request #18604 from eileenmcnaughton/act_cont
Browse files Browse the repository at this point in the history
[REF] Very minor cleanup
  • Loading branch information
mattwire authored Sep 26, 2020
2 parents f2ec3ed + 3d619e4 commit 483577b
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,8 @@ public static function create(&$params) {
$params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
}

// CRM-9137
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Activity', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'Activity', NULL, $params);
}
$action = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($action, 'Activity', $params['id'] ?? NULL, $params);

$activity->copyValues($params);
if (isset($params['case_id'])) {
Expand Down Expand Up @@ -411,11 +406,9 @@ public static function create(&$params) {
}

// attempt to save activity targets
$resultTarget = NULL;
if (!empty($params['target_contact_id'])) {

$targetParams = ['activity_id' => $activityId];
$resultTarget = [];
if (is_array($params['target_contact_id'])) {
// first delete existing targets if any
self::deleteActivityContact($activityId, $targetID);
Expand All @@ -442,11 +435,11 @@ public static function create(&$params) {

if ($target->contact_id != $params['target_contact_id']) {
$targetParams['id'] = $target->id;
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
CRM_Activity_BAO_ActivityContact::create($targetParams);
}
}
else {
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
CRM_Activity_BAO_ActivityContact::create($targetParams);
}
}
}
Expand Down Expand Up @@ -599,13 +592,7 @@ public static function create(&$params) {
self::logActivityAction($activity, "Case details for {$matches[1]} not found while recording an activity on case.");
}
}
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
}
else {
CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
}

CRM_Utils_Hook::post($action, 'Activity', $activity->id, $activity);
return $result;
}

Expand Down

0 comments on commit 483577b

Please sign in to comment.