Skip to content

Commit

Permalink
refs #39637, add sync all function
Browse files Browse the repository at this point in the history
  • Loading branch information
jimyhuang committed Jun 6, 2024
1 parent 3b7af85 commit 4e662fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ static function groupTypeCondition($groupType = NULL, $excludeHidden = TRUE) {
elseif ($groupType == 'Access') {
$value = CRM_Core_DAO::VALUE_SEPARATOR . '1' . CRM_Core_DAO::VALUE_SEPARATOR;
}
elseif (is_numeric($groupType)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . "$groupType" . CRM_Core_DAO::VALUE_SEPARATOR;
}

$condition = NULL;
if ($excludeHidden) {
Expand Down
27 changes: 26 additions & 1 deletion CRM/Mailing/External/SmartMarketing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,32 @@ abstract public function parseSavedData($json);
* Sync all smart marketing to remote
*/
public static function syncAll() {

$availableGroupTypes = CRM_Core_OptionGroup::values('group_type');
$typeNames = array();
foreach($availableGroupTypes as $typeId => $typeName) {
if (strstr($typeName, 'Smart Marketing')) {
list($smartMarketingVendor) = explode(' ', $typeName);
$typeNames[$typeId] = $smartMarketingVendor;
}
}
if (!empty($typeNames)) {
$syncResult = array();
foreach($typeNames as $typeId => $class) {
$groups = CRM_Core_PseudoConstant::allGroup($typeId);
if (!empty($groups)) {
foreach($groups as $groupId => $groupName) {
// skip synced
if (isset($syncResult[$groupId])) {
continue;
}
$syncResult[$groupId] = self::syncGroup($groupId);
if (!empty($syncResult[$groupId]['result']['#report'])) {
CRM_Core_Error::debug_log_message(implode(' / ', $syncResult[$groupId]['result']['#report']));
}
}
}
}
}
}

/**
Expand Down

0 comments on commit 4e662fd

Please sign in to comment.