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


PHP CRM_Core_BAO_Address::dataExists方法代码示例

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


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

示例1: add

 /**
  * takes an associative array and creates a contact object
  *
  * the function extract all the params it needs to initialize the create a
  * contact object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  * @param array  $ids            the array that holds all the db ids
  * @param array  $locationId     
  *
  * @return object CRM_Core_BAO_Address object
  * @access public
  * @static
  */
 function add(&$params, &$ids, $locationId)
 {
     if (!CRM_Core_BAO_Address::dataExists($params, $locationId, $ids)) {
         return null;
     }
     $address =& new CRM_Core_BAO_Address();
     $address->location_id = $params['location'][$locationId]['id'];
     $address->id = CRM_Utils_Array::value('address', $ids['location'][$locationId]);
     CRM_Core_BAO_Address::fixAddress($params['location'][$locationId]['address']);
     if ($address->copyValues($params['location'][$locationId]['address'])) {
         // we copied only null stuff, so we delete the object
         $address->delete();
         return null;
     }
     return $address->save();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:31,代码来源:Address.php

示例2: formRule

 /**
  * Check for correct state / country mapping.
  *
  * @param array $fields
  * @param array $files
  * @param CRM_Core_Form $self
  *
  * @return array|bool
  *   if no errors
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     $customDataRequiredFields = array();
     if ($self && property_exists($self, '_addressRequireOmission')) {
         $customDataRequiredFields = explode(',', $self->_addressRequireOmission);
     }
     if (!empty($fields['address']) && is_array($fields['address'])) {
         foreach ($fields['address'] as $instance => $addressValues) {
             if (CRM_Utils_System::isNull($addressValues)) {
                 // DETACH 'required' form rule error to
                 // custom data only if address data not exists upon submission
                 if (!empty($customDataRequiredFields)) {
                     foreach ($customDataRequiredFields as $customElementName) {
                         $elementName = "address[{$instance}][{$customElementName}]";
                         if ($self->getElementError($elementName)) {
                             // set element error to none
                             $self->setElementError($elementName, NULL);
                         }
                     }
                 }
                 continue;
             }
             // DETACH 'required' form rule error to
             // custom data only if address data not exists upon submission
             if (!empty($customDataRequiredFields) && !CRM_Core_BAO_Address::dataExists($addressValues)) {
                 foreach ($customDataRequiredFields as $customElementName) {
                     $elementName = "address[{$instance}][{$customElementName}]";
                     if ($self->getElementError($elementName)) {
                         // set element error to none
                         $self->setElementError($elementName, NULL);
                     }
                 }
             }
             if (!empty($addressValues['use_shared_address']) && empty($addressValues['master_id'])) {
                 $errors["address[{$instance}][use_shared_address]"] = ts('Please select valid shared contact or a contact with valid address.');
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:51,代码来源:Address.php

示例3: 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, $files, $self)
 {
     $errors = array();
     $customDataRequiredFields = array();
     if ($self && property_exists($self, '_addressRequireOmission')) {
         $customDataRequiredFields = explode(',', $self->_addressRequireOmission);
     }
     // check for state/county match if not report error to user.
     if (!empty($fields['address']) && is_array($fields['address'])) {
         foreach ($fields['address'] as $instance => $addressValues) {
             if (CRM_Utils_System::isNull($addressValues)) {
                 // DETACH 'required' form rule error to
                 // custom data only if address data not exists upon submission
                 if (!empty($customDataRequiredFields)) {
                     foreach ($customDataRequiredFields as $customElementName) {
                         $elementName = "address[{$instance}][{$customElementName}]";
                         if ($self->getElementError($elementName)) {
                             // set element error to none
                             $self->setElementError($elementName, NULL);
                         }
                     }
                 }
                 continue;
             }
             // DETACH 'required' form rule error to
             // custom data only if address data not exists upon submission
             if (!empty($customDataRequiredFields) && !CRM_Core_BAO_Address::dataExists($addressValues)) {
                 foreach ($customDataRequiredFields as $customElementName) {
                     $elementName = "address[{$instance}][{$customElementName}]";
                     if ($self->getElementError($elementName)) {
                         // set element error to none
                         $self->setElementError($elementName, NULL);
                     }
                 }
             }
             $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 (!empty($addressValues['use_shared_address']) && empty($addressValues['master_id'])) {
                 $errors["address[{$instance}][use_shared_address]"] = ts('Please select valid shared contact or a contact with valid address.');
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:79,代码来源:Address.php

示例4: dataExists

 /**
  * Check if there is data to create the object
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  * @param array  $locationId     
  * @param array  $ids            (reference ) the array that holds all the db ids
  *
  * @return boolean
  * @access public
  * @static
  */
 function dataExists(&$params, $locationId, &$ids)
 {
     if (CRM_Utils_Array::value('id', $ids['location'][$locationId])) {
         return true;
     }
     // return if no data present
     if (!array_key_exists('location', $params) || !array_key_exists($locationId, $params['location'])) {
         return false;
     }
     //if location name exits return true
     if (CRM_Utils_Array::value('name', $params['location'][$locationId])) {
         return true;
     }
     if (CRM_Core_BAO_Address::dataExists($params, $locationId, $ids)) {
         return true;
     }
     for ($i = 1; $i <= CRM_CONTACT_FORM_LOCATION_BLOCKS; $i++) {
         if (CRM_Core_BAO_Phone::dataExists($params, $locationId, $i, $ids) || CRM_Core_BAO_Email::dataExists($params, $locationId, $i, $ids) || CRM_Core_BAO_IM::dataExists($params, $locationId, $i, $ids)) {
             return true;
         }
     }
     return false;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:34,代码来源:Location.php


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