本文整理汇总了PHP中CRM_Core_SelectValues::privacy方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_SelectValues::privacy方法的具体用法?PHP CRM_Core_SelectValues::privacy怎么用?PHP CRM_Core_SelectValues::privacy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_SelectValues
的用法示例。
在下文中一共展示了CRM_Core_SelectValues::privacy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zombiefinder_civicrm_check
/**
* Implementation of hook_civicrm_check().
*
* Add a check to the status page/System.check results if $snafu is TRUE.
*/
function zombiefinder_civicrm_check(&$messages)
{
// The API should be able to provide this (as below), but there are problems
// in both 4.6 and 4.7 with finding privacy preferences (Do not mail, etc.)
// that are null using the API.
//
// try {
// $result = civicrm_api3('Contact', 'getcount', array(
// 'is_deceased' => array('IS NULL' => 1),
// ));
// }
// catch (CiviCRM_API3_Exception $e) {
// CRM_Core_Error::debug_log_message($e->getMessage());
// }
// Check for zombies.
$fieldsToCheck = CRM_Core_SelectValues::privacy();
$fieldsToCheck['is_deceased'] = ts('Is Deceased');
$fieldsToCheck['is_deleted'] = ts('Deleted');
$found = array();
foreach ($fieldsToCheck as $fieldName => $displayName) {
$sql = "SELECT COUNT(id) FROM civicrm_contact WHERE {$fieldName} IS NULL";
if (CRM_Core_DAO::singleValueQuery($sql)) {
$found[] = $displayName;
}
}
if (count($found)) {
$tsParams = array(1 => implode(', ', $found), 2 => 'http://civicrm.stackexchange.com/a/7396/44', 'domain' => 'com.aghstrategies.zombiefinder');
$details = ts('Zombies found. You have contacts who are undead or have null privacy options. One or more contacts have null values in the following fields: %1. <a href="%2">Read more about how to solve this.</a>', $tsParams);
$messages[] = new CRM_Utils_Check_Message('zombiefinder_found', $details, ts('Gaaargh! Braaaains!', array('domain' => 'com.aghstrategies.zombiefinder')), \Psr\Log\LogLevel::WARNING, 'fa-user-times');
}
}
示例2: buildQuickForm
/**
* Build the form object elements for Communication Preferences object.
*
* @param CRM_Core_Form $form
* Reference to the form object.
*
* @return void
*/
public static function buildQuickForm(&$form)
{
// since the pcm - preferred comminication method is logically
// grouped hence we'll use groups of HTML_QuickForm
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$privacy = $commPreff = $commPreference = array();
$privacyOptions = CRM_Core_SelectValues::privacy();
// we add is_opt_out as a separate checkbox below for display and help purposes so remove it here
unset($privacyOptions['is_opt_out']);
foreach ($privacyOptions as $name => $label) {
$privacy[] = $form->createElement('advcheckbox', $name, NULL, $label);
}
$form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// preferred communication method
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', array('loclize' => TRUE));
foreach ($comm as $value => $title) {
$commPreff[] = $form->createElement('advcheckbox', $value, NULL, $title);
}
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)'));
$form->addSelect('preferred_language');
if (!empty($privacyOptions)) {
$commPreference['privacy'] = $privacyOptions;
}
if (!empty($comm)) {
$commPreference['preferred_communication_method'] = $comm;
}
//using for display purpose.
$form->assign('commPreference', $commPreference);
$form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf());
$form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)'));
$communicationStyleOptions = array();
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id', array('localize' => TRUE));
foreach ($communicationStyle as $key => $var) {
$communicationStyleOptions[$key] = $form->createElement('radio', NULL, ts('Communication Style'), $var, $key, array('id' => "civicrm_communication_style_{$var}_{$key}"));
}
if (!empty($communicationStyleOptions)) {
$form->addGroup($communicationStyleOptions, 'communication_style_id', ts('Communication Style'));
}
//check contact type and build filter clause accordingly for greeting types, CRM-4575
$greetings = self::getGreetingFields($form->_contactType);
foreach ($greetings as $greeting => $fields) {
$filter = array('contact_type' => $form->_contactType, 'greeting_type' => $greeting);
//add addressee in Contact form
$greetingTokens = CRM_Core_PseudoConstant::greeting($filter);
if (!empty($greetingTokens)) {
$form->addElement('select', $fields['field'], $fields['label'], array('' => ts('- select -')) + $greetingTokens);
//custom addressee
$form->addElement('text', $fields['customField'], $fields['customLabel'], CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', $fields['customField']), $fields['js']);
}
}
}
示例3: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
$this->assign('contactId', $contactId);
$this->assign($defaults);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例4: buildQuickForm
/**
* build the form elements for Communication Preferences object
*
* @param CRM_Core_Form $form reference to the form object
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form)
{
// since the pcm - preferred comminication method is logically
// grouped hence we'll use groups of HTML_QuickForm
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$privacy = $commPreff = $commPreference = array();
$privacyOptions = CRM_Core_SelectValues::privacy();
foreach ($privacyOptions as $name => $label) {
$privacy[] = HTML_QuickForm::createElement('advcheckbox', $name, null, $label);
}
$form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// preferred communication method
require_once 'CRM/Core/PseudoConstant.php';
$comm = CRM_Core_PseudoConstant::pcm();
foreach ($comm as $value => $title) {
$commPreff[] = HTML_QuickForm::createElement('advcheckbox', $value, null, $title);
}
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)'));
$form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
if (!empty($privacyOptions)) {
$commPreference['privacy'] = $privacyOptions;
}
if (!empty($comm)) {
$commPreference['preferred_communication_method'] = $comm;
}
//using for display purpose.
$form->assign('commPreference', $commPreference);
$form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf());
$form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)'));
//check contact type and build filter clause accordingly for greeting types, CRM-4575
$greetings = self::getGreetingFields($form->_contactType);
foreach ($greetings as $greeting => $fields) {
$filter = array('contact_type' => $form->_contactType, 'greeting_type' => $greeting);
//add addressee in Contact form
$greetingTokens = CRM_Core_PseudoConstant::greeting($filter);
if (!empty($greetingTokens)) {
$form->addElement('select', $fields['field'], $fields['label'], array('' => ts('- select -')) + $greetingTokens);
//custom addressee
$form->addElement('text', $fields['customField'], $fields['customLabel'], CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', $fields['customField']), $fields['js']);
}
}
}
示例5: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
*/
public function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
if (!empty($communicationStyle)) {
if (!empty($defaults['communication_style_id'])) {
$defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
} else {
// Make sure the field is displayed as long as it is active, even if it is unset for this contact.
$defaults['communication_style_display'] = '';
}
}
$this->assign('contactId', $contactId);
$this->assign($defaults);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例6: basic
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 -')));
//.........这里部分代码省略.........
示例7: view
/**
* View summary details of a contact
*
* @return void
* @access public
*/
function view()
{
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = true;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, true);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type'), 'im' => array('type' => 'IMProvider', 'id' => 'provider'), 'website' => array('type' => 'websiteType', 'id' => 'website_type'), 'address' => array('skip' => true, 'customData' => 1), 'email' => array('skip' => true), 'openid' => array('skip' => true));
foreach ($communicationType as $key => $value) {
if (CRM_Utils_Array::value($key, $defaults)) {
foreach ($defaults[$key] as &$val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::locationType(), false);
if (!CRM_Utils_Array::value('skip', $value)) {
eval('$pseudoConst = CRM_Core_PseudoConstant::' . $value['type'] . '( );');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, false);
}
}
if (isset($value['customData'])) {
foreach ($defaults[$key] as $blockId => $blockVal) {
$groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), $this, $blockVal['id']);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$defaults[$key][$blockId]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, false, null, "dnc_");
}
// reset template variable since that won't be of any use, and could be misleading
$this->assign("dnc_viewCustomData", null);
}
}
}
if (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
// to make contact type label available in the template -
$contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type'];
$defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(true, $contactType);
// get contact tags
require_once 'CRM/Core/BAO/EntityTag.php';
$contactTags = CRM_Core_BAO_EntityTag::getContactTags($this->_contactId);
if (!empty($contactTags)) {
$defaults['contactTag'] = implode(', ', $contactTags);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
//Show blocks only if they are visible in edit form
require_once 'CRM/Core/BAO/Preferences.php';
$this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options');
$configItems = array('CommBlock' => 'Communication Preferences', 'Demographics' => 'Demographics', 'TagsAndGroups' => 'Tags and Groups', 'Notes' => 'Notes');
foreach ($configItems as $c => $t) {
$varName = '_show' . $c;
$this->{$varName} = CRM_Utils_Array::value($c, $this->_editOptions);
$this->assign(substr($varName, 1), $this->{$varName});
}
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (CRM_Utils_Array::value('master_id', $addressValue) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
$this->assign('sharedAddresses', $sharedAddresses);
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
if ($contact->employer_id && $contact->organization_name) {
$defaults['current_employer'] = $contact->organization_name;
$defaults['current_employer_id'] = $contact->employer_id;
}
//for birthdate format with respect to birth format set
$this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
}
$this->assign($defaults);
// also assign the last modifed details
require_once 'CRM/Core/BAO/Log.php';
$lastModified =& CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
$allTabs = array();
$weight = 10;
$this->_viewOptions = CRM_Core_BAO_Preferences::valueOptions('contact_view_options', true);
$changeLog = $this->_viewOptions['log'];
$this->assign_by_ref('changeLog', $changeLog);
require_once 'CRM/Core/Component.php';
$components = CRM_Core_Component::getEnabledComponents();
foreach ($components as $name => $component) {
if (CRM_Utils_Array::value($name, $this->_viewOptions) && CRM_Core_Permission::access($component->name)) {
$elem = $component->registerTab();
// FIXME: not very elegant, probably needs better approach
// allow explicit id, if not defined, use keyword instead
if (array_key_exists('id', $elem)) {
$i = $elem['id'];
} else {
$i = $component->getKeyword();
//.........这里部分代码省略.........
示例8: view
/**
* View summary details of a contact.
*/
public function view()
{
// Add js for tabs, in-place editing, and jstree for tags
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')->addSetting(array('summaryPrint' => array('mode' => $this->_print), 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary'))));
$this->assign('summaryPrint', $this->_print);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
// Let summary page know if outbound mail is disabled so email links can be built conditionally
$mailingBackend = Civi::settings()->get('mailing_backend');
$this->assign('mailingOutboundOption', $mailingBackend['outBound_option']);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type', 'daoName' => 'CRM_Core_DAO_Phone', 'fieldName' => 'phone_type_id'), 'im' => array('type' => 'IMProvider', 'id' => 'provider', 'daoName' => 'CRM_Core_DAO_IM', 'fieldName' => 'provider_id'), 'website' => array('type' => 'websiteType', 'id' => 'website_type', 'daoName' => 'CRM_Core_DAO_Website', 'fieldName' => 'website_type_id'), 'address' => array('skip' => TRUE, 'customData' => 1), 'email' => array('skip' => TRUE), 'openid' => array('skip' => TRUE));
foreach ($communicationType as $key => $value) {
if (!empty($defaults[$key])) {
foreach ($defaults[$key] as &$val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')), FALSE);
if (empty($value['skip'])) {
$daoName = $value['daoName'];
$pseudoConst = $daoName::buildOptions($value['fieldName'], 'get');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, FALSE);
}
}
if (isset($value['customData'])) {
foreach ($defaults[$key] as $blockId => $blockVal) {
$idValue = $blockVal['id'];
if ($key == 'address') {
if (!empty($blockVal['master_id'])) {
$idValue = $blockVal['master_id'];
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), $this, $idValue);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$defaults[$key][$blockId]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
}
// reset template variable since that won't be of any use, and could be misleading
$this->assign("dnc_viewCustomData", NULL);
}
}
}
if (!empty($defaults['gender_id'])) {
$defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id']);
}
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
if (!empty($communicationStyle)) {
if (!empty($defaults['communication_style_id'])) {
$defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
} else {
// Make sure the field is displayed as long as it is active, even if it is unset for this contact.
$defaults['communication_style_display'] = '';
}
}
// to make contact type label available in the template -
$contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type'];
$defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $contactType, ', ');
// get contact tags
$contactTags = CRM_Core_BAO_EntityTag::getContactTags($this->_contactId);
if (!empty($contactTags)) {
$defaults['contactTag'] = implode(', ', $contactTags);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
//Show blocks only if they are visible in edit form
$this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options');
foreach ($this->_editOptions as $blockName => $value) {
$varName = '_show' . $blockName;
$this->{$varName} = $value;
$this->assign(substr($varName, 1), $this->{$varName});
}
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
$this->assign('sharedAddresses', $sharedAddresses);
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
if ($contact->employer_id && $contact->organization_name) {
$defaults['current_employer'] = $contact->organization_name;
$defaults['current_employer_id'] = $contact->employer_id;
}
//for birthdate format with respect to birth format set
$this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
}
$defaults['external_identifier'] = $contact->external_identifier;
$this->assign($defaults);
// FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query
// also assign the last modifed details
$lastModified = CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
//.........这里部分代码省略.........
示例9: basic
//.........这里部分代码省略.........
}
}
$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'));
}
示例10: 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();
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'));
}
示例11: postProcess
//.........这里部分代码省略.........
continue;
} else {
$data[$key] = $value;
}
}
}
}
}
}
}
// fix all the custom field checkboxes which are empty
foreach ($this->_fields as $name => $field) {
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
// if there is a custom field of type checkbox and it has not been set
// then set it to null, thanx to html protocol
if ($cfID && $customFields[$cfID][3] == 'CheckBox' && CRM_Utils_Array::value('custom', $data) && !CRM_Utils_Array::value($cfID, $data['custom'])) {
$str = 'custom_value_' . $cfID . '_id';
if ($this->_contact[$str]) {
$id = $this->_contact[$str];
}
$data['custom'][$cfID] = array('id' => $id, 'value' => '', 'extends' => $customFields[$cfID][3], 'type' => $customFields[$cfID][2], 'custom_field_id' => $cfID);
}
}
if ($this->_id) {
$objects = array('contact_id', 'individual_id', 'location_id', 'address_id');
$ids = array();
$phoneLoc = 0;
foreach ($this->_fields as $name => $field) {
$nameValue = explode('-', $name);
foreach ($this->_contact as $key => $value) {
if (in_array($key, $objects)) {
$ids[substr($key, 0, strlen($key) - 3)] = $value;
} else {
if (is_array($value)) {
//fixed for CRM-665
if ($nameValue[1] == $value['location_type_id']) {
$locations[$value['location_type_id']] = 1;
$loc_no = count($locations);
if ($nameValue[0] == 'phone') {
$phoneLoc++;
if (isset($nameValue[2])) {
$ids['location'][$loc_no]['phone'][$phoneLoc] = $value['phone'][$nameValue[2] . '_id'];
} else {
$ids['location'][$loc_no]['phone'][$phoneLoc] = $value['phone']['1_id'];
}
} else {
if ($nameValue[0] == 'im') {
$ids['location'][$loc_no]['im'][1] = $value['im']['1_id'];
} else {
if ($nameValue[0] == 'email') {
$ids['location'][$loc_no]['email'][1] = $value['email']['1_id'];
} else {
$ids['location'][$loc_no]['address'] = $value['address_id'];
}
}
}
$ids['location'][$loc_no]['id'] = $value['location_id'];
}
}
}
}
}
}
//set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
$privacy = CRM_Core_SelectValues::privacy();
foreach ($privacy as $key => $value) {
if (array_key_exists($key, $this->_fields)) {
if ($params[$key]) {
$data[$key] = $params[$key];
} else {
$data[$key] = 0;
}
}
}
// manage is_opt_out
if (array_key_exists('is_opt_out', $this->_fields)) {
$wasOptOut = $this->_contact['is_opt_out'] ? true : false;
$isOptOut = $params['is_opt_out'] ? true : false;
$data['is_opt_out'] = $isOptOut;
// on change, create new civicrm_subscription_history entry
if ($wasOptOut != $isOptOut) {
$shParams = array('contact_id' => $this->_contact['contact_id'], 'status' => $isOptOut ? 'Removed' : 'Added', 'method' => 'Web');
CRM_Contact_BAO_SubscriptionHistory::create($shParams);
}
}
if ($this->_mode == CRM_PROFILE_FORM_MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Contact/BAO/Contact.php';
$contact = CRM_Contact_BAO_Contact::create($data, $ids, count($data['location']));
// Process group and tag
if (CRM_Utils_Array::value('group', $this->_fields)) {
CRM_Contact_BAO_GroupContact::create($params['group'], $contact->id);
}
if (CRM_Utils_Array::value('tag', $this->_fields)) {
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($params['tag'], $contact->id);
}
}
示例12: formatProfileContactParams
//.........这里部分代码省略.........
$data['address'][$loc][substr($fieldName, 8)] = $value;
} else {
$data['address'][$loc][$fieldName] = $value;
}
}
} else {
if (substr($key, 0, 4) === 'url-') {
$websiteField = explode('-', $key);
$data['website'][$websiteField[1]]['website_type_id'] = $websiteField[1];
$data['website'][$websiteField[1]]['url'] = $value;
} elseif (in_array($key, self::$_greetingTypes, TRUE)) {
//save email/postal greeting and addressee values if any, CRM-4575
$data[$key . '_id'] = $value;
} elseif (!$skipCustom && ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key))) {
// for autocomplete transfer hidden value instead of label
if ($params[$key] && isset($params[$key . '_id'])) {
$value = $params[$key . '_id'];
}
// we need to append time with date
if ($params[$key] && isset($params[$key . '_time'])) {
$value .= ' ' . $params[$key . '_time'];
}
// if auth source is not checksum / login && $value is blank, do not proceed - CRM-10128
if (($session->get('authSrc') & CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN) == 0 && ($value == '' || !isset($value))) {
continue;
}
$valueId = NULL;
if (!empty($params['customRecordValues'])) {
if (is_array($params['customRecordValues']) && !empty($params['customRecordValues'])) {
foreach ($params['customRecordValues'] as $recId => $customFields) {
if (is_array($customFields) && !empty($customFields)) {
foreach ($customFields as $customFieldName) {
if ($customFieldName == $key) {
$valueId = $recId;
break;
}
}
}
}
}
}
$type = $data['contact_type'];
if (!empty($data['contact_sub_type'])) {
$type = $data['contact_sub_type'];
$type = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($type, CRM_Core_DAO::VALUE_SEPARATOR));
// generally a contact even if, has multiple subtypes the parent-type is going to be one only
// and since formatCustomField() would be interested in parent type, lets consider only one subtype
// as the results going to be same.
$type = $type[0];
}
CRM_Core_BAO_CustomField::formatCustomField($customFieldId, $data['custom'], $value, $type, $valueId, $contactID);
} elseif ($key == 'edit') {
continue;
} else {
if ($key == 'location') {
foreach ($value as $locationTypeId => $field) {
foreach ($field as $block => $val) {
if ($block == 'address' && array_key_exists('address_name', $val)) {
$value[$locationTypeId][$block]['name'] = $value[$locationTypeId][$block]['address_name'];
}
}
}
}
if ($key == 'phone' && isset($params['phone_ext'])) {
$data[$key] = $value;
foreach ($value as $cnt => $phoneBlock) {
if ($params[$key][$cnt]['location_type_id'] == $params['phone_ext'][$cnt]['location_type_id']) {
$data[$key][$cnt]['phone_ext'] = CRM_Utils_Array::retrieveValueRecursive($params['phone_ext'][$cnt], 'phone_ext');
}
}
} elseif (in_array($key, array('nick_name', 'job_title', 'middle_name', 'birth_date', 'gender_id', 'current_employer', 'prefix_id', 'suffix_id')) && ($value == '' || !isset($value)) && ($session->get('authSrc') & CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN) == 0) {
// CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value
// to avoid update with empty values
continue;
} else {
$data[$key] = $value;
}
}
}
}
if (!isset($data['contact_type'])) {
$data['contact_type'] = 'Individual';
}
//set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
$privacy = CRM_Core_SelectValues::privacy();
foreach ($privacy as $key => $value) {
if (array_key_exists($key, $fields)) {
// do not reset values for existing contacts, if fields are added to a profile
if (array_key_exists($key, $params)) {
$data[$key] = $params[$key];
if (empty($params[$key])) {
$data[$key] = 0;
}
} elseif (!$contactID) {
$data[$key] = 0;
}
}
}
return array($data, $contactDetails);
}
示例13: createProfileContact
//.........这里部分代码省略.........
}
// FIX ME: need to check if we need this code
// //make sure primary location is at first position in location array
// if ( isset( $data['location'] ) && count( $data['location'] ) > 1 ) {
// // if first location is primary skip manipulation
// if ( !isset($data['location'][1]['is_primary']) ) {
// //find the key for primary location
// foreach ( $data['location'] as $primaryLocationKey => $value ) {
// if ( isset( $value['is_primary'] ) ) {
// break;
// }
// }
//
// // swap first location with primary location
// $tempLocation = $data['location'][1];
// $data['location'][1] = $data['location'][$primaryLocationKey];
// $data['location'][$primaryLocationKey] = $tempLocation;
// }
// }
if (!isset($data['contact_type'])) {
$data['contact_type'] = 'Individual';
}
if (CRM_Core_Permission::access('Quest')) {
$studentFieldPresent = 0;
foreach ($fields as $name => $field) {
// check if student fields present
require_once 'CRM/Quest/BAO/Student.php';
if (!$studentFieldPresent && array_key_exists($name, CRM_Quest_BAO_Student::exportableFields())) {
$studentFieldPresent = 1;
}
}
}
//set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
$privacy = CRM_Core_SelectValues::privacy();
foreach ($privacy as $key => $value) {
if (array_key_exists($key, $fields)) {
if ($params[$key]) {
$data[$key] = $params[$key];
} else {
$data[$key] = 0;
}
}
}
// manage is_opt_out
if (array_key_exists('is_opt_out', $fields)) {
$wasOptOut = CRM_Utils_Array::value('is_opt_out', $contactDetails, false);
$isOptOut = CRM_Utils_Array::value('is_opt_out', $params, false);
$data['is_opt_out'] = $isOptOut;
// on change, create new civicrm_subscription_history entry
if ($wasOptOut != $isOptOut && CRM_Utils_Array::value('contact_id', $contactDetails)) {
$shParams = array('contact_id' => $contactDetails['contact_id'], 'status' => $isOptOut ? 'Removed' : 'Added', 'method' => 'Web');
CRM_Contact_BAO_SubscriptionHistory::create($shParams);
}
}
require_once 'CRM/Contact/BAO/Contact.php';
if ($data['contact_type'] != 'Student') {
$contact =& self::create($data);
}
// contact is null if the profile does not have any contact fields
if ($contact) {
$contactID = $contact->id;
}
if (!$contactID) {
CRM_Core_Error::fatal('Cannot proceed without a valid contact id');
}
// Process group and tag
示例14: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
// add checkboxes for contact type
$contact_type = array();
foreach (CRM_Core_SelectValues::contactType() as $k => $v) {
if (!empty($k)) {
$contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
}
}
$this->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
// checkboxes for groups
$group = array();
foreach ($this->_group as $groupID => $groupName) {
$this->_groupElement =& $this->addElement('checkbox', "group[{$groupID}]", null, $groupName);
}
// checkboxes for categories
foreach ($this->_tag as $tagID => $tagName) {
$this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
}
// add text box for last name, first name, street name, city
$this->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$this->addElement('text', 'street_address', ts('Street Address'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'street_address'));
$this->addElement('text', 'city', ts('City'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'city'));
// select for state province
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$this->addElement('select', 'state_province', ts('State/Province'), $stateProvince);
// select for country
$country = array('' => ts('- any country -')) + CRM_Core_PseudoConstant::country();
$this->addElement('select', 'country', ts('Country'), $country);
// add text box for postal code
$this->addElement('text', 'postal_code', ts('Postal Code'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
$this->addElement('text', 'postal_code_low', ts('Range-From'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
$this->addElement('text', 'postal_code_high', ts('To'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
$this->addElement('text', 'location_name', ts('Location Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Location', 'name'));
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$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_trade', null, $t['do_not_trade']);
$this->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// checkboxes for location type
$location_type = array();
$locationType = CRM_Core_PseudoConstant::locationType();
foreach ($locationType as $locationTypeID => $locationTypeName) {
$location_type[] = HTML_QuickForm::createElement('checkbox', $locationTypeID, null, $locationTypeName);
}
$this->addGroup($location_type, 'location_type', ts('Location Types'), ' ');
// textbox for Activity Type
$this->addElement('text', 'activity_type', ts('Activity Type'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActivityHistory', 'activity_type'));
// Date selects for activity date
$this->add('date', 'activity_date_from', ts('Activity Dates - From'), CRM_Core_SelectValues::date('relative'));
$this->addRule('activity_date_from', ts('Select a valid date.'), 'qfDate');
$this->add('date', 'activity_date_to', ts('To'), CRM_Core_SelectValues::date('relative'));
$this->addRule('activity_date_to', ts('Select a valid date.'), 'qfDate');
$this->assign('validCiviContribute', false);
if (CRM_Utils_System::accessCiviContribute()) {
$this->assign('validCiviContribute', true);
require_once 'CRM/Contribute/Form/Search.php';
CRM_Contribute_Form_Search::buildQuickFormCommon($this);
}
//Custom data Search Fields
$this->customDataSearch();
$this->buildQuickFormCommon();
}
示例15: buildCommunicationBlock
/**
* Create communication preferences block for the contact.
*
* @param object $form - CRM_Core_Form (or it's subclass)
* @return none
*
* @access public
* @static
*/
function buildCommunicationBlock(&$form)
{
// since the pcm - preferred comminication method is logically
// grouped hence we'll use groups of HTML_QuickForm
$privacy = array();
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$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_trade', null, $t['do_not_trade']);
$form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// preferred communication method
$form->add('select', 'preferred_communication_method', ts('Prefers'), CRM_Core_SelectValues::pcm());
$form->add('select', 'preferred_mail_format', ts('Mail Format'), CRM_Core_SelectValues::pmf());
}