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


PHP CRM_Activity_BAO_Activity::getContactActivity方法代码示例

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


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

示例1: testGetContactActivity

 /**
  * Test case for getContactActivity() method.
  *
  * getContactActivity() method get activities detail for given target contact id.
  */
 public function testGetContactActivity()
 {
     $contactId = Contact::createIndividual();
     $params = array('first_name' => 'liz', 'last_name' => 'hurleey');
     $targetContactId = Contact::createIndividual($params);
     $params = array('source_contact_id' => $contactId, 'subject' => 'Scheduling Meeting', 'activity_type_id' => 2, 'target_contact_id' => array($targetContactId), 'activity_date_time' => date('Ymd'));
     CRM_Activity_BAO_Activity::create($params);
     $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', 'subject', 'Database check for created activity.');
     $activities = CRM_Activity_BAO_Activity::getContactActivity($targetContactId);
     $this->assertEquals($activities[$activityId]['subject'], 'Scheduling Meeting', 'Verify activity subject is correct.');
     Contact::delete($contactId);
     Contact::delete($targetContactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:18,代码来源:ActivityTest.php

示例2: foreach

/**
 * Retrieve a set of Activities specific to given contact Id.
 * @param int $contactID.
 *
 * @return array (reference)  array of activities.
 * @access public
 */
function &_civicrm_activities_get($contactID, $type = 'all')
{
    $activities = CRM_Activity_BAO_Activity::getContactActivity($contactID);
    //get the custom data.
    if (is_array($activities) && !empty($activities)) {
        require_once 'api/v2/Activity.php';
        foreach ($activities as $activityId => $values) {
            $customParams = array('activity_id' => $activityId, 'activity_type_id' => CRM_Utils_Array::value('activity_type_id', $values));
            $customData = civicrm_activity_custom_get($customParams);
            if (is_array($customData) && !empty($customData)) {
                $activities[$activityId] = array_merge($activities[$activityId], $customData);
            }
        }
    }
    return $activities;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:23,代码来源:ActivityContact.php

示例3: 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) {
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:SMSCommon.php

示例4: civicrm_api3_activity_get

/**
 * Gets a CiviCRM activity according to parameters.
 *
 * @param array $params
 *   Array per getfields documentation.
 *
 * @return array
 *   API result array
 */
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 {
        $sql = CRM_Utils_SQL_Select::fragment();
        $options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
        $options = $options['values'];
        $activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
        foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
            if (!empty($params[$activityContactName])) {
                // If the intent is to have multiple joins -- one for each relation -- then you would
                // need different table aliases. Consider replacing 'ac' and passing in a '!alias' param,
                // with a different value for each relation.
                $sql->join('activity_' . $activityContactName, 'LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = #typeId', array('typeId' => $activityContactValue));
                $sql->where('ac.contact_id IN (#cid)', array('cid' => $params[$activityContactName]));
            }
        }
        $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
    }
    $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
    if ($options['is_count']) {
        return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
    }
    $activities = _civicrm_api3_activity_get_formatResult($params, $activities);
    //legacy custom data get - so previous formatted response is still returned too
    return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:42,代码来源:Activity.php

示例5: 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

示例6: 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);
    }
    if (CRM_Utils_Array::value('return.assignee_contact_id', $params)) {
        foreach ($activities as $key => $activityArray) {
            $activities[$key]['assignee_contact_id'] = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($activityArray['id']);
        }
    }
    if (CRM_Utils_Array::value('return.target_contact_id', $params)) {
        foreach ($activities as $key => $activityArray) {
            $activities[$key]['target_contact_id'] = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId($activityArray['id']);
        }
    }
    foreach ($params as $n => $v) {
        // handle the format return.sort_name=1,return.display_name=1
        if (substr($n, 0, 13) == 'return.custom') {
            $returnProperties[substr($n, 7)] = $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:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:48,代码来源:Activity.php

示例7: civicrm_api3_activity_get

/**
 * Gets a CiviCRM activity according to parameters.
 *
 * @param array $params
 *   Array per getfields documentation.
 *
 * @return array
 *   API result array
 */
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, 'Activity');
    }
    $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
    if ($options['is_count']) {
        return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
    }
    $activities = _civicrm_api3_activity_get_formatResult($params, $activities);
    //legacy custom data get - so previous formatted response is still returned too
    return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
开发者ID:vajeevan,项目名称:civicrm-core,代码行数:29,代码来源:Activity.php

示例8: civicrm_api3_activity_get

/**
 * Gets a CiviCRM activity according to parameters.
 *
 * @param array $params
 *   Array per getfields documentation.
 *
 * @return array
 *   API result array
 */
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 {
        $extraSql = array();
        $options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
        $options = $options['values'];
        $activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
        foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
            if (!empty($params[$activityContactName])) {
                $extraSql['join'][] = array('activity_' . $activityContactName => '
          LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = ' . (int) $activityContactValue);
                // Note that if we later need to change the int to an array we would need sql escaping.
                $extraSql['where'] = array('activity_' . $activityContactName => 'ac.contact_id = ' . (int) $params[$activityContactName]);
            }
        }
        $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $extraSql);
    }
    $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
    if ($options['is_count']) {
        return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
    }
    $activities = _civicrm_api3_activity_get_formatResult($params, $activities);
    //legacy custom data get - so previous formatted response is still returned too
    return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:41,代码来源:Activity.php

示例9: civicrm_api3_activity_get

/**
 * Gets a CiviCRM activity according to parameters.
 *
 * @param array $params
 *   Array per getfields documentation.
 *
 * @return array API result array
 *   API result array
 *
 * @throws \API_Exception
 * @throws \CiviCRM_API3_Exception
 * @throws \Civi\API\Exception\UnauthorizedException
 */
function civicrm_api3_activity_get($params)
{
    if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('view all activities')) {
        // In absence of view all activities permission it's possible to see a specific activity by ACL.
        // Note still allowing view all activities to override ACLs is based on the 'don't change too much
        // if you are not sure principle' and it could be argued that the ACLs should always be applied.
        if (empty($params['id']) || !empty($params['contact_id'])) {
            // We fall back to the original blunt permissions if we don't have an id to check or we are about
            // to go to the weird place that the legacy 'contact_id' parameter takes us to.
            throw new \Civi\API\Exception\UnauthorizedException("Cannot access activities. Required permission: 'view all activities''");
        }
        if (!CRM_Activity_BAO_Activity::checkPermission($params['id'], CRM_Core_Action::VIEW)) {
            throw new \Civi\API\Exception\UnauthorizedException('You do not have permission to view this activity');
        }
    }
    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 {
        $sql = CRM_Utils_SQL_Select::fragment();
        $options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
        $options = $options['values'];
        $activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
        foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
            if (!empty($params[$activityContactName])) {
                // If the intent is to have multiple joins -- one for each relation -- then you would
                // need different table aliases. Consider replacing 'ac' and passing in a '!alias' param,
                // with a different value for each relation.
                $sql->join('activity_' . $activityContactName, 'LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = #typeId', array('typeId' => $activityContactValue));
                $sql->where('ac.contact_id IN (#cid)', array('cid' => $params[$activityContactName]));
            }
        }
        $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
    }
    $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
    if ($options['is_count']) {
        return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
    }
    $activities = _civicrm_api3_activity_get_formatResult($params, $activities);
    //legacy custom data get - so previous formatted response is still returned too
    return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:59,代码来源:Activity.php


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