/** * Build the form object. */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - Search Preferences')); // @todo remove the following adds in favour of setting via the settings array (above). $this->addYesNo('includeWildCardInName', ts('Automatic Wildcard')); $this->addYesNo('includeEmailInName', ts('Include Email')); $this->addYesNo('includeNickNameInName', ts('Include Nickname')); $this->addYesNo('includeAlphabeticalPager', ts('Include Alphabetical Pager')); $this->addYesNo('includeOrderByClause', ts('Include Order By Clause')); $this->addElement('text', 'smartGroupCacheTimeout', ts('Smart group cache timeout'), array('size' => 3, 'maxlength' => 5)); $types = array('Contact', 'Individual', 'Organization', 'Household'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); $this->add('select', 'defaultSearchProfileID', ts('Default Contact Search Profile'), array('' => ts('- none -')) + $profiles, FALSE, array('class' => 'crm-select2 huge')); // Autocomplete for Contact Search (quick search etc.) $options = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE)); $this->addCheckBox('autocompleteContactSearch', ts('Autocomplete Contact Search'), $options, NULL, NULL, NULL, NULL, array(' ')); $element = $this->getElement('autocompleteContactSearch'); $element->_elements[0]->_flagFrozen = TRUE; // Autocomplete for Contact Reference (custom fields) $optionsCR = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE)); $this->addCheckBox('autocompleteContactReference', ts('Contact Reference Options'), $optionsCR, NULL, NULL, NULL, NULL, array(' ')); $element = $this->getElement('autocompleteContactReference'); $element->_elements[0]->_flagFrozen = TRUE; parent::buildQuickForm(); }
/** * Build the form object. * * * @return void */ public function buildQuickForm() { $types = array('Participant'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { CRM_Core_Session::setStatus("To use Update multiple participants, you need to configure a profile containing only Participant fields (e.g. Participant Status, Participant Role, etc.). Configure a profile at 'Administer CiviCRM >> Customize >> CiviCRM Profile'."); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE); $this->addDefaultButtons(ts('Continue')); }
/** * Build the form object. * * * @return void */ public function buildQuickForm() { $types = array('Membership'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch update memberships via profile. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Batch Update Error'), 'error'); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE); $this->addDefaultButtons(ts('Continue')); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { require_once "CRM/Core/BAO/UFGroup.php"; $types = array('Contact', 'Individual', 'Contribution', 'Membership'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); if (empty($profiles)) { $this->assign('noProfile', true); } $this->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), array('' => ts('- select -')) + $profiles); $this->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), array('' => ts('- select -')) + $profiles); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id); parent::buildQuickForm(); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $types = array_merge(array('Contact', 'Individual', 'Contribution', 'Membership'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); $excludeTypes = array('Organization', 'Household', 'Participant', 'Activity'); $excludeProfiles = CRM_Core_BAO_UFGroup::getProfiles($excludeTypes); foreach ($excludeProfiles as $key => $value) { if (array_key_exists($key, $profiles)) { unset($profiles[$key]); } } if (empty($profiles)) { $this->assign('noProfile', TRUE); } $this->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), array('' => ts('- select -')) + $profiles); $this->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), array('' => ts('- select -')) + $profiles); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - Search')); $this->addYesNo('includeWildCardInName', ts('Automatic Wildcard')); $this->addYesNo('includeEmailInName', ts('Include Email')); $this->addYesNo('includeNickNameInName', ts('Include Nickname')); $this->addYesNo('includeAlphabeticalPager', ts('Include Alphabetical Pager')); $this->addYesNo('includeOrderByClause', ts('Include Order By Clause')); $this->addElement('text', 'smartGroupCacheTimeout', ts('Smart group cache timeout'), array('size' => 3, 'maxlength' => 5)); require_once "CRM/Core/BAO/UFGroup.php"; $types = array('Contact', 'Individual', 'Organization', 'Household'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); $this->add('select', 'defaultSearchProfileID', ts('Default Contact Search Profile'), array('' => ts('- select -')) + $profiles); require_once 'CRM/Core/OptionGroup.php'; $options = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', false, false, true)); $this->addCheckBox('autocompleteContactSearch', 'Autocomplete Contact Search', $options, null, null, null, null, array(' ')); $element = $this->getElement('autocompleteContactSearch'); $element->_elements[0]->_flagFrozen = true; parent::buildQuickForm(); }
/** * Build the form object. */ public function buildQuickForm() { $types = array('Activity'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); $activityTypeIds = array_flip(CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name')); $nonEditableActivityTypeIds = array($activityTypeIds['Email'], $activityTypeIds['Bulk Email'], $activityTypeIds['Contribution'], $activityTypeIds['Inbound Email'], $activityTypeIds['Pledge Reminder'], $activityTypeIds['Membership Signup'], $activityTypeIds['Membership Renewal'], $activityTypeIds['Event Registration'], $activityTypeIds['Pledge Acknowledgment']); $notEditable = FALSE; foreach ($this->_activityHolderIds as $activityId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); if (in_array($typeId, $nonEditableActivityTypeIds)) { $notEditable = TRUE; break; } } if (empty($profiles)) { CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple activities. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert"); CRM_Utils_System::redirect($this->_userContext); } elseif ($notEditable) { CRM_Core_Session::setStatus("", ts("Some of the selected activities are not editable."), "alert"); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE); $this->addDefaultButtons(ts('Continue')); }
/** * @return array */ public static function getAvailableProfiles() { return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array('Contact', 'Individual', 'Organization', 'Household')); }
static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type $contact_type = array(); require_once 'CRM/Contact/BAO/ContactType.php'; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, false, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { $form->add('select', 'group', ts('Groups'), $form->_group, false, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['tags']) { // multiselect for categories require_once 'CRM/Core/BAO/Tag.php'; $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $form->add('select', 'contact_tags', ts('Tags'), $contactTags, false, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } require_once 'CRM/Core/Form/Tag.php'; require_once 'CRM/Core/BAO/Tag.php'; $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', null, true); } // 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', 'source')); //added job title $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); $config =& CRM_Core_Config::singleton(); if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) { $form->add('checkbox', 'deleted_contacts', ts('Search in Trash (deleted contacts)')); } // add checkbox for cms users only $form->addYesNo('uf_user', ts('CMS User?')); // add search profiles require_once 'CRM/Core/BAO/UFGroup.php'; // 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->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles); require_once 'CRM/Contact/Form/Search.php'; $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::check('view all activities')) { unset($componentModes['4']); } if (count($componentModes) > 1) { $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes); } // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).'); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']); $form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>')); // preferred communication method require_once 'CRM/Core/PseudoConstant.php'; $comm = CRM_Core_PseudoConstant::pcm(); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v); } $onHold[] = HTML_QuickForm::createElement('advcheckbox', 'on_hold', null, ts('')); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $langPreff = CRM_Core_PseudoConstant::languages(); $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { require_once "CRM/Core/BAO/UFGroup.php"; $types = array('Activity'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, true); $activityTypeIds = array_flip(CRM_Core_PseudoConstant::activityType(true, false, false, 'name')); $nonEditableActivityTypeIds = array($activityTypeIds['Email'], $activityTypeIds['Bulk Email'], $activityTypeIds['Contribution'], $activityTypeIds['Inbound Email'], $activityTypeIds['Pledge Reminder'], $activityTypeIds['Membership Signup'], $activityTypeIds['Membership Renewal'], $activityTypeIds['Event Registration'], $activityTypeIds['Pledge Acknowledgment']); foreach ($this->_activityHolderIds as $activityId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); if (in_array($typeId, $nonEditableActivityTypeIds)) { $notEditable = true; break; } } if (empty($profiles)) { CRM_Core_Session::setStatus("You will need to create a Profile containing the {$types[0]} fields you want to edit before you can use Batch Update via Profile. Navigate to Administer Civicrm >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information."); CRM_Utils_System::redirect($this->_userContext); } else { if ($notEditable) { CRM_Core_Session::setStatus("Some of the selected activities are not editable."); CRM_Utils_System::redirect($this->_userContext); } } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, true); $this->addDefaultButtons(ts('Continue >>')); }
/** * Global validation rules for the form. * * @param array $values * @param $files * @param CRM_Core_Form $form * * @return array * list of errors to be posted back to the form */ public static function formRule($values, $files, $form) { if (!empty($values['is_online_registration'])) { if (!$values['confirm_title']) { $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page'); } if (!$values['thankyou_title']) { $errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page'); } if ($values['is_email_confirm']) { if (!$values['confirm_from_name']) { $errorMsg['confirm_from_name'] = ts('Please enter Confirmation Email FROM Name.'); } if (!$values['confirm_from_email']) { $errorMsg['confirm_from_email'] = ts('Please enter Confirmation Email FROM Email Address.'); } } if (isset($values['registration_start_date']) && isset($values['registration_end_date'])) { $start = CRM_Utils_Date::processDate($values['registration_start_date']); $end = CRM_Utils_Date::processDate($values['registration_end_date']); if ($end < $start) { $errorMsg['registration_end_date'] = ts('Registration end date should be after Registration start date'); } } //check that the selected profiles have either firstname+lastname or email required $profileIds = array(CRM_Utils_Array::value('custom_pre_id', $values), CRM_Utils_Array::value('custom_post_id', $values)); $additionalProfileIds = array(CRM_Utils_Array::value('additional_custom_pre_id', $values), CRM_Utils_Array::value('additional_custom_post_id', $values)); //additional profile fields default to main if not set if (!is_numeric($additionalProfileIds[0])) { $additionalProfileIds[0] = $profileIds[0]; } if (!is_numeric($additionalProfileIds[1])) { $additionalProfileIds[1] = $profileIds[1]; } //add multiple profiles if set self::addMultipleProfiles($profileIds, $values, 'custom_post_id_multiple'); self::addMultipleProfiles($additionalProfileIds, $values, 'additional_custom_post_id_multiple'); $isProfileComplete = self::isProfileComplete($profileIds); $isAdditionalProfileComplete = self::isProfileComplete($additionalProfileIds); //Check main profiles have an email address available if 'send confirmation email' is selected if ($values['is_email_confirm']) { $emailFields = self::getEmailFields($profileIds); if (!count($emailFields)) { $errorMsg['is_email_confirm'] = ts("Please add a profile with an email address if 'Send Confirmation Email?' is selected"); } } $additionalCustomPreId = $additionalCustomPostId = NULL; $isPreError = $isPostError = TRUE; if (!empty($values['allow_same_participant_emails']) && !empty($values['is_multiple_registrations'])) { $types = array_merge(array('Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); //check for additional custom pre profile $additionalCustomPreId = CRM_Utils_Array::value('additional_custom_pre_id', $values); if (!empty($additionalCustomPreId)) { if (!($additionalCustomPreId == 'none')) { $customPreId = $additionalCustomPreId; } else { $isPreError = FALSE; } } else { $customPreId = !empty($values['custom_pre_id']) ? $values['custom_pre_id'] : NULL; } //check whether the additional custom pre profile is of type 'Individual' and its subtypes if (!empty($customPreId)) { $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPreId); foreach ($types as $individualTypes) { if (in_array($individualTypes, $profileTypes)) { $isPreError = FALSE; break; } } } else { $isPreError = FALSE; } // We don't have required Individual fields in the pre-custom profile, so now check the post-custom profile if ($isPreError) { $additionalCustomPostId = CRM_Utils_Array::value('additional_custom_post_id', $values); if (!empty($additionalCustomPostId)) { if (!($additionalCustomPostId == 'none')) { $customPostId = $additionalCustomPostId; } else { $isPostError = FALSE; } } else { $customPostId = !empty($values['custom_post_id']) ? $values['custom_post_id'] : NULL; } //check whether the additional custom post profile is of type 'Individual' and its subtypes if (!empty($customPostId)) { $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPostId); foreach ($types as $individualTypes) { if (in_array($individualTypes, $profileTypes)) { $isPostError = FALSE; break; } } } else { $isPostError = FALSE; } if (empty($customPreId) && empty($customPostId)) { $errorMsg['additional_custom_pre_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'"); } if ($isPostError) { $errorMsg['additional_custom_post_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'"); } } } if (!$isProfileComplete) { $errorMsg['custom_pre_id'] = ts("Please include a Profile for online registration that contains an Email Address field and / or First Name + Last Name fields."); } if (!$isAdditionalProfileComplete) { $errorMsg['additional_custom_pre_id'] = ts("Please include a Profile for online registration of additional participants that contains an Email Address field and / or First Name + Last Name fields."); } // // CRM-8485 // $config = CRM_Core_Config::singleton(); // if ( $config->doNotAttachPDFReceipt ) { // if (!empty($values['custom_post_id_multiple'])) { // foreach( $values['custom_post_id_multiple'] as $count => $customPostMultiple ) { // if ( $customPostMultiple ) { // $errorMsg["custom_post_id_multiple[{$count}]"] = ts('Please disable PDF receipt as an attachment in <a href="%1">Miscellaneous Settings</a> if you want to add additional profiles.', array( 1 => CRM_Utils_System::url( 'civicrm/admin/setting/misc', 'reset=1' ) ) ); // break; // } // } // } // // if (!empty($values['is_multiple_registrations']) && // CRM_Utils_Array::value('additional_custom_post_id_multiple', $values) ) { // foreach( $values['additional_custom_post_id_multiple'] as $count => $customPostMultiple ) { // if ( $customPostMultiple ) { // $errorMsg["additional_custom_post_id_multiple[{$count}]"] = ts('Please disable PDF receipt as an attachment in <a href="%1">Miscellaneous Settings</a> if you want to add additional profiles.', array( 1 => CRM_Utils_System::url( 'civicrm/admin/setting/misc', 'reset=1' ) ) ); // break; // } // } // } // } if (!empty($errorMsg)) { if (!empty($values['custom_post_id_multiple'])) { foreach ($values['custom_post_id_multiple'] as $count => $customPostMultiple) { self::buildMultipleProfileBottom($form, $count); } $form->assign('profilePostMultiple', $values['custom_post_id_multiple']); } if (!empty($values['additional_custom_post_id_multiple'])) { foreach ($values['additional_custom_post_id_multiple'] as $count => $customPostMultiple) { self::buildMultipleProfileBottom($form, $count, 'additional_', ts('Profile for Additional Participants')); } $form->assign('profilePostMultipleAdd', $values['additional_custom_post_id_multiple']); } } } if (!empty($errorMsg)) { return $errorMsg; } return TRUE; }
/** * Function to build Registration Block * * @param int $pageId * @static */ function buildRegistrationBlock(&$form) { $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); $form->add('textarea', 'intro_text', ts('Introductory Text'), $attributes['intro_text']); $form->add('textarea', 'footer_text', ts('Footer Text'), $attributes['footer_text']); require_once "CRM/Core/BAO/UFGroup.php"; require_once "CRM/Contact/BAO/ContactType.php"; $types = array_merge(array('Contact', 'Individual', 'Participant'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); $mainProfiles = array('' => ts('- select -')) + $profiles; $addtProfiles = array('' => ts('- same as for main contact -'), 'none' => ts('- no profile -')) + $profiles; $form->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $mainProfiles); $form->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $mainProfiles); $form->add('select', 'additional_custom_pre_id', ts('Profile for Additional Participants') . '<br />' . ts('(top of page)'), $addtProfiles); $form->add('select', 'additional_custom_post_id', ts('Profile for Additional Participants') . '<br />' . ts('(bottom of page)'), $addtProfiles); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { CRM_Utils_System::setTitle(ts('Batch Profile Update for Contact')); foreach ($this->_contactIds as $id) { $this->_contactTypes = CRM_Contact_BAO_Contact::getContactTypes($id); } //add Contact type profiles $this->_contactTypes[] = 'Contact'; $profiles = CRM_Core_BAO_UFGroup::getProfiles($this->_contactTypes); if (empty($profiles)) { $types = implode(' ' . ts('or') . ' ', $this->_contactTypes); CRM_Core_Session::setStatus(ts("The contact type selected for Batch Update does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error'); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE, array('class' => 'crm-select2 huge')); $this->addDefaultButtons(ts('Continue >>')); }
/** * @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')); }
/** * global validation rules for the form * * @param array $fields posted values of the form * * @return array list of errors to be posted back to the form * @static * @access public */ static function formRule($values) { if (CRM_Utils_Array::value('is_online_registration', $values)) { if (!$values['confirm_title']) { $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page'); } if (!$values['thankyou_title']) { $errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page'); } if ($values['is_email_confirm']) { if (!$values['confirm_from_name']) { $errorMsg['confirm_from_name'] = ts('Please enter Confirmation Email FROM Name.'); } if (!$values['confirm_from_email']) { $errorMsg['confirm_from_email'] = ts('Please enter Confirmation Email FROM Email Address.'); } } $additionalCustomPreId = $additionalCustomPostId = null; $isPreError = $isPostError = true; if (CRM_Utils_Array::value('allow_same_participant_emails', $values) && CRM_Utils_Array::value('is_multiple_registrations', $values)) { $types = array_merge(array('Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); //check for additional custom pre profile $additionalCustomPreId = CRM_Utils_Array::value('additional_custom_pre_id', $values); if (!empty($additionalCustomPreId)) { if (!($additionalCustomPreId == 'none')) { $customPreId = $additionalCustomPreId; } else { $isPreError = false; } } else { $customPreId = CRM_Utils_Array::value('custom_pre_id', $values) ? $values['custom_pre_id'] : null; } //check whether the additional custom pre profile is of type 'Individual' and its subtypes if (!empty($customPreId)) { $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPreId); foreach ($types as $individualTypes) { if (in_array($individualTypes, $profileTypes)) { $isPreError = false; break; } } } else { $isPreError = false; } //check for additional custom post profile $additionalCustomPostId = CRM_Utils_Array::value('additional_custom_post_id', $values); if (!empty($additionalCustomPostId)) { if (!($additionalCustomPostId == 'none')) { $customPostId = $additionalCustomPostId; } else { $isPostError = false; } } else { $customPostId = CRM_Utils_Array::value('custom_post_id', $values) ? $values['custom_post_id'] : null; } //check whether the additional custom post profile is of type 'Individual' and its subtypes if (!empty($customPostId)) { $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPostId); foreach ($types as $individualTypes) { if (in_array($individualTypes, $profileTypes)) { $isPostError = false; break; } } } else { $isPostError = false; } if ($isPreError || empty($customPreId) && empty($customPostId)) { $errorMsg['additional_custom_pre_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'"); } if ($isPostError) { $errorMsg['additional_custom_post_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'"); } } } if (!empty($errorMsg)) { return $errorMsg; } return true; }
/** * Function to actually build the form * * @param null * * @return void * @access public */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } require_once 'CRM/Event/PseudoConstant.php'; require_once 'CRM/Core/BAO/UFGroup.php'; require_once 'CRM/Core/BAO/CustomField.php'; $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), true); $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType(); // Activity Type id $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => ts('- select -')) + $surveyActivityTypes, true); // Campaign id require_once 'CRM/Campaign/BAO/Campaign.php'; $campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign(); $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity')); // custom group id $this->add('select', 'profile_id', ts('Profile'), array('' => ts('- select -')) + $customProfiles); $optionGroups = CRM_Campaign_BAO_Survey::getResultSets(); if (empty($optionGroups)) { $optionTypes = array('1' => ts('Create new response set')); } else { $optionTypes = array('1' => ts('Create a new response set'), '2' => ts('Use existing response set')); $this->add('select', 'option_group_id', ts('Select Response Set'), array('' => ts('- select -')) + $optionGroups, false, array('onChange' => 'loadOptionGroup( )')); } $element =& $this->addRadio('option_type', ts('Survey Responses'), $optionTypes, array('onclick' => "showOptionSelect();"), '<br/>', true); if (empty($optionGroups) || !CRM_Utils_Array::value('result_id', $this->_values)) { $this->setdefaults(array('option_type' => 1)); } else { if (CRM_Utils_Array::value('result_id', $this->_values)) { $this->setdefaults(array('option_type' => 2, 'option_group_id' => $this->_values['result_id'])); } } // form fields of Custom Option rows $defaultOption = array(); $_showHide = new CRM_Core_ShowHideBlocks('', ''); $optionAttributes =& CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue'); $optionAttributes['label']['size'] = $optionAttributes['value']['size'] = 25; for ($i = 1; $i <= self::NUM_OPTION; $i++) { //the show hide blocks $showBlocks = 'optionField_' . $i; if ($i > 2) { $_showHide->addHide($showBlocks); if ($i == self::NUM_OPTION) { $_showHide->addHide('additionalOption'); } } else { $_showHide->addShow($showBlocks); } $this->add('text', 'option_label[' . $i . ']', ts('Label'), $optionAttributes['label']); // value $this->add('text', 'option_value[' . $i . ']', ts('Value'), $optionAttributes['value']); // weight $this->add('text', "option_weight[{$i}]", ts('Order'), $optionAttributes['weight']); $this->add('text', 'option_interval[' . $i . ']', ts('Recontact Interval'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency')); $defaultOption[$i] = $this->createElement('radio', null, null, null, $i); } //default option selection $this->addGroup($defaultOption, 'default_option'); $_showHide->addToTemplate(); // script / instructions $this->add('textarea', 'instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40)); // release frequency $this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency')); $this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger'); // max reserved contacts at a time $this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts')); $this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger'); // total reserved per interviewer $this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts')); $this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger'); // is active ? $this->add('checkbox', 'is_active', ts('Active?')); // is default ? $this->add('checkbox', 'is_default', ts('Default?')); // add buttons if ($this->_context == 'dialog') { $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "cj('#survey-dialog').dialog('close'); return false;")))); } else { $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); } // add a form rule to check default value $this->addFormRule(array('CRM_Campaign_Form_Survey', 'formRule'), $this); }
static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type $contact_type = array(); require_once 'CRM/Contact/BAO/ContactType.php'; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(); foreach ($contactTypes as $k => $v) { if (!empty($k)) { $contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v); } } $form->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />'); } if ($form->_searchOptions['groups']) { // checkboxes for groups foreach ($form->_group as $groupID => $group) { $form->_groupElement =& $form->addElement('checkbox', "group[{$groupID}]", null, $group); } } if ($form->_searchOptions['tags']) { // checkboxes for categories require_once 'CRM/Core/BAO/Tag.php'; $tags = new CRM_Core_BAO_Tag(); $tree = $tags->getTree(); $form->assign('tree', $tags->getTree()); foreach ($form->_tag as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "tag[{$tagID}]", null, $tagName); } } // 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', 'source')); // add checkbox for cms users only if (CIVICRM_UF != 'Standalone') { $form->addYesNo('uf_user', ts('CMS User?')); } // add search profiles require_once 'CRM/Core/BAO/UFGroup.php'; // 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->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles); // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).'); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']); $form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>')); // preferred communication method require_once 'CRM/Core/PseudoConstant.php'; $comm = CRM_Core_PseudoConstant::pcm(); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v); } $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); }
static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type $contact_type = array(); $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { $form->add('select', 'group', ts('Groups'), $form->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } 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', 'title' => ts('- select -'))); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE); } // 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', 'source')); //added job title $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); //added internal ID $attributes['id']['size'] = 30; $form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"'); //added external ID $attributes['external_identifier']['size'] = 30; $form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"'); $config = CRM_Core_Config::singleton(); if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) { $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?')); // 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->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles); $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->addElement('select', 'component_mode', ts('Display Results As'), $componentModes); } $form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR'))); // 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); // 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', 'title' => ts('- select -'))); $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND'))); $toggleChoice = array(); $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Exclude'), '1'); $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Include by Privacy Option(s)'), '2'); $form->addGroup($toggleChoice, 'privacy_toggle', 'Privacy Options'); // preferred communication method $comm = CRM_Core_PseudoConstant::pcm(); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v); } $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts('')); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $langPreff = CRM_Core_PseudoConstant::languages(); $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff); }
public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } $this->add('text', 'title', ts('Petition Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE); $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey'); $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); $this->addElement('hidden', 'activity_type_id', $petitionTypeID); // script / instructions / description of petition purpose $this->addWysiwyg('instructions', ts('Introduction'), $attributes['instructions']); // Campaign id $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values)); $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual')); // custom group id $this->add('select', 'contact_profile_id', ts('Contact Profile'), array('' => ts('- select -')) + $customContactProfiles, TRUE); $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity')); // custom group id $this->add('select', 'profile_id', ts('Activity Profile'), array('' => ts('- select -')) + $customProfiles); // thank you title and text (html allowed in text) $this->add('text', 'thankyou_title', ts('Thank-you Page Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'thankyou_title')); $this->addWysiwyg('thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'thankyou_text')); // bypass email confirmation? $this->add('checkbox', 'bypass_confirm', ts('Bypass email confirmation')); //is share through social media $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); // is active ? $this->add('checkbox', 'is_active', ts('Is Active?')); // is default ? $this->add('checkbox', 'is_default', ts('Is Default?')); // add buttons $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); // add a form rule to check default value $this->addFormRule(array('CRM_Campaign_Form_Petition', 'formRule'), $this); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { require_once "CRM/Core/BAO/UFGroup.php"; $types = array('Membership'); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, true); if (empty($profiles)) { CRM_Core_Session::setStatus("You will need to create a Profile containing the {$types[0]} fields you want to edit before you can use Batch Update via Profile. Navigate to Administer Civicrm >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information."); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, true); $this->addDefaultButtons(ts('Continue >>')); }
public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } require_once 'CRM/Event/PseudoConstant.php'; require_once 'CRM/Core/BAO/UFGroup.php'; require_once 'CRM/Core/OptionGroup.php'; $this->add('text', 'title', ts('Petition Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), true); $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey'); $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); $this->addElement('hidden', 'activity_type_id', $petitionTypeID); // $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType( ); // Activity Type id // $this->add('select', 'activity_type_id', ts('Select Activity Type'), array( '' => ts('- select -') ) + $surveyActivityTypes, true ); // script / instructions / description of petition purpose $this->addWysiwyg('instructions', ts('Introduction'), $attributes['instructions']); // Campaign id require_once 'CRM/Campaign/BAO/Campaign.php'; $campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign(); $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual')); // custom group id $this->add('select', 'contact_profile_id', ts('Contact Profile'), array('' => ts('- select -')) + $customContactProfiles, true); $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity')); // custom group id $this->add('select', 'profile_id', ts('Activity Profile'), array('' => ts('- select -')) + $customProfiles); // is active ? $this->add('checkbox', 'is_active', ts('Is Active?')); // is default ? $this->add('checkbox', 'is_default', ts('Is Default?')); // add buttons $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); // add a form rule to check default value $this->addFormRule(array('CRM_Campaign_Form_Survey', 'formRule'), $this); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { CRM_Utils_System::setTitle(ts('Batch Profile Update')); if (CRM_Core_Permission::access('Quest')) { $this->_contactTypes['Student'] = 'Student'; } //add Contact type profiles $this->_contactTypes[] = 'Contact'; foreach ($this->_contactIds as $id) { $this->_contactTypes = CRM_Contact_BAO_Contact::getContactTypes($id); } require_once "CRM/Core/BAO/UFGroup.php"; $profiles = CRM_Core_BAO_UFGroup::getProfiles($this->_contactTypes); if (empty($profiles)) { $types = implode('or', $this->_contactTypes); CRM_Core_Session::setStatus("The contact type selected for Batch Update do not have corresponding profiles. Please make sure that {$types} has a profile and try again."); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, true); $this->addDefaultButtons(ts('Continue >>')); }