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


PHP CRM_Campaign_BAO_Survey::getSurveyResponseFields方法代码示例

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


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

示例1: _addSurveyResponseColumns

    private function _addSurveyResponseColumns()
    {
        $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params);
        if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['survey_response'])) {
            return;
        }
        $responseFields = array();
        foreach ($surveyIds as $surveyId) {
            $responseFields += CRM_Campaign_BAO_Survey::getSurveyResponseFields($surveyId);
            $this->_surveyResponseFields = $responseFields;
        }
        foreach ($responseFields as $key => $value) {
            if (substr($key, 0, 5) == 'phone' && !empty($value['location_type_id'])) {
                $fName = str_replace('-', '_', $key);
                $this->_columns["civicrm_{$fName}"] = array('dao' => 'CRM_Core_DAO_Phone', 'alias' => "phone_civireport_{$fName}", 'fields' => array($fName => array_merge($value, array('is_required' => '1', 'alias' => "phone_civireport_{$fName}", 'dbAlias' => "phone_civireport_{$fName}.phone", 'no_display' => TRUE))));
                $this->_aliases["civicrm_phone_{$fName}"] = $this->_columns["civicrm_{$fName}"]['alias'];
                $this->_locationBasedPhoneField = TRUE;
            }
        }
        $responseFieldIds = array();
        foreach (array_keys($responseFields) as $key) {
            $cfId = CRM_Core_BAO_CustomField::getKeyID($key);
            if ($cfId) {
                $responseFieldIds[$cfId] = $cfId;
            }
        }
        if (empty($responseFieldIds)) {
            return;
        }
        $query = '
     SELECT  cg.extends,
             cf.data_type,
             cf.html_type,
             cg.table_name,
             cf.column_name,
             cf.time_format,
             cf.id as cfId,
             cf.option_group_id
       FROM  civicrm_custom_group cg
INNER  JOIN  civicrm_custom_field cf ON ( cg.id = cf.custom_group_id )
      WHERE  cf.id IN ( ' . implode(' , ', $responseFieldIds) . ' )  ORDER BY cf.weight';
        $response = CRM_Core_DAO::executeQuery($query);
        $fildCnt = 1;
        while ($response->fetch()) {
            $resTable = $response->table_name;
            $fieldName = "custom_{$response->cfId}";
            //need to check does these custom data already included.
            if (!array_key_exists($resTable, $this->_columns)) {
                $this->_columns[$resTable]['dao'] = 'CRM_Contact_DAO_Contact';
                $this->_columns[$resTable]['extends'] = $response->extends;
            }
            if (empty($this->_columns[$resTable]['alias'])) {
                $this->_columns[$resTable]['alias'] = "{$resTable}_survey_response";
            }
            if (!is_array(CRM_Utils_Array::value('fields', $this->_columns[$resTable]))) {
                $this->_columns[$resTable]['fields'] = array();
            }
            if (array_key_exists($fieldName, $this->_columns[$resTable]['fields'])) {
                $this->_columns[$resTable]['fields'][$fieldName]['required'] = TRUE;
                $this->_columns[$resTable]['fields'][$fieldName]['isSurveyResponseField'] = TRUE;
                continue;
            }
            $title = $responseFields[$fieldName]['title'];
            if (in_array($this->_outputMode, array('print', 'pdf'))) {
                $title = 'Q' . $fildCnt++;
            }
            $fldType = 'CRM_Utils_Type::T_STRING';
            if ($response->time_format) {
                $fldType = CRM_Utils_Type::T_TIMESTAMP;
            }
            $field = array('name' => $response->column_name, 'type' => $fldType, 'title' => $title, 'label' => $responseFields[$fieldName]['title'], 'dataType' => $response->data_type, 'htmlType' => $response->html_type, 'required' => TRUE, 'alias' => $response->data_type == 'ContactReference' ? $this->_columns[$resTable]['alias'] . '_contact' : $this->_columns[$resTable]['alias'], 'dbAlias' => $this->_columns[$resTable]['alias'] . '.' . $response->column_name, 'no_display' => TRUE, 'isSurveyResponseField' => TRUE);
            $this->_columns[$resTable]['fields'][$fieldName] = $field;
            $this->_aliases[$resTable] = $this->_columns[$resTable]['alias'];
        }
    }
开发者ID:konadave,项目名称:civicrm-core,代码行数:75,代码来源:SurveyDetails.php

示例2: registerInterview

 /**
  * @param array $params
  *
  * @return mixed
  */
 public static function registerInterview($params)
 {
     $activityId = CRM_Utils_Array::value('activity_id', $params);
     $surveyTypeId = CRM_Utils_Array::value('activity_type_id', $params);
     if (!is_array($params) || !$surveyTypeId || !$activityId) {
         return FALSE;
     }
     static $surveyFields;
     if (!is_array($surveyFields)) {
         $surveyFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $surveyTypeId, NULL, FALSE, TRUE);
     }
     static $statusId;
     if (!$statusId) {
         $statusId = array_search('Completed', CRM_Core_PseudoConstant::activityStatus('name'));
     }
     //format custom fields.
     $customParams = CRM_Core_BAO_CustomField::postProcess($params, $activityId, 'Activity');
     CRM_Core_BAO_CustomValueTable::store($customParams, 'civicrm_activity', $activityId);
     //process contact data.
     $contactParams = $fields = array();
     $contactFieldTypes = array_merge(array('Contact'), CRM_Contact_BAO_ContactType::basicTypes());
     $responseFields = CRM_Campaign_BAO_Survey::getSurveyResponseFields($params['survey_id']);
     if (!empty($responseFields)) {
         foreach ($params as $key => $value) {
             if (array_key_exists($key, $responseFields)) {
                 if (in_array($responseFields[$key]['field_type'], $contactFieldTypes)) {
                     $fields[$key] = $responseFields[$key];
                     $contactParams[$key] = $value;
                     if (isset($params["{$key}_id"])) {
                         $contactParams["{$key}_id"] = $params["{$key}_id"];
                     }
                 }
             }
         }
     }
     $contactId = CRM_Utils_Array::value('voter_id', $params);
     if ($contactId && !empty($contactParams)) {
         CRM_Contact_BAO_Contact::createProfileContact($contactParams, $fields, $contactId);
     }
     //update activity record.
     $activity = new CRM_Activity_DAO_Activity();
     $activity->id = $activityId;
     $activity->selectAdd();
     $activity->selectAdd('activity_date_time, status_id, result, subject');
     $activity->find(TRUE);
     $activity->activity_date_time = date('YmdHis');
     $activity->status_id = $statusId;
     if (!empty($params['activity_date_time'])) {
         $activity->activity_date_time = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     }
     $subject = '';
     $surveyTitle = CRM_Utils_Array::value('surveyTitle', $params);
     if ($surveyTitle) {
         $subject = $surveyTitle . ' - ';
     }
     $subject .= ts('Respondent Interview');
     $activity->subject = $subject;
     $activityParams = array('details' => 'details', 'result' => 'result', 'engagement_level' => 'activity_engagement_level', 'subject' => 'activity_subject', 'status_id' => 'activity_status_id', 'source_contact_id' => 'source_contact', 'location' => 'activity_location', 'campaign_id' => 'activity_campaign_id', 'duration' => 'activity_duration');
     foreach ($activityParams as $key => $field) {
         if (!empty($params[$field])) {
             $activity->{$key} = $params[$field];
         }
     }
     $activity->save();
     //really this should use Activity BAO& not be here but refactoring will have to be later
     //actually the whole ajax call could be done as an api ajax call & post hook would be sorted
     CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
     $activity->free();
     return $activityId;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:75,代码来源:Interview.php


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