-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core/287 Disable child groups if all parents are disabled #12797
Changes from 3 commits
230d43a
240c0eb
d023b62
08b5ed1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,6 +350,20 @@ public static function create(&$params) { | |
CRM_Utils_Hook::pre('create', 'Group', NULL, $params); | ||
} | ||
|
||
// dev/core#287 Disable child groups if all parents are disabled. | ||
if(!empty($params['id'])) { | ||
$allChildGroupIds = self::getChildGroupIds($params['id']); | ||
foreach ($allChildGroupIds as $childKey => $childValue) { | ||
$parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($childValue); | ||
$activeParentsCount = civicrm_api3('Group', 'getcount', [ | ||
'id' => ['IN' => $parentIds], | ||
'is_active' => 1, | ||
]); | ||
if (count($parentIds) == 1 || count($parentIds) > 1 && $activeParentsCount <= 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be written as |
||
$setDisable = self::setIsActive($childValue, $params['is_active']); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we group 362 and 365 with OR statement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the point :) . Have updated the conditions. |
||
} | ||
} | ||
// form the name only if missing: CRM-627 | ||
$nameParam = CRM_Utils_Array::value('name', $params, NULL); | ||
if (!$nameParam && empty($params['id'])) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
if (!empty($params['id'])) {