/**
* called when action is browse.
*
*/
public function browse()
{
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
// keep track of all 'added' contact groups so we can remove them from the smart group
// section
$staticGroups = array();
if (!empty($in)) {
foreach ($in as $group) {
$staticGroups[$group['group_id']] = 1;
}
}
$allGroup = CRM_Contact_BAO_GroupContactCache::contactGroup($this->_contactId);
$this->assign('groupSmart', NULL);
$this->assign('groupParent', NULL);
if (!empty($allGroup)) {
$smart = $parent = array();
foreach ($allGroup['group'] as $group) {
// delete all smart groups which are also in static groups
if (isset($staticGroups[$group['id']])) {
continue;
}
if (empty($group['children'])) {
$smart[] = $group;
} else {
$parent[] = $group;
}
}
if (!empty($smart)) {
$this->assign_by_ref('groupSmart', $smart);
}
if (!empty($parent)) {
$this->assign_by_ref('groupParent', $parent);
}
}
}
function where()
{
$petition_id = intval($this->_params['petition_id_value']);
$group_id = NULL;
if (array_key_exists('group_id_value', $this->_params)) {
$group_id = intval($this->_params['group_id_value']);
}
$petition_activity_type_id = intval(CRM_Core_OptionGroup::getValue('activity_type', 'Petition', 'name'));
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$source_activity_record_type_id = intval(CRM_Utils_Array::key('Activity Source', $activityContacts));
$this->_where = "WHERE ";
$signed = '';
$group = '';
// Include people who have signed the petition OR people who are in the passed in group
// First the signers.
$signed = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id\n FROM civicrm_activity_contact ac JOIN civicrm_activity a ON\n ac.activity_id = a.id WHERE ac.record_type_id = {$source_activity_record_type_id}\n AND source_record_id = {$petition_id} AND a.activity_type_id = {$petition_activity_type_id})";
// Now the people in the specified group
if ($group_id) {
// Check if we are a smart group or regular group
$results = civicrm_api3('Group', 'getsingle', array('id' => $group_id));
if (!empty($results['id'])) {
$group = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id FROM ";
if (!empty($results['saved_search_id'])) {
// Populate the cache
CRM_Contact_BAO_GroupContactCache::check($group_id);
$group .= "civicrm_group_contact_cache cc WHERE cc.group_id = {$group_id})";
} else {
$group .= "civicrm_group_contact gc WHERE gc.group_id = {$group_id}\n AND gc.status = 'Added')";
}
}
}
if (!empty($group)) {
$this->_where .= " ({$signed}) OR ({$group}) ";
} else {
$this->_where .= "{$signed}";
}
}
/**
* Takes an associative array and creates a participant object.
*
* the function extract all the params it needs to initialize the create a
* participant object. the params array could contain additional unused name/value
* pairs
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return CRM_Event_BAO_Participant
*/
public static function &add(&$params)
{
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Participant', NULL, $params);
}
// converting dates to mysql format
if (!empty($params['register_date'])) {
$params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
}
if (!empty($params['participant_fee_amount'])) {
$params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
}
if (!empty($params['fee_amount'])) {
$params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
}
// ensure that role ids are encoded as a string
if (isset($params['role_id']) && is_array($params['role_id'])) {
if (in_array(key($params['role_id']), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($params['role_id']);
$params['role_id'] = $params['role_id'][$op];
} else {
$params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
}
}
$participantBAO = new CRM_Event_BAO_Participant();
if (!empty($params['id'])) {
$participantBAO->id = CRM_Utils_Array::value('id', $params);
$participantBAO->find(TRUE);
$participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
}
$participantBAO->copyValues($params);
//CRM-6910
//1. If currency present, it should be valid one.
//2. We should have currency when amount is not null.
$currency = $participantBAO->fee_currency;
if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
if (!CRM_Utils_Rule::currencyCode($currency)) {
$config = CRM_Core_Config::singleton();
$currency = $config->defaultCurrency;
}
}
$participantBAO->fee_currency = $currency;
$participantBAO->save();
$session = CRM_Core_Session::singleton();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
} else {
CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
}
return $participantBAO;
}
/**
* Given an array of contact ids, remove all the contacts from the group
*
* @param array $contactIds
* (reference ) the array of contact ids to be removed.
* @param int $groupId
* The id of the group.
*
* @param string $method
* @param string $status
* @param NULL $tracking
*
* @return array
* (total, removed, notRemoved) count of contacts removed to group
*/
public static function removeContactsFromGroup(&$contactIds, $groupId, $method = 'Admin', $status = 'Removed', $tracking = NULL)
{
if (!is_array($contactIds)) {
return array(0, 0, 0);
}
if ($status == 'Removed' || $status == 'Deleted') {
$op = 'delete';
} else {
$op = 'edit';
}
CRM_Utils_Hook::pre($op, 'GroupContact', $groupId, $contactIds);
$date = date('YmdHis');
$numContactsRemoved = 0;
$numContactsNotRemoved = 0;
$group = new CRM_Contact_DAO_Group();
$group->id = $groupId;
$group->find(TRUE);
foreach ($contactIds as $contactId) {
if ($status == 'Deleted') {
$query = "DELETE FROM civicrm_group_contact WHERE contact_id={$contactId} AND group_id={$groupId}";
$dao = CRM_Core_DAO::executeQuery($query);
$historyParams = array('group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking);
CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
} else {
$groupContact = new CRM_Contact_DAO_GroupContact();
$groupContact->group_id = $groupId;
$groupContact->contact_id = $contactId;
// check if the selected contact id already a member, or if this is
// an opt-out of a smart group.
// if not a member remove to groupContact else keep the count of contacts that are not removed
if ($groupContact->find(TRUE) || $group->saved_search_id) {
// remove the contact from the group
$numContactsRemoved++;
} else {
$numContactsNotRemoved++;
}
//now we grant the negative membership to contact if not member. CRM-3711
$historyParams = array('group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking);
CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
$groupContact->status = $status;
$groupContact->save();
}
}
// also reset the acl cache
$config = CRM_Core_Config::singleton();
if (!$config->doNotResetCache) {
CRM_ACL_BAO_Cache::resetCache();
}
// reset the group contact cache for all group(s)
// if this group is being used as a smart group
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds);
return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved);
}
function addGroupContactCache($groups, $tableAlias = NULL, $joinTable = "contact_a")
{
$config = CRM_Core_Config::singleton();
// find all the groups that are part of a saved search
$groupIDs = implode(',', $groups);
if (empty($groupIDs)) {
return NULL;
}
$sql = "\nSELECT id, cache_date, saved_search_id, children\nFROM civicrm_group\nWHERE id IN ( {$groupIDs} )\n AND ( saved_search_id != 0\n OR saved_search_id IS NOT NULL\n OR children IS NOT NULL )\n";
$group = CRM_Core_DAO::executeQuery($sql);
$ssWhere = array();
while ($group->fetch()) {
if ($tableAlias == NULL) {
$alias = "`civicrm_group_contact_cache_{$group->id}`";
} else {
$alias = $tableAlias;
}
$this->_useDistinct = TRUE;
if (!$this->_smartGroupCache || $group->cache_date == NULL) {
CRM_Contact_BAO_GroupContactCache::load($group);
}
$this->_tables[$alias] = $this->_whereTables[$alias] = " LEFT JOIN civicrm_group_contact_cache {$alias} ON {$joinTable}.id = {$alias}.contact_id ";
$ssWhere[] = "{$alias}.group_id = {$group->id}";
}
if (!empty($ssWhere)) {
return implode(' OR ', $ssWhere);
}
return NULL;
}
/**
* Given an array of contact ids, remove all the contacts from the group
*
* @param array $contactIds (reference ) the array of contact ids to be removed
* @param int $groupId the id of the group
*
* @return array (total, removed, notRemoved) count of contacts removed to group
* @access public
* @static
*/
static function removeContactsFromGroup(&$contactIds, $groupId, $method = 'Admin', $status = 'Removed', $tracking = null)
{
if (!is_array($contactIds)) {
return array(0, 0, 0);
}
require_once 'CRM/Utils/Hook.php';
if ($status == 'Removed') {
$op = 'delete';
} else {
$op = 'edit';
}
CRM_Utils_Hook::pre($op, 'GroupContact', $groupId, $contactIds);
$date = date('YmdHis');
$numContactsRemoved = 0;
$numContactsNotRemoved = 0;
require_once "CRM/Contact/DAO/Group.php";
$group =& new CRM_Contact_DAO_Group();
$group->id = $groupId;
$group->find(true);
foreach ($contactIds as $contactId) {
$groupContact =& new CRM_Contact_DAO_GroupContact();
$groupContact->group_id = $groupId;
$groupContact->contact_id = $contactId;
// check if the selected contact id already a member, or if this is
// an opt-out of a smart group.
// if not a member remove to groupContact else keep the count of contacts that are not removed
if ($groupContact->find(true) || $group->saved_search_id) {
// remove the contact from the group
$numContactsRemoved++;
} else {
$numContactsNotRemoved++;
}
//now we grant the negative membership to contact if not member. CRM-3711
$historyParams = array('group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking);
CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
$groupContact->status = $status;
$groupContact->save();
}
// also reset the acl cache
require_once 'CRM/ACL/BAO/Cache.php';
CRM_ACL_BAO_Cache::resetCache();
// reset the group contact cache for all group(s)
// if this group is being used as a smart group
require_once 'CRM/Contact/BAO/GroupContactCache.php';
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds);
return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved);
}
/**
* Create a new group.
*
* @param array $params
*
* @return CRM_Contact_BAO_Group|NULL
* The new group BAO (if created)
*/
public static function &create(&$params)
{
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
}
// form the name only if missing: CRM-627
$nameParam = CRM_Utils_Array::value('name', $params, NULL);
if (!$nameParam && empty($params['id'])) {
$params['name'] = CRM_Utils_String::titleToVar($params['title']);
}
// convert params if array type
if (isset($params['group_type'])) {
if (is_array($params['group_type'])) {
$params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
}
} else {
$params['group_type'] = '';
}
$session = CRM_Core_Session::singleton();
$cid = $session->get('userID');
// this action is add
if ($cid && empty($params['id'])) {
$params['created_id'] = $cid;
}
// this action is update
if ($cid && !empty($params['id'])) {
$params['modified_id'] = $cid;
}
$group = new CRM_Contact_BAO_Group();
$group->copyValues($params);
//@todo very hacky fix for the fact this function wants to receive 'parents' as an array further down but
// needs it as a separated string for the DB. Preferred approaches are having the copyParams or save fn
// use metadata to translate the array to the appropriate DB type or altering the param in the api layer,
// or at least altering the param in same section as 'group_type' rather than repeating here. However, further down
// we need the $params one to be in it's original form & we are not sure what test coverage we have on that
if (isset($group->parents) && is_array($group->parents)) {
$group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($group->parents)) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if (empty($params['id']) && !$nameParam) {
$group->name .= "_tmp";
}
$group->save();
if (!$group->id) {
return NULL;
}
if (empty($params['id']) && !$nameParam) {
$group->name = substr($group->name, 0, -4) . "_{$group->id}";
}
$group->buildClause();
$group->save();
// add custom field values
if (!empty($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
}
// make the group, child of domain/site group by default.
$domainGroupID = CRM_Core_BAO_Domain::getGroupId();
if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
if (empty($params['parents']) && $domainGroupID != $group->id && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled') && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
// if no parent present and the group doesn't already have any parents,
// make sure site group goes as parent
$params['parents'] = array($domainGroupID => 1);
} elseif (array_key_exists('parents', $params) && !is_array($params['parents'])) {
$params['parents'] = array($params['parents'] => 1);
}
if (!empty($params['parents'])) {
foreach ($params['parents'] as $parentId => $dnc) {
if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
}
}
}
// clear any descendant groups cache if exists
$finalGroups = CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
// this is always required, since we don't know when a
// parent group is removed
CRM_Contact_BAO_GroupNestingCache::update();
// update group contact cache for all parent groups
$parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
foreach ($parentIds as $parentId) {
CRM_Contact_BAO_GroupContactCache::add($parentId);
}
}
if (!empty($params['organization_id'])) {
$groupOrg = array();
$groupOrg = $params;
$groupOrg['group_id'] = $group->id;
CRM_Contact_BAO_GroupOrganization::add($groupOrg);
}
CRM_Contact_BAO_GroupContactCache::add($group->id);
if (!empty($params['id'])) {
//.........这里部分代码省略.........
/**
* Process the user submitted custom data values.
*/
public function postProcess()
{
// Get the form values and groupTree
//CRM-18183
$params = $this->controller->exportValues($this->_name);
CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contact', $this->_tableID, $this->_entityType);
$table = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupID, 'table_name');
$cgcount = CRM_Core_BAO_CustomGroup::customGroupDataExistsForEntity($this->_tableID, $table, TRUE);
$cgcount += 1;
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/cd/edit', "reset=1&type={$this->_contactType}&groupID={$this->_groupID}&entityID={$this->_tableID}&cgcount={$cgcount}&multiRecordDisplay=single&mode=add"));
}
// Add entry in the log table
CRM_Core_BAO_Log::register($this->_tableID, 'civicrm_contact', $this->_tableID);
if (CRM_Core_Resources::isAjaxMode()) {
$this->ajaxResponse += CRM_Contact_Form_Inline::renderFooter($this->_tableID);
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
}
/**
* Build where clause for groups.
*
* This has been overridden in order to:
* 1) only build the group clause when filtering
* 2) render the id field as id rather than contact_id in
* order to allow us to join on hte created temp table as if it
* were the contact table.
*
* Further refactoring could break down the parent function so it can be selectively
* leveraged.
*
* @param string $field
* @param mixed $value
* @param string $op
*
* @return string
*/
public function whereGroupClause($field, $value, $op)
{
if ($op == 'notin') {
// We do not have an optimisation for this scenario at this stage. Use
// parent.
return parent::whereGroupClause($field, $value, $op);
}
if (empty($this->groupTempTable)) {
$group = new CRM_Contact_DAO_Group();
$group->is_active = 1;
$group->find();
$smartGroups = array();
while ($group->fetch()) {
if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
$smartGroups[] = $group->id;
}
}
CRM_Contact_BAO_GroupContactCache::check($smartGroups);
$smartGroupQuery = '';
if (!empty($smartGroups)) {
$smartGroups = implode(',', $smartGroups);
$smartGroupQuery = " UNION DISTINCT\n SELECT DISTINCT smartgroup_contact.contact_id as id\n FROM civicrm_group_contact_cache smartgroup_contact\n WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
}
$sqlOp = $this->getSQLOperator($op);
if (!is_array($value)) {
$value = array($value);
}
$clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
$query = "SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id as id\n FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'\n {$smartGroupQuery} ";
$this->buildGroupTempTable($query);
}
return "1";
}
/**
* takes an associative array and creates a participant object
*
* the function extract all the params it needs to initialize the create a
* participant object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
*
* @return object CRM_Event_BAO_Participant object
* @access public
* @static
*/
static function &add(&$params)
{
require_once 'CRM/Utils/Hook.php';
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Participant', null, $params);
}
// converting dates to mysql format
if (CRM_Utils_Array::value('register_date', $params)) {
$params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
}
if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
$params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
}
if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
$params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
}
$participantBAO = new CRM_Event_BAO_Participant();
if (CRM_Utils_Array::value('id', $params)) {
$participantBAO->id = CRM_Utils_Array::value('id', $params);
$participantBAO->find(true);
$participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
}
$participantBAO->copyValues($params);
//CRM-6910
//1. If currency present, it should be valid one.
//2. We should have currency when amount is not null.
require_once 'CRM/Utils/Rule.php';
$currency = $participantBAO->fee_currency;
if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
if (!CRM_Utils_Rule::currencyCode($currency)) {
$config = CRM_Core_Config::singleton();
$currency = $config->defaultCurrency;
}
}
$participantBAO->fee_currency = $currency;
$participantBAO->save();
$session =& CRM_Core_Session::singleton();
// reset the group contact cache for this group
require_once 'CRM/Contact/BAO/GroupContactCache.php';
CRM_Contact_BAO_GroupContactCache::remove();
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
} else {
CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
}
return $participantBAO;
}
/**
* Function to delete custom value
*
*/
static function deleteCustomValue()
{
$customValueID = CRM_Utils_Type::escape($_POST['valueID'], 'Positive');
$customGroupID = CRM_Utils_Type::escape($_POST['groupID'], 'Positive');
CRM_Core_BAO_CustomValue::deleteCustomValue($customValueID, $customGroupID);
if ($contactId = CRM_Utils_Array::value('contactId', $_POST)) {
echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $_POST['groupID'], $contactId);
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Utils_System::civiExit();
}
//.........这里部分代码省略.........
$customGroup = $customField = array();
CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
$dateDBField = $customField['column_name'];
$customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
$from = $table = "{$customGroup['table_name']} e";
$contactField = 'e.entity_id';
$where[] = '1';
// possible to have no "where" in this case
}
$status_ = explode(',', $status);
if (in_array(2, $status_)) {
// anniversary mode:
$dateField = 'DATE_ADD(e.' . $dateDBField . ', INTERVAL ROUND(DATEDIFF(DATE(' . $now . '), e.' . $dateDBField . ') / 365) YEAR)';
$anniversary = true;
} else {
// regular mode:
$dateField = 'e.' . $dateDBField;
}
// TODO get this working
// TODO: Make sure everything's provided for repetition, etc.
}
// CRM-13577 Introduce Smart Groups Handling
if ($actionSchedule->group_id) {
// Need to check if its a smart group or not
// Then decide which table to join onto the query
$group = CRM_Contact_DAO_Group::getTableName();
// Get the group information
$sql = "\nSELECT {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM {$group}\nWHERE {$group}.id = {$actionSchedule->group_id}\n";
$groupDAO = CRM_Core_DAO::executeQuery($sql);
$isSmartGroup = FALSE;
if ($groupDAO->fetch() && !empty($groupDAO->saved_search_id)) {
// Check that the group is in place in the cache and up to date
CRM_Contact_BAO_GroupContactCache::check($actionSchedule->group_id);
// Set smart group flag
$isSmartGroup = TRUE;
}
}
// CRM-13577 End Introduce Smart Groups Handling
if ($limitTo) {
if ($actionSchedule->group_id) {
// CRM-13577 If smart group then use Cache table
if ($isSmartGroup) {
$join[] = "INNER JOIN civicrm_group_contact_cache grp ON {$contactField} = grp.contact_id";
$where[] = "grp.group_id IN ({$actionSchedule->group_id})";
} else {
$join[] = "INNER JOIN civicrm_group_contact grp ON {$contactField} = grp.contact_id AND grp.status = 'Added'";
$where[] = "grp.group_id IN ({$actionSchedule->group_id})";
}
} elseif (!empty($actionSchedule->recipient_manual)) {
$rList = CRM_Utils_Type::escape($actionSchedule->recipient_manual, 'String');
$where[] = "{$contactField} IN ({$rList})";
}
} else {
$addGroup = $addWhere = '';
if ($actionSchedule->group_id) {
// CRM-13577 If smart group then use Cache table
if ($isSmartGroup) {
$addGroup = " INNER JOIN civicrm_group_contact_cache grp ON c.id = grp.contact_id";
$addWhere = " grp.group_id IN ({$actionSchedule->group_id})";
} else {
$addGroup = " INNER JOIN civicrm_group_contact grp ON c.id = grp.contact_id AND grp.status = 'Added'";
$addWhere = " grp.group_id IN ({$actionSchedule->group_id})";
}
}
if (!empty($actionSchedule->recipient_manual)) {
请发表评论