本文整理汇总了PHP中CRM_Activity_BAO_ActivityContact::getNames方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_ActivityContact::getNames方法的具体用法?PHP CRM_Activity_BAO_ActivityContact::getNames怎么用?PHP CRM_Activity_BAO_ActivityContact::getNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_ActivityContact
的用法示例。
在下文中一共展示了CRM_Activity_BAO_ActivityContact::getNames方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
$toArray = array();
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc');
$providerSelect = array();
foreach ($providers as $provider) {
$providerSelect[$provider['id']] = $provider['title'];
}
$suppressedSms = 0;
//here we are getting logged in user id as array but we need target contact id. CRM-5988
$cid = $form->get('cid');
if ($cid) {
$form->_contactIds = array($cid);
}
$to = $form->add('text', 'to', ts('To'), array('class' => 'huge'), TRUE);
$form->add('text', 'activity_subject', ts('Name The SMS'), array('class' => 'huge'), TRUE);
$toSetDefault = TRUE;
if (property_exists($form, '_context') && $form->_context == 'standalone') {
$toSetDefault = FALSE;
}
// when form is submitted recompute contactIds
$allToSMS = array();
if ($to->getValue()) {
$allToPhone = explode(',', $to->getValue());
$form->_contactIds = array();
foreach ($allToPhone as $value) {
list($contactId, $phone) = explode('::', $value);
if ($contactId) {
$form->_contactIds[] = $contactId;
$form->_toContactPhone[] = $phone;
}
}
$toSetDefault = TRUE;
}
//get the group of contacts as per selected by user in case of Find Activities
if (!empty($form->_activityHolderIds)) {
$extendTargetContacts = 0;
$invalidActivity = 0;
$validActivities = 0;
foreach ($form->_activityHolderIds as $key => $id) {
//valid activity check
if (CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $id, 'subject', 'id') != self::RECIEVED_SMS_ACTIVITY_SUBJECT) {
$invalidActivity++;
continue;
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//target contacts limit check
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
if (count($ids) > 1) {
$extendTargetContacts++;
continue;
}
$validActivities++;
$form->_contactIds = empty($form->_contactIds) ? $ids : array_unique(array_merge($form->_contactIds, $ids));
}
if (!$validActivities) {
$errorMess = "";
if ($extendTargetContacts) {
$errorMess = ts('One selected activity consists of more than one target contact.', array('count' => $extendTargetContacts, 'plural' => '%count selected activities consist of more than one target contact.'));
}
if ($invalidActivity) {
$errorMess = $errorMess ? ' ' : '';
$errorMess .= ts('The selected activity is invalid.', array('count' => $invalidActivity, 'plural' => '%count selected activities are invalid.'));
}
CRM_Core_Error::statusBounce(ts("%1: SMS Reply will not be sent.", array(1 => $errorMess)));
}
}
if (is_array($form->_contactIds) && !empty($form->_contactIds) && $toSetDefault) {
$returnProperties = array('sort_name' => 1, 'phone' => 1, 'do_not_sms' => 1, 'is_deceased' => 1, 'display_name' => 1);
list($form->_contactDetails) = CRM_Utils_Token::getTokenDetails($form->_contactIds, $returnProperties, FALSE, FALSE);
// make a copy of all contact details
$form->_allContactDetails = $form->_contactDetails;
foreach ($form->_contactIds as $key => $contactId) {
$value = $form->_contactDetails[$contactId];
//to check if the phone type is "Mobile"
$phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') {
//to check for "if the contact id belongs to a specified activity type"
$actDetails = CRM_Activity_BAO_Activity::getContactActivity($contactId);
if (self::RECIEVED_SMS_ACTIVITY_SUBJECT != CRM_Utils_Array::retrieveValueRecursive($actDetails, 'subject')) {
$suppressedSms++;
unset($form->_contactDetails[$contactId]);
continue;
}
}
if (isset($value['phone_type_id']) && $value['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes) || $value['do_not_sms'] || empty($value['phone']) || !empty($value['is_deceased'])) {
//if phone is not primary check if non-primary phone is "Mobile"
if (!empty($value['phone']) && $value['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes) && empty($value['is_deceased'])) {
$filter = array('do_not_sms' => 0);
$contactPhones = CRM_Core_BAO_Phone::allPhones($contactId, FALSE, 'Mobile', $filter);
if (count($contactPhones) > 0) {
//.........这里部分代码省略.........
示例2: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_activityClause);
$rows = array();
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail');
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$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);
//get all activity types
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
while ($result->fetch()) {
$row = array();
// ignore rows where we dont have an activity id
if (empty($result->activity_id)) {
continue;
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
$contactId = CRM_Utils_Array::value('contact_id', $row);
if (!$contactId) {
$contactId = CRM_Utils_Array::value('source_contact_id', $row);
}
$row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID);
$row['assignee_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $assigneeID);
list($row['source_contact_name'], $row['source_contact_id']) = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $sourceID, TRUE);
$row['source_contact_name'] = implode(',', array_values($row['source_contact_name']));
$row['source_contact_id'] = implode(',', $row['source_contact_id']);
if ($this->_context == 'search') {
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id;
}
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$accessMailingReport = FALSE;
$activityTypeId = $row['activity_type_id'];
if ($row['activity_is_test']) {
$row['activity_type'] = $row['activity_type'] . " (test)";
}
$bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
$row['mailingId'] = '';
if ($accessCiviMail && ($mailingIDs === TRUE || in_array($result->source_record_id, $mailingIDs)) && $bulkActivityTypeID == $activityTypeId) {
$row['mailingId'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$result->source_record_id}&reset=1&cid={$contactId}&context=activitySelector");
$row['recipients'] = ts('(recipients)');
$row['target_contact_name'] = '';
$row['assignee_contact_name'] = '';
$accessMailingReport = TRUE;
}
$activityActions = new CRM_Activity_Selector_Activity($result->contact_id, NULL);
$actionLinks = $activityActions->actionLinks($activityTypeId, CRM_Utils_Array::value('source_record_id', $row), $accessMailingReport, CRM_Utils_Array::value('activity_id', $row), $this->_key, $this->_compContext);
$row['action'] = CRM_Core_Action::formLink($actionLinks, NULL, array('id' => $result->activity_id, 'cid' => $contactId, 'cxt' => $this->_context), ts('more'), FALSE, 'activity.selector.row', 'Activity', $result->activity_id);
//carry campaign to selector.
$row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->activity_campaign_id;
if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) {
$row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
//Check if recurring activity
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity');
$row['repeat'] = '';
if ($repeat) {
$row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
$rows[] = $row;
}
return $rows;
}
示例3: 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;
}
示例4: getCaseActivity
//.........这里部分代码省略.........
$statusTitle = ts('Edit status');
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
// define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status)
$compStatusValues = array();
$compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required');
foreach ($compStatusNames as $name) {
$compStatusValues[] = CRM_Core_OptionGroup::getValue('activity_status', $name, 'name');
}
$contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE);
$hasViewContact = CRM_Core_Permission::giveMeAllACLs();
$clientIds = self::retrieveContactIdsByCaseId($caseID);
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
}
while ($dao->fetch()) {
$allowView = self::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID);
$allowEdit = self::checkPermission($dao->id, 'edit', $dao->activity_type_id, $userID);
$allowDelete = self::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID);
//do not have sufficient permission
//to access given case activity record.
if (!$allowView && !$allowEdit && !$allowDelete) {
continue;
}
$values[$dao->id]['id'] = $dao->id;
$values[$dao->id]['type'] = $activityTypes[$dao->type]['label'];
$reporterName = $dao->reporter;
if ($hasViewContact) {
$reporterName = '<a href="' . $contactViewUrl . $dao->reporter_id . '">' . $dao->reporter . '</a>';
}
$values[$dao->id]['reporter'] = $reporterName;
$targetNames = CRM_Activity_BAO_ActivityContact::getNames($dao->id, $targetID);
$targetContactUrls = $withContacts = array();
foreach ($targetNames as $targetId => $targetName) {
if (!in_array($targetId, $clientIds)) {
$withContacts[$targetId] = $targetName;
}
}
foreach ($withContacts as $cid => $name) {
if ($hasViewContact) {
$name = '<a href="' . $contactViewUrl . $cid . '">' . $name . '</a>';
}
$targetContactUrls[] = $name;
}
$values[$dao->id]['with_contacts'] = implode('; ', $targetContactUrls);
$values[$dao->id]['display_date'] = CRM_Utils_Date::customFormat($dao->display_date);
$values[$dao->id]['status'] = $activityStatus[$dao->status];
//check for view activity.
$subject = empty($dao->subject) ? '(' . ts('no subject') . ')' : $dao->subject;
if ($allowView) {
$url = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $dao->id));
$subject = '<a class="crm-popup medium-popup" href="' . $url . '" title="' . $viewTitle . '">' . $subject . '</a>';
}
$values[$dao->id]['subject'] = $subject;
// add activity assignee to activity selector. CRM-4485.
if (isset($dao->assignee)) {
if ($dao->ismultiple == 1) {
if ($dao->reporter_id != $dao->assignee_id) {
$values[$dao->id]['reporter'] .= $hasViewContact ? ' / ' . "<a href='{$contactViewUrl}{$dao->assignee_id}'>{$dao->assignee}</a>" : ' / ' . $dao->assignee;
}
$values[$dao->id]['assignee'] = $dao->assignee;
} else {
$values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)');
}
示例5: 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 (Civi::settings()->get('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];
}
}
$sent = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts);
if ($sent) {
$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;
}
}
$sentFollowup = CRM_Activity_BAO_Activity::sendToAssignee($followupActivity, $mailToFollowupContacts);
if ($sentFollowup) {
$mailStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
}
}
}
// set status message
$subject = '';
if (!empty($params['subject'])) {
$subject = "'" . $params['subject'] . "'";
}
CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
return $activity;
}
示例6: array
function &getActivity($clientID, $activityDAO, &$activityTypeInfo)
{
if (empty($this->_redactionStringRules)) {
$this->_redactionStringRules = array();
}
$activity = array();
$activity['fields'] = array();
if ($clientID) {
$clientID = CRM_Utils_Type::escape($clientID, 'Integer');
if (!in_array($activityTypeInfo['name'], array('Email', 'Inbound Email'))) {
$activity['editURL'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&cid={$clientID}&caseid={$activityDAO->caseID}&action=update&atype={$activityDAO->activity_type_id}&id={$activityDAO->id}");
} else {
$activity['editURL'] = '';
}
$client = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'display_name');
// add Client SortName as well as Display to the strings to be redacted across the case session
// suffixed with a randomly generated 4-digit number
if (!array_key_exists($client, $this->_redactionStringRules)) {
$this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, array($client => 'name_' . rand(10000, 100000)));
$clientSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'sort_name');
if (!array_key_exists($clientSortName, $this->_redactionStringRules)) {
$this->_redactionStringRules[$clientSortName] = $this->_redactionStringRules[$client];
}
}
$activity['fields'][] = array('label' => 'Client', 'value' => $this->redact($client), 'type' => 'String');
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
if (!empty($activityDAO->targetID)) {
// Re-lookup the target ID since the DAO only has the first recipient if there are multiple.
// Maybe not the best solution.
$targetNames = CRM_Activity_BAO_ActivityContact::getNames($activityDAO->id, $targetID);
$processTarget = FALSE;
$label = ts('With Contact(s)');
if (in_array($activityTypeInfo['name'], array('Email', 'Inbound Email'))) {
$processTarget = TRUE;
$label = ts('Recipient');
}
if (!$processTarget) {
foreach ($targetNames as $targetID => $targetName) {
if ($targetID != $clientID) {
$processTarget = TRUE;
break;
}
}
}
if ($processTarget) {
$targetRedacted = array();
foreach ($targetNames as $targetID => $target) {
// add Recipient SortName as well as Display to the strings to be redacted across the case session
// suffixed with a randomly generated 4-digit number
if (!array_key_exists($target, $this->_redactionStringRules)) {
$this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, array($target => 'name_' . rand(10000, 100000)));
$targetSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $targetID, 'sort_name');
if (!array_key_exists($targetSortName, $this->_redactionStringRules)) {
$this->_redactionStringRules[$targetSortName] = $this->_redactionStringRules[$target];
}
}
$targetRedacted[] = $this->redact($target);
}
$activity['fields'][] = array('label' => $label, 'value' => implode('; ', $targetRedacted), 'type' => 'String');
}
}
// Activity Type info is a special field
$activity['fields'][] = array('label' => ts('Activity Type'), 'value' => $activityTypeInfo['label'], 'type' => 'String');
$activity['fields'][] = array('label' => ts('Subject'), 'value' => htmlspecialchars($this->redact($activityDAO->subject)), 'type' => 'Memo');
$creator = $this->getCreatedBy($activityDAO->id);
// add Creator to the strings to be redacted across the case session
if (!array_key_exists($creator, $this->_redactionStringRules)) {
$this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, array($creator => 'name_' . rand(10000, 100000)));
}
$activity['fields'][] = array('label' => ts('Created By'), 'value' => $this->redact($creator), 'type' => 'String');
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$source_contact_id = CRM_Activity_BAO_Activity::getActivityContact($activityDAO->id, $sourceID);
$reporter = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $source_contact_id, 'display_name');
// add Reporter SortName as well as Display to the strings to be redacted across the case session
// suffixed with a randomly generated 4-digit number
if (!array_key_exists($reporter, $this->_redactionStringRules)) {
$this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, array($reporter => 'name_' . rand(10000, 100000)));
$reporterSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $source_contact_id, 'sort_name');
if (!array_key_exists($reporterSortName, $this->_redactionStringRules)) {
$this->_redactionStringRules[$reporterSortName] = $this->_redactionStringRules[$reporter];
}
}
$activity['fields'][] = array('label' => ts('Reported By'), 'value' => $this->redact($reporter), 'type' => 'String');
if (!empty($activityDAO->assigneeID)) {
//allow multiple assignee contacts.CRM-4503.
$assignee_contact_names = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($activityDAO->id), TRUE);
foreach ($assignee_contact_names as &$assignee) {
// add Assignee to the strings to be redacted across the case session
$this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, array($assignee => 'name_' . rand(10000, 100000)));
$assignee = $this->redact($assignee);
}
$assigneeContacts = implode(', ', $assignee_contact_names);
$activity['fields'][] = array('label' => ts('Assigned To'), 'value' => $assigneeContacts, 'type' => 'String');
}
if ($activityDAO->medium_id) {
$activity['fields'][] = array('label' => ts('Medium'), 'value' => CRM_Core_OptionGroup::getLabel('encounter_medium', $activityDAO->medium_id, FALSE), 'type' => 'String');
//.........这里部分代码省略.........
示例7: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess()
{
// Clear any formRule errors from Email form in case they came back here via Cancel button
$this->controller->resetPage('Email');
$params = $this->exportValues();
$this->_contacts = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// Get assignee contacts.
if (!empty($params['assigned_to'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
// Get target contacts.
if (!empty($params['with_contact'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
// Get 'Added by' contacts.
if (!empty($params['created_by'])) {
parent::setContactIDs();
if (!empty($this->_contactIds)) {
$this->_contacts = array_merge($this->_contacts, $this->_contactIds);
}
}
$this->_contacts = array_unique($this->_contacts);
// Bounce to pick option if no contacts to send to.
if (empty($this->_contacts)) {
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
CRM_Core_Error::statusBounce(ts('It appears you have no contacts with email addresses from the selected recipients.'), $urlRedirect);
}
$this->set('contacts', $this->_contacts);
}
示例8: recentApplicationActivities
static function recentApplicationActivities($limit = 10)
{
$recentActivities = array();
$customTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'application_case', 'table_name', 'name');
//Retrieve top $limit(as total activity count) recent activities
$query = CRM_Case_BAO_Case::getCaseActivityQuery($type = 'any', NULL, $condition = "AND c_type.name = 'Application' AND t_act.desired_date <= CURRENT_TIMESTAMP ");
$query .= "LIMIT 0, {$limit}";
$query = str_replace('ORDER BY case_activity_date ASC', 'ORDER BY case_activity_date DESC', $query);
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$query = "SELECT vacancy_id FROM {$customTableName} WHERE entity_id = {$dao->case_id}";
$ctDAO = CRM_Core_DAO::executeQuery($query);
$ctDAO->fetch();
$vacancyDAO = new self();
$vacancyDAO->id = $ctDAO->vacancy_id;
$vacancyDAO->find(TRUE);
//Applicant contact link
$applicant = "<a href='" . CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}") . "'>{$dao->sort_name}</a>";
//Position link
$position = "<a href='" . CRM_Utils_System::url('civicrm/case/pipeline', "reset=1&vid={$vacancyDAO->id}") . "'>{$vacancyDAO->position}</a>";
//Case Activity Source link
$sourceID = civicrm_api3('OptionValue', 'getvalue', array('option_group_id' => 'activity_contacts', 'name' => 'Activity Source', 'return' => 'value'));
$sourceContact = CRM_Activity_BAO_ActivityContact::getNames($dao->case_activity_id, $sourceID);
$sourceContactID = key($sourceContact);
$source = "<a href='" . CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$sourceContactID}") . "'>{$sourceContact[$sourceContactID]}</a>";
switch ($dao->case_activity_type_name) {
case 'Open Case':
$recentActivities[] = array('activity' => "{$applicant} applied for {$position}", 'time' => $dao->case_activity_date);
break;
case 'Comment':
$recentActivities[] = array('activity' => "{$source} commented on {$position}", 'time' => $dao->case_activity_date);
break;
case 'Phone Call':
case 'Meeting':
case 'Follow up':
$recentActivities[] = array('activity' => "{$source} had a {$dao->case_activity_type_name} with {$applicant} (vis-a-vis {$position})", 'time' => $dao->case_activity_date);
break;
case 'Email':
$recentActivities[] = array('activity' => "{$source} sent email to {$applicant}", 'time' => $dao->case_activity_date);
break;
case 'Change Case Status':
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$subject = str_replace('Assignment status changed', '', $subject);
$recentActivities[] = array('activity' => "{$source} changed the status of {$position} {$subject}", 'time' => $dao->case_activity_date);
break;
case 'Evaluation':
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$recentActivities[] = array('activity' => "{$source} evaluated {$applicant} for {$position}", 'time' => $dao->case_activity_date);
break;
default:
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$recentActivities[] = array('activity' => "{$position}: {$dao->case_activity_type_name} for {$applicant}", 'time' => $dao->case_activity_date);
break;
}
}
return $recentActivities;
}
示例9: processActivity
/**
* Process activity creation
*
* @param array $params associated array of submitted values
* @access protected
*/
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 (CRM_Utils_Array::value('is_multi_activity', $params)) {
$this->_activityIds[] = $activity->id;
} else {
$this->_activityId = $activity->id;
}
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
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_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
$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 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).");
}
}
// set status message
$subject = '';
if (CRM_Utils_Array::value('subject', $params)) {
$subject = "'" . $params['subject'] . "'";
}
CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
return $activity;
}