3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class provides the functionality to delete a group of
20 * contacts. This class provides functionality for the actual
21 * addition of contacts to groups.
23 class CRM_Contact_Form_Task_RemoveFromGroup
extends CRM_Contact_Form_Task
{
26 * Build the form object.
28 public function buildQuickForm() {
29 // add select for groups
30 $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant
::nestedGroup();
31 $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, TRUE, ['class' => 'crm-select2 huge']);
33 CRM_Utils_System
::setTitle(ts('Remove Contacts from Group'));
34 $this->addDefaultButtons(ts('Remove from Group'));
38 * Set the default form values.
42 * the default array reference
44 public function setDefaultValues() {
47 if ($this->get('context') === 'smog') {
48 $defaults['group_id'] = $this->get('gid');
54 * Process the form after the input has been submitted and validated.
56 public function postProcess() {
57 $groupId = $this->controller
->exportValue('RemoveFromGroup', 'group_id');
58 $group = CRM_Core_PseudoConstant
::group();
60 list($total, $removed, $notRemoved) = CRM_Contact_BAO_GroupContact
::removeContactsFromGroup($this->_contactIds
, $groupId);
63 ts("%count contact removed from '%2'", [
65 'plural' => "%count contacts removed from '%2'",
66 2 => $group[$groupId],
70 $status[] = ts('1 contact was already not in this group', [
71 'count' => $notRemoved,
72 'plural' => '%count contacts were already not in this group',
75 $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
76 CRM_Core_Session
::setStatus($status, ts("Removed Contact From Group", [
77 'plural' => "Removed Contacts From Group",
79 ]), 'success', ['expires' => 0]);