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


PHP CRM_Core_BAO_CustomValue类代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     $config = CRM_Chapters_AutomatchConfig::singelton();
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_CustomValue::deleteCustomValue($this->id, $config->getCustomGroup('id'));
         $this->updateAllContacts();
         return;
     }
     $cg = 'custom_';
     $id = ':-1';
     if ($this->id) {
         $id = ':' . $this->id;
     }
     $data['entity_id'] = $this->contact_id;
     $data[$cg . $config->getMatchTypeField('id') . $id] = $this->_submitValues['type'];
     $data[$cg . $config->getCountryField('id') . $id] = $this->_submitValues['country'];
     $data[$cg . $config->getZipCodeRangeFromField('id') . $id] = $this->_submitValues['zipcode_from'];
     $data[$cg . $config->getZipCodeRangeToField('id') . $id] = $this->_submitValues['zipcode_to'];
     civicrm_api3('CustomValue', 'create', $data);
     $this->updateAllContacts();
 }
开发者ID:CiviCooP,项目名称:net.emphanos.iida.chapters,代码行数:21,代码来源:AutomatchChapters.php

示例2: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is 
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  *
  * @param
  *
  * @return void 
  * @access public
  */
 function postProcess()
 {
     $session =& CRM_Core_Session::singleton();
     $session->set('isAdvanced', '1');
     // get user submitted values
     // get it from controller only if form has been submitted, else preProcess has set this
     if (!empty($_POST)) {
         $this->_formValues = $this->controller->exportValues($this->_name);
         // FIXME: couldn't figure out a good place to do this,
         // FIXME: so leaving this as a dependency for now
         if (array_key_exists('contribution_amount_low', $this->_formValues)) {
             foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) {
                 $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
             }
         }
         //assigning event values for autocomplete event selection
         $eventSearchIds = array('event_id' => 'event_name_id', 'event_type' => 'event_type_id', 'participant_fee_level' => 'participant_fee_id');
         foreach ($eventSearchIds as $key => $value) {
             $this->_formValues[$key] = empty($this->_formValues[$key]) ? '' : $this->_formValues[$value];
             $this->_formValues[$value] = '';
         }
         // set the group if group is submitted
         if ($this->_formValues['uf_group_id']) {
             $this->set('id', $this->_formValues['uf_group_id']);
         } else {
             $this->set('id', '');
         }
     }
     // retrieve ssID values only if formValues is null, i.e. form has never been posted
     if (empty($this->_formValues) && isset($this->_ssID)) {
         $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
     }
     if (isset($this->_groupID) && !CRM_Utils_Array::value('group', $this->_formValues)) {
         $this->_formValues['group'] = array($this->_groupID => 1);
     }
     //search for civicase
     if (is_array($this->_formValues)) {
         if (array_key_exists('case_owner', $this->_formValues) && !$this->_formValues['case_owner'] && !$this->_force) {
             $this->_formValues['case_owner'] = 0;
         } else {
             if (array_key_exists('case_owner', $this->_formValues)) {
                 $this->_formValues['case_owner'] = 1;
             }
         }
     }
     // we dont want to store the sortByCharacter in the formValue, it is more like
     // a filter on the result set
     // this filter is reset if we click on the search button
     if ($this->_sortByCharacter && empty($_POST)) {
         if ($this->_sortByCharacter == 1) {
             $this->_formValues['sortByCharacter'] = null;
         } else {
             $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
         }
     }
     require_once 'CRM/Core/BAO/CustomValue.php';
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     require_once 'CRM/Contact/BAO/Query.php';
     $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->_returnProperties =& $this->returnProperties();
     parent::postProcess();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:79,代码来源:Advanced.php

示例3: deleteCustomValue

 /**
  * Delete custom value.
  */
 public static function deleteCustomValue()
 {
     CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
     $customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive');
     $customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive');
     $contactId = CRM_Utils_Request::retrieve('contactId', 'Positive', CRM_Core_DAO::$_nullObject);
     CRM_Core_BAO_CustomValue::deleteCustomValue($customValueID, $customGroupID);
     if ($contactId) {
         echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $customGroupID, $contactId);
     }
     CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
     CRM_Utils_System::civiExit();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:16,代码来源:AJAX.php

示例4: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  *
  * @param
  *
  * @return void
  * @access public
  */
 function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     $this->_formValues = $this->controller->exportValues($this->_name);
     $this->fixFormValues();
     // We don't show test records in summaries or dashboards
     if (empty($this->_formValues['member_test']) && $this->_force) {
         $this->_formValues["member_test"] = 0;
     }
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine = $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Member_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = NULL;
     if ($this->_context == 'basic') {
         $prefix = $this->_prefix;
     }
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(TRUE);
     $query =& $selector->getQuery();
     $controller->run();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:58,代码来源:Search.php

示例5: validate

 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);
             break;
         case 'receive_date':
         case 'cancel_date':
         case 'receipt_date':
         case 'thankyou_date':
             return CRM_Utils_Rule::date($this->_value);
             break;
         case 'non_deductible_amount':
         case 'total_amount':
         case 'fee_amount':
         case 'net_amount':
             return CRM_Utils_Rule::money($this->_value);
             break;
         case 'trxn_id':
             static $seenTrxnIds = array();
             if (in_array($this->_value, $seenTrxnIds)) {
                 return false;
             } elseif ($this->_value) {
                 $seenTrxnIds[] = $this->_value;
                 return true;
             } else {
                 $this->_value = null;
                 return true;
             }
             break;
         case 'currency':
             return CRM_Utils_Rule::currencyCode($this->_value);
             break;
         case 'contribution_type':
             static $contributionTypes = null;
             if (!$contributionTypes) {
                 $contributionTypes =& CRM_Contribute_PseudoConstant::contributionType();
             }
             if (in_array($this->_value, $contributionTypes)) {
                 return true;
             } else {
                 return false;
             }
             break;
         case 'payment_instrument':
             static $paymentInstruments = null;
             if (!$paymentInstruments) {
                 $paymentInstruments =& CRM_Contribute_PseudoConstant::paymentInstrument();
             }
             if (in_array($this->_value, $paymentInstruments)) {
                 return true;
             } else {
                 return false;
             }
             break;
         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('Contribution');
         }
         if (!array_key_exists($customFieldID, $customFields)) {
             return false;
         }
         return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:77,代码来源:Field.php

示例6: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  */
 public function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     $this->_formValues = $this->controller->exportValues($this->_name);
     $this->fixFormValues();
     if (isset($this->_ssID) && empty($_POST)) {
         // if we are editing / running a saved search and the form has not been posted
         $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
     }
     //search for civicase
     if (!$this->_force) {
         if (array_key_exists('case_owner', $this->_formValues) && !$this->_formValues['case_owner']) {
             $this->_formValues['case_owner'] = 0;
         }
     }
     if (empty($this->_formValues['case_deleted'])) {
         $this->_formValues['case_deleted'] = 0;
     }
     CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine = $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Case_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = NULL;
     if ($this->_context == 'user') {
         $prefix = $this->_prefix;
     }
     $this->assign("{$prefix}limit", $this->_limit);
     $this->assign("{$prefix}single", $this->_single);
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(TRUE);
     $query =& $selector->getQuery();
     if ($this->_context == 'user') {
         $query->setSkipPermission(TRUE);
     }
     $controller->run();
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:67,代码来源:Search.php

示例7: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  *
  * @param
  *
  * @return void
  * @access public
  */
 function postProcess()
 {
     $this->set('isAdvanced', '1');
     // get user submitted values
     // get it from controller only if form has been submitted, else preProcess has set this
     if (!empty($_POST)) {
         $this->_formValues = $this->controller->exportValues($this->_name);
         $this->normalizeFormValues();
         // FIXME: couldn't figure out a good place to do this,
         // FIXME: so leaving this as a dependency for now
         if (array_key_exists('contribution_amount_low', $this->_formValues)) {
             foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) {
                 $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
             }
         }
         // set the group if group is submitted
         if (!empty($this->_formValues['uf_group_id'])) {
             $this->set('id', $this->_formValues['uf_group_id']);
         } else {
             $this->set('id', '');
         }
     }
     // retrieve ssID values only if formValues is null, i.e. form has never been posted
     if (empty($this->_formValues) && isset($this->_ssID)) {
         $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
     }
     if (isset($this->_groupID) && !CRM_Utils_Array::value('group', $this->_formValues)) {
         $this->_formValues['group'] = array($this->_groupID => 1);
     }
     //search for civicase
     if (is_array($this->_formValues)) {
         $allCases = FALSE;
         if (array_key_exists('case_owner', $this->_formValues) && !$this->_formValues['case_owner'] && !$this->_force) {
             foreach (array('case_type_id', 'case_status_id', 'case_deleted', 'case_tags') as $caseCriteria) {
                 if (CRM_Utils_Array::value($caseCriteria, $this->_formValues)) {
                     $allCases = TRUE;
                     $this->_formValues['case_owner'] = 1;
                     continue;
                 }
             }
             if ($allCases) {
                 if (CRM_Core_Permission::check('access all cases and activities')) {
                     $this->_formValues['case_owner'] = 1;
                 } else {
                     $this->_formValues['case_owner'] = 2;
                 }
             } else {
                 $this->_formValues['case_owner'] = 0;
             }
         }
     }
     // we dont want to store the sortByCharacter in the formValue, it is more like
     // a filter on the result set
     // this filter is reset if we click on the search button
     if ($this->_sortByCharacter !== NULL && empty($_POST)) {
         if (strtolower($this->_sortByCharacter) == 'all') {
             $this->_formValues['sortByCharacter'] = NULL;
         } else {
             $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
         }
     } else {
         $this->_sortByCharacter = NULL;
     }
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->_returnProperties =& $this->returnProperties();
     parent::postProcess();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:85,代码来源:Advanced.php

示例8: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post processing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submission is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  */
 public function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     if (!empty($_POST)) {
         $this->_formValues = $this->controller->exportValues($this->_name);
     }
     $this->fixFormValues();
     // We don't show test records in summaries or dashboards
     if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context == 'dashboard') {
         $this->_formValues["contribution_test"] = 0;
     }
     foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) {
         if (isset($this->_formValues[$f])) {
             $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
         }
     }
     $config = CRM_Core_Config::singleton();
     if (!empty($_POST)) {
         $specialParams = array('financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status_id', 'contribution_source', 'contribution_trxn_id', 'contribution_page_id', 'contribution_product_id');
         foreach ($specialParams as $element) {
             $value = CRM_Utils_Array::value($element, $this->_formValues);
             if ($value) {
                 if (is_array($value)) {
                     $this->_formValues[$element] = array('IN' => $value);
                 } else {
                     $this->_formValues[$element] = array('LIKE' => "%{$value}%");
                 }
             }
         }
         $tags = CRM_Utils_Array::value('contact_tags', $this->_formValues);
         if ($tags && !is_array($tags)) {
             unset($this->_formValues['contact_tags']);
             $this->_formValues['contact_tags'][$tags] = 1;
         }
         if ($tags && is_array($tags)) {
             unset($this->_formValues['contact_tags']);
             foreach ($tags as $notImportant => $tagID) {
                 $this->_formValues['contact_tags'][$tagID] = 1;
             }
         }
         if (!$config->groupTree) {
             $group = CRM_Utils_Array::value('group', $this->_formValues);
             if ($group && !is_array($group)) {
                 unset($this->_formValues['group']);
                 $this->_formValues['group'][$group] = 1;
             }
             if ($group && is_array($group)) {
                 unset($this->_formValues['group']);
                 foreach ($group as $notImportant => $groupID) {
                     $this->_formValues['group'][$groupID] = 1;
                 }
             }
         }
     }
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine = $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Contribute_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = NULL;
     if ($this->_context == 'basic' || $this->_context == 'user') {
         $prefix = $this->_prefix;
     }
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(TRUE);
     $query =& $selector->getQuery();
     if ($this->_context == 'user') {
         $query->setSkipPermission(TRUE);
     }
     $summary =& $query->summaryContribution($this->_context);
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Search.php

示例9: isErrorInCustomData

 /**
  * Check if an error in custom data.
  *
  * @param array $params
  * @param string $errorMessage
  *   A string containing all the error-fields.
  *
  * @param null $csType
  * @param null $relationships
  */
 public static function isErrorInCustomData($params, &$errorMessage, $csType = NULL, $relationships = NULL)
 {
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get("dateTypes");
     if (!empty($params['contact_sub_type'])) {
         $csType = CRM_Utils_Array::value('contact_sub_type', $params);
     }
     if (empty($params['contact_type'])) {
         $params['contact_type'] = 'Individual';
     }
     $customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, FALSE, $csType);
     $addressCustomFields = CRM_Core_BAO_CustomField::getFields('Address');
     $customFields = $customFields + $addressCustomFields;
     foreach ($params as $key => $value) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
             /* check if it's a valid custom field id */
             if (!array_key_exists($customFieldID, $customFields)) {
                 self::addToErrorMsg(ts('field ID'), $errorMessage);
             }
             // validate null values for required custom fields of type boolean
             if (!empty($customFields[$customFieldID]['is_required']) && (empty($params['custom_' . $customFieldID]) && !is_numeric($params['custom_' . $customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
                 self::addToErrorMsg($customFields[$customFieldID]['label'] . '::' . $customFields[$customFieldID]['groupTitle'], $errorMessage);
             }
             //For address custom fields, we do get actual custom field value as an inner array of
             //values so need to modify
             if (array_key_exists($customFieldID, $addressCustomFields)) {
                 $value = $value[0][$key];
             }
             /* validate the data against the CF type */
             if ($value) {
                 if ($customFields[$customFieldID]['data_type'] == 'Date') {
                     if (array_key_exists($customFieldID, $addressCustomFields) && CRM_Utils_Date::convertToDefaultDate($params[$key][0], $dateType, $key)) {
                         $value = $params[$key][0][$key];
                     } elseif (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         $value = $params[$key];
                     } else {
                         self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                     }
                 } elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
                     if (CRM_Utils_String::strtoboolstr($value) === FALSE) {
                         self::addToErrorMsg($customFields[$customFieldID]['label'] . '::' . $customFields[$customFieldID]['groupTitle'], $errorMessage);
                     }
                 }
                 // need not check for label filed import
                 $htmlType = array('CheckBox', 'Multi-Select', 'AdvMulti-Select', 'Select', 'Radio', 'Multi-Select State/Province', 'Multi-Select Country');
                 if (!in_array($customFields[$customFieldID]['html_type'], $htmlType) || $customFields[$customFieldID]['data_type'] == 'Boolean' || $customFields[$customFieldID]['data_type'] == 'ContactReference') {
                     $valid = CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $value);
                     if (!$valid) {
                         self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                     }
                 }
                 // check for values for custom fields for checkboxes and multiselect
                 if ($customFields[$customFieldID]['html_type'] == 'CheckBox' || $customFields[$customFieldID]['html_type'] == 'AdvMulti-Select' || $customFields[$customFieldID]['html_type'] == 'Multi-Select') {
                     $value = trim($value);
                     $value = str_replace('|', ',', $value);
                     $mulValues = explode(',', $value);
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                     foreach ($mulValues as $v1) {
                         if (strlen($v1) == 0) {
                             continue;
                         }
                         $flag = FALSE;
                         foreach ($customOption as $v2) {
                             if (strtolower(trim($v2['label'])) == strtolower(trim($v1)) || strtolower(trim($v2['value'])) == strtolower(trim($v1))) {
                                 $flag = TRUE;
                             }
                         }
                         if (!$flag) {
                             self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                         }
                     }
                 } elseif ($customFields[$customFieldID]['html_type'] == 'Select' || $customFields[$customFieldID]['html_type'] == 'Radio' && $customFields[$customFieldID]['data_type'] != 'Boolean') {
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
                     $flag = FALSE;
                     foreach ($customOption as $v2) {
                         if (strtolower(trim($v2['label'])) == strtolower(trim($value)) || strtolower(trim($v2['value'])) == strtolower(trim($value))) {
                             $flag = TRUE;
                         }
                     }
                     if (!$flag) {
                         self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
                     }
                 } elseif ($customFields[$customFieldID]['html_type'] == 'Multi-Select State/Province') {
                     $mulValues = explode(',', $value);
                     foreach ($mulValues as $stateValue) {
                         if ($stateValue) {
                             if (self::in_value(trim($stateValue), CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || self::in_value(trim($stateValue), CRM_Core_PseudoConstant::stateProvince())) {
                                 continue;
                             } else {
                                 self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Contact.php

示例10: array

 /**
  * takes an associative array and creates a contribution object
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object 
  * @access public
  * @static
  */
 function &create(&$params, &$ids)
 {
     require_once 'CRM/Utils/Money.php';
     require_once 'CRM/Utils/Date.php';
     // FIXME: a cludgy hack to fix the dates to MySQL format
     $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     CRM_Core_DAO::transaction('BEGIN');
     $contribution = CRM_Contribute_BAO_Contribution::add($params, $ids);
     if (is_a($contribution, 'CRM_Core_Error')) {
         CRM_Core_DAO::transaction('ROLLBACK');
         return $contribution;
     }
     $params['contribution_id'] = $contribution->id;
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         foreach ($params['custom'] as $customValue) {
             $cvParams = array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution->id, 'value' => $customValue['value'], 'type' => $customValue['type'], 'custom_field_id' => $customValue['custom_field_id']);
             if ($customValue['id']) {
                 $cvParams['id'] = $customValue['id'];
             }
             CRM_Core_BAO_CustomValue::create($cvParams);
         }
     }
     // let's create an (or update the relevant) Acitivity History record
     $contributionType = CRM_Contribute_PseudoConstant::contributionType($contribution->contribution_type_id);
     if (!$contributionType) {
         $contributionType = ts('Contribution');
     }
     if (!$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate']) {
         $GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate'] = CRM_Utils_Date::customFormat(date('Y-m-d H:i'));
     }
     $activitySummary = ts('%1 - %2 (updated on %3)', array(1 => CRM_Utils_Money::format($contribution->total_amount, $contribution->currency), 2 => $contributionType, 3 => $GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate']));
     $historyParams = array('entity_table' => 'civicrm_contact', 'entity_id' => $contribution->contact_id, 'activity_type' => $contributionType, 'module' => 'CiviContribute', 'callback' => 'CRM_Contribute_Page_Contribution::details', 'activity_id' => $contribution->id, 'activity_summary' => $activitySummary, 'activity_date' => $contribution->receive_date);
     if (CRM_Utils_Array::value('contribution', $ids)) {
         // this contribution should have an Activity History record already
         $getHistoryParams = array('module' => 'CiviContribute', 'activity_id' => $contribution->id);
         $getHistoryValues =& CRM_Core_BAO_History::getHistory($getHistoryParams, 0, 1, null, 'Activity');
         if (!empty($getHistoryValues)) {
             $tmp = array_keys($getHistoryValues);
             $ids['activity_history'] = $tmp[0];
         }
     }
     $historyDAO =& CRM_Core_BAO_History::create($historyParams, $ids, 'Activity');
     if (is_a($historyDAO, 'CRM_Core_Error')) {
         CRM_Core_Error::fatal("Failed creating Activity History for contribution of id {$contribution->id}");
     }
     CRM_Core_DAO::transaction('COMMIT');
     return $contribution;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:64,代码来源:Contribution.php

示例11: array_merge

 /**
  * Replace all the org-level tokens in $str
  *
  * @param string $str       The string with tokens to be replaced
  * @param object $org       Associative array of org properties
  * @param boolean $html     Replace tokens with HTML or plain text
  * @return string           The processed string
  * @access public
  * @static
  */
 public static function &replaceOrgTokens($str, &$org, $html = false)
 {
     self::$_tokens['org'] = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields('Organization')), array('address', 'display_name', 'checksum', 'contact_id'));
     /*
     print "org tokens: <pre>";
     print_r( $_tokens['org'] );
     print "</pre>";
     */
     $cv = null;
     foreach (self::$_tokens['org'] as $token) {
         // print "Getting token value for $token<br/><br/>";
         if ($token == '') {
             continue;
         }
         /* If the string doesn't contain this token, skip it. */
         if (!self::token_match('org', $token, $str)) {
             continue;
         }
         /* Construct value from $token and $contact */
         $value = null;
         if ($cfID = CRM_Core_BAO_CustomField::getKeyID($token)) {
             // only generate cv if we need it
             if ($cv === null) {
                 $cv =& CRM_Core_BAO_CustomValue::getContactValues($org['contact_id']);
             }
             foreach ($cv as $cvFieldID => $value) {
                 if ($cvFieldID == $cfID) {
                     $value = CRM_Core_BAO_CustomOption::getOptionLabel($cfID, $value);
                     break;
                 }
             }
         } else {
             if ($token == 'checksum') {
                 require_once 'CRM/Contact/BAO/Contact/Utils.php';
                 $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($org['contact_id']);
                 $value = "cs={$cs}";
             } else {
                 if ($token == 'address') {
                     /* Build the location values array */
                     $loc = array();
                     $loc['display_name'] = CRM_Utils_Array::retrieveValueRecursive($org, 'display_name');
                     $loc['street_address'] = CRM_Utils_Array::retrieveValueRecursive($org, 'street_address');
                     $loc['city'] = CRM_Utils_Array::retrieveValueRecursive($org, 'city');
                     $loc['state_province'] = CRM_Utils_Array::retrieveValueRecursive($org, 'state_province');
                     $loc['postal_code'] = CRM_Utils_Array::retrieveValueRecursive($org, 'postal_code');
                     /* Construct the address token */
                     $value = CRM_Utils_Address::format($loc);
                     if ($html) {
                         $value = str_replace("\n", '<br />', $value);
                     }
                 } else {
                     /*
                     print "\$org: <pre>";
                     print_r( $org );
                     print "</pre>";
                     */
                     $value = CRM_Utils_Array::retrieveValueRecursive($org, $token);
                     /*
                     print "\$value: <pre>";
                     print_r( $value );
                     print "</pre>";
                     */
                 }
             }
         }
         self::token_replace('org', $token, $value, $str);
     }
     return $str;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:79,代码来源:Token.php

示例12: searchRange

 function searchRange(&$id, &$label, $type, &$value)
 {
     $qill = array();
     $crmType = CRM_Core_BAO_CustomValue::fieldToType($type);
     if (isset($value['from'])) {
         $val = CRM_Utils_Type::escape($value['from'], $crmType);
         if ($type == 'char_data') {
             $this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . "{$id}.{$type} >= '{$val}'";
         } else {
             $this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . "{$id}.{$type} >= {$val}";
         }
         $qill[] = ts('greater than "%1"', array(1 => $value['from']));
     }
     if (isset($value['to'])) {
         $val = CRM_Utils_Type::escape($value['to'], $crmType);
         if ($type == 'char_data') {
             $this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . "{$id}.{$type} <= '{$val}'";
         } else {
             $this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . "{$id}.{$type} <= {$val}";
         }
         $qill[] = ts('less than "%1"', array(1 => $value['to']));
     }
     if (!empty($qill)) {
         $this->_qill[] = $label . ' - ' . implode(' ' . ts('and') . ' ', $qill);
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:26,代码来源:CustomQuery.php

示例13: _civicrm_validate_formatted_contact

/**
 * Validate a formatted contact parameter list.
 *
 * @param array $params  Structured parameter list (as in crm_format_params)
 *
 * @return bool|CRM_Core_Error
 * @access public
 */
function _civicrm_validate_formatted_contact(&$params)
{
    /* Look for offending email addresses */
    if (array_key_exists('email', $params)) {
        foreach ($params['email'] as $count => $values) {
            if (!is_array($values)) {
                continue;
            }
            if ($email = CRM_Utils_Array::value('email', $values)) {
                //validate each email
                if (!CRM_Utils_Rule::email($email)) {
                    return civicrm_create_error('No valid email address');
                }
                //check for loc type id.
                if (!CRM_Utils_Array::value('location_type_id', $values)) {
                    return civicrm_create_error('Location Type Id missing.');
                }
            }
        }
    }
    /* Validate custom data fields */
    if (is_array($params['custom'])) {
        foreach ($params['custom'] as $key => $custom) {
            if (is_array($custom)) {
                $valid = CRM_Core_BAO_CustomValue::typecheck($custom['type'], $custom['value']);
                if (!$valid) {
                    return civicrm_create_error('Invalid value for custom field \'' . $custom['name'] . '\'');
                }
                if ($custom['type'] == 'Date') {
                    $params['custom'][$key]['value'] = str_replace('-', '', $params['custom'][$key]['value']);
                }
            }
        }
    }
    return civicrm_create_success(true);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:44,代码来源:utils.php

示例14: _crm_validate_formatted_contribution

/**
 * Validate a formatted contribution parameter list.
 *
 * @param array $params  Structured parameter list (as in crm_format_params)
 *
 * @return bool|CRM_Core_Error
 * @access public
 */
function _crm_validate_formatted_contribution(&$params)
{
    static $domainID = null;
    if (!$domainID) {
        $config =& CRM_Core_Config::singleton();
        $domainID = $config->domainID();
    }
    foreach ($params as $key => $value) {
        switch ($key) {
            case 'contact_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return _crm_error("contact_id not valid: {$value}");
                }
                $dao =& new CRM_Core_DAO();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE domain_id = {$domainID} AND id = {$value}");
                if (!$svq) {
                    return _crm_error("there's no contact with contact_id of {$value}");
                }
                break;
            case 'receive_date':
            case 'cancel_date':
            case 'receipt_date':
            case 'thankyou_date':
                if (!CRM_Utils_Rule::date($value)) {
                    return _crm_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'non_deductible_amount':
            case 'total_amount':
            case 'fee_amount':
            case 'net_amount':
                if (!CRM_Utils_Rule::money($value)) {
                    return _crm_error("{$key} not a valid amount: {$value}");
                }
                break;
            case 'currency':
                if (!CRM_Utils_Rule::currencyCode($value)) {
                    return _crm_error("currency not a valid code: {$value}");
                }
                break;
            default:
                break;
        }
    }
    /* Validate custom data fields */
    if (is_array($params['custom'])) {
        foreach ($params['custom'] as $key => $custom) {
            if (is_array($custom)) {
                $valid = CRM_Core_BAO_CustomValue::typecheck($custom['type'], $custom['value']);
                if (!$valid) {
                    return _crm_error('Invalid value for custom field \'' . $custom['name'] . '\'');
                }
                if ($custom['type'] == 'Date') {
                    $params['custom'][$key]['value'] = str_replace('-', '', $params['custom'][$key]['value']);
                }
            }
        }
    }
    return true;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:68,代码来源:utils.php

示例15: postProcess

 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is 
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  *
  * @param
  *
  * @return void 
  * @access public
  */
 function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = true;
     $this->_formValues = $this->controller->exportValues($this->_name);
     $this->fixFormValues();
     // we don't show test memberships in Contact Summary / User Dashboard
     // in Search mode by default we hide test memberships
     if (!CRM_Utils_Array::value('member_test', $this->_formValues)) {
         $this->_formValues["member_test"] = 0;
     }
     require_once 'CRM/Core/BAO/CustomValue.php';
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     require_once 'CRM/Contact/BAO/Query.php';
     $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine =& $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = null;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     require_once 'CRM/Contact/BAO/Query.php';
     $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     require_once "CRM/Member/Selector/Search.php";
     $selector = new CRM_Member_Selector_Search($this->_queryParams, $this->_action, null, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = null;
     if ($this->_context == 'basic') {
         $prefix = $this->_prefix;
     }
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(true);
     $query =& $selector->getQuery();
     $controller->run();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Search.php


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