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


PHP CRM_Campaign_BAO_Survey::voterDetails方法代码示例

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


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

示例1: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_votingTab = $this->get('votingTab');
     $this->_reserveToInterview = $this->get('reserveToInterview');
     if ($this->_reserveToInterview || $this->_votingTab) {
         //user came from voting tab / reserve form.
         foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
             $this->{"_{$fld}"} = $this->get($fld);
         }
         //get the target voter ids.
         if ($this->_votingTab) {
             $this->getVoterIds();
         }
     } else {
         parent::preProcess();
         //get the survey id from user submitted values.
         $this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
         $this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
     }
     //get the contact read only fields to display.
     require_once 'CRM/Core/BAO/Preferences.php';
     $readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $returnProperties['contact_sub_type'] = true;
     //get the profile id.
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_id' => $this->_surveyId, 'entity_table' => 'civicrm_survey', 'module' => 'CiviCampaign');
     $this->_ufGroupId = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     $this->assign('ufGroupId', $this->_ufGroupId);
     //validate all voters for required activity.
     //get the survey activities for given voters.
     require_once 'CRM/Campaign/BAO/Survey.php';
     $this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
     require_once 'CRM/Core/PseudoConstant.php';
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $scheduledStatusId = array_search('Scheduled', $activityStatus);
     $activityIds = array();
     foreach ($this->_contactIds as $key => $voterId) {
         $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
         $statusId = CRM_Utils_Array::value('status_id', $actVals);
         $activityId = CRM_Utils_Array::value('activity_id', $actVals);
         if ($activityId && $statusId && $scheduledStatusId == $statusId) {
             $activityIds["activity_id_{$voterId}"] = $activityId;
         } else {
             unset($this->_contactIds[$key]);
         }
     }
     //retrieve the contact details.
     $voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
     $this->_allowAjaxReleaseButton = false;
     if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
         $this->_allowAjaxReleaseButton = true;
     }
     $this->assign('votingTab', $this->_votingTab);
     $this->assign('componentIds', $this->_contactIds);
     $this->assign('voterDetails', $voterDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
     $this->assign('interviewerId', $this->_interviewerId);
     $this->assign('surveyActivityIds', json_encode($activityIds));
     $this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
     //get the survey values.
     $this->_surveyValues = $this->get('surveyValues');
     if (!is_array($this->_surveyValues)) {
         $this->_surveyValues = array();
         if ($this->_surveyId) {
             require_once 'CRM/Campaign/BAO/Survey.php';
             $surveyParams = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
         }
         $this->set('surveyValues', $this->_surveyValues);
     }
     $this->assign('surveyValues', $this->_surveyValues);
     //get the survey result options.
     $this->_resultOptions = $this->get('resultOptions');
     if (!is_array($this->_resultOptions)) {
         $this->_resultOptions = array();
         if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
             require_once 'CRM/Core/OptionGroup.php';
             $this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
         }
         $this->set('resultOptions', $this->_resultOptions);
     }
     //validate the required ids.
     $this->validateIds();
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the title.
     require_once 'CRM/Core/PseudoConstant.php';
     $activityTypes = CRM_Core_PseudoConstant::activityType(false, true, false, 'label', true);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Interview.php

示例2: preProcess

 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $this->_votingTab = $this->get('votingTab');
     $this->_reserveToInterview = $this->get('reserveToInterview');
     if ($this->_reserveToInterview || $this->_votingTab) {
         //user came from voting tab / reserve form.
         foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
             $this->{"_{$fld}"} = $this->get($fld);
         }
         //get the target voter ids.
         if ($this->_votingTab) {
             $this->getVoterIds();
         }
     } else {
         parent::preProcess();
         //get the survey id from user submitted values.
         $this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
         $this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
     }
     if ($this->_surveyId) {
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
     }
     $orderClause = FALSE;
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
         $orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
     } elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
         $orderByParams = array(1 => array('column' => 'civicrm_address.street_name', 'order' => 'ASC'), 2 => array('column' => 'civicrm_address.street_number%2', 'order' => 'ASC'), 3 => array('column' => 'civicrm_address.street_number', 'order' => 'ASC'), 4 => array('column' => 'contact_a.sort_name', 'order' => 'ASC'));
     }
     $orderBy = array();
     if (!empty($orderByParams)) {
         foreach ($orderByParams as $key => $val) {
             if (!empty($val['column'])) {
                 $orderBy[] = "{$val['column']} {$val['order']}";
             }
         }
         if (!empty($orderBy)) {
             $orderClause = "ORDER BY " . implode(', ', $orderBy);
         }
     }
     $this->_contactIds = array_unique($this->_contactIds);
     if (!empty($this->_contactIds) && $orderClause) {
         $clause = 'contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
         $sql = "\nSELECT contact_a.id\nFROM civicrm_contact contact_a\nLEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id\nWHERE {$clause}\n{$orderClause}";
         $this->_contactIds = array();
         $dao = CRM_Core_DAO::executeQuery($sql);
         while ($dao->fetch()) {
             $this->_contactIds[] = $dao->id;
         }
     }
     //get the contact read only fields to display.
     $readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $returnProperties['contact_sub_type'] = TRUE;
     //validate all voters for required activity.
     //get the survey activities for given voters.
     $this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $scheduledStatusId = array_search('Scheduled', $activityStatus);
     $activityIds = array();
     foreach ($this->_contactIds as $key => $voterId) {
         $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
         $statusId = CRM_Utils_Array::value('status_id', $actVals);
         $activityId = CRM_Utils_Array::value('activity_id', $actVals);
         if ($activityId && $statusId && $scheduledStatusId == $statusId) {
             $activityIds["activity_id_{$voterId}"] = $activityId;
         } else {
             unset($this->_contactIds[$key]);
         }
     }
     //retrieve the contact details.
     $voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
     $this->_allowAjaxReleaseButton = FALSE;
     if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
         $this->_allowAjaxReleaseButton = TRUE;
     }
     //validate voter ids across profile.
     $this->filterVoterIds();
     $this->assign('votingTab', $this->_votingTab);
     $this->assign('componentIds', $this->_contactIds);
     $this->assign('componentIdsJson', json_encode($this->_contactIds));
     $this->assign('voterDetails', $voterDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
     $this->assign('interviewerId', $this->_interviewerId);
     $this->assign('surveyActivityIds', json_encode($activityIds));
     $this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
     //get the survey values.
     $this->_surveyValues = $this->get('surveyValues');
     if (!is_array($this->_surveyValues)) {
         $this->_surveyValues = array();
         if ($this->_surveyId) {
             $surveyParams = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
         }
         $this->set('surveyValues', $this->_surveyValues);
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Interview.php


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