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


PHP CRM_Core_BAO_CustomField::getKeyID方法代码示例

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


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

示例1: buildWhereClause

 /**
  * @inheritDoc
  */
 protected function buildWhereClause()
 {
     foreach ($this->where as $key => $value) {
         $table_name = NULL;
         $column_name = NULL;
         $field = $this->getField($key);
         if (in_array($key, $this->entityFieldNames)) {
             $table_name = self::MAIN_TABLE_ALIAS;
             $column_name = $key;
         } elseif (($cf_id = \CRM_Core_BAO_CustomField::getKeyID($key)) != FALSE) {
             //list($table_name, $column_name) = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], 'INNER');
         } elseif (strpos($key, '.')) {
             $fkInfo = $this->addFkField($key, 'INNER');
             if ($fkInfo) {
                 list($table_name, $column_name) = $fkInfo;
                 $this->validateNestedInput($key, $value);
             }
         }
         if (!$table_name || !$column_name || is_null($value)) {
             throw new \API_Exception("Invalid field '{$key}' in where clause.");
         }
         if (!is_array($value)) {
             $this->query->where(array("`{$table_name}`.`{$column_name}` = @value"), array("@value" => $value));
         } elseif (count($value) !== 1) {
             throw new \API_Exception("Invalid value in where clause for field '{$key}'");
         } else {
             $clause = \CRM_Core_DAO::createSQLFilter("`{$table_name}`.`{$column_name}`", $value);
             if ($clause === NULL) {
                 throw new \API_Exception("Invalid value in where clause for field '{$key}'");
             }
             $this->query->where($clause);
         }
     }
 }
开发者ID:civicrm,项目名称:api4,代码行数:37,代码来源:Api4SelectQuery.php

示例2: setDefaultValues

 /**
  * Set the default form values
  *
  * @access protected
  *
  * @return array the default array reference
  */
 function setDefaultValues()
 {
     $defaults = array();
     $stateCountryMap = array();
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
             CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
         }
         //CRM-5403
         if (substr($name, 0, 14) === 'state_province' || substr($name, 0, 7) === 'country' || substr($name, 0, 6) === 'county') {
             list($fieldName, $index) = CRM_Utils_System::explode('-', $name, 2);
             if (!array_key_exists($index, $stateCountryMap)) {
                 $stateCountryMap[$index] = array();
             }
             $stateCountryMap[$index][$fieldName] = $name;
         }
     }
     // also take care of state country widget
     if (!empty($stateCountryMap)) {
         CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap, $defaults);
     }
     //set default for country.
     CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
     // now fix all state country selectors
     CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     return $defaults;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:34,代码来源:AbstractPreview.php

示例3: setDefaultValues

 /**
  * Set the default form values.
  *
  *
  * @return array
  *   the default array reference
  */
 public function setDefaultValues()
 {
     $defaults = array();
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
             CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
         }
     }
     //set default for country.
     CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
     return $defaults;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:19,代码来源:AbstractPreview.php

示例4: setDefaultValues

 function setDefaultValues()
 {
     $defaults = array();
     $profileFields = CRM_Core_BAO_UFGroup::getFields($this->_profileID);
     $contactID = $this->_contactID;
     $entityCaseID = NULL;
     $cases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($contactID, FALSE, 'Application');
     $entityCaseID = end($cases);
     if ($contactID) {
         $options = array();
         $fields = array();
         foreach ($profileFields as $name => $field) {
             if (substr($name, 0, 7) == 'custom_') {
                 $id = substr($name, 7);
                 if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                     if ($entityCaseID) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, $entityCaseID, CRM_Profile_Form::MODE_REGISTER);
                     }
                     if (!isset($defaults[$name])) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, $contactID, CRM_Profile_Form::MODE_REGISTER);
                     }
                     $htmlType = $field['html_type'];
                     if ($htmlType == 'File') {
                         $this->assign('customname', $name);
                         $entityId = $entityCaseID;
                         $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                         if ($url) {
                             $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                             $deleteExtra = ts("Are you sure you want to delete attached file?");
                             $fileId = $url['file_id'];
                             $session = CRM_Core_Session::singleton();
                             $session->pushUserContext(CRM_Utils_System::url('civicrm/vacancy/apply', "reset=1&id={$this->_id}&cid={$contactID}"));
                             $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                             $text = ts("Delete Attached File");
                             $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                             $this->assign('customFiles', $customFiles);
                         }
                     }
                 }
             } else {
                 $fields[$name] = 1;
             }
         }
         CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $defaults);
     }
     return $defaults;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:47,代码来源:Application.php

示例5: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $ufGroupId = $this->get('ufGroupId');
     if (!$ufGroupId) {
         CRM_Core_Error::fatal('ufGroupId is missing');
     }
     $this->_title = ts('Update multiple contacts') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
     CRM_Utils_System::setTitle($this->_title);
     $this->addDefaultButtons(ts('Save'));
     $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
     // remove file type field and then limit fields
     $suppressFields = FALSE;
     $removehtmlTypes = array('File', 'Autocomplete-Select');
     foreach ($this->_fields as $name => $field) {
         if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
             $suppressFields = TRUE;
             unset($this->_fields[$name]);
         }
     }
     //FIX ME: phone ext field is added at the end and it gets removed because of below code
     //$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Contact(s)'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_contactIds);
     // if below fields are missing we should not reset sort name / display name
     // CRM-6794
     $preserveDefaultsArray = array('first_name', 'last_name', 'middle_name', 'organization_name', 'prefix_id', 'suffix_id', 'household_name');
     foreach ($this->_contactIds as $contactId) {
         $profileFields = $this->_fields;
         CRM_Core_BAO_Address::checkContactSharedAddressFields($profileFields, $contactId);
         foreach ($profileFields as $name => $field) {
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
             if (in_array($field['name'], $preserveDefaultsArray)) {
                 $this->_preserveDefault = FALSE;
             }
         }
     }
     $this->assign('fields', $this->_fields);
     // don't set the status message when form is submitted.
     $buttonName = $this->controller->getButtonName('submit');
     if ($suppressFields && $buttonName != '_qf_BatchUpdateProfile_next') {
         CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple contacts."), ts('Some Fields Excluded'), 'info');
     }
     $this->addDefaultButtons(ts('Update Contacts'));
     $this->addFormRule(array('CRM_Contact_Form_Task_Batch', 'formRule'));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:49,代码来源:Batch.php

示例6: setDefaultValues

 function setDefaultValues()
 {
     if (!$this->_donorID) {
         return;
     }
     foreach ($this->_fields as $name => $dontcare) {
         $fields[$name] = 1;
     }
     require_once "CRM/Core/BAO/UFGroup.php";
     CRM_Core_BAO_UFGroup::setProfileDefaults($this->_donorID, $fields, $this->_defaults);
     //set custom field defaults
     require_once "CRM/Core/BAO/CustomField.php";
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             if (!isset($this->_defaults[$name])) {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
             }
         }
     }
     return $this->_defaults;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:21,代码来源:ItemAccount.php

示例7: setDefaultValues


//.........这里部分代码省略.........
         $paymentAmount = 0;
         $duePayment = FALSE;
         foreach ($pledgePayments as $payId => $value) {
             if ($value['status'] == 'Overdue') {
                 $this->_defaults['pledge_amount'][$payId] = 1;
                 $paymentAmount += $value['scheduled_amount'];
             } elseif (!$duePayment && $value['status'] == 'Pending') {
                 $this->_defaults['pledge_amount'][$payId] = 1;
                 $paymentAmount += $value['scheduled_amount'];
                 $duePayment = TRUE;
             } elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
                 $completedContributionIds[] = $value['contribution_id'];
             }
         }
         $this->_defaults['price_' . $this->_priceSetId] = $paymentAmount;
         if (count($completedContributionIds)) {
             $softCredit = array();
             foreach ($completedContributionIds as $id) {
                 $softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
             }
             if (isset($softCredit['soft_credit'])) {
                 $this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
                 //since honoree profile fieldname of fields are prefixed with 'honor'
                 //we need to reformat the fieldname to append prefix during setting default values
                 CRM_Core_BAO_UFGroup::setProfileDefaults($softCredit['soft_credit'][1]['contact_id'], CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId), $defaults);
                 foreach ($defaults as $fieldName => $value) {
                     $this->_defaults['honor[' . $fieldName . ']'] = $value;
                 }
             }
         }
     } elseif (!empty($this->_values['pledge_block_id'])) {
         //set default to one time contribution.
         $this->_defaults['is_pledge'] = 0;
     }
     // to process Custom data that are appended to URL
     $getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
     $this->_defaults = array_merge($this->_defaults, $getDefaults);
     $config = CRM_Core_Config::singleton();
     // set default country from config if no country set
     if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
         $this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
     }
     // set default state/province from config if no state/province set
     if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
         $this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
     }
     $entityId = $memtypeID = NULL;
     if ($this->_priceSetId) {
         if ($this->_useForMember && !empty($this->_currentMemberships) || $this->_defaultMemTypeId) {
             $selectedCurrentMemTypes = array();
             foreach ($this->_priceSet['fields'] as $key => $val) {
                 foreach ($val['options'] as $keys => $values) {
                     $opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values);
                     $priceFieldName = 'price_' . $values['price_field_id'];
                     $priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName);
                     if (!empty($priceFieldValue)) {
                         CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $priceFieldValue, $val['html_type'], $this->_defaults);
                         // break here to prevent overwriting of default due to 'is_default'
                         // option configuration or setting of current membership or
                         // membership for related organization.
                         // The value sent via URL get's higher priority.
                         break;
                     } elseif ($opMemTypeId && in_array($opMemTypeId, $this->_currentMemberships) && !in_array($opMemTypeId, $selectedCurrentMemTypes)) {
                         CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults);
                         $memtypeID = $selectedCurrentMemTypes[] = $values['membership_type_id'];
                     } elseif (!empty($values['is_default']) && !$opMemTypeId && (!isset($this->_defaults[$priceFieldName]) || $val['html_type'] == 'CheckBox' && !isset($this->_defaults[$priceFieldName][$keys]))) {
                         CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults);
                         $memtypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_defaults[$priceFieldName], 'membership_type_id');
                     }
                 }
             }
             $entityId = CRM_Utils_Array::value('id', CRM_Member_BAO_Membership::getContactMembership($contactID, $memtypeID, NULL));
         } else {
             CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $this->_defaults);
         }
     }
     //set custom field defaults set by admin if value is not set
     if (!empty($this->_fields)) {
         //load default campaign from page.
         if (array_key_exists('contribution_campaign_id', $this->_fields)) {
             $this->_defaults['contribution_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
         }
         //set custom field defaults
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 if (!isset($this->_defaults[$name])) {
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $entityId, CRM_Profile_Form::MODE_REGISTER);
                 }
             }
         }
     }
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $pid => $value) {
             if (!empty($value['is_default'])) {
                 $this->_defaults['payment_processor_id'] = $pid;
             }
         }
     }
     return $this->_defaults;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例8: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $ufGroupId = $this->get('ufGroupId');
     if (!$ufGroupId) {
         CRM_Core_Error::fatal('ufGroupId is missing');
     }
     $this->_title = ts('Batch Update for Events') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
     CRM_Utils_System::setTitle($this->_title);
     $this->addDefaultButtons(ts('Save'));
     $this->_fields = array();
     $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
     // remove file type field and then limit fields
     $suppressFields = FALSE;
     $removehtmlTypes = array('File', 'Autocomplete-Select');
     foreach ($this->_fields as $name => $field) {
         if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
             $suppressFields = TRUE;
             unset($this->_fields[$name]);
         }
         //fix to reduce size as we are using this field in grid
         if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
             //shrink class to "form-text-medium"
             $this->_fields[$name]['attributes']['size'] = 19;
         }
     }
     $this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Participant(s)'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_participantIds);
     $fileFieldExists = FALSE;
     //load all campaigns.
     if (array_key_exists('participant_campaign_id', $this->_fields)) {
         $this->_componentCampaigns = array();
         CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Event_DAO_Participant', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_participantIds)) . ' ) ');
     }
     //fix for CRM-2752
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     // build custom data getFields array
     $customFieldsRole = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_roleCustomDataTypeID);
     $customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_eventNameCustomDataTypeID);
     $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE));
     $this->_customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
     foreach ($this->_participantIds as $participantId) {
         $roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'role_id');
         $eventId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'event_id');
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $customValue = CRM_Utils_Array::value($customFieldID, $this->_customFields);
                 $entityColumnValue = array();
                 if (CRM_Utils_Array::value('extends_entity_column_value', $customValue)) {
                     $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']);
                 }
                 $entityColumnValueRole = CRM_Utils_Array::value($roleId, $entityColumnValue);
                 if ($this->_roleCustomDataTypeID == $customValue['extends_entity_column_id'] && $entityColumnValueRole) {
                     CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
                 } elseif ($this->_eventNameCustomDataTypeID == $customValue['extends_entity_column_id'] && $eventId == $entityColumnValueRole) {
                     CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
                 } elseif (CRM_Utils_System::isNull($entityColumnValueRole)) {
                     CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
                 }
             } else {
                 if ($field['name'] == 'participant_role_id') {
                     $field['is_multiple'] = TRUE;
                 }
                 // handle non custom fields
                 CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
             }
         }
     }
     $this->assign('fields', $this->_fields);
     // don't set the status message when form is submitted.
     $buttonName = $this->controller->getButtonName('submit');
     if ($suppressFields && $buttonName != '_qf_Batch_next') {
         CRM_Core_Session::setStatus("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update and have been excluded.");
     }
     $this->addDefaultButtons(ts('Update Participant(s)'));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:86,代码来源:Batch.php

示例9: import

 /**
  * Handle the values in import mode.
  *
  * @param int $onDuplicate
  *   The code for what action to take on duplicates.
  * @param array $values
  *   The array of values belonging to this line.
  *
  * @return bool
  *   the result of this processing
  */
 public function import($onDuplicate, &$values)
 {
     // first make sure this is a valid line
     $response = $this->summary($values);
     if ($response != CRM_Import_Parser::VALID) {
         return $response;
     }
     $params =& $this->getActiveFieldParams();
     $formatted = array('version' => 3);
     // don't add to recent items, CRM-4399
     $formatted['skipRecentView'] = TRUE;
     //for date-Formats
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get('dateTypes');
     $customDataType = !empty($params['contact_type']) ? $params['contact_type'] : 'Contribution';
     $customFields = CRM_Core_BAO_CustomField::getFields($customDataType);
     //CRM-10994
     if (isset($params['total_amount']) && $params['total_amount'] == 0) {
         $params['total_amount'] = '0.00';
     }
     foreach ($params as $key => $val) {
         if ($val) {
             switch ($key) {
                 case 'receive_date':
                 case 'cancel_date':
                 case 'receipt_date':
                 case 'thankyou_date':
                     $params[$key] = CRM_Utils_Date::formatDate($params[$key], $dateType);
                     break;
                 case 'pledge_payment':
                     $params[$key] = CRM_Utils_String::strtobool($val);
                     break;
             }
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
                 if ($customFields[$customFieldID]['data_type'] == 'Date') {
                     CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
                     unset($params[$key]);
                 } elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
                     $params[$key] = CRM_Utils_String::strtoboolstr($val);
                 }
             }
         }
     }
     //date-Format part ends
     static $indieFields = NULL;
     if ($indieFields == NULL) {
         $tempIndieFields = CRM_Contribute_DAO_Contribution::import();
         $indieFields = $tempIndieFields;
     }
     $paramValues = array();
     foreach ($params as $key => $field) {
         if ($field == NULL || $field === '') {
             continue;
         }
         $paramValues[$key] = $field;
     }
     //import contribution record according to select contact type
     if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP && (!empty($paramValues['contribution_contact_id']) || !empty($paramValues['external_identifier']))) {
         $paramValues['contact_type'] = $this->_contactType;
     } elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && (!empty($paramValues['contribution_id']) || !empty($values['trxn_id']) || !empty($paramValues['invoice_id']))) {
         $paramValues['contact_type'] = $this->_contactType;
     } elseif (!empty($params['soft_credit'])) {
         $paramValues['contact_type'] = $this->_contactType;
     } elseif (!empty($paramValues['pledge_payment'])) {
         $paramValues['contact_type'] = $this->_contactType;
     }
     //need to pass $onDuplicate to check import mode.
     if (!empty($paramValues['pledge_payment'])) {
         $paramValues['onDuplicate'] = $onDuplicate;
     }
     require_once 'CRM/Utils/DeprecatedUtils.php';
     $formatError = _civicrm_api3_deprecated_formatted_param($paramValues, $formatted, TRUE, $onDuplicate);
     if ($formatError) {
         array_unshift($values, $formatError['error_message']);
         if (CRM_Utils_Array::value('error_data', $formatError) == 'soft_credit') {
             return CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR;
         } elseif (CRM_Utils_Array::value('error_data', $formatError) == 'pledge_payment') {
             return CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR;
         }
         return CRM_Import_Parser::ERROR;
     }
     if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
         $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, NULL, 'Contribution');
     } else {
         //fix for CRM-2219 - Update Contribution
         // onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
         if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) {
             $dupeIds = array('id' => CRM_Utils_Array::value('contribution_id', $paramValues), 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paramValues), 'invoice_id' => CRM_Utils_Array::value('invoice_id', $paramValues));
             $ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds);
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例10: run


//.........这里部分代码省略.........
         }
         /* trim whitespace around the values */
         $empty = TRUE;
         foreach ($values as $k => $v) {
             $values[$k] = trim($v, " \t\r\n");
         }
         if (CRM_Utils_System::isNull($values)) {
             continue;
         }
         $this->_totalCount++;
         if ($mode == self::MODE_MAPFIELD) {
             $returnCode = $this->mapField($values);
         } elseif ($mode == self::MODE_PREVIEW) {
             $returnCode = $this->preview($values);
         } elseif ($mode == self::MODE_SUMMARY) {
             $returnCode = $this->summary($values);
         } elseif ($mode == self::MODE_IMPORT) {
             $returnCode = $this->import($onDuplicate, $values);
         } else {
             $returnCode = self::ERROR;
         }
         // note that a line could be valid but still produce a warning
         if ($returnCode & self::VALID) {
             $this->_validCount++;
             if ($mode == self::MODE_MAPFIELD) {
                 $this->_rows[] = $values;
                 $this->_activeFieldCount = max($this->_activeFieldCount, count($values));
             }
         }
         if ($returnCode & self::WARNING) {
             $this->_warningCount++;
             if ($this->_warningCount < $this->_maxWarningCount) {
                 $this->_warningCount[] = $line;
             }
         }
         if ($returnCode & self::ERROR) {
             $this->_invalidRowCount++;
             if ($this->_invalidRowCount < $this->_maxErrorCount) {
                 $recordNumber = $this->_lineCount;
                 array_unshift($values, $recordNumber);
                 $this->_errors[] = $values;
             }
         }
         if ($returnCode & self::CONFLICT) {
             $this->_conflictCount++;
             $recordNumber = $this->_lineCount;
             array_unshift($values, $recordNumber);
             $this->_conflicts[] = $values;
         }
         if ($returnCode & self::DUPLICATE) {
             if ($returnCode & self::MULTIPLE_DUPE) {
                 /* TODO: multi-dupes should be counted apart from singles
                  * on non-skip action */
             }
             $this->_duplicateCount++;
             $recordNumber = $this->_lineCount;
             array_unshift($values, $recordNumber);
             $this->_duplicates[] = $values;
             if ($onDuplicate != self::DUPLICATE_SKIP) {
                 $this->_validCount++;
             }
         }
         // we give the derived class a way of aborting the process
         // note that the return code could be multiple code or'ed together
         if ($returnCode & self::STOP) {
             break;
         }
         // if we are done processing the maxNumber of lines, break
         if ($this->_maxLinesToProcess > 0 && $this->_validCount >= $this->_maxLinesToProcess) {
             break;
         }
     }
     fclose($fd);
     if ($mode == self::MODE_PREVIEW || $mode == self::MODE_IMPORT) {
         $customHeaders = $mapper;
         $customfields = CRM_Core_BAO_CustomField::getFields('Membership');
         foreach ($customHeaders as $key => $value) {
             if ($id = CRM_Core_BAO_CustomField::getKeyID($value)) {
                 $customHeaders[$key] = $customfields[$id][0];
             }
         }
         if ($this->_invalidRowCount) {
             // removed view url for invlaid contacts
             $headers = array_merge(array(ts('Line Number'), ts('Reason')), $customHeaders);
             $this->_errorFileName = self::errorFileName(self::ERROR);
             self::exportCSV($this->_errorFileName, $headers, $this->_errors);
         }
         if ($this->_conflictCount) {
             $headers = array_merge(array(ts('Line Number'), ts('Reason')), $customHeaders);
             $this->_conflictFileName = self::errorFileName(self::CONFLICT);
             self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
         }
         if ($this->_duplicateCount) {
             $headers = array_merge(array(ts('Line Number'), ts('View Membership URL')), $customHeaders);
             $this->_duplicateFileName = self::errorFileName(self::DUPLICATE);
             self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
         }
     }
     return $this->fini();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:Parser.php

示例11: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $ufGroupId = $this->get('ufGroupId');
     if (!$ufGroupId) {
         CRM_Core_Error::fatal('ufGroupId is missing');
     }
     $this->_title = ts('Batch Update for Activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
     CRM_Utils_System::setTitle($this->_title);
     $this->addDefaultButtons(ts('Save'));
     $this->_fields = array();
     $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
     // remove file type field and then limit fields
     $suppressFields = FALSE;
     $removehtmlTypes = array('File', 'Autocomplete-Select');
     foreach ($this->_fields as $name => $field) {
         if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
             $suppressFields = TRUE;
             unset($this->_fields[$name]);
         }
         //fix to reduce size as we are using this field in grid
         if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
             //shrink class to "form-text-medium"
             $this->_fields[$name]['attributes']['size'] = 19;
         }
     }
     $this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Activities'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_activityHolderIds);
     $fileFieldExists = FALSE;
     //load all campaigns.
     if (array_key_exists('activity_campaign_id', $this->_fields)) {
         $this->_componentCampaigns = array();
         CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Activity_DAO_Activity', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) ');
     }
     $customFields = CRM_Core_BAO_CustomField::getFields('Activity');
     foreach ($this->_activityHolderIds as $activityId) {
         $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $customValue = CRM_Utils_Array::value($customFieldID, $customFields);
                 if (!empty($customValue['extends_entity_column_value'])) {
                     $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']);
                 }
                 if (!empty($entityColumnValue[$typeId]) || CRM_Utils_System::isNull($entityColumnValue[$typeId])) {
                     CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
                 }
             } else {
                 // handle non custom fields
                 CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
             }
         }
     }
     $this->assign('fields', $this->_fields);
     // don't set the status message when form is submitted.
     // $buttonName = $this->controller->getButtonName('submit');
     if ($suppressFields) {
         CRM_Core_Session::setStatus(ts("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update."), ts("Some fields have been excluded"), "info");
     }
     $this->addDefaultButtons(ts('Update Activities'));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:68,代码来源:Batch.php

示例12: validate

 /**
  * @return bool
  */
 public function validate()
 {
     if (CRM_Utils_System::isNull($this->_value)) {
         return TRUE;
     }
     switch ($this->_name) {
         case 'contact_id':
             // note: we validate extistence of the contact in API, upon
             // insert (it would be too costlty to do a db call here)
             return CRM_Utils_Rule::integer($this->_value);
         case 'register_date':
             return CRM_Utils_Rule::date($this->_value);
             /* @codingStandardsIgnoreStart
                  case 'event_id':
                      static $events = null;
                      if (!$events) {
                          $events = CRM_Event_PseudoConstant::event();
                      }
                      if (in_array($this->_value, $events)) {
                          return true;
                      }
                      else {
                          return false;
                      }
                      break;
                @codingStandardsIgnoreEnd */
         /* @codingStandardsIgnoreStart
              case 'event_id':
                  static $events = null;
                  if (!$events) {
                      $events = CRM_Event_PseudoConstant::event();
                  }
                  if (in_array($this->_value, $events)) {
                      return true;
                  }
                  else {
                      return false;
                  }
                  break;
            @codingStandardsIgnoreEnd */
         default:
             break;
     }
     // check whether that's a valid custom field id
     // and if so, check the contents' validity
     if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) {
         static $customFields = NULL;
         if (!$customFields) {
             $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
         }
         if (!array_key_exists($customFieldID, $customFields)) {
             return FALSE;
         }
         return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
     }
     return TRUE;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:60,代码来源:Field.php

示例13: getTokenDetails

 /**
  * Gives required details of contacts in an indexed array format so we
  * can iterate in a nice loop and do token evaluation
  *
  * @param $contactIDs
  * @param array $returnProperties
  *   Of required properties.
  * @param bool $skipOnHold Don't return on_hold contact info also.
  *   Don't return on_hold contact info also.
  * @param bool $skipDeceased Don't return deceased contact info.
  *   Don't return deceased contact info.
  * @param array $extraParams
  *   Extra params.
  * @param array $tokens
  *   The list of tokens we've extracted from the content.
  * @param null $className
  * @param int $jobID
  *   The mailing list jobID - this is a legacy param.
  *
  * @return array
  */
 public static function getTokenDetails($contactIDs, $returnProperties = NULL, $skipOnHold = TRUE, $skipDeceased = TRUE, $extraParams = NULL, $tokens = array(), $className = NULL, $jobID = NULL)
 {
     if (empty($contactIDs)) {
         // putting a fatal here so we can track if/when this happens
         CRM_Core_Error::fatal();
     }
     // @todo this functions needs unit tests.
     $params = array();
     foreach ($contactIDs as $key => $contactID) {
         $params[] = array(CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0);
     }
     // fix for CRM-2613
     if ($skipDeceased) {
         $params[] = array('is_deceased', '=', 0, 0, 0);
     }
     //fix for CRM-3798
     if ($skipOnHold) {
         $params[] = array('on_hold', '=', 0, 0, 0);
     }
     if ($extraParams) {
         $params = array_merge($params, $extraParams);
     }
     // if return properties are not passed then get all return properties
     if (empty($returnProperties)) {
         $fields = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields()), array('display_name', 'checksum', 'contact_id'));
         foreach ($fields as $key => $val) {
             // The unavailable fields are not available as tokens, do not have a one-2-one relationship
             // with contacts and are expensive to resolve.
             // @todo see CRM-17253 - there are some other fields (e.g note) that should be excluded
             // and upstream calls to this should populate return properties.
             $unavailableFields = array('group', 'tag');
             if (!in_array($val, $unavailableFields)) {
                 $returnProperties[$val] = 1;
             }
         }
     }
     $custom = array();
     foreach ($returnProperties as $name => $dontCare) {
         $cfID = CRM_Core_BAO_CustomField::getKeyID($name);
         if ($cfID) {
             $custom[] = $cfID;
         }
     }
     //get the total number of contacts to fetch from database.
     $numberofContacts = count($contactIDs);
     $query = new CRM_Contact_BAO_Query($params, $returnProperties);
     $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
     $contactDetails =& $details[0];
     foreach ($contactIDs as $key => $contactID) {
         if (array_key_exists($contactID, $contactDetails)) {
             if (CRM_Utils_Array::value('preferred_communication_method', $returnProperties) == 1 && array_key_exists('preferred_communication_method', $contactDetails[$contactID])) {
                 $pcm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
                 // communication Preference
                 $contactPcm = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contactDetails[$contactID]['preferred_communication_method']);
                 $result = array();
                 foreach ($contactPcm as $key => $val) {
                     if ($val) {
                         $result[$val] = $pcm[$val];
                     }
                 }
                 $contactDetails[$contactID]['preferred_communication_method'] = implode(', ', $result);
             }
             foreach ($custom as $cfID) {
                 if (isset($contactDetails[$contactID]["custom_{$cfID}"])) {
                     $contactDetails[$contactID]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::getDisplayValue($contactDetails[$contactID]["custom_{$cfID}"], $cfID, $details[1]);
                 }
             }
             // special case for greeting replacement
             foreach (array('email_greeting', 'postal_greeting', 'addressee') as $val) {
                 if (!empty($contactDetails[$contactID][$val])) {
                     $contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"];
                 }
             }
         }
     }
     // also call a hook and get token details
     CRM_Utils_Hook::tokenValues($details[0], $contactIDs, $jobID, $tokens, $className);
     return $details;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:100,代码来源:Token.php

示例14: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     $fv = $this->controller->exportValues($this->_name);
     $config = CRM_Core_Config::singleton();
     $locName = NULL;
     //get the address format sequence from the config file
     $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     $sequence = CRM_Utils_Address::sequence($mailingFormat);
     foreach ($sequence as $v) {
         $address[$v] = 1;
     }
     if (array_key_exists('postal_code', $address)) {
         $address['postal_code_suffix'] = 1;
     }
     //build the returnproperties
     $returnProperties = array('display_name' => 1, 'contact_type' => 1);
     $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     $mailingFormatProperties = array();
     if ($mailingFormat) {
         $mailingFormatProperties = self::getReturnProperties($mailingFormat);
         $returnProperties = array_merge($returnProperties, $mailingFormatProperties);
     }
     //we should not consider addressee for data exists, CRM-6025
     if (array_key_exists('addressee', $mailingFormatProperties)) {
         unset($mailingFormatProperties['addressee']);
     }
     $customFormatProperties = array();
     if (stristr($mailingFormat, 'custom_')) {
         foreach ($mailingFormatProperties as $token => $true) {
             if (substr($token, 0, 7) == 'custom_') {
                 if (empty($customFormatProperties[$token])) {
                     $customFormatProperties[$token] = $mailingFormatProperties[$token];
                 }
             }
         }
     }
     if (!empty($customFormatProperties)) {
         $returnProperties = array_merge($returnProperties, $customFormatProperties);
     }
     if (isset($fv['merge_same_address'])) {
         // we need first name/last name for summarising to avoid spillage
         $returnProperties['first_name'] = 1;
         $returnProperties['last_name'] = 1;
     }
     $individualFormat = FALSE;
     /*
      * CRM-8338: replace ids of household members with the id of their household
      * so we can merge labels by household.
      */
     if (isset($fv['merge_same_household'])) {
         $this->mergeContactIdsByHousehold();
         $individualFormat = TRUE;
     }
     //get the contacts information
     $params = array();
     if (!empty($fv['location_type_id'])) {
         $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
         $locName = $locType[$fv['location_type_id']];
         $location = array('location' => array("{$locName}" => $address));
         $returnProperties = array_merge($returnProperties, $location);
         $params[] = array('location_type', '=', array($fv['location_type_id'] => 1), 0, 0);
     } else {
         $returnProperties = array_merge($returnProperties, $address);
     }
     $rows = array();
     foreach ($this->_contactIds as $key => $contactID) {
         $params[] = array(CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0);
     }
     // fix for CRM-2651
     if (!empty($fv['do_not_mail'])) {
         $params[] = array('do_not_mail', '=', 0, 0, 0);
     }
     // fix for CRM-2613
     $params[] = array('is_deceased', '=', 0, 0, 0);
     $custom = array();
     foreach ($returnProperties as $name => $dontCare) {
         $cfID = CRM_Core_BAO_CustomField::getKeyID($name);
         if ($cfID) {
             $custom[] = $cfID;
         }
     }
     //get the total number of contacts to fetch from database.
     $numberofContacts = count($this->_contactIds);
     $query = new CRM_Contact_BAO_Query($params, $returnProperties);
     $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
     $messageToken = CRM_Utils_Token::getTokens($mailingFormat);
     // also get all token values
     CRM_Utils_Hook::tokenValues($details[0], $this->_contactIds, NULL, $messageToken, 'CRM_Contact_Form_Task_Label');
     $tokens = array();
     CRM_Utils_Hook::tokens($tokens);
     $tokenFields = array();
     foreach ($tokens as $category => $catTokens) {
         foreach ($catTokens as $token => $tokenName) {
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Label.php

示例15: formatCustomFieldName

 /**
  * Format custom field name.
  *
  * Combine group and field name to avoid conflict.
  *
  * @param array $fields
  *
  * @return array
  */
 public function formatCustomFieldName(&$fields)
 {
     //CRM-2676, replacing the conflict for same custom field name from different custom group.
     $fieldIds = $formattedFieldNames = array();
     foreach ($fields as $key => $value) {
         if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key)) {
             $fieldIds[] = $customFieldId;
         }
     }
     if (!empty($fieldIds) && is_array($fieldIds)) {
         $groupTitles = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldIds);
         if (!empty($groupTitles)) {
             foreach ($groupTitles as $fId => $values) {
                 $key = "custom_{$fId}";
                 $groupTitle = $values['groupTitle'];
                 $formattedFieldNames[$key] = $fields[$key] . ' :: ' . $groupTitle;
             }
         }
     }
     return $formattedFieldNames;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:30,代码来源:MapField.php


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