ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(); $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, TRUE, array('class' => 'crm-select2 huge')); CRM_Utils_System::setTitle(ts('Remove Contacts from Group')); $this->addDefaultButtons(ts('Remove from Group')); } /** * Set the default form values. * * * @return array * the default array reference */ public function setDefaultValues() { $defaults = array(); if ($this->get('context') === 'smog') { $defaults['group_id'] = $this->get('gid'); } return $defaults; } /** * Process the form after the input has been submitted and validated. */ public function postProcess() { $groupId = $this->controller->exportValue('RemoveFromGroup', 'group_id'); $group = CRM_Core_PseudoConstant::group(); list($total, $removed, $notRemoved) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($this->_contactIds, $groupId); $status = array( ts("%count contact removed from '%2'", array( 'count' => $removed, 'plural' => "%count contacts removed from '%2'", 2 => $group[$groupId], )), ); if ($notRemoved) { $status[] = ts('1 contact was already not in this group', array( 'count' => $notRemoved, 'plural' => '%count contacts were already not in this group', )); } $status = ''; CRM_Core_Session::setStatus($status, ts("Removed Contact From Group", array( 'plural' => "Removed Contacts From Group", 'count' => $removed, )), 'success', array('expires' => 0)); } }