function buildQuickForm() { // Contact $this->add('hidden', 'contact_id', ts('Contact id'), '', true); // get the list of all the groups $allGroups = CRM_Core_PseudoConstant::group(); // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, ' ', TRUE); // get the list of groups contact is currently in ("Added") or unsubscribed ("Removed"). $currentGroups = CRM_Contact_BAO_GroupContact::getGroupList($this->_contactId); // Remove current groups from drowdown options ($groupSelect) if (is_array($currentGroups)) { // Compare array keys, since the array values (group title) in $groupList may have extra spaces for indenting child groups $groupSelect = array_diff_key($groupHierarchy, $currentGroups); } else { $groupSelect = $groupHierarchy; } $groupSelect = array('' => ts('- select group -')) + $groupSelect; if (count($groupSelect) > 1) { $session = CRM_Core_Session::singleton(); $msg = ts('Add to a group'); $this->add('select', 'group_id', $msg, $groupSelect, false); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Opslaan / Volgende'), 'isDefault' => TRUE))); // export form elements $this->assign('elementNames', $this->getRenderableElementNames()); } parent::buildQuickForm(); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes); } if (!empty($searchOptions['groups'])) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE); // add select for groups $group = array('' => ts('- any group -')) + $groupHierarchy; $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag); } } parent::buildQuickForm(); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { // get the list of all the groups if ($this->_context == 'user') { $onlyPublicGroups = CRM_Utils_Request::retrieve('onlyPublicGroups', 'Boolean', $this, FALSE); $allGroups = CRM_Core_PseudoConstant::staticGroup($onlyPublicGroups); } else { $allGroups = CRM_Core_PseudoConstant::group(); } // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, ' ', TRUE); // get the list of groups contact is currently in ("Added") or unsubscribed ("Removed"). $currentGroups = CRM_Contact_BAO_GroupContact::getGroupList($this->_contactId); // Remove current groups from drowdown options ($groupSelect) if (is_array($currentGroups)) { // Compare array keys, since the array values (group title) in $groupList may have extra spaces for indenting child groups $groupSelect = array_diff_key($groupHierarchy, $currentGroups); } else { $groupSelect = $groupHierarchy; } $groupSelect = array('' => ts('- select group -')) + $groupSelect; if (count($groupSelect) > 1) { $session = CRM_Core_Session::singleton(); // user dashboard if (strstr($session->readUserContext(), 'user')) { $msg = ts('Join a Group'); } else { $msg = ts('Add to a group'); } $this->add('select', 'group_id', '', $groupSelect, TRUE, array('class' => 'crm-select2 crm-action-menu action-icon-plus', 'placeholder' => $msg)); $this->addButtons(array(array('type' => 'next', 'name' => ts('Add'), 'isDefault' => TRUE))); } }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); $shortCuts = array(); //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2')); } if (!empty($searchOptions['groups'])) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE); // add select for groups $group = array('' => ts('- any group -')) + $groupHierarchy; $this->add('select', 'group', ts('in'), $group, FALSE, array('class' => 'crm-select2')); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->add('select', 'tag', ts('with'), $tag, FALSE, array('class' => 'crm-select2')); } } parent::buildQuickForm(); }
/** * Get options for a given field. * @see CRM_Core_DAO::buildOptions * * @param string $fieldName * @param string $context * @see CRM_Core_DAO::buildOptionsContext * @param array $props * whatever is known about this dao object. * * @return array|bool */ public static function buildOptions($fieldName, $context = NULL, $props = array()) { $params = array(); $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); // Sort group list by hierarchy // TODO: This will only work when api.entity is "group_contact". What about others? if (($fieldName == 'group' || $fieldName == 'group_id') && ($context == 'search' || $context == 'create')) { $options = CRM_Contact_BAO_Group::getGroupsHierarchy($options, NULL, '- ', TRUE); } return $options; }
/** * build form elements. * params object $form object of the form * * @param CRM_Core_Form $form * The form object that we are operating on. * @param int $contactId * Contact id. * @param int $type * What components are we interested in. * @param bool $visibility * Visibility of the field. * @param null $isRequired * @param string $groupName * If used for building group block. * @param string $tagName * If used for building tag block. * @param string $fieldName * This is used in batch profile(i.e to build multiple blocks). * * @param string $groupElementType * */ public static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox') { if (!isset($form->_tagGroup)) { $form->_tagGroup = array(); } // NYSS 5670 if (!$contactId && !empty($form->_contactId)) { $contactId = $form->_contactId; } $type = (int) $type; if ($type & self::GROUP) { $fName = 'group'; if ($fieldName) { $fName = $fieldName; } $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { $ids = array($groupID => $groupID); } else { if ($visibility) { $group = CRM_Core_PseudoConstant::allGroup(); } else { $group = CRM_Core_PseudoConstant::group(); } $ids = $group; } if ($groupID || !empty($group)) { $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids); $attributes['skiplabel'] = TRUE; $elements = array(); $groupsOptions = array(); foreach ($groups as $id => $group) { // make sure that this group has public visibility if ($visibility && $group['visibility'] == 'User and User Admin Only') { continue; } if ($groupElementType == 'select') { $groupsOptions[$id] = $group['title']; } else { $form->_tagGroup[$fName][$id]['description'] = $group['description']; $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes); } } if ($groupElementType == 'select' && !empty($groupsOptions)) { $form->add('select', $fName, $groupName, $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2')); $form->assign('groupCount', count($groupsOptions)); } if ($groupElementType == 'checkbox' && !empty($elements)) { $form->addGroup($elements, $fName, $groupName, ' <br />'); $form->assign('groupCount', count($elements)); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } $form->assign('groupElementType', $groupElementType); } } if ($type & self::TAG) { $fName = 'tag'; if ($fieldName) { $fName = $fieldName; } $form->_tagGroup[$fName] = 1; // get the list of all the categories $tags = new CRM_Core_BAO_Tag(); $tree = $tags->getTree('civicrm_contact', TRUE); // let's not load jstree if there are not children. This also fixes blank // display at the beginning of checkboxes $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children'); $form->assign('loadjsTree', FALSE); if (!empty($loadJsTree)) { // CODE FROM CRM/Tag/Form/Tag.php // CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header'); $form->assign('loadjsTree', TRUE); } $elements = array(); self::climbtree($form, $tree, $elements); $form->addGroup($elements, $fName, $tagName, '<br />'); $form->assign('tagCount', count($elements)); $form->assign('tree', $tree); $form->assign('tag', $tree); $form->assign('entityID', $contactId); $form->assign('entityTable', 'civicrm_contact'); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required'); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE); } $form->assign('tagGroup', $form->_tagGroup); }
/** * Fetch groups in a nested format suitable for use in select form element * @param bool $checkPermissions * @param string|null $groupType * @param bool $excludeHidden * @return array */ public static function nestedGroup($checkPermissions = TRUE, $groupType = NULL, $excludeHidden = TRUE) { $groups = $checkPermissions ? self::group($groupType, $excludeHidden) : self::allGroup($groupType, $excludeHidden); return CRM_Contact_BAO_Group::getGroupsHierarchy($groups, NULL, ' ', TRUE); }
/** * @param CRM_Core_Form $form */ public static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, ' ', TRUE); $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')); $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type'); $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2')); $form->add('hidden', 'group_search_selected', 'group'); } } if ($form->_searchOptions['tags']) { // multiselect for categories $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE); $used_for = CRM_Core_OptionGroup::values('tag_used_for'); $tagsTypes = array(); $showAllTagTypes = FALSE; foreach ($used_for as $key => $value) { //check tags for every type and find if there are any defined $tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL); // check if there are tags other than contact type, if no - keep checkbox hidden on adv search // we will hide searching contact by attachments tags until it will be implemented in core if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') { //if tags exists then add type to display in adv search form help text $tagsTypes[] = ts($value); $showAllTagTypes = TRUE; } } $tagTypesText = implode(" or ", $tagsTypes); if ($showAllTagTypes) { $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText))); $form->add('hidden', 'tag_types_text', $tagTypesText); } } // add text box for last name, first name, street name, city $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // add text box for last name, first name, street name, city $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); //added contact source $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source')); //added job title $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title')); //added internal ID $form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id')); $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger'); //added external ID $form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier')); if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) { $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)')); } // add checkbox for cms users only $form->addYesNo('uf_user', ts('CMS User?'), TRUE); // tag all search $form->add('text', 'tag_search', ts('All Tags')); // add search profiles // FIXME: This is probably a part of profiles - need to be // FIXME: eradicated from here when profiles are reworked. $types = array('Participant', 'Contribution', 'Membership'); // get component profiles $componentProfiles = array(); $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types); $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1); $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW); $searchProfiles = array(); foreach ($ufGroups as $key => $var) { if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) { $searchProfiles[$key] = $var['title']; } } $form->add('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles, FALSE, array('class' => 'crm-select2')); $componentModes = CRM_Contact_Form_Search::getModeSelect(); // unset contributions or participants if user does not have // permission on them if (!CRM_Core_Permission::access('CiviContribute')) { unset($componentModes['2']); } if (!CRM_Core_Permission::access('CiviEvent')) { unset($componentModes['3']); } if (!CRM_Core_Permission::access('CiviMember')) { unset($componentModes['5']); } if (!CRM_Core_Permission::check('view all activities')) { unset($componentModes['4']); } if (count($componentModes) > 1) { $form->add('select', 'component_mode', ts('Display Results As'), $componentModes, FALSE, array('class' => 'crm-select2')); } $form->addRadio('operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')), array('allowClear' => FALSE)); // add the option to display relationships $rTypes = CRM_Core_PseudoConstant::relationshipType(); $rSelect = array('' => ts('- Select Relationship Type-')); foreach ($rTypes as $rid => $rValue) { if ($rValue['label_a_b'] == $rValue['label_b_a']) { $rSelect[$rid] = $rValue['label_a_b']; } else { $rSelect["{$rid}_a_b"] = $rValue['label_a_b']; $rSelect["{$rid}_b_a"] = $rValue['label_b_a']; } } $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect, array('class' => 'crm-select2')); // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'class' => 'crm-select2')); $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND'))); $options = array(1 => ts('Exclude'), 2 => ts('Include by Privacy Option(s)')); $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, array('allowClear' => FALSE)); // preferred communication method $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v); } $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ''); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search')); // Phone search $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2')); $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2')); }
/** * This function is to build form elements * params object $form object of the form * * @param Object $form the form object that we are operating on * @param int $contactId contact id * @param int $type what components are we interested in * @param boolean $visibility visibility of the field * @param string $groupName if used for building group block * @param string $tagName if used for building tag block * @param string $fieldName this is used in batch profile(i.e to build multiple blocks) * * @static * @access public */ static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox') { if (!isset($form->_tagGroup)) { $form->_tagGroup = array(); } // NYSS 5670 if (!$contactId && !empty($form->_contactId)) { $contactId = $form->_contactId; } $type = (int) $type; if ($type & self::GROUP) { $fName = 'group'; if ($fieldName) { $fName = $fieldName; } $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { $ids = array($groupID => $groupID); } else { if ($visibility) { $group = CRM_Core_PseudoConstant::allGroup(); } else { $group = CRM_Core_PseudoConstant::nestedGroup(); } $ids = $group; } if ($groupID || !empty($group)) { $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids); $attributes['skiplabel'] = TRUE; $elements = array(); $groupsOptions = array(); foreach ($groups as $id => $group) { // make sure that this group has public visibility if ($visibility && $group['visibility'] == 'User and User Admin Only') { continue; } if ($groupElementType == 'crmasmSelect') { $groupsOptions[$id] = $group['title']; } else { $form->_tagGroup[$fName][$id]['description'] = $group['description']; $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes); } } if ($groupElementType == 'crmasmSelect' && !empty($groupsOptions)) { $form->add('select', $fName, ts('%1', array(1 => $groupName)), $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'title' => ts('- select -'))); $form->assign('groupCount', count($groupsOptions)); } if ($groupElementType == 'checkbox' && !empty($elements)) { $form->addGroup($elements, $fName, $groupName, ' <br />'); $form->assign('groupCount', count($elements)); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } $form->assign('groupElementType', $groupElementType); } } if ($type & self::TAG) { $fName = 'tag'; if ($fieldName) { $fName = $fieldName; } $form->_tagGroup[$fName] = 1; $elements = array(); $tag = CRM_Core_BAO_Tag::getTags(); foreach ($tag as $id => $name) { $elements[] = $form->createElement('checkbox', $id, NULL, $name); } if (!empty($elements)) { $form->addGroup($elements, $fName, $tagName, '<br />'); $form->assign('tagCount', count($elements)); } if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required'); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, TRUE, TRUE); } $form->assign('tagGroup', $form->_tagGroup); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { //get the context $context = $this->get('context'); if ($this->_searchBasedMailing) { $context = 'search'; } $this->assign('context', $context); $this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE); $hiddenMailingGroup = NULL; $campaignId = NULL; //CRM-7362 --add campaigns. if ($this->_mailingID) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'campaign_id'); $hiddenMailingGroup = CRM_Mailing_BAO_Mailing::hiddenMailingGroup($this->_mailingID); } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); //dedupe on email option $this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?')); // location types $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('id' => 'display_name')); $this->addElement('select', 'location_type_id', ts("Location Type"), array('' => ts('Automatic')) + $locationTypes); $methods = CRM_Core_SelectValues::emailSelectMethods(); $this->addElement('select', 'email_selection_method', ts("Email Selection Method"), $methods); //get the mailing groups. $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing'); if ($hiddenMailingGroup) { $groups[$hiddenMailingGroup] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title'); } $mailings = CRM_Mailing_PseudoConstant::completed(); if (!$mailings) { $mailings = array(); } // run the groups through a hook so users can trim it if needed CRM_Utils_Hook::mailingGroups($this, $groups, $mailings); //when the context is search add base group's. if ($this->_searchBasedMailing) { //get the static groups $staticGroups = CRM_Core_PseudoConstant::staticGroup(FALSE, 'Mailing'); $this->add('select', 'baseGroup', ts('Unsubscription Group'), array('' => ts('- select -')) + CRM_Contact_BAO_Group::getGroupsHierarchy($staticGroups, NULL, ' ', TRUE), TRUE, array('class' => 'crm-select2 huge')); } $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -')); $this->add('select', 'includeGroups', ts('Include Group(s)'), $groups, !$this->_searchBasedMailing, $select2style); $this->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style); $this->add('select', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, FALSE, $select2style); $this->add('select', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, FALSE, $select2style); $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule')); $buttons = array(array('type' => 'next', 'name' => ts('Next'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel'))); $this->addButtons($buttons); $this->assign('groupCount', count($groups)); $this->assign('mailingCount', count($mailings)); if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) { CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search"); } }