本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getProfiles方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getProfiles方法的具体用法?PHP CRM_Core_BAO_UFGroup::getProfiles怎么用?PHP CRM_Core_BAO_UFGroup::getProfiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getProfiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* 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();
}
示例2: 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'));
}
示例3: buildQuickForm
/**
* 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'));
}
示例4: buildQuickForm
/**
* 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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'));
}
示例8: getAvailableProfiles
/**
* @return array
*/
public static function getAvailableProfiles()
{
return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array('Contact', 'Individual', 'Organization', 'Household'));
}
示例9: basic
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
//.........这里部分代码省略.........
示例10: buildQuickForm
/**
* 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 >>'));
}
示例11: formRule
/**
* 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) {
//.........这里部分代码省略.........
示例12: buildRegistrationBlock
/**
* 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);
}
示例13: buildQuickForm
/**
* 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 >>'));
}
示例14: basic
/**
* @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']);
}
//.........这里部分代码省略.........
示例15: formRule
/**
* 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;
}