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


PHP CRM_Activity_BAO_Activity::getSourceContactID方法代码示例

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


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

示例1: sendActivityCopy

 /**
  * Function that sends e-mail copy of activity
  *
  * @param $clientId
  * @param int $activityId activity Id
  * @param array $contacts array of related contact
  *
  * @param null $attachments
  * @param $caseId
  *
  * @return void
  * @access public
  */
 static function sendActivityCopy($clientId, $activityId, $contacts, $attachments = NULL, $caseId)
 {
     if (!$activityId) {
         return;
     }
     $tplParams = $activityInfo = array();
     //if its a case activity
     if ($caseId) {
         $activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityId, 'activity_type_id');
         $nonCaseActivityTypes = CRM_Core_PseudoConstant::activityType();
         if (!empty($nonCaseActivityTypes[$activityTypeId])) {
             $anyActivity = TRUE;
         } else {
             $anyActivity = FALSE;
         }
         $tplParams['isCaseActivity'] = 1;
         $tplParams['client_id'] = $clientId;
     } else {
         $anyActivity = TRUE;
     }
     $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
     $isRedact = $xmlProcessorProcess->getRedactActivityEmail();
     $xmlProcessorReport = new CRM_Case_XMLProcessor_Report();
     $activityInfo = $xmlProcessorReport->getActivityInfo($clientId, $activityId, $anyActivity, $isRedact);
     if ($caseId) {
         $activityInfo['fields'][] = array('label' => 'Case ID', 'type' => 'String', 'value' => $caseId);
     }
     $tplParams['activity'] = $activityInfo;
     foreach ($tplParams['activity']['fields'] as $k => $val) {
         if (CRM_Utils_Array::value('label', $val) == ts('Subject')) {
             $activitySubject = $val['value'];
             break;
         }
     }
     $session = CRM_Core_Session::singleton();
     // CRM-8926 If user is not logged in, use the activity creator as userID
     if (!($userID = $session->get('userID'))) {
         $userID = CRM_Activity_BAO_Activity::getSourceContactID($activityId);
     }
     //also create activities simultaneously of this copy.
     $activityParams = array();
     $activityParams['source_record_id'] = $activityId;
     $activityParams['source_contact_id'] = $userID;
     $activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
     $activityParams['activity_date_time'] = date('YmdHis');
     $activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
     $activityParams['medium_id'] = CRM_Core_OptionGroup::getValue('encounter_medium', 'email', 'name');
     $activityParams['case_id'] = $caseId;
     $activityParams['is_auto'] = 0;
     $activityParams['target_id'] = $clientId;
     $tplParams['activitySubject'] = $activitySubject;
     // if it’s a case activity, add hashed id to the template (CRM-5916)
     if ($caseId) {
         $tplParams['idHash'] = substr(sha1(CIVICRM_SITE_KEY . $caseId), 0, 7);
     }
     $result = array();
     list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
     $receiptFrom = "{$name} <{$address}>";
     $recordedActivityParams = array();
     foreach ($contacts as $mail => $info) {
         $tplParams['contact'] = $info;
         self::buildPermissionLinks($tplParams, $activityParams);
         $displayName = CRM_Utils_Array::value('display_name', $info);
         list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_case', 'valueName' => 'case_activity', 'contactId' => CRM_Utils_Array::value('contact_id', $info), 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $displayName, 'toEmail' => $mail, 'attachments' => $attachments));
         $activityParams['subject'] = $activitySubject . ' - copy sent to ' . $displayName;
         $activityParams['details'] = $message;
         if (!empty($result[$info['contact_id']])) {
             /*
              * Really only need to record one activity with all the targets combined.
              * Originally the template was going to possibly have different content, e.g. depending on permissions,
              * but it's always the same content at the moment.
              */
             if (empty($recordedActivityParams)) {
                 $recordedActivityParams = $activityParams;
             } else {
                 $recordedActivityParams['subject'] .= "; {$displayName}";
             }
             $recordedActivityParams['target_contact_id'][] = $info['contact_id'];
         } else {
             unset($result[CRM_Utils_Array::value('contact_id', $info)]);
         }
     }
     if (!empty($recordedActivityParams)) {
         $activity = CRM_Activity_BAO_Activity::create($recordedActivityParams);
         //create case_activity record if its case activity.
         if ($caseId) {
             $caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Case.php

示例2: _civicrm_api3_activity_get_formatResult

/**
 * Given a list of activities, append any extra data requested about the activities.
 *
 * @note Called by civicrm-core and CiviHR
 *
 * @param array $params
 *   API request parameters.
 * @param array $activities
 *
 * @return array
 *   new activities list
 */
function _civicrm_api3_activity_get_formatResult($params, $activities)
{
    $returns = CRM_Utils_Array::value('return', $params, array());
    if (!is_array($returns)) {
        $returns = str_replace(' ', '', $returns);
        $returns = explode(',', $returns);
    }
    $returns = array_fill_keys($returns, 1);
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            $returnkey = substr($n, 7);
            $returns[$returnkey] = $v;
        }
    }
    $returns['source_contact_id'] = 1;
    foreach ($returns as $n => $v) {
        switch ($n) {
            case 'assignee_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['assignee_contact_id'] = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($activityArray['id']);
                }
                break;
            case 'target_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['target_contact_id'] = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId($activityArray['id']);
                }
                break;
            case 'source_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['source_contact_id'] = CRM_Activity_BAO_Activity::getSourceContactID($activityArray['id']);
                }
                break;
            default:
                if (substr($n, 0, 6) == 'custom') {
                    $returnProperties[$n] = $v;
                }
        }
    }
    if (!empty($activities) && (!empty($returnProperties) || !empty($params['contact_id']))) {
        foreach ($activities as $activityId => $values) {
            //@todo - should possibly load activity type id if not loaded (update with id)
            _civicrm_api3_custom_data_get($activities[$activityId], CRM_Utils_Array::value('check_permissions', $params), 'Activity', $activityId, NULL, CRM_Utils_Array::value('activity_type_id', $values));
        }
    }
    return $activities;
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:58,代码来源:Activity.php

示例3: _convertToCaseActivity

 /**
  * @param array $params
  *
  * @return array
  */
 public static function _convertToCaseActivity($params)
 {
     if (!$params['activityID'] || !$params['caseID']) {
         return array('error_msg' => 'required params missing.');
     }
     $otherActivity = new CRM_Activity_DAO_Activity();
     $otherActivity->id = $params['activityID'];
     if (!$otherActivity->find(TRUE)) {
         return array('error_msg' => 'activity record is missing.');
     }
     $actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
     // Create new activity record.
     $mainActivity = new CRM_Activity_DAO_Activity();
     $mainActVals = array();
     CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
     // Get new activity subject.
     if (!empty($params['newSubject'])) {
         $mainActVals['subject'] = $params['newSubject'];
     }
     $mainActivity->copyValues($mainActVals);
     $mainActivity->id = NULL;
     $mainActivity->activity_date_time = $actDateTime;
     // Make sure this is current revision.
     $mainActivity->is_current_revision = TRUE;
     // Drop all relations.
     $mainActivity->parent_id = $mainActivity->original_id = NULL;
     $mainActivity->save();
     $mainActivityId = $mainActivity->id;
     CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
     $mainActivity->free();
     // Mark previous activity as deleted. If it was a non-case activity
     // then just change the subject.
     if (in_array($params['mode'], array('move', 'file'))) {
         $caseActivity = new CRM_Case_DAO_CaseActivity();
         $caseActivity->case_id = $params['caseID'];
         $caseActivity->activity_id = $otherActivity->id;
         if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
             $otherActivity->is_deleted = 1;
         } else {
             $otherActivity->subject = ts('(Filed on case %1)', array(1 => $params['caseID'])) . ' ' . $otherActivity->subject;
         }
         $otherActivity->activity_date_time = $actDateTime;
         $otherActivity->save();
         $caseActivity->free();
     }
     $otherActivity->free();
     $targetContacts = array();
     if (!empty($params['targetContactIds'])) {
         $targetContacts = array_unique(explode(',', $params['targetContactIds']));
     }
     $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 = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
     $src_params = array('activity_id' => $mainActivityId, 'contact_id' => $sourceContactID, 'record_type_id' => $sourceID);
     CRM_Activity_BAO_ActivityContact::create($src_params);
     foreach ($targetContacts as $key => $value) {
         $targ_params = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $targetID);
         CRM_Activity_BAO_ActivityContact::create($targ_params);
     }
     // typically this will be empty, since assignees on another case may be completely different
     $assigneeContacts = array();
     if (!empty($params['assigneeContactIds'])) {
         $assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
     }
     foreach ($assigneeContacts as $key => $value) {
         $assigneeParams = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $assigneeID);
         CRM_Activity_BAO_ActivityContact::create($assigneeParams);
     }
     // Attach newly created activity to case.
     $caseActivity = new CRM_Case_DAO_CaseActivity();
     $caseActivity->case_id = $params['caseID'];
     $caseActivity->activity_id = $mainActivityId;
     $caseActivity->save();
     $error_msg = $caseActivity->_lastError;
     $caseActivity->free();
     $params['mainActivityId'] = $mainActivityId;
     CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
     return array('error_msg' => $error_msg, 'newId' => $mainActivity->id);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:86,代码来源:AJAX.php

示例4: civicrm_api3_activity_get

/**
 * Gets a CiviCRM activity according to parameters
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs for the activity.
 *
 * @return array
 *
 * {@getfields activity_get}
 * @example ActivityGet.php Basic example
 * @example Activity/DateTimeHigh.php Example get with date filtering
 * {@example ActivityGet.php 0}
 */
function civicrm_api3_activity_get($params)
{
    if (!empty($params['contact_id'])) {
        $activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
        //BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write happens it won't get missed
        foreach ($activities as $key => $activityArray) {
            $activities[$key]['id'] = $key;
        }
    } else {
        $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
    }
    $returns = CRM_Utils_Array::value('return', $params, array());
    if (!is_array($returns)) {
        $returns = str_replace(' ', '', $returns);
        $returns = explode(',', $returns);
    }
    $returns = array_fill_keys($returns, 1);
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            $returnkey = substr($n, 7);
            $returns[$returnkey] = $v;
        }
    }
    $returns['source_contact_id'] = 1;
    foreach ($returns as $n => $v) {
        switch ($n) {
            case 'assignee_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['assignee_contact_id'] = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($activityArray['id']);
                }
                break;
            case 'target_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['target_contact_id'] = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId($activityArray['id']);
                }
                break;
            case 'source_contact_id':
                foreach ($activities as $key => $activityArray) {
                    $activities[$key]['source_contact_id'] = CRM_Activity_BAO_Activity::getSourceContactID($activityArray['id']);
                }
                break;
            default:
                if (substr($n, 0, 6) == 'custom') {
                    $returnProperties[$n] = $v;
                }
        }
    }
    if (!empty($activities) && (!empty($returnProperties) || !empty($params['contact_id']))) {
        foreach ($activities as $activityId => $values) {
            _civicrm_api3_custom_data_get($activities[$activityId], 'Activity', $activityId, NULL, $values['activity_type_id']);
        }
    }
    //legacy custom data get - so previous formatted response is still returned too
    return civicrm_api3_create_success($activities, $params, 'activity', 'get');
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:68,代码来源:Activity.php


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