本文整理汇总了PHP中CRM_Utils_array::crmIsEmptyArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_array::crmIsEmptyArray方法的具体用法?PHP CRM_Utils_array::crmIsEmptyArray怎么用?PHP CRM_Utils_array::crmIsEmptyArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_array
的用法示例。
在下文中一共展示了CRM_Utils_array::crmIsEmptyArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
//.........这里部分代码省略.........
} else {
$targetParams['contact_id'] = $params['target_contact_id'];
$targetParams['record_type_id'] = $targetID;
if (!empty($params['id'])) {
$target = new CRM_Activity_BAO_ActivityContact();
$target->activity_id = $activityId;
$target->record_type_id = $targetID;
$target->find(TRUE);
if ($target->contact_id != $params['target_contact_id']) {
$targetParams['id'] = $target->id;
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
}
} else {
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
}
}
} else {
if (CRM_Utils_Array::value('deleteActivityTarget', $params, TRUE)) {
self::deleteActivityContact($activityId, $targetID);
}
}
// write to changelog before transaction is committed/rolled
// back (and prepare status to display)
if (!empty($params['id'])) {
$logMsg = "Activity (id: {$result->id} ) updated with ";
} else {
$logMsg = "Activity created for ";
}
$msgs = array();
if (isset($params['source_contact_id'])) {
$msgs[] = "source={$params['source_contact_id']}";
}
if (!empty($params['target_contact_id'])) {
if (is_array($params['target_contact_id']) && !CRM_Utils_array::crmIsEmptyArray($params['target_contact_id'])) {
$msgs[] = "target=" . implode(',', $params['target_contact_id']);
// take only first target
// will be used for recently viewed display
$t = array_slice($params['target_contact_id'], 0, 1);
$recentContactId = $t[0];
} elseif (isset($params['target_contact_id']) && !is_array($params['target_contact_id'])) {
$msgs[] = "target={$params['target_contact_id']}";
// will be used for recently viewed display
$recentContactId = $params['target_contact_id'];
}
} else {
// at worst, take source for recently viewed display
$recentContactId = CRM_Utils_Array::value('source_contact_id', $params);
}
if (isset($params['assignee_contact_id'])) {
if (is_array($params['assignee_contact_id'])) {
$msgs[] = "assignee=" . implode(',', $params['assignee_contact_id']);
} else {
$msgs[] = "assignee={$params['assignee_contact_id']}";
}
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($result, $logMsg);
if (!empty($params['custom']) && is_array($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
}
$transaction->commit();
if (empty($params['skipRecentView'])) {
$recentOther = array();
if (!empty($params['case_id'])) {
$caseContactID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $params['case_id'], 'contact_id', 'case_id');
$url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activity->id}&cid={$caseContactID}&caseID={$params['case_id']}&context=home");
示例2: processActivity
/**
* Process activity creation.
*
* @param array $params
* Associated array of submitted values.
*
* @return self|null|object
*/
protected function processActivity(&$params)
{
$activityAssigned = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
//save free tags
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// CRM-9590
if (!empty($params['is_multi_activity'])) {
$this->_activityIds[] = $activity->id;
} else {
$this->_activityId = $activity->id;
}
// create follow up activity if needed
$followupStatus = '';
$followupActivity = NULL;
if (!empty($params['followup_activity_type_id'])) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = ts('A followup activity has been scheduled.');
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
$activityIDs = array($activity->id);
if ($followupActivity) {
$activityIDs = array_merge($activityIDs, array($followupActivity->id));
}
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityIDs, TRUE, FALSE);
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
$mailToContacts = array();
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sending a copy of activity.
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
$ics = new CRM_Activity_BAO_ICalendar($activity);
$ics->addAttachment($attachments, $mailToContacts);
// CRM-8400 add param with _currentlyViewedContactId for URL link in mail
CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
$ics->cleanup();
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// Also send email to follow-up activity assignees if set
if ($followupActivity) {
$mailToFollowupContacts = array();
foreach ($assigneeContacts as $values) {
if ($values['activity_id'] == $followupActivity->id) {
$mailToFollowupContacts[$values['email']] = $values;
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToFollowupContacts)) {
$ics = new CRM_Activity_BAO_ICalendar($followupActivity);
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $followupActivity->id);
$ics->addAttachment($attachments, $mailToFollowupContacts);
CRM_Case_BAO_Case::sendActivityCopy(NULL, $followupActivity->id, $mailToFollowupContacts, $attachments, NULL);
$ics->cleanup();
$mailStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
}
}
//.........这里部分代码省略.........
示例3: postProcess
//.........这里部分代码省略.........
$this->endPostProcess($newActParams, $activity);
}
// copy files attached to old activity if any, to new one,
// as long as users have not selected the 'delete attachment' option.
if (empty($newActParams['is_delete_attachment'])) {
CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $this->_activityId, 'civicrm_activity', $activity->id);
}
// copy back params to original var
$params = $newActParams;
}
foreach ($vvalue as $vkey => $vval) {
if ($vval['actId']) {
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $vval['actId']);
//save free tags
if (isset($params['taglist']) && !empty($params['taglist'])) {
CRM_Core_Form_Tag::postProcess($params['taglist'], $vval['actId'], 'civicrm_activity', $this);
}
}
// update existing case record if needed
$caseParams = $params;
$caseParams['id'] = $vval['case_id'];
if (!empty($caseParams['case_status_id'])) {
$caseParams['status_id'] = $caseParams['case_status_id'];
}
// unset params intended for activities only
unset($caseParams['subject'], $caseParams['details'], $caseParams['status_id'], $caseParams['custom']);
$case = CRM_Case_BAO_Case::create($caseParams);
// create case activity record
$caseParams = array('activity_id' => $vval['actId'], 'case_id' => $vval['case_id']);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
}
// Insert civicrm_log record for the activity (e.g. store the
// created / edited by contact id and date for the activity)
// Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
// send copy to selected contacts.
$mailStatus = '';
$mailToContacts = array();
//CRM-5695
//check for notification settings for assignee contacts
$selectedContacts = array('contact_check');
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
$selectedContacts[] = 'assignee_contact_id';
}
foreach ($vvalue as $vkey => $vval) {
foreach ($selectedContacts as $dnt => $val) {
if (array_key_exists($val, $params) && !CRM_Utils_array::crmIsEmptyArray($params[$val])) {
if ($val == 'contact_check') {
$mailStatus = ts("A copy of the activity has also been sent to selected contacts(s).");
} else {
$this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($vval['actId']), TRUE, FALSE);
$mailStatus .= ' ' . ts("A copy of the activity has also been sent to assignee contacts(s).");
}
//build an associative array with unique email addresses.
foreach ($params[$val] as $key => $value) {
if ($val == 'contact_check') {
$id = $key;
} else {
$id = $value;
}
if (isset($id) && array_key_exists($id, $this->_relatedContacts) && isset($this->_relatedContacts[$id]['email'])) {
//if email already exists in array then append with ', ' another role only otherwise add it to array.
if ($contactDetails = CRM_Utils_Array::value($this->_relatedContacts[$id]['email'], $mailToContacts)) {
$caseRole = CRM_Utils_Array::value('role', $this->_relatedContacts[$id]);
$mailToContacts[$this->_relatedContacts[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole;
} else {
$mailToContacts[$this->_relatedContacts[$id]['email']] = $this->_relatedContacts[$id];
}
}
}
}
}
$extraParams = array('case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId);
$result = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts, $extraParams);
if (empty($result)) {
$mailStatus = '';
}
// create follow up activity if needed
$followupStatus = '';
if (!empty($params['followup_activity_type_id'])) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($vval['actId'], $params);
if ($followupActivity) {
$caseParams = array('activity_id' => $followupActivity->id, 'case_id' => $vval['case_id']);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
$followupStatus = ts("A followup activity has been scheduled.") . '<br /><br />';
}
}
$title = ts("%1 Saved", array(1 => $this->_activityTypeName));
CRM_Core_Session::setStatus($followupStatus . $mailStatus, $title, 'success');
}
}
示例4: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess($params = null)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted sucessfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = "A followup activity has been scheduled.";
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
$config =& CRM_Core_Config::singleton();
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && $config->activityAssigneeNotification) {
$mailToContacts = array();
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sendig a copy of activity.
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
require_once "CRM/Case/BAO/Case.php";
$result = CRM_Case_BAO_Case::sendActivityCopy(null, $activity->id, $mailToContacts, $attachments, null);
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// set status message
//.........这里部分代码省略.........
示例5: create
//.........这里部分代码省略.........
return $resultTarget;
}
}
}
} else {
$targetParams['target_contact_id'] = $params['target_contact_id'];
if (CRM_Utils_Array::value('id', $params)) {
$target =& new CRM_Activity_BAO_ActivityTarget();
$target->activity_id = $activityId;
$target->find(true);
if ($target->target_contact_id != $params['target_contact_id']) {
$targetParams['id'] = $target->id;
$resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
}
} else {
$resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
}
}
} else {
if (CRM_Utils_Array::value('deleteActivityTarget', $params, true)) {
self::deleteActivityTarget($activityId);
}
}
// write to changelog before transation is committed/rolled
// back (and prepare status to display)
if (CRM_Utils_Array::value('id', $params)) {
$logMsg = "Activity (id: {$result->id} ) updated with ";
} else {
$logMsg = "Activity created for ";
}
$msgs = array();
if (isset($params['source_contact_id'])) {
$msgs[] = "source={$params['source_contact_id']}";
}
if (CRM_Utils_Array::value('target_contact_id', $params)) {
if (is_array($params['target_contact_id']) && !CRM_Utils_array::crmIsEmptyArray($params['target_contact_id'])) {
$msgs[] = "target=" . implode(',', $params['target_contact_id']);
// take only first target
// will be used for recently viewed display
$t = array_slice($params['target_contact_id'], 0, 1);
$recentContactId = $t[0];
} else {
if (isset($params['target_contact_id'])) {
$msgs[] = "target={$params['target_contact_id']}";
// will be used for recently viewed display
$recentContactId = $params['target_contact_id'];
}
}
} else {
// at worst, take source for recently viewed display
$recentContactId = $params['source_contact_id'];
}
if (isset($params['assignee_contact_id'])) {
if (is_array($params['assignee_contact_id'])) {
$msgs[] = "assignee=" . implode(',', $params['assignee_contact_id']);
} else {
$msgs[] = "assignee={$params['assignee_contact_id']}";
}
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($result, $logMsg);
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
}
$transaction->commit();
if (!CRM_Utils_Array::value('skipRecentView', $params)) {
require_once 'CRM/Utils/Recent.php';
if (CRM_Utils_Array::value('case_id', $params)) {
$caseContactID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $params['case_id'], 'contact_id', 'case_id');
$url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activity->id}&cid={$caseContactID}&caseID={$params['case_id']}&context=home");
} else {
$q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$activity->source_contact_id}&context=home";
if ($activity->activity_type_id != CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name')) {
$url = CRM_Utils_System::url('civicrm/contact/view/activity', $q);
} else {
$url = CRM_Utils_System::url('civicrm/activity', $q);
}
}
if (!isset($activity->parent_id)) {
require_once 'CRM/Contact/BAO/Contact.php';
$recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
// add the recently created Activity
$activityTypes = CRM_Core_Pseudoconstant::activityType(true, true);
$activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activity->id, 'subject');
$title = "";
if (isset($activitySubject)) {
$title = $activitySubject . ' - ';
}
$title = $title . $recentContactDisplay . ' (' . $activityTypes[$activity->activity_type_id] . ')';
CRM_Utils_Recent::add($title, $url, $activity->id, 'Activity', $recentContactId, $recentContactDisplay);
}
}
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
} else {
CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
}
return $result;
}
示例6: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess($params = NULL)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
// delete tags for the entity
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
//save free tags
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// CRM-9590
$this->_activityId = $activity->id;
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = ts('A followup activity has been scheduled.');
}
// send copy to assignee contacts.CRM-4509
//.........这里部分代码省略.........
示例7: postProcess
//.........这里部分代码省略.........
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
//save free tags
if (isset($params['taglist']) && !empty($params['taglist'])) {
require_once 'CRM/Core/Form/Tag.php';
CRM_Core_Form_Tag::postProcess($params['taglist'], $activity->id, 'civicrm_activity', $this);
}
}
$params['assignee_contact_id'] = $assineeContacts;
// update existing case record if needed
$caseParams = $params;
$caseParams['id'] = $this->_caseId;
if (CRM_Utils_Array::value('case_type_id', $caseParams)) {
$caseParams['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . $caseParams['case_type_id'] . CRM_Case_BAO_Case::VALUE_SEPERATOR;
}
if (CRM_Utils_Array::value('case_status_id', $caseParams)) {
$caseParams['status_id'] = $caseParams['case_status_id'];
}
// unset params intended for activities only
unset($caseParams['subject'], $caseParams['details'], $caseParams['status_id'], $caseParams['custom']);
$case = CRM_Case_BAO_Case::create($caseParams);
// create case activity record
$caseParams = array('activity_id' => $activity->id, 'case_id' => $this->_caseId);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
// create activity assignee records
$assigneeParams = array('activity_id' => $activity->id);
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
$activityId = isset($this->_activityId) ? $this->_activityId : $activity->id;
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
foreach ($params['assignee_contact_id'] as $key => $id) {
$assigneeParams['assignee_contact_id'] = $id;
CRM_Activity_BAO_Activity::createActivityAssignment($assigneeParams);
}
//modify assigne_contact as per newly assigned contact before sending copy. CRM-4509.
$params['assignee_contact_id'] = $activityAssigned;
}
// Insert civicrm_log record for the activity (e.g. store the
// created / edited by contact id and date for the activity)
// Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
// send copy to selected contacts.
$mailStatus = '';
$mailToContacts = array();
//CRM-5695
//check for notification settings for assignee contacts
$selectedContacts = array('contact_check');
$config =& CRM_Core_Config::singleton();
if ($config->activityAssigneeNotification) {
$selectedContacts[] = 'assignee_contact_id';
}
foreach ($selectedContacts as $dnt => $val) {
if (array_key_exists($val, $params) && !CRM_Utils_array::crmIsEmptyArray($params[$val])) {
if ($val == 'contact_check') {
$mailStatus = ts("A copy of the activity has also been sent to selected contacts(s).");
} else {
$this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
示例8: create
//.........这里部分代码省略.........
}
}
} else {
$targetParams['target_contact_id'] = $params['target_contact_id'];
if (CRM_Utils_Array::value('id', $params)) {
$target = new CRM_Activity_BAO_ActivityTarget();
$target->activity_id = $activityId;
$target->find(true);
if ($target->target_contact_id != $params['target_contact_id']) {
$targetParams['id'] = $target->id;
$resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
}
} else {
$resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
}
}
} else {
if (CRM_Utils_Array::value('deleteActivityTarget', $params, true)) {
self::deleteActivityTarget($activityId);
}
}
// write to changelog before transation is committed/rolled
// back (and prepare status to display)
if (CRM_Utils_Array::value('id', $params)) {
$logMsg = "Activity (id: {$result->id} ) updated with ";
} else {
$logMsg = "Activity created for ";
}
$msgs = array();
if (isset($params['source_contact_id'])) {
$msgs[] = "source={$params['source_contact_id']}";
}
if (CRM_Utils_Array::value('target_contact_id', $params)) {
if (is_array($params['target_contact_id']) && !CRM_Utils_array::crmIsEmptyArray($params['target_contact_id'])) {
$msgs[] = "target=" . implode(',', $params['target_contact_id']);
// take only first target
// will be used for recently viewed display
$t = array_slice($params['target_contact_id'], 0, 1);
$recentContactId = $t[0];
} else {
if (isset($params['target_contact_id'])) {
$msgs[] = "target={$params['target_contact_id']}";
// will be used for recently viewed display
$recentContactId = $params['target_contact_id'];
}
}
} else {
// at worst, take source for recently viewed display
$recentContactId = $params['source_contact_id'];
}
if (isset($params['assignee_contact_id'])) {
if (is_array($params['assignee_contact_id'])) {
$msgs[] = "assignee=" . implode(',', $params['assignee_contact_id']);
} else {
$msgs[] = "assignee={$params['assignee_contact_id']}";
}
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($result, $logMsg);
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
}
$transaction->commit();
if (!CRM_Utils_Array::value('skipRecentView', $params)) {
$recentOther = array();