本文整理汇总了PHP中CRM_Campaign_BAO_Survey::getSurveyContactType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Survey::getSurveyContactType方法的具体用法?PHP CRM_Campaign_BAO_Survey::getSurveyContactType怎么用?PHP CRM_Campaign_BAO_Survey::getSurveyContactType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::getSurveyContactType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: voterList
public function voterList()
{
//get the search criteria params.
$searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
$searchParams = explode(',', $searchCriteria);
$params = $searchRows = array();
foreach ($searchParams as $param) {
if (!empty($_POST[$param])) {
$params[$param] = $_POST[$param];
}
}
//format multi-select group and contact types.
foreach (array('group', 'contact_type') as $param) {
$paramValue = CRM_Utils_Array::value($param, $params);
if ($paramValue) {
unset($params[$param]);
$paramValue = explode(',', $paramValue);
foreach ($paramValue as $key => $value) {
$params[$param][$value] = 1;
}
}
}
$voterClauseParams = array();
foreach (array('campaign_survey_id', 'survey_interviewer_id', 'campaign_search_voter_for') as $fld) {
$voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params);
}
$interviewerId = $surveyTypeId = $surveyId = NULL;
$searchVoterFor = $params['campaign_search_voter_for'];
if ($searchVoterFor == 'reserve') {
if (!empty($params['campaign_survey_id'])) {
$survey = new CRM_Campaign_DAO_Survey();
$survey->id = $surveyId = $params['campaign_survey_id'];
$survey->selectAdd('campaign_id, activity_type_id');
$survey->find(TRUE);
$campaignId = $survey->campaign_id;
$surveyTypeId = $survey->activity_type_id;
//allow voter search in sub-part of given constituents,
//but make sure in case user does not select any group.
//get all associated campaign groups in where filter, CRM-7406
$groups = CRM_Utils_Array::value('group', $params);
if ($campaignId && CRM_Utils_System::isNull($groups)) {
$campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
foreach ($campaignGroups as $id => $group) {
$params['group'][$id] = 1;
}
}
//apply filter of survey contact type for search.
$contactType = CRM_Campaign_BAO_Survey::getSurveyContactType($surveyId);
if ($contactType) {
$params['contact_type'][$contactType] = 1;
}
unset($params['campaign_survey_id']);
}
unset($params['survey_interviewer_id']);
} else {
//get the survey status in where clause.
$scheduledStatusId = array_search('Scheduled', CRM_Core_PseudoConstant::activityStatus('name'));
if ($scheduledStatusId) {
$params['survey_status_id'] = $scheduledStatusId;
}
//BAO/Query knows reserve/release/interview processes.
if ($params['campaign_search_voter_for'] == 'gotv') {
$params['campaign_search_voter_for'] = 'release';
}
}
$selectorCols = array('sort_name', 'street_address', 'street_name', 'street_number', 'street_unit');
// get the data table params.
$dataTableParams = array('sEcho' => array('name' => 'sEcho', 'type' => 'Integer', 'default' => 0), 'offset' => array('name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0), 'rowCount' => array('name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25), 'sort' => array('name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'sort_name'), 'sortOrder' => array('name' => 'sSortDir_0', 'type' => 'String', 'default' => 'asc'));
foreach ($dataTableParams as $pName => $pValues) {
${$pName} = $pValues['default'];
if (!empty($_POST[$pValues['name']])) {
${$pName} = CRM_Utils_Type::escape($_POST[$pValues['name']], $pValues['type']);
if ($pName == 'sort') {
${$pName} = $selectorCols[${$pName}];
}
}
}
$queryParams = CRM_Contact_BAO_Query::convertFormValues($params);
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CAMPAIGN, TRUE);
//get the voter clause to restrict and validate search.
$voterClause = CRM_Campaign_BAO_Query::voterClause($voterClauseParams);
$searchCount = $query->searchQuery(0, 0, NULL, TRUE, FALSE, FALSE, FALSE, FALSE, CRM_Utils_Array::value('whereClause', $voterClause), NULL, CRM_Utils_Array::value('fromClause', $voterClause));
$iTotal = $searchCount;
$selectorCols = array('contact_type', 'sort_name', 'street_address', 'street_name', 'street_number', 'street_unit');
$extraVoterColName = 'is_interview_conducted';
if ($params['campaign_search_voter_for'] == 'reserve') {
$extraVoterColName = 'reserve_voter';
}
if ($searchCount > 0) {
if ($searchCount < $offset) {
$offset = 0;
}
$config = CRM_Core_Config::singleton();
// get the result of the search
$result = $query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, CRM_Utils_Array::value('whereClause', $voterClause), $sortOrder, CRM_Utils_Array::value('fromClause', $voterClause));
while ($result->fetch()) {
$contactID = $result->contact_id;
$typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$searchRows[$contactID] = array('id' => $contactID);
foreach ($selectorCols as $col) {
//.........这里部分代码省略.........
示例2: formatParams
public function formatParams()
{
$interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->_formValues);
if ($interviewerId) {
$this->set('interviewerId', $interviewerId);
}
//format multi-select group and contact types.
foreach (array('group', 'contact_type') as $param) {
if ($this->_force) {
continue;
}
$paramValue = CRM_Utils_Array::value($param, $this->_formValues);
if ($paramValue && is_array($paramValue)) {
unset($this->_formValues[$param]);
foreach ($paramValue as $key => $value) {
$this->_formValues[$param][$value] = 1;
}
}
}
//apply filter of survey contact type for search.
$contactType = CRM_Campaign_BAO_Survey::getSurveyContactType(CRM_Utils_Array::value('campaign_survey_id', $this->_formValues));
if ($contactType && in_array($this->_operation, array('reserve', 'interview'))) {
$this->_formValues['contact_type'][$contactType] = 1;
}
if ($this->_operation == 'reserve') {
if (!empty($this->_formValues['campaign_survey_id'])) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'campaign_id');
//allow voter search in sub-part of given constituents,
//but make sure in case user does not select any group.
//get all associated campaign groups in where filter, CRM-7406
$groups = CRM_Utils_Array::value('group', $this->_formValues);
if ($campaignId && CRM_Utils_System::isNull($groups)) {
$campGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
foreach ($campGroups as $id => $title) {
$this->_formValues['group'][$id] = 1;
}
}
//carry servey id w/ this.
$this->set('surveyId', $this->_formValues['campaign_survey_id']);
unset($this->_formValues['campaign_survey_id']);
}
unset($this->_formValues['survey_interviewer_id']);
} elseif ($this->_operation == 'interview' || $this->_operation == 'release') {
//to conduct interview / release activity status should be scheduled.
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
if ($scheduledStatusId = array_search('Scheduled', $activityStatus)) {
$this->_formValues['survey_status_id'] = $scheduledStatusId;
}
}
//pass voter search operation.
$this->_formValues['campaign_search_voter_for'] = $this->_operation;
}