self::logActivityAction($activity, $logMsg);
}
- // delete the recently created Activity
- if ($result) {
- $activityRecent = [
- 'id' => $activity->id,
- 'type' => 'Activity',
- ];
- CRM_Utils_Recent::del($activityRecent);
- }
-
$transaction->commit();
if (isset($activity)) {
// CRM-8708
CRM_Utils_Hook::post('delete', 'Case', $caseId, $case);
- // remove case from recent items.
- $caseRecent = [
- 'id' => $caseId,
- 'type' => 'Case',
- ];
- CRM_Utils_Recent::del($caseRecent);
return TRUE;
}
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Group', $id, $group);
-
- // delete the recently created Group
- $groupRecent = [
- 'id' => $id,
- 'type' => 'Group',
- ];
- CRM_Utils_Recent::del($groupRecent);
}
/**
CRM_Utils_Hook::post('delete', 'Relationship', $id, $relationship);
- // delete the recently created Relationship
- $relationshipRecent = [
- 'id' => $id,
- 'type' => 'Relationship',
- ];
- CRM_Utils_Recent::del($relationshipRecent);
-
return $relationship;
}
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
- // delete the recently created Contribution
- $contributionRecent = [
- 'id' => $id,
- 'type' => 'Contribution',
- ];
- CRM_Utils_Recent::del($contributionRecent);
-
return $results;
}
CRM_Utils_Hook::post('delete', 'Participant', $participant->id, $participant);
- // delete the recently created Participant
- $participantRecent = [
- 'id' => $id,
- 'type' => 'Participant',
- ];
-
- CRM_Utils_Recent::del($participantRecent);
-
return $participant;
}
$grant->find();
- // delete the recently created Grant
- $grantRecent = [
- 'id' => $id,
- 'type' => 'Grant',
- ];
- CRM_Utils_Recent::del($grantRecent);
-
if ($grant->fetch()) {
$results = $grant->delete();
CRM_Utils_Hook::post('delete', 'Grant', $grant->id, $grant);
CRM_Utils_Hook::post('delete', 'Membership', $membership->id, $membership);
- // delete the recently created Membership
- $membershipRecent = [
- 'id' => $membershipId,
- 'type' => 'Membership',
- ];
- CRM_Utils_Recent::del($membershipRecent);
-
return $results;
}
CRM_Utils_Hook::post('delete', 'Pledge', $dao->id, $dao);
- // delete the recently created Pledge
- $pledgeRecent = [
- 'id' => $id,
- 'type' => 'Pledge',
- ];
- CRM_Utils_Recent::del($pledgeRecent);
-
return $results;
}
$session->set(self::STORE_NAME, self::$_recent);
}
+ /**
+ * Callback for hook_civicrm_post().
+ * @param \Civi\Core\Event\PostEvent $event
+ */
+ public static function on_hook_civicrm_post(\Civi\Core\Event\PostEvent $event) {
+ if ($event->action === 'delete' && $event->id && CRM_Core_Session::getLoggedInContactID()) {
+ // Is this an entity that might be in the recent items list?
+ $providersPermitted = Civi::settings()->get('recentItemsProviders') ?: array_keys(self::getProviders());
+ if (in_array($event->entity, $providersPermitted)) {
+ self::del(['id' => $event->id, 'type' => $event->entity]);
+ }
+ }
+ }
+
/**
* Delete an item from the recent stack.
*
$dispatcher->addListener('hook_civicrm_coreResourceList', ['\CRM_Utils_System', 'appendCoreResources']);
$dispatcher->addListener('hook_civicrm_getAssetUrl', ['\CRM_Utils_System', 'alterAssetUrl']);
$dispatcher->addListener('hook_civicrm_alterExternUrl', ['\CRM_Utils_System', 'migrateExternUrl'], 1000);
+ // Not a BAO class so it can't implement hookInterface
+ $dispatcher->addListener('hook_civicrm_post', ['CRM_Utils_Recent', 'on_hook_civicrm_post']);
$dispatcher->addListener('hook_civicrm_permissionList', ['CRM_Core_Permission_List', 'findConstPermissions'], 975);
$dispatcher->addListener('hook_civicrm_permissionList', ['CRM_Core_Permission_List', 'findCiviPermissions'], 950);
$dispatcher->addListener('hook_civicrm_permissionList', ['CRM_Core_Permission_List', 'findCmsPermissions'], 925);