当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_PseudoConstant::county方法代码示例

本文整理汇总了PHP中CRM_Core_PseudoConstant::county方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::county方法的具体用法?PHP CRM_Core_PseudoConstant::county怎么用?PHP CRM_Core_PseudoConstant::county使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_PseudoConstant的用法示例。


在下文中一共展示了CRM_Core_PseudoConstant::county方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: alterDisplayAddressFields

 /**
  * Do AlterDisplay processing on Address Fields.
  *
  * @param array $row
  * @param array $rows
  * @param int $rowNum
  * @param string $baseUrl
  * @param string $linkText
  *
  * @return bool
  */
 public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText)
 {
     $criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
     $entryFound = FALSE;
     // handle country
     if (array_key_exists('civicrm_address_country_id', $row)) {
         if ($value = $row['civicrm_address_country_id']) {
             $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
             if ($baseUrl) {
                 $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, "reset=1&force=1&{$criteriaQueryParams}&" . "country_id_op=in&country_id_value={$value}", $this->_absoluteUrl, $this->_id);
                 $rows[$rowNum]['civicrm_address_country_id_link'] = $url;
                 $rows[$rowNum]['civicrm_address_country_id_hover'] = ts("%1 for this country.", array(1 => $linkText));
             }
         }
         $entryFound = TRUE;
     }
     if (array_key_exists('civicrm_address_county_id', $row)) {
         if ($value = $row['civicrm_address_county_id']) {
             $rows[$rowNum]['civicrm_address_county_id'] = CRM_Core_PseudoConstant::county($value, FALSE);
             if ($baseUrl) {
                 $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, "reset=1&force=1&{$criteriaQueryParams}&" . "county_id_op=in&county_id_value={$value}", $this->_absoluteUrl, $this->_id);
                 $rows[$rowNum]['civicrm_address_county_id_link'] = $url;
                 $rows[$rowNum]['civicrm_address_county_id_hover'] = ts("%1 for this county.", array(1 => $linkText));
             }
         }
         $entryFound = TRUE;
     }
     // handle state province
     if (array_key_exists('civicrm_address_state_province_id', $row)) {
         if ($value = $row['civicrm_address_state_province_id']) {
             $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
             if ($baseUrl) {
                 $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, "reset=1&force=1&{$criteriaQueryParams}&state_province_id_op=in&state_province_id_value={$value}", $this->_absoluteUrl, $this->_id);
                 $rows[$rowNum]['civicrm_address_state_province_id_link'] = $url;
                 $rows[$rowNum]['civicrm_address_state_province_id_hover'] = ts("%1 for this state.", array(1 => $linkText));
             }
         }
         $entryFound = TRUE;
     }
     return $entryFound;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:52,代码来源:Form.php

示例2: resolveDefaults

 /**
  * Get the values for pseudoconstants for name->value and reverse.
  *
  * @param array $defaults
  *   (reference) the default values, some of which need to be resolved.
  * @param bool $reverse
  *   True if we want to resolve the values in the reverse direction (value -> name).
  */
 public static function resolveDefaults(&$defaults, $reverse = FALSE)
 {
     // Hack for birth_date.
     if (!empty($defaults['birth_date'])) {
         if (is_array($defaults['birth_date'])) {
             $defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-');
         }
     }
     CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
     CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
     CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
     CRM_Utils_Array::lookupValue($defaults, 'communication_style', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'), $reverse);
     //lookup value of email/postal greeting, addressee, CRM-4575
     foreach (self::$_greetingTypes as $greeting) {
         $filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults), 'greeting_type' => $greeting);
         CRM_Utils_Array::lookupValue($defaults, $greeting, CRM_Core_PseudoConstant::greeting($filterCondition), $reverse);
     }
     $blocks = array('address', 'im', 'phone');
     foreach ($blocks as $name) {
         if (!array_key_exists($name, $defaults) || !is_array($defaults[$name])) {
             continue;
         }
         foreach ($defaults[$name] as $count => &$values) {
             //get location type id.
             CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), $reverse);
             if ($name == 'address') {
                 // FIXME: lookupValue doesn't work for vcard_name
                 if (!empty($values['location_type_id'])) {
                     $vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
                     $values['vcard_name'] = $vcardNames[$values['location_type_id']];
                 }
                 if (!CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::country(), $reverse) && $reverse) {
                     CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::countryIsoCode(), $reverse);
                 }
                 // CRM-7597
                 // if we find a country id above, we need to restrict it to that country
                 // rather than the list of all countries
                 if (!empty($values['country_id'])) {
                     $stateProvinceList = CRM_Core_PseudoConstant::stateProvinceForCountry($values['country_id']);
                 } else {
                     $stateProvinceList = CRM_Core_PseudoConstant::stateProvince();
                 }
                 if (!CRM_Utils_Array::lookupValue($values, 'state_province', $stateProvinceList, $reverse) && $reverse) {
                     if (!empty($values['country_id'])) {
                         $stateProvinceList = CRM_Core_PseudoConstant::stateProvinceForCountry($values['country_id'], 'abbreviation');
                     } else {
                         $stateProvinceList = CRM_Core_PseudoConstant::stateProvinceAbbreviation();
                     }
                     CRM_Utils_Array::lookupValue($values, 'state_province', $stateProvinceList, $reverse);
                 }
                 if (!empty($values['state_province_id'])) {
                     $countyList = CRM_Core_PseudoConstant::countyForState($values['state_province_id']);
                 } else {
                     $countyList = CRM_Core_PseudoConstant::county();
                 }
                 CRM_Utils_Array::lookupValue($values, 'county', $countyList, $reverse);
             }
             if ($name == 'im') {
                 CRM_Utils_Array::lookupValue($values, 'provider', CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $reverse);
             }
             if ($name == 'phone') {
                 CRM_Utils_Array::lookupValue($values, 'phone_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'), $reverse);
             }
             // Kill the reference.
             unset($values);
         }
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:76,代码来源:Contact.php

示例3: 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);
 }
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:76,代码来源:Query.php

示例4: formRule

 /**
  * check for correct state / country mapping.
  *
  * @param array reference $fields - submitted form values.
  * @param array reference $errors - if any errors found add to this array. please.
  * @return true if no errors
  *         array of errors if any present.
  *
  * @access public
  * @static
  */
 static function formRule($fields, $errors)
 {
     $errors = array();
     // check for state/county match if not report error to user.
     if (is_array($fields['address'])) {
         foreach ($fields['address'] as $instance => $addressValues) {
             if (CRM_Utils_System::isNull($addressValues)) {
                 continue;
             }
             if ($countryId = CRM_Utils_Array::value('country_id', $addressValues)) {
                 if (!array_key_exists($countryId, CRM_Core_PseudoConstant::country())) {
                     $countryId = null;
                     $errors["address[{$instance}][country_id]"] = ts('Enter a valid country name.');
                 }
             }
             if ($stateProvinceId = CRM_Utils_Array::value('state_province_id', $addressValues)) {
                 // hack to skip  - type first letter(s) - for state_province
                 // CRM-2649
                 if ($stateProvinceId != ts('- type first letter(s) -')) {
                     if (!array_key_exists($stateProvinceId, CRM_Core_PseudoConstant::stateProvince(false, false))) {
                         $stateProvinceId = null;
                         $errors["address[{$instance}][state_province_id]"] = ts('Please select a valid State/Province name.');
                     }
                 }
             }
             //do check for mismatch countries
             if ($stateProvinceId && $countryId) {
                 $stateProvinceDAO = new CRM_Core_DAO_StateProvince();
                 $stateProvinceDAO->id = $stateProvinceId;
                 $stateProvinceDAO->find(true);
                 if ($stateProvinceDAO->country_id != $countryId) {
                     // countries mismatch hence display error
                     $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
                     $countries =& CRM_Core_PseudoConstant::country();
                     $errors["address[{$instance}][state_province_id]"] = ts('State/Province %1 is not part of %2. It belongs to %3.', array(1 => $stateProvinces[$stateProvinceId], 2 => $countries[$countryId], 3 => $countries[$stateProvinceDAO->country_id]));
                 }
             }
             $countyId = CRM_Utils_Array::value('county_id', $addressValues);
             //state county validation
             if ($stateProvinceId && $countyId) {
                 $countyDAO = new CRM_Core_DAO_County();
                 $countyDAO->id = $countyId;
                 $countyDAO->find(true);
                 if ($countyDAO->state_province_id != $stateProvinceId) {
                     $counties =& CRM_Core_PseudoConstant::county();
                     $errors["address[{$instance}][county_id]"] = ts('County %1 is not part of %2. It belongs to %3.', array(1 => $counties[$countyId], 2 => $stateProvinces[$stateProvinceId], 3 => $stateProvinces[$countyDAO->state_province_id]));
                 }
             }
             if (CRM_Utils_Array::value('use_shared_address', $addressValues) && !CRM_Utils_Array::value('master_id', $addressValues)) {
                 $errors["address[{$instance}][use_shared_address]"] = ts('Please select valid shared contact or a contact with valid address.');
             }
         }
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:66,代码来源:Address.php

示例5: formRule


//.........这里部分代码省略.........
             $exceptions = array($form->_session->get('userID'));
         }
         // for dialog mode we should always use fuzzy rule.
         $ruleType = 'Unsupervised';
         if ($form->_context == 'dialog') {
             $ruleType = 'Supervised';
         }
         $dedupeParams['check_permission'] = FALSE;
         $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $ctype, $ruleType, $exceptions, $form->_ruleGroupID);
         if ($ids) {
             if ($form->_isUpdateDupe == 2) {
                 CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
             } elseif ($form->_isUpdateDupe == 1) {
                 if (!$form->_id) {
                     $form->_id = $ids[0];
                 }
             } else {
                 if ($form->_context == 'dialog') {
                     $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE);
                     $duplicateContactsLinks = '<div class="matching-contacts-found">';
                     $duplicateContactsLinks .= ts('One matching contact was found. ', array('count' => count($contactLinks['rows']), 'plural' => '%count matching contacts were found.<br />'));
                     if ($contactLinks['msg'] == 'view') {
                         $duplicateContactsLinks .= ts('You can View the existing contact.', array('count' => count($contactLinks['rows']), 'plural' => 'You can View the existing contacts.'));
                     } else {
                         $duplicateContactsLinks .= ts('You can View or Edit the existing contact.', array('count' => count($contactLinks['rows']), 'plural' => 'You can View or Edit the existing contacts.'));
                     }
                     $duplicateContactsLinks .= '</div>';
                     $duplicateContactsLinks .= '<table class="matching-contacts-actions">';
                     $row = '';
                     for ($i = 0; $i < count($contactLinks['rows']); $i++) {
                         $row .= '  <tr>   ';
                         $row .= '    <td class="matching-contacts-name"> ';
                         $row .= $contactLinks['rows'][$i]['display_name'];
                         $row .= '    </td>';
                         $row .= '    <td class="matching-contacts-email"> ';
                         $row .= $contactLinks['rows'][$i]['primary_email'];
                         $row .= '    </td>';
                         $row .= '    <td class="action-items"> ';
                         $row .= $contactLinks['rows'][$i]['view'] . ' ';
                         $row .= $contactLinks['rows'][$i]['edit'];
                         $row .= '    </td>';
                         $row .= '  </tr>   ';
                     }
                     $duplicateContactsLinks .= $row . '</table>';
                     $duplicateContactsLinks .= "If you're sure this record is not a duplicate, click the 'Save Matching Contact' button below.";
                     $errors['_qf_default'] = $duplicateContactsLinks;
                     // let smarty know that there are duplicates
                     $template = CRM_Core_Smarty::singleton();
                     $template->assign('isDuplicate', 1);
                 } else {
                     $errors['_qf_default'] = ts('A record already exists with the same information.');
                 }
             }
         }
     }
     foreach ($fields as $key => $value) {
         list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $key, 3);
         if ($fieldName == 'state_province' && !empty($fields["country-{$locTypeId}"])) {
             // Validate Country - State list
             $countryId = $fields["country-{$locTypeId}"];
             $stateProvinceId = $value;
             if ($stateProvinceId && $countryId) {
                 $stateProvinceDAO = new CRM_Core_DAO_StateProvince();
                 $stateProvinceDAO->id = $stateProvinceId;
                 $stateProvinceDAO->find(TRUE);
                 if ($stateProvinceDAO->country_id != $countryId) {
                     // country mismatch hence display error
                     $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
                     $countries = CRM_Core_PseudoConstant::country();
                     $errors[$key] = "State/Province " . $stateProvinces[$stateProvinceId] . " is not part of " . $countries[$countryId] . ". It belongs to " . $countries[$stateProvinceDAO->country_id] . ".";
                 }
             }
         }
         if ($fieldName == 'county' && $fields["state_province-{$locTypeId}"]) {
             // Validate County - State list
             $stateProvinceId = $fields["state_province-{$locTypeId}"];
             $countyId = $value;
             if ($countyId && $stateProvinceId) {
                 $countyDAO = new CRM_Core_DAO_County();
                 $countyDAO->id = $countyId;
                 $countyDAO->find(TRUE);
                 if ($countyDAO->state_province_id != $stateProvinceId) {
                     // state province mismatch hence display error
                     $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
                     $counties = CRM_Core_PseudoConstant::county();
                     $errors[$key] = "County " . $counties[$countyId] . " is not part of " . $stateProvinces[$stateProvinceId] . ". It belongs to " . $stateProvinces[$countyDAO->state_province_id] . ".";
                 }
             }
         }
     }
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
         if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
             $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
             if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) {
                 $errors[$greeting . '_custom'] = ts('Custom  %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', ' ', $greeting))));
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Form.php

示例6: fixStateSelect

 static function fixStateSelect(&$form, $countryElementName, $stateElementName, $countyElementName, $countryDefaultValue, $stateDefaultValue = NULL)
 {
     $countryID = $stateID = NULL;
     if (isset($form->_elementIndex[$countryElementName])) {
         //get the country id to load states -
         //first check for submitted value,
         //then check for user passed value.
         //finally check for element default val.
         $submittedVal = $form->getSubmitValue($countryElementName);
         if ($submittedVal) {
             $countryID = $submittedVal;
         } elseif ($countryDefaultValue) {
             $countryID = $countryDefaultValue;
         } else {
             $countryID = CRM_Utils_Array::value(0, $form->getElementValue($countryElementName));
         }
     }
     $stateTitle = ts('State/Province');
     if (isset($form->_fields[$stateElementName]['title'])) {
         $stateTitle = $form->_fields[$stateElementName]['title'];
     }
     if (isset($form->_elementIndex[$stateElementName])) {
         $submittedValState = $form->getSubmitValue($stateElementName);
         if ($submittedValState) {
             $stateID = $submittedValState;
         } elseif ($stateDefaultValue) {
             $stateID = $stateDefaultValue;
         } else {
             $stateID = CRM_Utils_Array::value(0, $form->getElementValue($stateElementName));
         }
     }
     if (isset($form->_elementIndex[$stateElementName])) {
         if ($countryID) {
             $stateProvinces = CRM_Core_PseudoConstant::stateProvinceForCountry($countryID);
         } else {
             $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
         }
         $stateSelect =& $form->addElement('select', $stateElementName, $stateTitle, array('' => ts('- select -')) + $stateProvinces);
     }
     if (isset($form->_elementIndex[$stateElementName]) && isset($form->_elementIndex[$countyElementName])) {
         if ($stateID) {
             $counties = CRM_Core_PseudoConstant::countyForState($stateID);
         } else {
             $counties = CRM_Core_PseudoConstant::county();
         }
         $form->addElement('select', $countyElementName, ts('County'), array('' => ts('- select -')) + $counties);
     }
     // CRM-7296 freeze the select for state if address is shared with household
     // CRM-9070 freeze the select for state if it is view only
     if (isset($form->_fields) && !empty($form->_fields[$stateElementName]) && (!empty($form->_fields[$stateElementName]['is_shared']) || !empty($form->_fields[$stateElementName]['is_view']))) {
         $stateSelect->freeze();
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:53,代码来源:Address.php

示例7: alterCountyID

 function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName)
 {
     $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl);
     $row[$selectedfield . '_link'] = $url;
     $row[$selectedfield . '_hover'] = ts("%1 for this county.", array(1 => $value));
     $counties = CRM_Core_PseudoConstant::county($value, FALSE);
     if (!is_array($counties)) {
         return $counties;
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:10,代码来源:Extended.php

示例8: formRule

 /**
  * global form rule
  *
  * @param array  $fields the input form values
  * @param array  $files  the uploaded files if any
  * @param object $form   the form object
  *
  * @return true if no errors, else array of errors
  * @access public
  * @static
  */
 static function formRule(&$fields, &$files, &$form)
 {
     $errors = array();
     // if no values, return
     if (empty($fields)) {
         return true;
     }
     $cid = $register = null;
     // hack we use a -1 in options to indicate that its registration
     if ($form->_id) {
         $cid = $form->_id;
         $form->_isUpdateDupe = true;
     }
     if ($form->_mode == CRM_Profile_Form::MODE_REGISTER) {
         $register = true;
     }
     // dont check for duplicates during registration validation: CRM-375
     if (!$register && !CRM_Utils_Array::value('_qf_Edit_upload_duplicate', $fields)) {
         // fix for CRM-3240
         if (CRM_Utils_Array::value('email-Primary', $fields)) {
             $fields['email'] = CRM_Utils_Array::value('email-Primary', $fields);
         }
         $session =& CRM_Core_Session::singleton();
         $ctype = CRM_Core_BAO_UFGroup::getContactType($form->_gid);
         require_once 'CRM/Dedupe/Finder.php';
         $dedupeParams = CRM_Dedupe_Finder::formatParams($fields, $ctype);
         if ($form->_mode == CRM_Profile_Form::MODE_CREATE) {
             // fix for CRM-2888
             $exceptions = array();
         } else {
             // for edit mode we need to allow our own record to be a dupe match!
             $exceptions = array($session->get('userID'));
         }
         // for dialog mode we should always use fuzzy rule.
         $ruleType = 'Strict';
         if ($form->_context == 'dialog') {
             $ruleType = 'Fuzzy';
         }
         $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $ctype, $ruleType, $exceptions);
         if ($ids) {
             if ($form->_isUpdateDupe) {
                 if (!$form->_id) {
                     $form->_id = $ids[0];
                 }
             } else {
                 if ($form->_context == 'dialog') {
                     $viewUrls = array();
                     require_once 'CRM/Contact/BAO/Contact/Utils.php';
                     list($viewUrls) = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids);
                     $viewUrl = implode(', ', $viewUrls);
                     $errors['_qf_default'] = ts('One matching contact was found.', array('count' => count($viewUrls), 'plural' => '%count matching contacts were found.'));
                     $errors['_qf_default'] .= '<br />';
                     $errors['_qf_default'] .= ts('If you need to verify if this is the same contact, click here - %1 - to VIEW the existing contact in a new tab.', array(1 => $viewUrl, 'count' => count($viewUrls), 'plural' => 'If you need to verify whether one of these is the same contact, click here - %1 - to VIEW the existing contact in a new tab.'));
                     $errors['_qf_default'] .= '<br />';
                     $errors['_qf_default'] .= ts('If you are sure this is NOT a duplicate, click the Save Matching Contact button to create a new contact record.');
                     // let smarty know that there are duplicates
                     $template =& CRM_Core_Smarty::singleton();
                     $template->assign('isDuplicate', 1);
                 } else {
                     $errors['_qf_default'] = ts('A record already exists with the same information.');
                 }
             }
         }
     }
     foreach ($fields as $key => $value) {
         list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $key, 3);
         if ($fieldName == 'state_province' && $fields["country-{$locTypeId}"]) {
             // Validate Country - State list
             $countryId = $fields["country-{$locTypeId}"];
             $stateProvinceId = $value;
             if ($stateProvinceId && $countryId) {
                 $stateProvinceDAO =& new CRM_Core_DAO_StateProvince();
                 $stateProvinceDAO->id = $stateProvinceId;
                 $stateProvinceDAO->find(true);
                 if ($stateProvinceDAO->country_id != $countryId) {
                     // country mismatch hence display error
                     $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
                     $countries =& CRM_Core_PseudoConstant::country();
                     $errors[$key] = "State/Province " . $stateProvinces[$stateProvinceId] . " is not part of " . $countries[$countryId] . ". It belongs to " . $countries[$stateProvinceDAO->country_id] . ".";
                 }
             }
         }
         if ($fieldName == 'county' && $fields["state_province-{$locTypeId}"]) {
             // Validate County - State list
             $stateProvinceId = $fields["state_province-{$locTypeId}"];
             $countyId = $value;
             if ($countyId && $stateProvinceId) {
                 $countyDAO =& new CRM_Core_DAO_County();
                 $countyDAO->id = $countyId;
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Form.php

示例9: isErrorInCoreData


//.........这里部分代码省略.........
                                 } else {
                                     self::addToErrorMsg(ts('State/Province'), $errorMessage);
                                 }
                             }
                         }
                     }
                     break;
                 case 'country':
                     if (!empty($value)) {
                         foreach ($value as $stateValue) {
                             if ($stateValue['country']) {
                                 CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
                                 CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
                                 $config = CRM_Core_Config::singleton();
                                 $limitCodes = $config->countryLimit();
                                 //If no country is selected in
                                 //localization then take all countries
                                 if (empty($limitCodes)) {
                                     $limitCodes = $countryIsoCodes;
                                 }
                                 if (self::in_value($stateValue['country'], $limitCodes) || self::in_value($stateValue['country'], CRM_Core_PseudoConstant::country())) {
                                     continue;
                                 } else {
                                     if (self::in_value($stateValue['country'], $countryIsoCodes) || self::in_value($stateValue['country'], $countryNames)) {
                                         self::addToErrorMsg(ts('Country input value is in table but not "available": "This Country is valid but is NOT in the list of Available Countries currently configured for your site. This can be viewed and modifed from Administer > Localization > Languages Currency Locations." '), $errorMessage);
                                     } else {
                                         self::addToErrorMsg(ts('Country input value not in country table: "The Country value appears to be invalid. It does not match any value in CiviCRM table of countries."'), $errorMessage);
                                     }
                                 }
                             }
                         }
                     }
                     break;
                 case 'county':
                     if (!empty($value)) {
                         foreach ($value as $county) {
                             if ($county['county']) {
                                 $countyNames = CRM_Core_PseudoConstant::county();
                                 if (!empty($county['county']) && !in_array($county['county'], $countyNames)) {
                                     self::addToErrorMsg(ts('County input value not in county table: The County value appears to be invalid. It does not match any value in CiviCRM table of counties.'), $errorMessage);
                                 }
                             }
                         }
                     }
                     break;
                 case 'geo_code_1':
                     if (!empty($value)) {
                         foreach ($value as $codeValue) {
                             if (!empty($codeValue['geo_code_1'])) {
                                 if (CRM_Utils_Rule::numeric($codeValue['geo_code_1'])) {
                                     continue;
                                 } else {
                                     self::addToErrorMsg(ts('Geo code 1'), $errorMessage);
                                 }
                             }
                         }
                     }
                     break;
                 case 'geo_code_2':
                     if (!empty($value)) {
                         foreach ($value as $codeValue) {
                             if (!empty($codeValue['geo_code_2'])) {
                                 if (CRM_Utils_Rule::numeric($codeValue['geo_code_2'])) {
                                     continue;
                                 } else {
                                     self::addToErrorMsg(ts('Geo code 2'), $errorMessage);
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:67,代码来源:Contact.php

示例10: resolveDefaults

 /**
  *
  * Get the values for pseudoconstants for name->value and reverse.
  *
  * @param array   $defaults (reference) the default values, some of which need to be resolved.
  * @param boolean $reverse  true if we want to resolve the values in the reverse direction (value -> name)
  *
  * @return none
  * @access public
  * @static
  */
 static function resolveDefaults(&$defaults, $reverse = false)
 {
     // hack for birth_date
     if (CRM_Utils_Array::value('birth_date', $defaults)) {
         if (is_array($defaults['birth_date'])) {
             $defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-');
         }
     }
     CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::individualPrefix(), $reverse);
     CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::individualSuffix(), $reverse);
     CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::gender(), $reverse);
     //lookup value of email/postal greeting, addressee, CRM-4575
     $filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults), 'greeting_type' => 'email_greeting');
     CRM_Utils_Array::lookupValue($defaults, 'email_greeting', CRM_Core_PseudoConstant::greeting($filterCondition), $reverse);
     $filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults), 'greeting_type' => 'postal_greeting');
     CRM_Utils_Array::lookupValue($defaults, 'postal_greeting', CRM_Core_PseudoConstant::greeting($filterCondition), $reverse);
     $filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults), 'greeting_type' => 'addressee');
     CRM_Utils_Array::lookupValue($defaults, 'addressee', CRM_Core_PseudoConstant::greeting($filterCondition), $reverse);
     $blocks = array('address', 'im', 'phone');
     foreach ($blocks as $name) {
         if (!array_key_exists($name, $defaults) || !is_array($defaults[$name])) {
             continue;
         }
         foreach ($defaults[$name] as $count => &$values) {
             //get location type id.
             CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::locationType(), $reverse);
             if ($name == 'address') {
                 // FIXME: lookupValue doesn't work for vcard_name
                 if (CRM_Utils_Array::value('location_type_id', $values)) {
                     $vcardNames =& CRM_Core_PseudoConstant::locationVcardName();
                     $values['vcard_name'] = $vcardNames[$values['location_type_id']];
                 }
                 if (!CRM_Utils_Array::lookupValue($values, 'state_province', CRM_Core_PseudoConstant::stateProvince(), $reverse) && $reverse) {
                     CRM_Utils_Array::lookupValue($values, 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), $reverse);
                 }
                 if (!CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::country(), $reverse) && $reverse) {
                     CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::countryIsoCode(), $reverse);
                 }
                 CRM_Utils_Array::lookupValue($values, 'county', CRM_Core_PseudoConstant::county(), $reverse);
             }
             if ($name == 'im') {
                 CRM_Utils_Array::lookupValue($values, 'provider', CRM_Core_PseudoConstant::IMProvider(), $reverse);
             }
             if ($name == 'phone') {
                 CRM_Utils_Array::lookupValue($values, 'phone_type', CRM_Core_PseudoConstant::phoneType(), $reverse);
             }
             //kill the reference.
             unset($values);
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:Contact.php

示例11: restWhere

 function restWhere(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     if (!CRM_Utils_Array::value($grouping, $this->_where)) {
         $this->_where[$grouping] = array();
     }
     $multipleFields = array('url');
     //check if the location type exits for fields
     $lType = '';
     $locType = array();
     $locType = explode('-', $name);
     if (!in_array($locType[0], $multipleFields)) {
         //add phone type if exists
         if (isset($locType[2]) && $locType[2]) {
             $locType[2] = CRM_Core_DAO::escapeString($locType[2]);
         }
     }
     $field = CRM_Utils_Array::value($name, $this->_fields);
     if (!$field) {
         $field = CRM_Utils_Array::value($locType[0], $this->_fields);
         if (!$field) {
             return;
         }
     }
     $setTables = true;
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     if (substr($name, 0, 14) === 'state_province') {
         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'];
         }
         $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
         if (is_numeric($value)) {
             $where = str_replace('.name', '.id', $where);
             $this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
             $states =& CRM_Core_PseudoConstant::stateProvince();
             $value = $states[(int) $value];
         } else {
             $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
             $this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
         }
         if (!$lType) {
             $this->_qill[$grouping][] = ts('State') . " {$op} '{$value}'";
         } else {
             $this->_qill[$grouping][] = ts('State') . " ({$lType}) {$op} '{$value}'";
         }
     } else {
         if (substr($name, 0, 7) === 'country') {
             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');
                 $countries =& CRM_Core_PseudoConstant::country();
                 $value = $countries[(int) $value];
             } else {
                 $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
                 $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}'";
             }
         } 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) {
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Query.php

示例12: restWhere

 function restWhere(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     if (!CRM_Utils_Array::value($grouping, $this->_where)) {
         $this->_where[$grouping] = array();
     }
     //check if the location type exits for fields
     $lType = '';
     $locType = array();
     $locType = explode('-', $name);
     //add phone type if exists
     if (isset($locType[2]) && $locType[2]) {
         $locType[2] = CRM_Core_DAO::escapeString($locType[2]);
     }
     $field = CRM_Utils_Array::value($name, $this->_fields);
     if (!$field) {
         $field = CRM_Utils_Array::value($locType[0], $this->_fields);
         if (!$field) {
             return;
         }
     }
     $setTables = true;
     // FIXME: the LOWER/strtolower pairs below most probably won't work
     // with non-US-ASCII characters, as even if MySQL does the proper
     // thing with LOWER-ing them (4.0 almost certainly won't, but then
     // we don't officially support 4.0 for non-US-ASCII data), PHP
     // won't do the proper thing with strtolower-ing them unless the
     // underlying operating system uses an UTF-8 locale for LC_CTYPE
     // for the user the webserver runs at (or suEXECs); we should use
     // mb_strtolower(), but then we'd require mb_strings support; we
     // could wrap this in function_exist(), though
     if (substr($name, 0, 14) === 'state_province') {
         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'];
         }
         $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
         if (is_numeric($value)) {
             $where = str_replace('.name', '.id', $where);
             $this->_where[$grouping][] = self::buildClause($where, $op, $value, 'Positive');
             $states =& CRM_Core_PseudoConstant::stateProvince();
             $value = $states[(int) $value];
         } else {
             $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
             $this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
         }
         if (!$lType) {
             $this->_qill[$grouping][] = ts('State') . " {$op} '{$value}'";
         } else {
             $this->_qill[$grouping][] = ts('State') . " ({$lType}) {$op} '{$value}'";
         }
     } else {
         if (substr($name, 0, 7) === 'country') {
             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');
                 $countries =& CRM_Core_PseudoConstant::country();
                 $value = $countries[(int) $value];
             } else {
                 $wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
                 $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}'";
             }
         } 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];
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Query.php

示例13: buildAddressBlock

 function buildAddressBlock($locationId, $title, $phone, $alternatePhone = null, $addressRequired = null, $phoneRequired = null, $altPhoneRequired = null, $locationName = null)
 {
     if (!$locationName) {
         $locationName = "location";
     }
     $config = CRM_Core_Config::singleton();
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
     $location[$locationId]['address']['street_address'] = $this->addElement('text', "{$locationName}[{$locationId}][address][street_address]", $title, $attributes['street_address']);
     if ($addressRequired) {
         $this->addRule("{$locationName}[{$locationId}][address][street_address]", ts("Please enter the Street Address for %1.", array(1 => $title)), 'required');
     }
     $location[$locationId]['address']['supplemental_address_1'] = $this->addElement('text', "{$locationName}[{$locationId}][address][supplemental_address_1]", ts('Additional Address 1'), $attributes['supplemental_address_1']);
     $location[$locationId]['address']['supplemental_address_2'] = $this->addElement('text', "{$locationName}[{$locationId}][address][supplemental_address_2]", ts('Additional Address 2'), $attributes['supplemental_address_2']);
     $location[$locationId]['address']['city'] = $this->addElement('text', "{$locationName}[{$locationId}][address][city]", ts('City'), $attributes['city']);
     if ($addressRequired) {
         $this->addRule("{$locationName}[{$locationId}][address][city]", ts("Please enter the City for %1.", array(1 => $title)), 'required');
     }
     $location[$locationId]['address']['postal_code'] = $this->addElement('text', "{$locationName}[{$locationId}][address][postal_code]", ts('Zip / Postal Code'), $attributes['postal_code']);
     if ($addressRequired) {
         $this->addRule("{$locationName}[{$locationId}][address][postal_code]", ts("Please enter the Zip/Postal Code for %1.", array(1 => $title)), 'required');
     }
     $location[$locationId]['address']['postal_code_suffix'] = $this->addElement('text', "{$locationName}[{$locationId}][address][postal_code_suffix]", ts('Add-on Code'), array('size' => 4, 'maxlength' => 12));
     $this->addRule("{$locationName}[{$locationId}][address][postal_code_suffix]", ts('Zip-Plus not valid.'), 'positiveInteger');
     if ($config->includeCounty) {
         $location[$locationId]['address']['county_id'] = $this->addElement('select', "{$locationName}[{$locationId}][address][county_id]", ts('County'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::county());
     }
     $location[$locationId]['address']['state_province_id'] = $this->addElement('select', "{$locationName}[{$locationId}][address][state_province_id]", ts('State / Province'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince());
     $location[$locationId]['address']['country_id'] = $this->addElement('select', "{$locationName}[{$locationId}][address][country_id]", ts('Country'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::country());
     if ($addressRequired) {
         $this->addRule("{$locationName}[{$locationId}][address][country_id]", ts("Please select the Country for %1.", array(1 => $title)), 'required');
     }
     if ($phone) {
         $location[$locationId]['phone'][1]['phone'] = $this->addElement('text', "{$locationName}[{$locationId}][phone][1][phone]", $phone, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
         if ($phoneRequired) {
             $this->addRule("{$locationName}[{$locationId}][phone][1][phone]", ts('Please enter a value for %1', array(1 => $phone)), 'required');
         }
         $this->addRule("{$locationName}[{$locationId}][phone][1][phone]", ts('Please enter a valid number for %1', array(1 => $phone)), 'phone');
     }
     if ($alternatePhone) {
         $location[$locationId]['phone'][2]['phone'] = $this->addElement('text', "{$locationName}[{$locationId}][phone][2][phone]", $alternatePhone, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
         if ($alternatePhoneRequired) {
             $this->addRule("{$locationName}[{$locationId}][phone][2][phone]", ts('Please enter a value for %1', array(1 => $alternatePhone)), 'required');
         }
         $this->addRule("{$locationName}[{$locationId}][phone][2][phone]", ts('Please enter a valid number for %1', array(1 => $alternatePhone)), 'phone');
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:46,代码来源:Form.php

示例14: formRule

 /**
  * check for correct state / country mapping.
  *
  * @param array reference $fields - submitted form values.
  * @param array reference $errors - if any errors found add to this array. please.
  *
  * @return true if no errors
  *         array of errors if any present.
  *
  * @access public
  * @static
  */
 static function formRule($fields)
 {
     $errors = array();
     // check for state/county match if not report error to user.
     if (CRM_Utils_Array::value('address', $fields) && is_array($fields['address'])) {
         foreach ($fields['address'] as $instance => $addressValues) {
             if (CRM_Utils_System::isNull($addressValues)) {
                 continue;
             }
             $countryId = CRM_Utils_Array::value('country_id', $addressValues);
             $stateProvinceId = CRM_Utils_Array::value('state_province_id', $addressValues);
             //do check for mismatch countries
             if ($stateProvinceId && $countryId) {
                 $stateProvinceDAO = new CRM_Core_DAO_StateProvince();
                 $stateProvinceDAO->id = $stateProvinceId;
                 $stateProvinceDAO->find(TRUE);
                 if ($stateProvinceDAO->country_id != $countryId) {
                     // countries mismatch hence display error
                     $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
                     $countries = CRM_Core_PseudoConstant::country();
                     $errors["address[{$instance}][state_province_id]"] = ts('State/Province %1 is not part of %2. It belongs to %3.', array(1 => $stateProvinces[$stateProvinceId], 2 => $countries[$countryId], 3 => $countries[$stateProvinceDAO->country_id]));
                 }
             }
             $countyId = CRM_Utils_Array::value('county_id', $addressValues);
             //state county validation
             if ($stateProvinceId && $countyId) {
                 $countyDAO = new CRM_Core_DAO_County();
                 $countyDAO->id = $countyId;
                 $countyDAO->find(TRUE);
                 if ($countyDAO->state_province_id != $stateProvinceId) {
                     $counties = CRM_Core_PseudoConstant::county();
                     $errors["address[{$instance}][county_id]"] = ts('County %1 is not part of %2. It belongs to %3.', array(1 => $counties[$countyId], 2 => $stateProvinces[$stateProvinceId], 3 => $stateProvinces[$countyDAO->state_province_id]));
                 }
             }
             if (CRM_Utils_Array::value('use_shared_address', $addressValues) && !CRM_Utils_Array::value('master_id', $addressValues)) {
                 $errors["address[{$instance}][use_shared_address]"] = ts('Please select valid shared contact or a contact with valid address.');
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:53,代码来源:Address.php

示例15: displayProfile

 /**
  * Function to build the array for display the profile fields
  *
  * @param array $params key value.
  * @param int $gid profile Id
  * @param array $groupTitle Profile Group Title.
  * @param array $values formatted array of key value
  *
  * @param array $profileFields
  *
  * @return void
  * @access public
  * @static
  */
 static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array())
 {
     if ($gid) {
         $config = CRM_Core_Config::singleton();
         $session = CRM_Core_Session::singleton();
         $contactID = $session->get('userID');
         if ($contactID) {
             if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $contactID)) {
                 $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW);
             }
         } else {
             $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::ADD);
         }
         foreach ($fields as $v) {
             if (!empty($v['groupTitle'])) {
                 $groupTitle['groupTitle'] = $v['groupTitle'];
                 break;
             }
         }
         $customVal = '';
         $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
         //start of code to set the default values
         foreach ($fields as $name => $field) {
             $skip = FALSE;
             // skip fields that should not be displayed separately
             if ($field['skipDisplay']) {
                 continue;
             }
             $index = $field['title'];
             if ($name === 'organization_name') {
                 $values[$index] = $params[$name];
             }
             if ('state_province' == substr($name, 0, 14)) {
                 if ($params[$name]) {
                     $values[$index] = CRM_Core_PseudoConstant::stateProvince($params[$name]);
                 } else {
                     $values[$index] = '';
                 }
             } elseif ('date' == substr($name, -4)) {
                 $values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::processDate($params[$name]), $config->dateformatFull);
             } elseif ('country' == substr($name, 0, 7)) {
                 if ($params[$name]) {
                     $values[$index] = CRM_Core_PseudoConstant::country($params[$name]);
                 } else {
                     $values[$index] = '';
                 }
             } elseif ('county' == substr($name, 0, 6)) {
                 if ($params[$name]) {
                     $values[$index] = CRM_Core_PseudoConstant::county($params[$name]);
                 } else {
                     $values[$index] = '';
                 }
             } elseif (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix', 'communication_style'))) {
                 $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $params[$name]);
             } elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
                 $filterCondition = array('greeting_type' => $name);
                 $greeting = CRM_Core_PseudoConstant::greeting($filterCondition);
                 $values[$index] = $greeting[$params[$name]];
             } elseif ($name === 'preferred_communication_method') {
                 $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
                 $compref = array();
                 $pref = $params[$name];
                 if (is_array($pref)) {
                     foreach ($pref as $k => $v) {
                         if ($v) {
                             $compref[] = $communicationFields[$k];
                         }
                     }
                 }
                 $values[$index] = implode(',', $compref);
             } elseif ($name == 'contact_sub_type') {
                 $values[$index] = implode(', ', $params[$name]);
             } elseif ($name == 'group') {
                 $groups = CRM_Contact_BAO_GroupContact::getGroupList();
                 $title = array();
                 foreach ($params[$name] as $gId => $dontCare) {
                     if ($dontCare) {
                         $title[] = $groups[$gId];
                     }
                 }
                 $values[$index] = implode(', ', $title);
             } elseif ($name == 'tag') {
                 $entityTags = $params[$name];
                 $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
                 $title = array();
                 if (is_array($entityTags)) {
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Event.php


注:本文中的CRM_Core_PseudoConstant::county方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。