本文整理匯總了PHP中CRM_Activity_DAO_Activity::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Activity_DAO_Activity::delete方法的具體用法?PHP CRM_Activity_DAO_Activity::delete怎麽用?PHP CRM_Activity_DAO_Activity::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Activity_DAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_DAO_Activity::delete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteActivity
/**
* Delete the activity.
*
* @param array $params
* @param bool $moveToTrash
*
* @return mixed
*/
public static function deleteActivity(&$params, $moveToTrash = FALSE)
{
// CRM-9137
if (!empty($params['id']) && !is_array($params['id'])) {
CRM_Utils_Hook::pre('delete', 'Activity', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('delete', 'Activity', NULL, $params);
}
$transaction = new CRM_Core_Transaction();
if (is_array(CRM_Utils_Array::value('source_record_id', $params))) {
$sourceRecordIds = implode(',', $params['source_record_id']);
} else {
$sourceRecordIds = CRM_Utils_Array::value('source_record_id', $params);
}
$result = NULL;
if (!$moveToTrash) {
if (!isset($params['id'])) {
if (is_array($params['activity_type_id'])) {
$activityTypes = implode(',', $params['activity_type_id']);
} else {
$activityTypes = $params['activity_type_id'];
}
$query = "DELETE FROM civicrm_activity WHERE source_record_id IN ({$sourceRecordIds}) AND activity_type_id IN ( {$activityTypes} )";
$dao = CRM_Core_DAO::executeQuery($query);
} else {
$activity = new CRM_Activity_DAO_Activity();
$activity->copyValues($params);
$result = $activity->delete();
// CRM-8708
$activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
// CRM-13994 delete activity entity_tag
$query = "DELETE FROM civicrm_entity_tag WHERE entity_table = 'civicrm_activity' AND entity_id = {$activity->id}";
$dao = CRM_Core_DAO::executeQuery($query);
}
} else {
$activity = new CRM_Activity_DAO_Activity();
$activity->copyValues($params);
$activity->is_deleted = 1;
$result = $activity->save();
// CRM-4525 log activity delete
$logMsg = 'Case Activity deleted for';
$msgs = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceContactId = self::getActivityContact($activity->id, $sourceID);
if ($sourceContactId) {
$msgs[] = " source={$sourceContactId}";
}
// get target contacts.
$targetContactIds = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $targetID);
if (!empty($targetContactIds)) {
$msgs[] = " target =" . implode(',', array_keys($targetContactIds));
}
// get assignee contacts.
$assigneeContactIds = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $assigneeID);
if (!empty($assigneeContactIds)) {
$msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($activity, $logMsg);
}
// delete the recently created Activity
if ($result) {
$activityRecent = array('id' => $activity->id, 'type' => 'Activity');
CRM_Utils_Recent::del($activityRecent);
}
$transaction->commit();
if (isset($activity)) {
// CRM-8708
$activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
CRM_Utils_Hook::post('delete', 'Activity', $activity->id, $activity);
}
return $result;
}
示例2: updateRecords
/**
* Updates contacts affected by the option value passed.
*
* @param int $optionValueId
* The option value id.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
*
* @return bool
*/
public static function updateRecords(&$optionValueId, $action)
{
//finding group name
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
$optionValue->find(TRUE);
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionValue->option_group_id;
$optionGroup->find(TRUE);
// group name
$gName = $optionGroup->name;
// value
$value = $optionValue->value;
// get the proper group name & affected field name
// todo: this may no longer be needed for individuals - check inputs
$individuals = array('gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'communication_style' => 'communication_style_id');
$contributions = array('payment_instrument' => 'payment_instrument_id');
$activities = array('activity_type' => 'activity_type_id');
$participant = array('participant_role' => 'role_id');
$eventType = array('event_type' => 'event_type_id');
$aclRole = array('acl_role' => 'acl_role_id');
$all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole);
$fieldName = '';
foreach ($all as $name => $id) {
if ($gName == $name) {
$fieldName = $id;
}
}
if ($fieldName == '') {
return TRUE;
}
if (array_key_exists($gName, $individuals)) {
$contactDAO = new CRM_Contact_DAO_Contact();
$contactDAO->{$fieldName} = $value;
$contactDAO->find();
while ($contactDAO->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $contactDAO->id;
$contact->find(TRUE);
// make sure dates doesn't get reset
$contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
$contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
$contact->{$fieldName} = 'NULL';
$contact->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $contributions)) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->{$fieldName} = $value;
$contribution->find();
while ($contribution->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contribution->{$fieldName} = 'NULL';
$contribution->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $activities)) {
$activity = new CRM_Activity_DAO_Activity();
$activity->{$fieldName} = $value;
$activity->find();
while ($activity->fetch()) {
$activity->delete();
}
return TRUE;
}
//delete participant role, type and event type option value
if (array_key_exists($gName, $participant)) {
$participantValue = new CRM_Event_DAO_Participant();
$participantValue->{$fieldName} = $value;
if ($participantValue->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete event type option value
if (array_key_exists($gName, $eventType)) {
$event = new CRM_Event_DAO_Event();
$event->{$fieldName} = $value;
if ($event->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete acl_role option value
if (array_key_exists($gName, $aclRole)) {
//.........這裏部分代碼省略.........
示例3: deleteActivity
/**
* Function to delete the activity
* @param array $params associated array
*
* @return void
* @access public
*
*/
public function deleteActivity(&$params, $moveToTrash = false)
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
if (!$moveToTrash) {
if (!isset($params['id'])) {
if (is_array($params['activity_type_id'])) {
$activityTypes = implode(',', $params['activity_type_id']);
} else {
$activityTypes = $params['activity_type_id'];
}
$query = "DELETE FROM civicrm_activity WHERE source_record_id = {$params['source_record_id']} AND activity_type_id IN ( {$activityTypes} )";
$dao = CRM_Core_DAO::executeQuery($query);
} else {
$activity = new CRM_Activity_DAO_Activity();
$activity->copyValues($params);
$result = $activity->delete();
}
} else {
$activity = new CRM_Activity_DAO_Activity();
$activity->copyValues($params);
$activity->is_deleted = 1;
$result = $activity->save();
//log activty delete.CRM-4525.
$logMsg = "Case Activity deleted for";
$msgs = array();
$sourceContactId = CRM_Core_DAO::getfieldValue('CRM_Activity_DAO_Activity', $activity->id, 'source_contact_id');
if ($sourceContactId) {
$msgs[] = " source={$sourceContactId}";
}
//get target contacts.
$targetContactIds = CRM_Activity_BAO_ActivityTarget::getTargetNames($activity->id);
if (!empty($targetContactIds)) {
$msgs[] = " target =" . implode(',', array_keys($targetContactIds));
}
//get assignee contacts.
$assigneeContactIds = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id);
if (!empty($assigneeContactIds)) {
$msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($activity, $logMsg);
}
// delete the recently created Activity
require_once 'CRM/Utils/Recent.php';
if ($result) {
$activityRecent = array('id' => $activity->id, 'type' => 'Activity');
CRM_Utils_Recent::del($activityRecent);
}
$transaction->commit();
return $result;
}