本文整理汇总了PHP中CRM_Core_PseudoConstant::worldRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::worldRegion方法的具体用法?PHP CRM_Core_PseudoConstant::worldRegion怎么用?PHP CRM_Core_PseudoConstant::worldRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::worldRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
$this->case_statuses = CRM_Case_PseudoConstant::caseStatus();
$this->case_types = CRM_Case_PseudoConstant::caseType();
$rels = CRM_Core_PseudoConstant::relationshipType();
foreach ($rels as $relid => $v) {
$this->rel_types[$relid] = $v['label_b_a'];
}
$this->_columns = array('civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'no_display' => true, 'required' => true), 'subject' => array('title' => ts('Subject'), 'required' => true), 'start_date' => array('title' => ts('Start Date')), 'end_date' => array('title' => ts('End Date')), 'status_id' => array('title' => ts('Case Status')), 'case_type_id' => array('title' => ts('Case Type'))), 'filters' => array('start_date' => array('title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Case Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Client Name'), 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('display_name' => array('title' => ts('Client Name')))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('relationship_type_id' => array('title' => ts('Case Role'))), 'filters' => array('relationship_type_id' => array('title' => ts('Case Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types))), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'))), 'grouping' => 'contact-fields', 'filters' => array('country_id' => array('title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()))), 'civicrm_worldregion' => array('dao' => 'CRM_Core_DAO_Worldregion', 'filters' => array('worldregion_id' => array('name' => 'id', 'title' => ts('WorldRegion'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion()))), 'civicrm_country' => array('dao' => 'CRM_Core_DAO_Country'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('activity_subject' => array('name' => 'subject', 'title' => ts('Activity Subject'), 'no_display' => true)), 'filters' => array('activity_date_time' => array('title' => ts('Last Action Date'), 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_case_contact' => array('dao' => 'CRM_Case_DAO_CaseContact'));
$this->_options = array('my_cases' => array('title' => ts('My Cases'), 'type' => 'checkbox'));
parent::__construct();
}
示例2: __construct
/**
*
*/
function __construct()
{
$this->case_statuses = CRM_Case_PseudoConstant::caseStatus();
$this->case_types = CRM_Case_PseudoConstant::caseType();
$rels = CRM_Core_PseudoConstant::relationshipType();
foreach ($rels as $relid => $v) {
$this->rel_types[$relid] = $v['label_b_a'];
}
$this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'));
$this->caseActivityTypes = array();
foreach (CRM_Case_PseudoConstant::caseActivityType() as $typeDetail) {
$this->caseActivityTypes[$typeDetail['id']] = $typeDetail['label'];
}
$this->_columns = array('civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'no_display' => TRUE, 'required' => TRUE), 'subject' => array('title' => ts('Subject'), 'required' => TRUE), 'start_date' => array('title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Case Status')), 'case_type_id' => array('title' => ts('Case Type')), 'is_deleted' => array('title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT)), 'filters' => array('start_date' => array('title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Case Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types), 'is_deleted' => array('title' => ts('Deleted?'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, 'default' => 0))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('client_sort_name' => array('name' => 'sort_name', 'title' => ts('Client Name'), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Client Name')))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('case_role' => array('name' => 'relationship_type_id', 'title' => ts('Case Role(s)'))), 'filters' => array('case_role' => array('name' => 'relationship_type_id', 'title' => ts('Case Role(s)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'))), 'grouping' => 'contact-fields', 'filters' => array('country_id' => array('title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()))), 'civicrm_worldregion' => array('dao' => 'CRM_Core_DAO_Worldregion', 'filters' => array('worldregion_id' => array('name' => 'id', 'title' => ts('WorldRegion'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion()))), 'civicrm_country' => array('dao' => 'CRM_Core_DAO_Country'), 'civicrm_activity_last' => array('dao' => 'CRM_Activity_DAO_Activity', 'filters' => array('last_activity_date_time' => array('name' => 'activity_date_time', 'title' => ts('Last Action Date'), 'operatorType' => CRM_Report_Form::OP_DATE)), 'alias' => 'civireport_activity_last'), 'civicrm_activity_last_completed' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('last_completed_activity_subject' => array('name' => 'subject', 'title' => ts('Subject of the last completed activity in the case')), 'last_completed_activity_type' => array('name' => 'activity_type_id', 'title' => ts('Activity type of the last completed activity')))));
$this->_options = array('my_cases' => array('title' => ts('My Cases'), 'type' => 'checkbox'));
parent::__construct();
}
示例3: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$config = CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = TRUE;
} else {
$includeContactIds = FALSE;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
if ($rowCount) {
$cacheKey = $this->buildPrevNextCache($sort);
$result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
} else {
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
}
// process the result of the query
$rows = array();
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// mask value to hide map link if there are not lat/long
$mapMask = $mask & 4095;
if ($this->_searchContext == 'smog') {
$gc = CRM_Core_SelectValues::groupContactStatus();
}
if ($this->_ufGroupID) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$names = array();
static $skipFields = array('group', 'tag');
foreach ($this->_fields as $key => $field) {
if (!empty($field['in_selector']) && !in_array($key, $skipFields)) {
if (strpos($key, '-') !== FALSE) {
list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $key, 3);
if ($id == 'Primary') {
$locationTypeName = 1;
} else {
$locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
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[] = $field['name'];
}
}
}
$names[] = "status";
} elseif (!empty($this->_returnProperties)) {
$names = self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$links = self::links($this->_context, $this->_contextMenu, $this->_key);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
$pseudoconstants = array();
// for CRM-3157 purposes
if (in_array('world_region', $names)) {
$pseudoconstants['world_region'] = array('dbName' => 'world_region_id', 'values' => CRM_Core_PseudoConstant::worldRegion());
}
$seenIDs = array();
while ($result->fetch()) {
$row = array();
$this->_query->convertToPseudoNames($result);
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} elseif ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
$key = $property;
$paramsNew = array($key => $result->{$property});
//.........这里部分代码省略.........
示例4: __construct
function __construct()
{
$this->_columns = array('civicrm_grant' => array('dao' => 'CRM_Grant_DAO_Grant', 'fields' => array('summary_statistics' => array('name' => 'id', 'title' => ts('Summary Statistics'), 'required' => TRUE), 'grant_type_id' => array('name' => 'grant_type_id', 'title' => ts('By Grant Type')), 'status_id' => array('no_display' => TRUE, 'required' => TRUE), 'amount_total' => array('no_display' => TRUE, 'required' => TRUE), 'grant_report_received' => array('no_display' => TRUE, 'required' => TRUE), 'currency' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('application_received_date' => array('name' => 'application_received_date', 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'decision_date' => array('name' => 'decision_date', 'title' => ts('Grant Decision'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'money_transfer_date' => array('name' => 'money_transfer_date', 'title' => ts('Money Transferred'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'grant_due_date' => array('name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'grant_type' => array('name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id')), 'status_id' => array('name' => 'status_id', 'title' => ts('Grant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id')), 'amount_requested' => array('name' => 'amount_requested', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY), 'amount_granted' => array('name' => 'amount_granted', 'title' => ts('Amount Granted')), 'grant_report_received' => array('name' => 'grant_report_received', 'title' => ts('Report Received'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'))))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('required' => TRUE, 'no_display' => TRUE), 'gender_id' => array('name' => 'gender_id', 'title' => ts('By Gender')), 'contact_type' => array('name' => 'contact_type', 'title' => ts('By Contact Type'))), 'filters' => array('gender_id' => array('name' => 'gender_id', 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'contact_type' => array('name' => 'contact_type', 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_ContactType::basicTypePairs())), 'grouping' => 'contact-fields'), 'civicrm_world_region' => array('dao' => 'CRM_Core_DAO_Worldregion', 'fields' => array('id' => array('no_display' => TRUE), 'name' => array('name' => 'name', 'title' => ts('By World Region'))), 'filters' => array('region_id' => array('name' => 'id', 'title' => ts('World Region'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion()))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('country_id' => array('name' => 'country_id', 'title' => ts('By Country'))), 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()))));
parent::__construct();
}
示例5: restWhere
//.........这里部分代码省略.........
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('Country') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('Country') . " ({$lType}) {$op} '{$value}'";
}
} elseif (substr($name, 0, 6) === 'county') {
if (isset($locType[1]) && is_numeric($locType[1])) {
$setTables = FALSE;
//get the location name
$locationType = CRM_Core_PseudoConstant::locationType();
list($tName, $fldName) = self::getLocationTableName($field['where'], $locType);
$this->_whereTables[$tName] = $this->_tables[$tName];
$where = "`{$tName}`.{$fldName}";
} else {
$where = $field['where'];
}
if (is_numeric($value)) {
$where = str_replace('.name', '.id', $where);
$this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
$counties = CRM_Core_PseudoConstant::county();
$value = $counties[(int) $value];
} else {
$wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('County') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('County') . " ({$lType}) {$op} '{$value}'";
}
} elseif ($name === 'world_region') {
$worldRegions = CRM_Core_PseudoConstant::worldRegion();
if (is_numeric($value)) {
$value = $worldRegions[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('World Region') . " {$op} '{$value}'";
} elseif ($name === 'individual_prefix') {
$individualPrefixs = CRM_Core_PseudoConstant::individualPrefix();
if (is_numeric($value)) {
$value = $individualPrefixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Prefix') . " {$op} '{$value}'";
} elseif ($name === 'individual_suffix') {
$individualSuffixs = CRM_Core_PseudoConstant::individualsuffix();
if (is_numeric($value)) {
$value = $individualSuffixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Suffix') . " {$op} '{$value}'";
} elseif ($name === 'gender') {
$genders = CRM_Core_PseudoConstant::gender();
if (is_numeric($value)) {
$value = $genders[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Gender') . " {$op} '{$value}'";
self::$_openedPanes['Demographics'] = TRUE;
} elseif ($name === 'birth_date') {
示例6: buildOptions
/**
* Get options for a given address field.
* @see CRM_Core_DAO::buildOptions
*
* TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow?
* TODO: In context of chainselect, what to return if e.g. a country has no states?
*
* @param string $fieldName
* @param string $context
* @see CRM_Core_DAO::buildOptionsContext
* @param array $props
* whatever is known about this dao object.
*
* @return array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array())
{
$params = array();
// Special logic for fields whose options depend on context or properties
switch ($fieldName) {
// Filter state_province list based on chosen country or site defaults
case 'state_province_id':
if (empty($props['country_id'])) {
$config = CRM_Core_Config::singleton();
if (!empty($config->provinceLimit)) {
$props['country_id'] = $config->provinceLimit;
} else {
$props['country_id'] = $config->defaultContactCountry;
}
}
if (!empty($props['country_id']) && $context !== 'validate') {
$params['condition'] = 'country_id IN (' . implode(',', (array) $props['country_id']) . ')';
}
break;
// Filter country list based on site defaults
// Filter country list based on site defaults
case 'country_id':
if ($context != 'get' && $context != 'validate') {
$config = CRM_Core_Config::singleton();
if (!empty($config->countryLimit) && is_array($config->countryLimit)) {
$params['condition'] = 'id IN (' . implode(',', $config->countryLimit) . ')';
}
}
break;
// Filter county list based on chosen state
// Filter county list based on chosen state
case 'county_id':
if (!empty($props['state_province_id'])) {
$params['condition'] = 'state_province_id IN (' . implode(',', (array) $props['state_province_id']) . ')';
}
break;
// Not a real field in this entity
// Not a real field in this entity
case 'world_region':
return CRM_Core_PseudoConstant::worldRegion();
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
示例7: buildQillForFieldValue
/**
* Build qill for field.
*
* Qill refers to the query detail visible on the UI.
*
* @param string $daoName
* @param string $fieldName
* @param mixed $fieldValue
* @param string $op
* @param array $pseudoExtraParam
* @param int $type
* Type of the field per CRM_Utils_Type
*
* @return array
*/
public static function buildQillForFieldValue($daoName, $fieldName, $fieldValue, $op, $pseudoExtraParam = array(), $type = CRM_Utils_Type::T_STRING)
{
$qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators();
// if Operator chosen is NULL/EMPTY then
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return array(CRM_Utils_Array::value($op, $qillOperators, $op), '');
}
if ($fieldName == 'activity_type_id') {
$pseudoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
} elseif ($fieldName == 'country_id') {
$pseduoOptions = CRM_Core_PseudoConstant::country();
} elseif ($fieldName == 'county_id') {
$pseduoOptions = CRM_Core_PseudoConstant::county();
} elseif ($fieldName == 'world_region') {
$pseduoOptions = CRM_Core_PseudoConstant::worldRegion();
} elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
$pseudoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
} elseif ($fieldName == 'contribution_product_id') {
$pseudoOptions = CRM_Contribute_PseudoConstant::products();
} elseif ($daoName == 'CRM_Contact_DAO_Group' && $fieldName == 'id') {
$pseudoOptions = CRM_Core_PseudoConstant::group();
} elseif ($fieldName == 'country_id') {
$pseudoOptions = CRM_Core_PseudoConstant::country();
} elseif ($daoName) {
$pseudoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseudoExtraParam);
}
//API usually have fieldValue format as array(operator => array(values)),
//so we need to separate operator out of fieldValue param
if (is_array($fieldValue) && in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($fieldValue);
$fieldValue = $fieldValue[$op];
}
if (is_array($fieldValue)) {
$qillString = array();
if (!empty($pseudoOptions)) {
foreach ((array) $fieldValue as $val) {
$qillString[] = CRM_Utils_Array::value($val, $pseudoOptions, $val);
}
$fieldValue = implode(', ', $qillString);
} else {
if ($type == CRM_Utils_Type::T_DATE) {
foreach ($fieldValue as $index => $value) {
$fieldValue[$index] = CRM_Utils_Date::customFormat($value);
}
}
$separator = ', ';
// @todo - this is a bit specific (one operator).
// However it is covered by a unit test so can be altered later with
// some confidence.
if ($op == 'BETWEEN') {
$separator = ' AND ';
}
$fieldValue = implode($separator, $fieldValue);
}
} elseif (!empty($pseudoOptions) && array_key_exists($fieldValue, $pseudoOptions)) {
$fieldValue = $pseudoOptions[$fieldValue];
} elseif ($type === CRM_Utils_Type::T_DATE) {
$fieldValue = CRM_Utils_Date::customFormat($fieldValue);
}
return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue);
}
示例8: restWhere
//.........这里部分代码省略.........
$value = $countries[(int) $value];
} else {
$intVal = CRM_Utils_Array::key($value, $countries);
$this->_where[$grouping][] = self::buildClause($where, $op, $intVal, 'Positive');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('Country') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('Country') . " ({$lType}) {$op} '{$value}'";
}
} elseif (substr($name, 0, 6) === 'county') {
if (isset($locType[1]) && is_numeric($locType[1])) {
$setTables = FALSE;
$aName = "{$locationType[$locType[1]]}-address";
$where = "`{$aName}`.county_id";
} else {
$where = "civicrm_address.county_id";
}
$counties = CRM_Core_PseudoConstant::county();
if (is_numeric($value)) {
$this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
$value = $counties[(int) $value];
} else {
$intVal = CRM_Utils_Array::key($value, $counties);
$this->_where[$grouping][] = self::buildClause($where, $op, $intVal, 'Positive');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('County') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('County') . " ({$lType}) {$op} '{$value}'";
}
} elseif ($name === 'world_region') {
$field['where'] = 'civicrm_worldregion.id';
$this->optionValueQuery($name, $op, $value, $grouping, CRM_Core_PseudoConstant::worldRegion(), $field, ts('World Region'), 'Positive', TRUE);
} elseif ($name === 'is_deceased') {
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$value}\"";
self::$_openedPanes[ts('Demographics')] = TRUE;
} elseif ($name === 'created_date' || $name === 'modified_date' || $name === 'deceased_date' || $name === 'birth_date') {
$appendDateTime = TRUE;
if ($name === 'deceased_date' || $name === 'birth_date') {
$appendDateTime = FALSE;
self::$_openedPanes[ts('Demographics')] = TRUE;
}
$this->dateQueryBuilder($values, 'contact_a', $name, $name, $field['title'], $appendDateTime);
} elseif ($name === 'contact_id') {
if (is_int($value)) {
$this->_where[$grouping][] = self::buildClause($field['where'], $op, $value);
$this->_qill[$grouping][] = "{$field['title']} {$op} {$value}";
}
} elseif ($name === 'name') {
$value = $strtolower(CRM_Core_DAO::escapeString($value));
if ($wildcard) {
$value = "%{$value}%";
$op = 'LIKE';
}
$wc = self::caseImportant($op) ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, "'{$value}'");
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$value}\"";
} elseif ($name === 'current_employer') {
$value = $strtolower(CRM_Core_DAO::escapeString($value));
if ($wildcard) {
$value = "%{$value}%";
$op = 'LIKE';
}
$wc = self::caseImportant($op) ? "LOWER(contact_a.organization_name)" : "contact_a.organization_name";
示例9: buildProfile
//.........这里部分代码省略.........
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type"));
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
$SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
$form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (!empty($field['is_multiple'])) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, CRM_Core_PseudoConstant::worldRegion(), $required, $selectAttributes);
} elseif ($fieldName == 'signature_html') {
$form->add('wysiwyg', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"');
}
} elseif ($fieldName == 'activity_details') {
$form->add('wysiwyg', $fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $name, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
} else {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('advcheckbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
static $hiddenSubtype = FALSE;
if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
// In registration mode params are submitted via POST and we don't have any clue
// about profile-id or the profile-type (which could be a subtype)
// To generalize the behavior and simplify the process,
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
if ($usedFor) {
$form->addElement('hidden', $usedFor . '[contact_sub_type]', $field['field_type']);
} else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
}
$hiddenSubtype = TRUE;
}
if ($view && $mode != CRM_Profile_Form::MODE_SEARCH || $isShared) {
$form->freeze($name);
}
//add the rules
if (in_array($fieldName, array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
}
}
}
示例10: location
static function location(&$form)
{
$form->addElement('hidden', 'hidden_location', 1);
require_once 'CRM/Core/BAO/Preferences.php';
$addressOptions = CRM_Core_BAO_Preferences::valueOptions('address_options', true, null, true);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array('street_address' => array(ts('Street Address'), $attributes['street_address'], null, null), 'city' => array(ts('City'), $attributes['city'], null, null), 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], null, null), 'county' => array(ts('County'), $attributes['county_id'], 'county', false), 'state_province' => array(ts('State / Province'), $attributes['state_province_id'], 'stateProvince', true), 'country' => array(ts('Country'), $attributes['country_id'], 'country', false), 'address_name' => array(ts('Address Name'), $attributes['address_name'], null, null));
foreach ($elements as $name => $v) {
list($title, $attributes, $select, $multiSelect) = $v;
if (!$addressOptions[$name]) {
continue;
}
if (!$attributes) {
$attributes = $attributes[$name];
}
if ($select) {
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select();
$element = $form->addElement('select', $name, $title, $selectElements);
if ($multiSelect) {
$element->setMultiple(true);
}
} else {
$form->addElement('text', $name, $title, $attributes);
}
if ($addressOptions['postal_code']) {
$form->addElement('text', 'postal_code_low', ts('Range-From'), CRM_Utils_Array::value('postal_code', $attributes));
$form->addElement('text', 'postal_code_high', ts('To'), CRM_Utils_Array::value('postal_code', $attributes));
}
// select for state province
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
}
$worldRegions = array('' => ts('- any region -')) + CRM_Core_PseudoConstant::worldRegion();
$form->addElement('select', 'world_region', ts('World Region'), $worldRegions);
// 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);
}
$form->addGroup($location_type, 'location_type', ts('Location Types'), ' ');
}
示例11: buildProfile
//.........这里部分代码省略.........
require_once "CRM/Contribute/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} else {
if ($fieldName == 'contribution_status_id') {
require_once "CRM/Contribute/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);
} else {
if ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} else {
if ($fieldName == 'participant_status_id') {
require_once "CRM/Event/PseudoConstant.php";
$cond = null;
if ($online == true) {
$cond = "visibility_id = 1";
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(null, $cond), $required);
} else {
if ($fieldName == 'participant_role_id') {
require_once "CRM/Event/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
} else {
if ($fieldName == 'scholarship_type_id') {
$form->add('select', $name, $title, array("" => "-- Select -- ") + array_flip(CRM_Core_OptionGroup::values('scholarship_type', true)));
} else {
if ($fieldName == 'applicant_status_id') {
$form->add('select', $name, $title, array("" => "-- Select -- ") + array_flip(CRM_Core_OptionGroup::values('applicant_status', true)));
} else {
if ($fieldName == 'highschool_gpa_id') {
$form->add('select', $name, $title, array("" => "-- Select -- ") + CRM_Core_OptionGroup::values('highschool_gpa'));
} else {
if ($fieldName == 'world_region') {
require_once "CRM/Core/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::worldRegion(), $required);
} else {
$processed = false;
if (CRM_Core_Permission::access('Quest', false)) {
require_once 'CRM/Quest/BAO/Student.php';
$processed = CRM_Quest_BAO_Student::buildStudentForm($form, $fieldName, $title, $contactId);
}
if (!$processed) {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('checkbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
示例12: buildProfile
//.........这里部分代码省略.........
} elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'contribution_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (CRM_Utils_Array::value('is_multiple', $field)) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'scholarship_type_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + array_flip(CRM_Core_OptionGroup::values('scholarship_type', TRUE)));
} elseif ($fieldName == 'applicant_status_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + array_flip(CRM_Core_OptionGroup::values('applicant_status', TRUE)));
} elseif ($fieldName == 'highschool_gpa_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + CRM_Core_OptionGroup::values('highschool_gpa'));
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::worldRegion(), $required);
} elseif ($fieldName == 'signature_html') {
$form->addWysiwyg($name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$campaign =& $form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="big"');
}
} elseif ($fieldName == 'activity_details') {
$form->addWysiwyg($fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $fieldName, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
} else {
$processed = FALSE;
if (CRM_Core_Permission::access('Quest', FALSE)) {
$processed = CRM_Quest_BAO_Student::buildStudentForm($form, $fieldName, $title, $contactId);
}
if (!$processed) {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('advcheckbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
}
static $hiddenSubtype = FALSE;
if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
// In registration mode params are submitted via POST and we don't have any clue
// about profile-id or the profile-type (which could be a subtype)
// To generalize the behavior and simplify the process,
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
if ($onBehalf) {
$form->addElement('hidden', 'onbehalf[contact_sub_type]', $field['field_type']);
} else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
}
$hiddenSubtype = TRUE;
}
if ($view && $mode != CRM_Profile_Form::MODE_SEARCH || $isShared) {
$form->freeze($name);
}
//add the rules
if (in_array($fieldName, array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
}
}
}
示例13: location
static function location(&$form)
{
// Build location criteria based on _submitValues if
// available; otherwise, use $form->_formValues.
$formValues = $form->_submitValues;
if (empty($formValues) && !empty($form->_formValues)) {
$formValues = $form->_formValues;
}
$form->addElement('hidden', 'hidden_location', 1);
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array('street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL), 'city' => array(ts('City'), $attributes['city'], NULL, NULL), 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], NULL, NULL), 'county' => array(ts('County'), $attributes['county_id'], 'county', TRUE), 'state_province' => array(ts('State / Province'), $attributes['state_province_id'], 'stateProvince', TRUE), 'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE), 'address_name' => array(ts('Address Name'), $attributes['address_name'], NULL, NULL), 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL, NULL), 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL, NULL), 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL, NULL));
$parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', $addressOptions, 0);
$form->assign('parseStreetAddress', $parseStreetAddress);
foreach ($elements as $name => $v) {
list($title, $attributes, $select, $multiSelect) = $v;
if (in_array($name, array('street_number', 'street_name', 'street_unit'))) {
if (!$parseStreetAddress) {
continue;
}
} elseif (!$addressOptions[$name]) {
continue;
}
if (!$attributes) {
$attributes = $attributes[$name];
}
if ($select) {
$config = CRM_Core_Config::singleton();
$countryDefault = $config->defaultContactCountry;
$stateCountryMap[] = array('state_province' => 'state_province', 'country' => 'country', 'county' => 'county');
if ($select == 'stateProvince') {
if ($countryDefault && !isset($formValues['country'])) {
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
} elseif ($formValues['country']) {
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($formValues['country']);
} else {
//if not setdefault any country
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select();
}
$element = $form->addElement('select', $name, $title, $selectElements);
} elseif ($select == 'country') {
if ($countryDefault) {
//for setdefault country
$defaultValues = array();
$defaultValues[$name] = $countryDefault;
$form->setDefaults($defaultValues);
}
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select();
$element = $form->addElement('select', $name, $title, $selectElements);
} elseif ($select == 'county') {
if (array_key_exists('state_province', $formValues) && !CRM_Utils_System::isNull($formValues['state_province'])) {
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::countyForState($formValues['state_province']);
} else {
$selectElements = array('' => ts('- select a state -'));
}
$element = $form->addElement('select', $name, $title, $selectElements);
} else {
$selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select();
$element = $form->addElement('select', $name, $title, $selectElements);
}
if ($multiSelect) {
$element->setMultiple(TRUE);
}
} else {
$form->addElement('text', $name, $title, $attributes);
}
if ($addressOptions['postal_code']) {
$form->addElement('text', 'postal_code_low', ts('Range-From'), CRM_Utils_Array::value('postal_code', $attributes));
$form->addElement('text', 'postal_code_high', ts('To'), CRM_Utils_Array::value('postal_code', $attributes));
}
}
// extend addresses with proximity search
$form->addElement('text', 'prox_distance', ts('Find contacts within'));
$form->addElement('select', 'prox_distance_unit', NULL, array('miles' => ts('Miles'), 'kilos' => ts('Kilometers')));
// is there another form rule that does decimals besides money ? ...
$form->addRule('prox_distance', ts('Please enter positive number as a distance'), 'numeric');
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
$worldRegions = array('' => ts('- any region -')) + CRM_Core_PseudoConstant::worldRegion();
$form->addElement('select', 'world_region', ts('World Region'), $worldRegions);
// checkboxes for location type
$location_type = array();
$locationType = CRM_Core_PseudoConstant::locationType();
foreach ($locationType as $locationTypeID => $locationTypeName) {
$location_type[] = $form->createElement('checkbox', $locationTypeID, NULL, $locationTypeName);
}
$form->addGroup($location_type, 'location_type', ts('Location Types'), ' ');
// custom data extending addresses -
$extends = array('Address');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('addressGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$elementName = 'custom_' . $field['id'];
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $field['id'], FALSE, FALSE, TRUE);
}
}
}
}
示例14: restWhere
//.........这里部分代码省略.........
if (!$lType) {
$this->_qill[$grouping][] = ts('Country') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('Country') . " ({$lType}) {$op} '{$value}'";
}
} else {
if (substr($name, 0, 6) === 'county') {
if (isset($locType[1]) && is_numeric($locType[1])) {
$setTables = false;
//get the location name
$locationType =& CRM_Core_PseudoConstant::locationType();
list($tName, $fldName) = self::getLocationTableName($field['where'], $locType);
$this->_whereTables[$tName] = $this->_tables[$tName];
$where = "`{$tName}`.{$fldName}";
} else {
$where = $field['where'];
}
if (is_numeric($value)) {
$where = str_replace('.name', '.id', $where);
$this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
$counties =& CRM_Core_PseudoConstant::county();
$value = $counties[(int) $value];
} else {
$wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('County') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('County') . " ({$lType}) {$op} '{$value}'";
}
} else {
if ($name === 'world_region') {
$worldRegions =& CRM_Core_PseudoConstant::worldRegion();
if (is_numeric($value)) {
$value = $worldRegions[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('World Region') . " {$op} '{$value}'";
} else {
if ($name === 'individual_prefix') {
$individualPrefixs =& CRM_Core_PseudoConstant::individualPrefix();
if (is_numeric($value)) {
$value = $individualPrefixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Prefix') . " {$op} '{$value}'";
} else {
if ($name === 'individual_suffix') {
$individualSuffixs =& CRM_Core_PseudoConstant::individualsuffix();
if (is_numeric($value)) {
$value = $individualSuffixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Suffix') . " {$op} '{$value}'";
} else {
if ($name === 'gender') {
$genders =& CRM_Core_PseudoConstant::gender();
if (is_numeric($value)) {
$value = $genders[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
示例15: restWhere
//.........这里部分代码省略.........
$value = $countries[(int) $value];
} else {
$intVal = CRM_Utils_Array::key($value, $countries);
$this->_where[$grouping][] = self::buildClause($where, $op, $intVal, 'Positive');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('Country') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('Country') . " ({$lType}) {$op} '{$value}'";
}
} elseif (substr($name, 0, 6) === 'county') {
if (isset($locType[1]) && is_numeric($locType[1])) {
$setTables = FALSE;
$aName = "{$locationType[$locType[1]]}-address";
$where = "`{$aName}`.county_id";
} else {
$where = "civicrm_address.county_id";
}
$counties = CRM_Core_PseudoConstant::county();
if (is_numeric($value)) {
$this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
$value = $counties[(int) $value];
} else {
$intVal = CRM_Utils_Array::key($value, $counties);
$this->_where[$grouping][] = self::buildClause($where, $op, $intVal, 'Positive');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('County') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('County') . " ({$lType}) {$op} '{$value}'";
}
} elseif ($name === 'world_region') {
$field['where'] = 'civicrm_worldregion.id';
$this->optionValueQuery($name, $op, $value, $grouping, CRM_Core_PseudoConstant::worldRegion(), $field, ts('World Region'));
} elseif ($name === 'birth_date') {
$date = CRM_Utils_Date::processDate($value);
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $date);
if ($date) {
$date = CRM_Utils_Date::customFormat($date);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$date}\"";
} else {
$this->_qill[$grouping][] = "{$field['title']} {$op}";
}
self::$_openedPanes[ts('Demographics')] = TRUE;
} elseif ($name === 'deceased_date') {
$date = CRM_Utils_Date::processDate($value);
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $date);
if ($date) {
$date = CRM_Utils_Date::customFormat($date);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$date}\"";
} else {
$this->_qill[$grouping][] = "{$field['title']} {$op}";
}
self::$_openedPanes[ts('Demographics')] = TRUE;
} elseif ($name === 'is_deceased') {
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$value}\"";
self::$_openedPanes[ts('Demographics')] = TRUE;
} elseif ($name === 'contact_id') {
if (is_int($value)) {
$this->_where[$grouping][] = self::buildClause($field['where'], $op, $value);
$this->_qill[$grouping][] = "{$field['title']} {$op} {$value}";
}
} elseif ($name === 'name') {
$value = $strtolower(CRM_Core_DAO::escapeString($value));
if ($wildcard) {