本文整理汇总了PHP中CRM_Contact_BAO_GroupContact::getGroupContacts方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_GroupContact::getGroupContacts方法的具体用法?PHP CRM_Contact_BAO_GroupContact::getGroupContacts怎么用?PHP CRM_Contact_BAO_GroupContact::getGroupContacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_GroupContact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_GroupContact::getGroupContacts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTestRecipients
/**
* Generate an event queue for a test job
*
* @params array $params contains form values
*
* @return void
* @access public
*/
public function getTestRecipients($testParams)
{
if (array_key_exists($testParams['test_group'], CRM_Core_PseudoConstant::group())) {
$group = new CRM_Contact_DAO_Group();
$group->id = $testParams['test_group'];
$contacts = CRM_Contact_BAO_GroupContact::getGroupContacts($group);
foreach ($contacts as $contact) {
$query = "SELECT DISTINCT civicrm_email.id AS email_id, civicrm_email.is_primary as is_primary,\n civicrm_email.is_bulkmail as is_bulkmail\nFROM civicrm_email\nINNER JOIN civicrm_contact ON civicrm_email.contact_id = civicrm_contact.id\nWHERE civicrm_email.is_bulkmail = 1\nAND civicrm_contact.id = {$contact->contact_id}\nAND civicrm_contact.do_not_email = 0\nAND civicrm_contact.is_deceased = 0\nAND civicrm_email.on_hold = 0\nAND civicrm_contact.is_opt_out =0";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
if ($dao->fetch()) {
$params = array('job_id' => $testParams['job_id'], 'email_id' => $dao->email_id, 'contact_id' => $contact->contact_id);
$queue = CRM_Mailing_Event_BAO_Queue::create($params);
} else {
$query = "SELECT DISTINCT civicrm_email.id AS email_id, civicrm_email.is_primary as is_primary,\n civicrm_email.is_bulkmail as is_bulkmail\nFROM civicrm_email\nINNER JOIN civicrm_contact ON civicrm_email.contact_id = civicrm_contact.id\nWHERE civicrm_email.is_primary = 1\nAND civicrm_contact.id = {$contact->contact_id}\nAND civicrm_contact.do_not_email =0\nAND civicrm_contact.is_deceased = 0\nAND civicrm_email.on_hold = 0\nAND civicrm_contact.is_opt_out =0";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
if ($dao->fetch()) {
$params = array('job_id' => $testParams['job_id'], 'email_id' => $dao->email_id, 'contact_id' => $contact->contact_id);
$queue = CRM_Mailing_Event_BAO_Queue::create($params);
}
}
}
}
}
示例2: crm_get_group_contacts
/**
* Returns array of contacts who are members of the specified group.
*
* @param CRM_Contact $group A valid group object (passed by reference)
* @param array $returnProperties Which properties should be included in the returned Contact object(s). If NULL, the default set of contact properties will be included. group_contact properties (such as 'status', 'in_date', etc.) are included automatically.Note:Do not inclue Id releted properties.
* @param text $status A valid status value ('Added', 'Pending', 'Removed').
* @param text $sort Associative array of one or more "property_name"=>"sort direction" pairs which will control order of Contact objects returned.
* @param Int $offset Starting row index.
* @param Int $row_count Maximum number of rows to returns.
*
*
* @return $contactArray Array of contacts who are members of the specified group
*
* @access public
*/
function crm_get_group_contacts(&$group, $returnProperties = null, $status = 'Added', $sort = null, $offset = null, $row_count = null)
{
_crm_initialize();
if (!is_a($group, 'CRM_Contact_BAO_Group') && !is_a($group, 'CRM_Contact_DAO_Group')) {
return _crm_error('Invalid group object passed in');
}
if (!isset($group->id)) {
return _crm_error('Invalid group object passed in');
}
if ($returnProperties != null && !is_array($returnProperties)) {
return _crm_error('$returnProperties is not an array');
}
if ($sort != null && !is_array($sort)) {
return _crm_error('$sort is not an array');
}
$contacts = array();
$contacts = CRM_Contact_BAO_GroupContact::getGroupContacts($group, $returnProperties, $status, $sort, $offset, $row_count);
return $contacts;
}
示例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(' ', $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);
}
}