当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Activity_BAO_Activity::sendToAssignee方法代码示例

本文整理汇总了PHP中CRM_Activity_BAO_Activity::sendToAssignee方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::sendToAssignee方法的具体用法?PHP CRM_Activity_BAO_Activity::sendToAssignee怎么用?PHP CRM_Activity_BAO_Activity::sendToAssignee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Activity_BAO_Activity的用法示例。


在下文中一共展示了CRM_Activity_BAO_Activity::sendToAssignee方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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');
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例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 (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;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:99,代码来源:Activity.php

示例3: postProcess


//.........这里部分代码省略.........
     // CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
     if (isset($form->_caseId) && is_numeric($form->_caseId)) {
         $hash = substr(sha1(CIVICRM_SITE_KEY . $form->_caseId), 0, 7);
         $subject = "[case #{$hash}] {$subject}";
     }
     // process message template
     if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
         $messageTemplate = array('msg_text' => $formValues['text_message'], 'msg_html' => $formValues['html_message'], 'msg_subject' => $formValues['subject'], 'is_active' => TRUE);
         if (!empty($formValues['saveTemplate'])) {
             $messageTemplate['msg_title'] = $formValues['saveTemplateName'];
             CRM_Core_BAO_MessageTemplate::add($messageTemplate);
         }
         if (!empty($formValues['template']) && !empty($formValues['updateTemplate'])) {
             $messageTemplate['id'] = $formValues['template'];
             unset($messageTemplate['msg_title']);
             CRM_Core_BAO_MessageTemplate::add($messageTemplate);
         }
     }
     $attachments = array();
     CRM_Core_BAO_File::formatAttachment($formValues, $attachments, NULL, NULL);
     // format contact details array to handle multiple emails from same contact
     $formattedContactDetails = array();
     $tempEmails = array();
     foreach ($form->_contactIds as $key => $contactId) {
         // if we dont have details on this contactID, we should ignore
         // potentially this is due to the contact not wanting to receive email
         if (!isset($form->_contactDetails[$contactId])) {
             continue;
         }
         $email = $form->_toContactEmails[$key];
         // prevent duplicate emails if same email address is selected CRM-4067
         // we should allow same emails for different contacts
         $emailKey = "{$contactId}::{$email}";
         if (!in_array($emailKey, $tempEmails)) {
             $tempEmails[] = $emailKey;
             $details = $form->_contactDetails[$contactId];
             $details['email'] = $email;
             unset($details['email_id']);
             $formattedContactDetails[] = $details;
         }
     }
     // send the mail
     list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail($formattedContactDetails, $subject, $formValues['text_message'], $formValues['html_message'], NULL, NULL, $from, $attachments, $cc, $bcc, array_keys($form->_toContactDetails), $additionalDetails);
     $followupStatus = '';
     if ($sent) {
         $followupActivity = NULL;
         if (!empty($formValues['followup_activity_type_id'])) {
             $params['followup_activity_type_id'] = $formValues['followup_activity_type_id'];
             $params['followup_activity_subject'] = $formValues['followup_activity_subject'];
             $params['followup_date'] = $formValues['followup_date'];
             $params['followup_date_time'] = $formValues['followup_date_time'];
             $params['target_contact_id'] = $form->_contactIds;
             $params['followup_assignee_contact_id'] = explode(',', $formValues['followup_assignee_contact_id']);
             $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activityId, $params);
             $followupStatus = ts('A followup activity has been scheduled.');
             if (Civi::settings()->get('activity_assignee_notification')) {
                 if ($followupActivity) {
                     $mailToFollowupContacts = array();
                     $assignee = array($followupActivity->id);
                     $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($assignee, TRUE, FALSE);
                     foreach ($assigneeContacts as $values) {
                         $mailToFollowupContacts[$values['email']] = $values;
                     }
                     $sentFollowup = CRM_Activity_BAO_Activity::sendToAssignee($followupActivity, $mailToFollowupContacts);
                     if ($sentFollowup) {
                         $followupStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
                     }
                 }
             }
         }
         $count_success = count($form->_toContactDetails);
         CRM_Core_Session::setStatus(ts('One message was sent successfully. ', array('plural' => '%count messages were sent successfully. ', 'count' => $count_success)) . $followupStatus, ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $count_success)), 'success');
     }
     // Display the name and number of contacts for those email is not sent.
     // php 5.4 throws out a notice since the values of these below arrays are arrays.
     // the behavior is not documented in the php manual, but it does the right thing
     // suppressing the notices to get things in good shape going forward
     $emailsNotSent = @array_diff_assoc($form->_allContactDetails, $form->_contactDetails);
     if ($emailsNotSent) {
         $not_sent = array();
         foreach ($emailsNotSent as $contactId => $values) {
             $displayName = $values['display_name'];
             $email = $values['email'];
             $contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactId}");
             $not_sent[] = "<a href='{$contactViewUrl}' title='{$email}'>{$displayName}</a>" . ($values['on_hold'] ? '(' . ts('on hold') . ')' : '');
         }
         $status = '(' . ts('because no email address on file or communication preferences specify DO NOT EMAIL or Contact is deceased or Primary email address is On Hold') . ')<ul><li>' . implode('</li><li>', $not_sent) . '</li></ul>';
         CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($emailsNotSent), 'plural' => '%count Messages Not Sent')), 'info');
     }
     if (isset($form->_caseId)) {
         // if case-id is found in the url, create case activity record
         $cases = explode(',', $form->_caseId);
         foreach ($cases as $key => $val) {
             if (is_numeric($val)) {
                 $caseParams = array('activity_id' => $activityId, 'case_id' => $val);
                 CRM_Case_BAO_Case::processCaseActivity($caseParams);
             }
         }
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:EmailCommon.php


注:本文中的CRM_Activity_BAO_Activity::sendToAssignee方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。