本文整理汇总了PHP中CRM_Core_BAO_Setting::valueOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Setting::valueOptions方法的具体用法?PHP CRM_Core_BAO_Setting::valueOptions怎么用?PHP CRM_Core_BAO_Setting::valueOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Setting
的用法示例。
在下文中一共展示了CRM_Core_BAO_Setting::valueOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
$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();
}
示例2: setDefaultValues
/**
* This function sets the default values for the form.
* default values are retrieved from the database
*
* @access public
*
* @return None
*/
function setDefaultValues()
{
if (!$this->_defaults) {
$this->_defaults = array();
$formArray = array('Component', 'Localization');
$formMode = FALSE;
if (in_array($this->_name, $formArray)) {
$formMode = TRUE;
}
CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
$list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name'));
$cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name'));
$listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
$cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
$autoSearchFields = array();
if (!empty($list) && !empty($listEnabled)) {
$autoSearchFields = array_combine($list, $listEnabled);
}
$cRSearchFields = array();
if (!empty($cRlist) && !empty($cRlistEnabled)) {
$cRSearchFields = array_combine($cRlist, $cRlistEnabled);
}
//Set defaults for autocomplete and contact reference options
$this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
$this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields;
$this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
$this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
$sql = "\nSELECT time_format\nFROM civicrm_preferences_date\nWHERE time_format IS NOT NULL\nAND time_format <> ''\nLIMIT 1\n";
$this->_defaults['timeInputFormat'] = CRM_Core_DAO::singleValueQuery($sql);
}
return $this->_defaults;
}
示例3: buildQuickForm
/**
* Build the form object.
*
*
* @return void
*/
public 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'));
}
// add select for groups
if (!empty($searchOptions['groups'])) {
$this->addSelect('group', array('entity' => 'group_contact', 'label' => ts('in'), 'context' => 'search', 'placeholder' => ts('- any group -')));
}
if (!empty($searchOptions['tags'])) {
// tag criteria
if (!empty($this->_tag)) {
$this->addSelect('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'context' => 'search', 'placeholder' => ts('- any tag -')));
}
}
parent::buildQuickForm();
}
示例4: 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();
}
示例5: buildQuickForm
/**
* This function provides the HTML form elements that are specific
* to the Individual Contact Type
*
* @param CRM_Core_Form $form form object
* @param int $inlineEditMode ( 1 for contact summary
* top bar form and 2 for display name edit )
*
* @access public
* @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL)
{
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
$nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
//prefix
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
if (isset($nameFields['Prefix']) && !empty($prefix)) {
$form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' '));
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
if (isset($nameFields['Formal Title'])) {
$form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
}
// first_name
if (isset($nameFields['First Name'])) {
$form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
}
//middle_name
if (isset($nameFields['Middle Name'])) {
$form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
}
// last_name
if (isset($nameFields['Last Name'])) {
$form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
}
// suffix
$suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
if (isset($nameFields['Suffix']) && $suffix) {
$form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' '));
}
}
if (!$inlineEditMode || $inlineEditMode == 2) {
// nick_name
$form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
// job title
// override the size for UI to look better
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//Current Employer Element
$employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE);
$form->assign('employerDataURL', $employerDataURL);
$form->addElement('text', 'current_employer', ts('Current Employer'), '');
$form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
$form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
}
if (!$inlineEditMode) {
$checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
if ($checkSimilar == null) {
$checkSimilar = 0;
}
$form->assign('checkSimilar', $checkSimilar);
//External Identifier Element
$form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
$form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
$config = CRM_Core_Config::singleton();
CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
}
}
示例6: testSetValueOptions
public function testSetValueOptions()
{
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
$addressOptions['county'] = 1;
CRM_Core_BAO_Setting::setValueOption(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', $addressOptions);
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
$this->assertEquals($addressOptions['county'], 1, 'County was set but did not stick in db');
}
示例7: buildQuickForm
/**
* This function provides the HTML form elements that are specific
* to the Individual Contact Type
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
*
* @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL)
{
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
$nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
//prefix
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
if (isset($nameFields['Prefix']) && !empty($prefix)) {
$form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
if (isset($nameFields['Formal Title'])) {
$form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
}
// first_name
if (isset($nameFields['First Name'])) {
$form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
}
//middle_name
if (isset($nameFields['Middle Name'])) {
$form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
}
// last_name
if (isset($nameFields['Last Name'])) {
$form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
}
// suffix
$suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
if (isset($nameFields['Suffix']) && $suffix) {
$form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
}
}
if (!$inlineEditMode || $inlineEditMode == 2) {
// nick_name
$form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
// job title
// override the size for UI to look better
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//Current Employer Element
$props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
$form->addEntityRef('employer_id', ts('Current Employer'), $props);
$attributes['source']['class'] = 'big';
$form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
}
if (!$inlineEditMode) {
$checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
if ($checkSimilar == NULL) {
$checkSimilar = 0;
}
$form->assign('checkSimilar', $checkSimilar);
//External Identifier Element
$form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
$form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
$config = CRM_Core_Config::singleton();
CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
}
}
示例8: __construct
/**
* Class constructor.
*
* @param int $contactId
* Contact whose activities we want to display.
* @param int $permission
* The permission we have for this contact.
*
* @param bool $admin
* @param string $context
* @param null $activityTypeIDs
*
* @return \CRM_Activity_Selector_Activity
*/
public function __construct($contactId, $permission, $admin = FALSE, $context = 'activity', $activityTypeIDs = NULL)
{
$this->_contactId = $contactId;
$this->_permission = $permission;
$this->_admin = $admin;
$this->_context = $context;
$this->_activityTypeIDs = $activityTypeIDs;
// get all enabled view componentc (check if case is enabled)
$this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE, NULL, TRUE);
}
示例9: preProcess
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess()
{
// initialize the task and row fields
parent::preProcess();
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_memberIds, 'CiviMember', $returnProperties);
$this->assign('contactDetails', $contactDetails);
$this->assign('readOnlyFields', $readOnlyFields);
}
示例10: buildQuickForm
/**
* This function provides the HTML form elements that are specific to the Individual Contact Type.
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL)
{
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
$nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
// Use names instead of labels to build form.
$nameFields = array_keys($nameFields);
// Fixme: dear god why? these come out in a format that is NOT the name of the fields.
foreach ($nameFields as &$fix) {
$fix = str_replace(' ', '_', strtolower($fix));
if ($fix == 'prefix' || $fix == 'suffix') {
// God, why god?
$fix .= '_id';
}
}
foreach ($nameFields as $name) {
$props = array();
if ($name == 'prefix_id' || $name == 'suffix_id') {
$options = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name);
// Skip if we have no options available
if (!CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name)) {
//continue;
}
$props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix'));
}
$form->addField($name, $props);
}
}
if (!$inlineEditMode || $inlineEditMode == 2) {
// nick_name
$form->addField('nick_name');
// job title
// override the size for UI to look better
$form->addField('job_title', array('size' => '30'));
//Current Employer Element
$props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
$form->addField('employer_id', $props);
$form->addField('contact_source', array('class' => 'big'));
}
if (!$inlineEditMode) {
$checkSimilar = Civi::settings()->get('contact_ajax_check_similar');
if ($checkSimilar == NULL) {
$checkSimilar = 0;
}
$form->assign('checkSimilar', $checkSimilar);
//External Identifier Element
$form->addField('external_identifier', array('label' => 'External ID'));
$form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
}
}
示例11: buildUserDashBoard
/**
* Function to build user dashboard
*
* @return void
* @access public
*/
function buildUserDashBoard()
{
//build component selectors
$dashboardElements = array();
$config = CRM_Core_Config::singleton();
$this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'user_dashboard_options');
$this->assign('contactId', $this->_contactId);
if (!empty($this->_userOptions['PCP'])) {
//My Personal campaign pages
$dashboardElements[] = array('class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/Pages.tpl', 'sectionTitle' => ts('My fundraising pages'), 'weight' => 40);
$pcpInfo = civicrm_api('pcpteams', 'getContactPcp', array('version' => 3, 'contact_id' => $this->_contactId, 'is_active' => 1));
$this->assign('pcpInfo', isset($pcpInfo['values']) ? $pcpInfo['values'] : NULL);
//My Teams
$dashboardElements[] = array('class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/Teams.tpl', 'sectionTitle' => ts('My Teams'), 'weight' => 40);
$teamInfo = civicrm_api('pcpteams', 'getMyTeamInfo', array('version' => 3, 'contact_id' => $this->_contactId));
$this->assign('teamInfo', isset($teamInfo['values']) ? $teamInfo['values'] : NULL);
$is_admin = FALSE;
foreach ($teamInfo['values'] as $team) {
if ($team['role'] == 'Admin') {
$is_admin = TRUE;
break;
}
}
//Team Members
if ($is_admin) {
$dashboardElements[] = array('class' => 'crm-dashboard-permissionedteammembers', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamMembers.tpl', 'sectionTitle' => ts('Team Members'), 'weight' => 41);
$teamMemberInfo = civicrm_api('pcpteams', 'getTeamMembers', array('version' => 3, 'contact_id' => $this->_contactId));
$this->assign('teamMemberInfo', isset($teamMemberInfo['values']) ? $teamMemberInfo['values'] : NULL);
}
//New Team Member Requests
if ($is_admin) {
$dashboardElements[] = array('class' => 'crm-dashboard-permissionednewteamreq', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamMemberRequests.tpl', 'sectionTitle' => ts('New Team Member Requests'), 'weight' => 43);
$teamRequestInfo = civicrm_api('pcpteams', 'getTeamRequest', array('version' => 3, 'contact_id' => $this->_contactId));
$this->assign('teamRequestInfo', isset($teamRequestInfo['values']) ? $teamRequestInfo['values'] : NULL);
}
//My Pending Team Requests
$dashboardElements[] = array('class' => 'crm-dashboard-permissionedteamreq', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamRequests.tpl', 'sectionTitle' => ts('My Pending Team Requests'), 'weight' => 42);
$teamPendingInfo = civicrm_api('pcpteams', 'getMyPendingTeam', array('version' => 3, 'contact_id' => $this->_contactId));
$this->assign('teamPendingInfo', isset($teamPendingInfo['values']) ? $teamPendingInfo['values'] : NULL);
//Archived (inactive) Pages
$dashboardElements[] = array('class' => 'crm-dashboard-permissionedinactive', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/PagesDisabled.tpl', 'sectionTitle' => ts('Archived Pages'), 'weight' => 44);
$pcpInactiveInfo = civicrm_api('pcpteams', 'getContactPcp', array('version' => 3, 'contact_id' => $this->_contactId, 'is_active' => 0));
$this->assign('pcpInactiveInfo', isset($pcpInactiveInfo['values']) ? $pcpInactiveInfo['values'] : NULL);
}
// usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
$this->assign('dashboardElements', $dashboardElements);
}
示例12: __construct
/**
* Class constructor.
*
* @param array $formValues
*/
public function __construct(&$formValues)
{
parent::__construct($formValues);
$this->_columns = array('' => 'contact_type', ts('Name') => 'sort_name', ts('Address') => 'street_address', ts('City') => 'city', ts('State') => 'state_province', ts('Postal') => 'postal_code', ts('Country') => 'country', ts('Email') => 'email', ts('Phone') => 'phone');
$params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$returnProperties = array();
$returnProperties['contact_sub_type'] = 1;
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
foreach ($this->_columns as $name => $field) {
if (in_array($field, array('street_address', 'city', 'state_province', 'postal_code', 'country')) && empty($addressOptions[$field])) {
unset($this->_columns[$name]);
continue;
}
$returnProperties[$field] = 1;
}
$this->_query = new CRM_Contact_BAO_Query($params, $returnProperties, NULL, FALSE, FALSE, 1, FALSE, FALSE);
}
示例13: 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 (CRM_Utils_Array::value('contactType', $searchOptions)) {
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
$this->add('select', 'contact_type', ts('is...'), $contactTypes);
}
if (CRM_Utils_Array::value('groups', $searchOptions)) {
if ($config->groupTree) {
$this->add('hidden', 'group', NULL, array('id' => 'group'));
$group = CRM_Utils_Array::value('group', $this->_formValues);
$selectedGroups = explode(',', $group);
if (is_array($selectedGroups)) {
$groupNames = NULL;
$groupIds = array();
foreach ($selectedGroups as $groupId) {
if ($groupNames) {
$groupNames .= '<br/>';
}
$groupNames .= $this->_group[$groupId];
}
$groupIds[] = $groupId;
}
$this->assign('groupIds', implode(',', $groupIds));
$this->assign('groupNames', $groupNames);
} else {
// add select for groups
$group = array('' => ts('- any group -')) + $this->_group;
$this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group);
}
}
if (CRM_Utils_Array::value('tags', $searchOptions)) {
// tag criteria
if (!empty($this->_tag)) {
$tag = array('' => ts('- any tag -')) + $this->_tag;
$this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag);
}
}
parent::buildQuickForm();
}
示例14: run
/**
* @return array
*/
public function run()
{
$config =& CRM_Core_Config::singleton();
// do check for geocoding.
$processGeocode = FALSE;
if (empty($config->geocodeMethod)) {
if (CRM_Utils_String::strtobool($this->geocoding) === TRUE) {
$this->returnMessages[] = ts('Error: You need to set a mapping provider under Administer > System Settings > Mapping and Geocoding');
$this->returnError = 1;
$this->returnResult();
}
} else {
$processGeocode = TRUE;
// user might want to over-ride.
if (CRM_Utils_String::strtobool($this->geocoding) === FALSE) {
$processGeocode = FALSE;
}
}
// do check for parse street address.
$parseAddress = FALSE;
$parseAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE);
$parseStreetAddress = FALSE;
if (!$parseAddress) {
if (CRM_Utils_String::strtobool($this->parse) === TRUE) {
$this->returnMessages[] = ts('Error: You need to enable Street Address Parsing under Administer > Localization > Address Settings.');
$this->returnError = 1;
return $this->returnResult();
}
} else {
$parseStreetAddress = TRUE;
// user might want to over-ride.
if (CRM_Utils_String::strtobool($this->parse) === FALSE) {
$parseStreetAddress = FALSE;
}
}
// don't process.
if (!$parseStreetAddress && !$processGeocode) {
$this->returnMessages[] = ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
$this->returnError = 1;
return $this->returnResult();
}
// do check for parse street address.
return $this->processContacts($config, $processGeocode, $parseStreetAddress);
}
示例15: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$this->addSortNameField();
$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, FALSE, array('class' => 'crm-select2'));
}
// add select for groups
if (!empty($searchOptions['groups'])) {
$this->addField('group', array('entity' => 'group_contact', 'label' => ts('in'), 'placeholder' => ts('- any group -')));
}
if (!empty($searchOptions['tags'])) {
// tag criteria
if (!empty($this->_tag)) {
$this->addField('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'placeholder' => ts('- any tag -')));
}
}
parent::buildQuickForm();
}