本文整理汇总了PHP中CRM_Core_PseudoConstant::languages方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::languages方法的具体用法?PHP CRM_Core_PseudoConstant::languages怎么用?PHP CRM_Core_PseudoConstant::languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::languages方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
function setDefaultValues(&$form, &$defaults)
{
if (!empty($defaults['preferred_language'])) {
$languages = array_flip(CRM_Core_PseudoConstant::languages());
$defaults['preferred_language'] = $languages[$defaults['preferred_language']];
}
// CRM-7119: set preferred_language to default if unset
if (empty($defaults['preferred_language'])) {
$config = CRM_Core_Config::singleton();
$defaults['preferred_language'] = $config->lcMessages;
}
//set default from greeting types CRM-4575, CRM-9739
if ($form->_action & CRM_Core_Action::ADD) {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if (empty($defaults[$greeting . '_id'])) {
if ($defaultGreetingTypeId = CRM_Contact_BAO_Contact_Utils::defaultGreeting($form->_contactType, $greeting)) {
$defaults[$greeting . '_id'] = $defaultGreetingTypeId;
}
}
}
} else {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
$name = "{$greeting}_display";
$form->assign($name, CRM_Utils_Array::value($name, $defaults));
}
}
}
示例2: buildProfile
//.........这里部分代码省略.........
$subtypeList = array();
$subtypeList[$setSubtype] = $subtypes[$setSubtype];
} else {
$subtypeList = $subtypes;
}
$sel = $form->add('select', $name, $title, $subtypeList, $required);
$sel->setMultiple(TRUE);
} elseif (in_array($fieldName, CRM_Contact_BAO_Contact::$_greetingTypes)) {
//add email greeting, postal greeting, addressee, CRM-4575
$gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
$profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE);
if (empty($profileType) || in_array($profileType, array('Contact', 'Contribution', 'Participant', 'Membership'))) {
$profileType = 'Individual';
}
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
$greeting = array('contact_type' => $profileType, 'greeting_type' => $fieldName);
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($greeting), $required);
// add custom greeting element
$form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))), NULL, FALSE);
} elseif ($fieldName === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
foreach ($communicationFields as $key => $var) {
if ($key == '') {
continue;
}
$communicationOptions[] = $form->createElement('checkbox', $key, NULL, $var);
}
$form->addGroup($communicationOptions, $name, $title, '<br/>');
} elseif ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} elseif ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
} elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} elseif ($fieldName === 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, TRUE, $required, $title, NULL, $name);
} elseif ($fieldName === 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, FALSE, $required, NULL, $title, $name);
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
if ($onBehalf) {
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
$form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
} else {
$form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
}
// added because note appeared as a standard text input
} elseif ($fieldName == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
示例3: diffsInTable
private function diffsInTable($table)
{
// caches for pretty field titles and value mappings
static $titles = null;
static $values = null;
$params = array(1 => array($this->log_conn_id, 'Integer'), 2 => array($this->log_date, 'String'));
// we look for the last change in the given connection that happended less than 10 seconds later than log_date to catch multi-query changes
$changedSQL = "SELECT * FROM `{$this->loggingDB}`.`{$table}` WHERE log_conn_id = %1 AND log_date < DATE_ADD(%2, INTERVAL 10 SECOND) ORDER BY log_date DESC LIMIT 1";
$changed = $this->sqlToArray($changedSQL, $params);
// return early if nothing found
if (empty($changed)) {
return array();
}
// seed caches with civicrm_contact titles/values
if (!isset($titles['log_civicrm_contact']) or !isset($values['log_civicrm_contact'])) {
$titles['log_civicrm_contact'] = array('gender_id' => ts('Gender'), 'preferred_communication_method' => ts('Preferred Communication Method'), 'preferred_language' => ts('Preferred Language'), 'prefix_id' => ts('Prefix'), 'suffix_id' => ts('Suffix'));
$values['log_civicrm_contact'] = array('gender_id' => CRM_Core_PseudoConstant::gender(), 'preferred_communication_method' => CRM_Core_PseudoConstant::pcm(), 'preferred_language' => CRM_Core_PseudoConstant::languages(), 'prefix_id' => CRM_Core_PseudoConstant::individualPrefix(), 'suffix_id' => CRM_Core_PseudoConstant::individualSuffix());
require_once 'CRM/Contact/DAO/Contact.php';
$dao = new CRM_Contact_DAO_Contact();
foreach ($dao->fields() as $field) {
if (!isset($titles['log_civicrm_contact'][$field['name']])) {
$titles['log_civicrm_contact'][$field['name']] = $field['title'];
}
if ($field['type'] == CRM_Utils_Type::T_BOOLEAN) {
$values['log_civicrm_contact'][$field['name']] = array('0' => ts('false'), '1' => ts('true'));
}
}
}
// add custom data titles/values for the given table
if (!isset($titles[$table]) or !isset($values[$table])) {
$titles[$table] = array();
$values[$table] = array();
$params[3] = array(substr($table, 4), 'String');
$sql = "SELECT id, title FROM `{$this->loggingDB}`.log_civicrm_custom_group WHERE log_date <= %2 AND table_name = %3 ORDER BY log_date DESC LIMIT 1";
$cgDao =& CRM_Core_DAO::executeQuery($sql, $params);
$cgDao->fetch();
$params[3] = array($cgDao->id, 'Integer');
$sql = "SELECT column_name, data_type, label, name FROM `{$this->loggingDB}`.log_civicrm_custom_field WHERE log_date <= %2 AND custom_group_id = %3 ORDER BY log_date";
$cfDao =& CRM_Core_DAO::executeQuery($sql, $params);
while ($cfDao->fetch()) {
$titles[$table][$cfDao->column_name] = "{$cgDao->title}: {$cfDao->label}";
switch ($cfDao->data_type) {
case 'Boolean':
$values[$table][$cfDao->column_name] = array('0' => ts('false'), '1' => ts('true'));
break;
case 'String':
$values[$table][$cfDao->column_name] = array();
$params[3] = array("custom_{$cfDao->name}", 'String');
$sql = "SELECT id FROM `{$this->loggingDB}`.log_civicrm_option_group WHERE log_date <= %2 AND name = %3 ORDER BY log_date DESC LIMIT 1";
$ogId = CRM_Core_DAO::singleValueQuery($sql, $params);
$params[3] = array($ogId, 'Integer');
$sql = "SELECT label, value FROM `{$this->loggingDB}`.log_civicrm_option_value WHERE log_date <= %2 AND option_group_id = %3 ORDER BY log_date";
$ovDao =& CRM_Core_DAO::executeQuery($sql, $params);
while ($ovDao->fetch()) {
$values[$table][$cfDao->column_name][$ovDao->value] = $ovDao->label;
}
break;
}
}
}
// we look for the previous state (different log_conn_id) of the found id
$params[3] = array($changed['id'], 'Integer');
$originalSQL = "SELECT * FROM `{$this->loggingDB}`.`{$table}` WHERE log_conn_id != %1 AND log_date < %2 AND id = %3 ORDER BY log_date DESC LIMIT 1";
$original = $this->sqlToArray($originalSQL, $params);
$rows = array();
// populate $rows with only the differences between $changed and $original (skipping certain columns and NULL ↔ empty changes)
$skipped = array('entity_id', 'id', 'log_action', 'log_conn_id', 'log_date', 'log_user_id');
foreach (array_keys(array_diff_assoc($changed, $original)) as $diff) {
if (in_array($diff, $skipped)) {
continue;
}
if ($original[$diff] == $changed[$diff]) {
continue;
}
$rows[] = array('field' => isset($titles[$table][$diff]) ? $titles[$table][$diff] : substr($table, 4) . ".{$diff}", 'from' => isset($values[$table][$diff][$original[$diff]]) ? $values[$table][$diff][$original[$diff]] : $original[$diff], 'to' => isset($values[$table][$diff][$changed[$diff]]) ? $values[$table][$diff][$changed[$diff]] : $changed[$diff]);
}
return $rows;
}
示例4: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues(&$form, &$defaults)
{
if (!empty($defaults['preferred_language'])) {
$languages = array_flip(CRM_Core_PseudoConstant::languages());
$defaults['preferred_language'] = $languages[$defaults['preferred_language']];
}
// CRM-7119: set preferred_language to default if unset
if (!isset($defaults['preferred_language']) or empty($defaults['preferred_language'])) {
$config =& CRM_Core_Config::singleton();
$defaults['preferred_language'] = $config->lcMessages;
}
//set default from greeting types CRM-4575.
$greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
if ($form->_action & CRM_Core_Action::ADD) {
$contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
$filter = CRM_Utils_Array::key($form->_contactType, $contactTypeFilters);
require_once 'CRM/Core/OptionGroup.php';
foreach ($greetingTypes as $greetingType => $greeting) {
if (!CRM_Utils_Array::value($greeting, $defaults)) {
//get the default from email address.
$defaultGreetingTypeId = CRM_Core_OptionGroup::values($greetingType, null, null, null, " AND is_default = 1 AND ( filter = {$filter} OR filter = 0 )", 'value');
if (!empty($defaultGreetingTypeId)) {
$defaults[$greeting] = key($defaultGreetingTypeId);
}
}
}
} else {
foreach ($greetingTypes as $greetingType => $greeting) {
$name = "{$greetingType}_display";
$form->assign($name, CRM_Utils_Array::value($name, $defaults));
}
}
}
示例5: basic
//.........这里部分代码省略.........
// multiselect for categories
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE);
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
//added job title
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//added internal ID
$attributes['id']['size'] = 30;
$form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"');
//added external ID
$attributes['external_identifier']['size'] = 30;
$form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"');
$config = CRM_Core_Config::singleton();
if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
$form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
}
// add checkbox for cms users only
$form->addYesNo('uf_user', ts('CMS User?'));
// tag all search
$form->add('text', 'tag_search', ts('All Tags'));
// add search profiles
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
$componentModes = CRM_Contact_Form_Search::getModeSelect();
// unset contributions or participants if user does not have
// permission on them
if (!CRM_Core_Permission::access('CiviContribute')) {
unset($componentModes['2']);
}
if (!CRM_Core_Permission::access('CiviEvent')) {
unset($componentModes['3']);
}
if (!CRM_Core_Permission::access('CiviMember')) {
unset($componentModes['5']);
}
if (!CRM_Core_Permission::check('view all activities')) {
unset($componentModes['4']);
}
if (count($componentModes) > 1) {
$form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
}
$form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')));
// add the option to display relationships
$rTypes = CRM_Core_PseudoConstant::relationshipType();
$rSelect = array('' => ts('- Select Relationship Type-'));
foreach ($rTypes as $rid => $rValue) {
if ($rValue['label_a_b'] == $rValue['label_b_a']) {
$rSelect[$rid] = $rValue['label_a_b'];
} else {
$rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
$rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
}
}
$form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect);
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'title' => ts('- select -')));
$form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND')));
$toggleChoice = array();
$toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Exclude'), '1');
$toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Include by Privacy Option(s)'), '2');
$form->addGroup($toggleChoice, 'privacy_toggle', 'Privacy Options');
// preferred communication method
$comm = CRM_Core_PseudoConstant::pcm();
$commPreff = array();
foreach ($comm as $k => $v) {
$commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
}
$onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
$form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
//CRM-6138 Preferred Language
$langPreff = CRM_Core_PseudoConstant::languages();
$form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
}
示例6: array
//.........这里部分代码省略.........
}
}
if (!$locationTypeName) {
continue;
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "website-{$id}-{$fieldName}";
}
} elseif ($field['name'] == 'id') {
$names[] = 'contact_id';
} else {
$names[] = $field['name'];
}
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
if (CRM_Core_Permission::access('Quest')) {
$multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
}
// we need to determine of overlay profile should be shown
$showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$languages = CRM_Core_PseudoConstant::languages();
while ($result->fetch()) {
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n = CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = TRUE;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
if ($result->sort_name) {
$row['sort_name'] = $result->sort_name;
$empty = FALSE;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$typeId = substr($name, 0, -4) . "-website_type_id";
$typeName = $websiteTypes[$result->{$typeId}];
if ($typeName) {
$row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
} else {
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
}
} elseif ($name == 'preferred_language') {
$row[] = $languages[$result->{$name}];
} elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
//fix to display student checkboxes
$key = $name;
示例7: _getValues
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param array $params input parameters to find object
* @param array $values output values of the object
*
* @return CRM_Contact_BAO_Contact|null the found object or null
* @access public
* @static
*/
private static function _getValues(&$params, &$values)
{
$contact = new CRM_Contact_BAO_Contact();
$contact->copyValues($params);
if ($contact->find(true)) {
CRM_Core_DAO::storeValues($contact, $values);
$privacy = array();
foreach (self::$_commPrefs as $name) {
if (isset($contact->{$name})) {
$privacy[$name] = $contact->{$name};
}
}
if (!empty($privacy)) {
$values['privacy'] = $privacy;
}
// communication Prefferance
$preffComm = $comm = array();
$comm = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $contact->preferred_communication_method);
foreach ($comm as $value) {
$preffComm[$value] = 1;
}
$temp = array('preferred_communication_method' => $contact->preferred_communication_method);
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::lookupValues($temp, $names, false);
$values['preferred_communication_method'] = $preffComm;
$values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
CRM_Contact_DAO_Contact::addDisplayEnums($values);
// get preferred languages
if (!empty($contact->preferred_language)) {
$languages =& CRM_Core_PseudoConstant::languages();
$values['preferred_language'] = CRM_Utils_Array::value($contact->preferred_language, $languages);
}
// Calculating Year difference
if ($contact->birth_date) {
$birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
if ($birthDate < date('Ymd')) {
$age = CRM_Utils_Date::calculateAge($birthDate);
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}
list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
$values['birth_date_display'] = $contact->birth_date;
}
if ($contact->deceased_date) {
list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
$values['deceased_date_display'] = $contact->deceased_date;
}
$contact->contact_id = $contact->id;
return $contact;
}
return null;
}
示例8: titlesAndValuesForTable
function titlesAndValuesForTable($table)
{
// static caches for subsequent calls with the same $table
static $titles = array();
static $values = array();
// FIXME: split off the table → DAO mapping to a GenCode-generated class
static $daos = array('civicrm_address' => 'CRM_Core_DAO_Address', 'civicrm_contact' => 'CRM_Contact_DAO_Contact', 'civicrm_email' => 'CRM_Core_DAO_Email', 'civicrm_im' => 'CRM_Core_DAO_IM', 'civicrm_openid' => 'CRM_Core_DAO_OpenID', 'civicrm_phone' => 'CRM_Core_DAO_Phone', 'civicrm_website' => 'CRM_Core_DAO_Website', 'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution', 'civicrm_note' => 'CRM_Core_DAO_Note', 'civicrm_relationship' => 'CRM_Contact_DAO_Relationship');
if (!isset($titles[$table]) or !isset($values[$table])) {
if (in_array($table, array_keys($daos))) {
// FIXME: these should be populated with pseudo constants as they
// were at the time of logging rather than their current values
$values[$table] = array('contribution_page_id' => CRM_Contribute_PseudoConstant::contributionPage(), 'contribution_status_id' => CRM_Contribute_PseudoConstant::contributionStatus(), 'contribution_type_id' => CRM_Contribute_PseudoConstant::contributionType(), 'country_id' => CRM_Core_PseudoConstant::country(), 'gender_id' => CRM_Core_PseudoConstant::gender(), 'location_type_id' => CRM_Core_PseudoConstant::locationType(), 'payment_instrument_id' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'phone_type_id' => CRM_Core_PseudoConstant::phoneType(), 'preferred_communication_method' => CRM_Core_PseudoConstant::pcm(), 'preferred_language' => CRM_Core_PseudoConstant::languages(), 'prefix_id' => CRM_Core_PseudoConstant::individualPrefix(), 'provider_id' => CRM_Core_PseudoConstant::IMProvider(), 'state_province_id' => CRM_Core_PseudoConstant::stateProvince(), 'suffix_id' => CRM_Core_PseudoConstant::individualSuffix(), 'website_type_id' => CRM_Core_PseudoConstant::websiteType());
require_once str_replace('_', DIRECTORY_SEPARATOR, $daos[$table]) . '.php';
eval("\$dao = new {$daos[$table]};");
foreach ($dao->fields() as $field) {
$titles[$table][$field['name']] = CRM_Utils_Array::value('title', $field);
if ($field['type'] == CRM_Utils_Type::T_BOOLEAN) {
$values[$table][$field['name']] = array('0' => ts('false'), '1' => ts('true'));
}
}
} elseif (substr($table, 0, 14) == 'civicrm_value_') {
list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table);
}
}
return array($titles[$table], $values[$table]);
}
示例9: buildProfile
//.........这里部分代码省略.........
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($emailGreeting), $required);
// adding custom email greeting element alongwith email greeting
$form->add('text', 'email_greeting_custom', ts('Custom Email Greeting'), null, false);
} else {
if ($fieldName === 'postal_greeting') {
$postalGreeting = array('contact_type' => $profileType, 'greeting_type' => 'postal_greeting');
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($postalGreeting), $required);
// adding custom postal greeting element alongwith postal greeting
$form->add('text', 'postal_greeting_custom', ts('Custom Postal Greeting'), null, false);
} else {
if ($fieldName === 'addressee') {
$addressee = array('contact_type' => $profileType, 'greeting_type' => 'addressee');
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($addressee), $required);
// adding custom addressee element alongwith addressee type
$form->add('text', 'addressee_custom', ts('Custom Addressee'), null, false);
}
}
}
} else {
if ($fieldName === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
foreach ($communicationFields as $key => $var) {
if ($key == '') {
continue;
}
$communicationOptions[] =& HTML_QuickForm::createElement('checkbox', $key, null, $var);
}
$form->addGroup($communicationOptions, $name, $title, '<br/>');
} else {
if ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} else {
if ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
} else {
if ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} else {
if ($fieldName === 'group') {
require_once 'CRM/Contact/Form/Edit/TagsAndGroups.php';
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, true, $required, $title, null, $name);
} else {
if ($fieldName === 'tag') {
require_once 'CRM/Contact/Form/Edit/TagsAndGroups.php';
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, false, $required, null, $title, $name);
} else {
if (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
$form->addElement('select', $name . '-website_type_id', null, CRM_Core_PseudoConstant::websiteType());
} else {
if ($fieldName == 'note') {
//added because note appeared as a standard text input
$form->add('textarea', $name, $title, $attributes, $required);
} else {
if (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, false, $required, $search, $title);
}
示例10: basic
//.........这里部分代码省略.........
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
$contact_type = array();
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
if ($contactTypes) {
$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, false, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
}
if ($form->_searchOptions['groups']) {
// multiselect for groups
if ($form->_group) {
$form->add('select', 'group', ts('Groups'), $form->_group, false, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
}
if ($form->_searchOptions['tags']) {
// multiselect for categories
require_once 'CRM/Core/BAO/Tag.php';
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$form->add('select', 'contact_tags', ts('Tags'), $contactTags, false, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
require_once 'CRM/Core/Form/Tag.php';
require_once 'CRM/Core/BAO/Tag.php';
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', null, true);
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
//added job title
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
$config =& CRM_Core_Config::singleton();
if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
$form->add('checkbox', 'deleted_contacts', ts('Search in Trash (deleted contacts)'));
}
// add checkbox for cms users only
$form->addYesNo('uf_user', ts('CMS User?'));
// add search profiles
require_once 'CRM/Core/BAO/UFGroup.php';
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
require_once 'CRM/Contact/Form/Search.php';
$componentModes =& CRM_Contact_Form_Search::getModeSelect();
// unset contributions or participants if user does not have
// permission on them
if (!CRM_Core_Permission::access('CiviContribute')) {
unset($componentModes['2']);
}
if (!CRM_Core_Permission::access('CiviEvent')) {
unset($componentModes['3']);
}
if (!CRM_Core_Permission::check('view all activities')) {
unset($componentModes['4']);
}
if (count($componentModes) > 1) {
$form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
}
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
$form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>'));
// preferred communication method
require_once 'CRM/Core/PseudoConstant.php';
$comm = CRM_Core_PseudoConstant::pcm();
$commPreff = array();
foreach ($comm as $k => $v) {
$commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
}
$onHold[] = HTML_QuickForm::createElement('advcheckbox', 'on_hold', null, ts(''));
$form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
//CRM-6138 Preferred Language
$langPreff = CRM_Core_PseudoConstant::languages();
$form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
}