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


PHP CRM_Campaign_BAO_Campaign::getCampaignGroups方法代码示例

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


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

示例1: campaignGroups

 public function campaignGroups()
 {
     $surveyId = CRM_Utils_Request::retrieve('survey_id', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
     $campGroups = array();
     if ($surveyId) {
         $campaignId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'campaign_id');
         if ($campaignId) {
             $campGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
         }
     }
     //CRM-7406 --If there is no campaign or no group associated with
     //campaign of given survey, lets allow to search across all groups.
     if (empty($campGroups)) {
         $campGroups = CRM_Core_PseudoConstant::group();
     }
     $groups = array(array('value' => '', 'title' => ts('- select -')));
     foreach ($campGroups as $grpId => $title) {
         $groups[] = array('value' => $grpId, 'title' => $title);
     }
     $results = array('status' => 'success', 'groups' => $groups);
     CRM_Utils_JSON::output($results);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:22,代码来源:AJAX.php

示例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;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:52,代码来源:Search.php

示例3: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $existingVoterIds = $campGrpContacts = $reservedVoterIds = array();
     foreach ($this->_surveyActivities as $actId => $actVals) {
         $voterId = $actVals['voter_id'];
         $existingVoterIds[$voterId] = $voterId;
     }
     $campaignId = CRM_Utils_Array::value('campaign_id', $this->_surveyDetails);
     require_once 'CRM/Campaign/BAO/Campaign.php';
     require_once 'CRM/Contact/DAO/Group.php';
     require_once 'CRM/Contact/BAO/GroupContact.php';
     $campGrps = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
     foreach ($campGrps as $grpId => $grpVals) {
         $group = new CRM_Contact_DAO_Group();
         $group->id = $grpVals['entity_id'];
         $contacts = CRM_Contact_BAO_GroupContact::getGroupContacts($group);
         foreach ($contacts as $contact) {
             $campContacts[$contact->contact_id] = $contact->contact_id;
         }
     }
     //add reservation.
     require_once 'CRM/Core/PseudoConstant.php';
     $countVoters = 0;
     $maxVoters = $surveyDetails['max_number_of_contacts'];
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $statusHeld = array_search('Scheduled', $activityStatus);
     require_once 'CRM/Activity/BAO/Activity.php';
     foreach ($this->_contactIds as $cid) {
         //apply filter for existing voters
         //and do check across campaign contacts.
         if (in_array($cid, $existingVoterIds) || !empty($campContacts) && !in_array($cid, $campContacts)) {
             continue;
         }
         $subject = ts('%1', array(1 => $this->_surveyDetails['title'])) . ' - ' . ts('Respondent Reservation');
         $session =& CRM_Core_Session::singleton();
         $activityParams = array('source_contact_id' => $session->get('userID'), 'assignee_contact_id' => array($this->_interviewerId), 'target_contact_id' => array($cid), 'source_record_id' => $this->_surveyId, 'activity_type_id' => $this->_surveyDetails['activity_type_id'], 'subject' => $subject, 'activity_date_time' => date('YmdHis'), 'status_id' => $statusHeld, 'skipRecentView' => 1);
         $activity = CRM_Activity_BAO_Activity::create($activityParams);
         if ($activity->id) {
             $countVoters++;
             $reservedVoterIds[$cid] = $cid;
         }
         if ($maxVoters && $maxVoters <= $this->_numVoters + $countVoters) {
             break;
         }
     }
     $status = array();
     if ($countVoters > 0) {
         $status[] = ts('Reservation has been added for %1 Contact(s).', array(1 => $countVoters));
     }
     if (count($this->_contactIds) > $countVoters) {
         $status[] = ts('Reservation did not add for %1 Contact(s).', array(1 => count($this->_contactIds) - $countVoters));
     }
     if (!empty($status)) {
         CRM_Core_Session::setStatus(implode('&nbsp;&nbsp;', $status));
     }
     //get ready to jump to voter interview form.
     $buttonName = $this->controller->getButtonName();
     if (!empty($reservedVoterIds) && $buttonName == '_qf_Reserve_next_reserveToInterview') {
         $this->controller->set('surveyId', $this->_surveyId);
         $this->controller->set('contactIds', $reservedVoterIds);
         $this->controller->set('interviewerId', $this->_interviewerId);
         $this->controller->set('reserveToInterview', true);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:70,代码来源:Reserve.php

示例4: formatParams

 function formatParams()
 {
     $interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->_formValues);
     if (!$interviewerId) {
         $session =& CRM_Core_Session::singleton();
         $this->_formValues['survey_interviewer_id'] = $interviewerId = $session->get('userID');
     }
     $this->set('interviewerId', $interviewerId);
     if (!CRM_Utils_Array::value('survey_interviewer_name', $this->_formValues)) {
         $this->_formValues['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $interviewerId, 'sort_name', 'id');
     }
     if ($this->_operation == 'reserve') {
         if (CRM_Utils_Array::value('campaign_survey_id', $this->_formValues)) {
             $campaignId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'campaign_id');
             if ($campaignId) {
                 require_once 'CRM/Campaign/BAO/Campaign.php';
                 $campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
                 foreach ($campaignGroups as $id => $group) {
                     if ($group['entity_table'] == 'civicrm_group') {
                         $this->_formValues['group'][$group['entity_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']);
     } else {
         if ($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;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:40,代码来源:Search.php

示例5: voterList

 function voterList()
 {
     $searchParams = array('city', 'sort_name', 'street_unit', 'street_name', 'postal_code', 'street_number', 'street_address', 'survey_interviewer_id', 'campaign_survey_id', 'campaign_search_voter_for');
     $params = $searchRows = array();
     foreach ($searchParams as $param) {
         if (CRM_Utils_Array::value($param, $_POST)) {
             $params[$param] = $_POST[$param];
         }
     }
     $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 (CRM_Utils_Array::value('campaign_survey_id', $params)) {
             require_once 'CRM/Campaign/DAO/Survey.php';
             $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;
             if ($campaignId) {
                 require_once 'CRM/Campaign/BAO/Campaign.php';
                 $campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
                 foreach ($campaignGroups as $id => $group) {
                     if ($group['entity_table'] == 'civicrm_group') {
                         $params['group'][$group['entity_id']] = 1;
                     }
                 }
             }
             unset($params['campaign_survey_id']);
         }
         unset($params['survey_interviewer_id']);
     } else {
         //get the survey status in where clause.
         require_once 'CRM/Core/PseudoConstant.php';
         $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 (CRM_Utils_Array::value($pValues['name'], $_POST)) {
             ${$pName} = CRM_Utils_Type::escape($_POST[$pValues['name']], $pValues['type']);
             if ($pName == 'sort') {
                 ${$pName} = $selectorCols[${$pName}];
             }
         }
     }
     require_once 'CRM/Contact/BAO/Query.php';
     $queryParams = CRM_Contact_BAO_Query::convertFormValues($params);
     $query = new CRM_Contact_BAO_Query($queryParams, null, null, false, false, CRM_Contact_BAO_Query::MODE_CAMPAIGN);
     //get the voter clause to restrict and validate search.
     require_once 'CRM/Campaign/BAO/Query.php';
     $voterClause = CRM_Campaign_BAO_Query::voterClause($voterClauseParams);
     $searchCount = $query->searchQuery(0, 0, null, true, false, false, false, false, $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;
         }
         require_once 'CRM/Contact/BAO/Contact/Utils.php';
         $config = CRM_Core_Config::singleton();
         // get the result of the search
         $result = $query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $voterClause, $sortOrder);
         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) {
                 $val = $result->{$col};
                 if ($col == 'contact_type') {
                     $val = $typeImage;
                 }
                 $searchRows[$contactID][$col] = $val;
             }
             if ($searchVoterFor == 'reserve') {
                 $voterExtraColHtml = '<input type="checkbox" id="survey_activity[' . $contactID . ']" name="survey_activity[' . $contactID . ']" value=' . $contactID . ' onClick="processVoterData( this, \'reserve\' );" />';
                 $msg = ts('Respondent Reserved.');
                 $voterExtraColHtml .= "&nbsp;<span id='success_msg_{$contactID}' class='ok' style='display:none;'>{$msg}</span>";
             } else {
                 if ($searchVoterFor == 'gotv') {
                     $surveyActId = $result->survey_activity_id;
                     $voterExtraColHtml = '<input type="checkbox" id="survey_activity[' . $surveyActId . ']" name="survey_activity[' . $surveyActId . ']" value=' . $surveyActId . ' onClick="processVoterData( this, \'gotv\' );" />';
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:AJAX.php


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