• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_BAO_CustomOption类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getOptionList

 /**
  * This function uses the deprecated v1 datatable api and needs updating. See CRM-16353.
  * @deprecated
  */
 public static function getOptionList()
 {
     $params = $_REQUEST;
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $params['page'] = $offset / $rowCount + 1;
     $params['rp'] = $rowCount;
     $options = CRM_Core_BAO_CustomOption::getOptionListSelector($params);
     $iFilteredTotal = $iTotal = $params['total'];
     $selectorElements = array('label', 'value', 'is_default', 'is_active', 'links', 'class');
     CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
     echo CRM_Utils_JSON::encodeDataTableSelector($options, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:19,代码来源:AJAX.php


示例2: setDefaultValues

 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  * 
  * @access public 
  * @return void 
  */
 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     require_once 'CRM/Core/BAO/CustomOption.php';
     CRM_Core_BAO_CustomOption::getAssoc('civicrm_contribution_page', $this->_id, $defaults);
     if (CRM_Utils_Array::value('value', $defaults)) {
         foreach ($defaults['value'] as $i => $v) {
             if ($v == $defaults['default_amount']) {
                 $defaults['default'] = $i;
                 break;
             }
         }
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:Amount.php


示例3: preProcess

 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     // current contribution page id
     $this->_id = $this->get('id');
     // get all the values from the dao object
     $params = array('id' => $this->_id);
     $this->_values = array();
     CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values);
     // get the amounts and the label
     require_once 'CRM/Core/BAO/CustomOption.php';
     CRM_Core_BAO_CustomOption::getAssoc('civicrm_contribution_page', $this->_id, $this->_values);
     // get the profile ids
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id, 'weight' => 1);
     $this->_values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     $ufJoinParams['weight'] = 2;
     $this->_values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:24,代码来源:Preview.php


示例4: _civicrm_activity_formatted_param

/**
 * take the input parameter list as specified in the data model and 
 * convert it into the same format that we use in QF and BAO object
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contact.
 * @param array  $values       The reformatted properties that we can use internally
 *
 * @param array  $create       Is the formatted Values array going to
 *                             be used for CRM_Activity_BAO_Activity::create()
 *
 * @return array|CRM_Error
 * @access public
 */
function _civicrm_activity_formatted_param(&$params, &$values, $create = false)
{
    $fields =& CRM_Activity_DAO_Activity::fields();
    _civicrm_store_values($fields, $params, $values);
    require_once 'CRM/Core/OptionGroup.php';
    $customFields = CRM_Core_BAO_CustomField::getFields('Activity');
    foreach ($params as $key => $value) {
        // ignore empty values or empty arrays etc
        if (CRM_Utils_System::isNull($value)) {
            continue;
        }
        //Handling Custom Data
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            $values[$key] = $value;
            $type = $customFields[$customFieldID]['html_type'];
            if ($type == 'CheckBox' || $type == 'Multi-Select') {
                $mulValues = explode(',', $value);
                $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                $values[$key] = array();
                foreach ($mulValues as $v1) {
                    foreach ($customOption as $customValueID => $customLabel) {
                        $customValue = $customLabel['value'];
                        if (strtolower($customLabel['label']) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
                            if ($type == 'CheckBox') {
                                $values[$key][$customValue] = 1;
                            } else {
                                $values[$key][] = $customValue;
                            }
                        }
                    }
                }
            } else {
                if ($type == 'Select' || $type == 'Radio') {
                    $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                    foreach ($customOption as $customValue => $customLabel) {
                        if (strtolower($customLabel) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
                            $values[$key] = $customValue;
                        }
                    }
                }
            }
        }
    }
    return null;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:59,代码来源:utils.php


示例5: 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 bool $html
  *   Replace tokens with HTML or plain text.
  *
  * @param bool $escapeSmarty
  *
  * @return string
  *   The processed string
  */
 public static function &replaceOrgTokens($str, &$org, $html = FALSE, $escapeSmarty = FALSE)
 {
     self::$_tokens['org'] = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields('Organization')), array('address', 'display_name', 'checksum', 'contact_id'));
     $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;
                 }
             }
         } elseif ($token == 'checksum') {
             $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($org['contact_id']);
             $value = "cs={$cs}";
         } elseif ($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 {
             $value = CRM_Utils_Array::retrieveValueRecursive($org, $token);
         }
         self::token_replace('org', $token, $value, $str, $escapeSmarty);
     }
     return $str;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:64,代码来源:Token.php


示例6: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues('Option');
     // set values for custom field properties and save
     require_once 'CRM/Core/DAO/OptionValue.php';
     require_once 'CRM/Utils/String.php';
     $customOption =& new CRM_Core_DAO_OptionValue();
     $customOption->label = $params['label'];
     $customOption->name = CRM_Utils_String::titleToVar($params['label']);
     $customOption->weight = $params['weight'];
     $customOption->value = $params['value'];
     $customOption->is_active = CRM_Utils_Array::value('is_active', $params, false);
     if ($this->_action == CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_optionGroupID);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
         CRM_Core_BAO_CustomOption::del($this->_id);
         CRM_Core_Session::setStatus(ts('Your multiple choice option has been deleted', array(1 => $customOption->label)));
         return;
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $customOption->id = $this->_id;
         CRM_Core_BAO_CustomOption::updateCustomValues($params);
     }
     if ($this->_id) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id');
     }
     $fieldValues = array('option_group_id' => $this->_optionGroupID);
     $customOption->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, $params['weight'], $fieldValues);
     $customOption->option_group_id = $this->_optionGroupID;
     $customField =& new CRM_Core_DAO_CustomField();
     $customField->id = $this->_fid;
     if ($customField->find(true) && ($customField->html_type == 'CheckBox' || $customField->html_type == 'AdvMulti-Select' || $customField->html_type == 'Multi-Select')) {
         $defVal = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($customField->default_value, 1, -1));
         if (CRM_Utils_Array::value('default_value', $params)) {
             if (!in_array($customOption->value, $defVal)) {
                 if (empty($defVal[0])) {
                     $defVal = array($customOption->value);
                 } else {
                     $defVal[] = $customOption->value;
                 }
                 $customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $defVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
                 $customField->save();
             }
         } else {
             if (in_array($customOption->value, $defVal)) {
                 $tempVal = array();
                 foreach ($defVal as $v) {
                     if ($v != $customOption->value) {
                         $tempVal[] = $v;
                     }
                 }
                 $customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $tempVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
                 $customField->save();
             }
         }
     } else {
         switch ($customField->data_type) {
             case 'Money':
                 require_once 'CRM/Utils/Rule.php';
                 $customOption->value = CRM_Utils_Rule::cleanMoney($customOption->value);
                 break;
             case 'Int':
                 $customOption->value = intval($customOption->value);
                 break;
             case 'Float':
                 $customOption->value = floatval($customOption->value);
                 break;
         }
         if (CRM_Utils_Array::value('default_value', $params)) {
             $customField->default_value = $customOption->value;
             $customField->save();
         } else {
             if ($customField->find(true) && $customField->default_value == $customOption->value) {
                 // this is the case where this option is the current default value and we have been reset
                 $customField->default_value = 'null';
                 $customField->save();
             }
         }
     }
     $customOption->save();
     CRM_Core_Session::setStatus(ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)));
     $buttonName = $this->controller->getButtonName();
     $session =& CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another option.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/option', 'reset=1&action=add&fid=' . $this->_fid . '&gid=' . $this->_gid));
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:97,代码来源:Option.php


示例7: autocomplete

 /**
  * Function to fetch the values 
  */
 function autocomplete(&$config)
 {
     $fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
     $optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
     $label = CRM_Utils_Type::escape($_GET['s'], 'String');
     require_once 'CRM/Core/BAO/CustomOption.php';
     $selectOption =& CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
     $completeList = null;
     foreach ($selectOption as $id => $value) {
         if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
             echo $completeList = "{$value}|{$id}\n";
         }
     }
     exit;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:18,代码来源:AJAX.php


示例8: run

 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action. 
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function run()
 {
     require_once 'CRM/Core/BAO/CustomField.php';
     // get the field id
     $this->_fid = CRM_Utils_Request::retrieve('fid', $this, false, 0);
     $this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, 0);
     if ($this->_fid) {
         $fieldTitle = CRM_Core_BAO_CustomField::getTitle($this->_fid);
         $this->assign('fid', $this->_fid);
         $this->assign('fieldTitle', $fieldTitle);
         CRM_Utils_System::setTitle(ts('%1 - Multiple Choice Options', array(1 => $fieldTitle)));
     }
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     // default to 'browse'
     // assign vars to templates
     $this->assign('action', $action);
     $id = CRM_Utils_Request::retrieve('id', $this, false, 0);
     // what action to take ?
     if ($action & (CRM_CORE_ACTION_UPDATE | CRM_CORE_ACTION_ADD | CRM_CORE_ACTION_VIEW | CRM_CORE_ACTION_DELETE)) {
         $this->edit($action);
         // no browse for edit/update/view
     } else {
         if ($action & CRM_CORE_ACTION_DISABLE) {
             CRM_Core_BAO_CustomOption::setIsActive($id, 0);
         } else {
             if ($action & CRM_CORE_ACTION_ENABLE) {
                 CRM_Core_BAO_CustomOption::setIsActive($id, 1);
             }
         }
         $this->browse();
     }
     // Call the parents run method
     parent::run();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:46,代码来源:Option.php


示例9: setProfileDefaults

 /**
  * Function to set default values for custom data used in profile
  *
  * @params int    $customFieldId custom field id
  * @params string $elementName   custom field name
  * @params array  $defaults      associated array of fields
  * @params int    $contactId     contact id
  * @param  int    $mode          profile mode
  * 
  * @static
  * @access public
  */
 function setProfileDefaults($customFieldId, $elementName, &$defaults, $contactId = null, $mode = null)
 {
     //get the type of custom field
     $customField =& new CRM_Core_BAO_CustomField();
     $customField->id = $customFieldId;
     $customField->find(true);
     require_once "CRM/Profile/Form.php";
     if (!$contactId) {
         if ($mode == CRM_PROFILE_FORM_MODE_CREATE) {
             $value = $customField->default_value;
         }
     } else {
         // make sure the custom value exists
         $cv =& new CRM_Core_BAO_CustomValue();
         $cv->custom_field_id = $customFieldId;
         $cv->entity_table = 'civicrm_contact';
         $cv->entity_id = $contactId;
         if ($cv->find(true)) {
             switch ($customField->data_type) {
                 case 'String':
                     $value = $cv->char_data;
                     break;
                 case 'Int':
                 case 'Boolean':
                 case 'StateProvince':
                 case 'Country':
                     $value = $cv->int_data;
                     break;
                 case 'Float':
                     $value = $cv->int_float;
                     break;
                 case 'Money':
                     $value = $cv->decimal_data;
                     break;
                 case 'Memo':
                     $value = $cv->memo_data;
                     break;
                 case 'Date':
                     $value = $cv->date_data;
                     break;
             }
         }
     }
     //set defaults if mode is registration / edit
     if (!trim($value) && $mode != CRM_PROFILE_FORM_MODE_SEARCH) {
         $value = $customField->default_value;
     }
     switch ($customField->html_type) {
         case 'CheckBox':
             $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldId, $inactiveNeeded);
             $defaults[$elementName] = array();
             $checkedValue = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $value);
             foreach ($customOption as $val) {
                 if (in_array($val['value'], $checkedValue)) {
                     $defaults[$elementName][$val['value']] = 1;
                 } else {
                     $defaults[$elementName][$val['value']] = 0;
                 }
             }
             break;
             //added a case for Multi-Select option
         //added a case for Multi-Select option
         case 'Multi-Select':
             $customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded);
             $defaults[$elementName] = array();
             $checkedValue = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $value);
             foreach ($customOption as $val) {
                 if (in_array($val['value'], $checkedValue)) {
                     $defaults[$elementName][$val['value']] = $val['value'];
                 }
             }
             break;
         default:
             $defaults[$elementName] = $value;
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:88,代码来源:CustomField.php


示例10: browse

 /**
  * Browse the listing.
  *
  * @return void
  */
 public function browse()
 {
     $dateFields = NULL;
     $cgcount = 0;
     $attributes = array();
     $dateFieldsVals = NULL;
     if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
         $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
         $multiRecordFields = array();
         $fieldIDs = NULL;
         $result = NULL;
         $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
         $multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
         $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('gid', $this->_profileId);
         }
         $this->assign('reachedMax', $reached);
         if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
             $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
         }
     } elseif ($this->_pageViewType == 'customDataView') {
         // require custom group id for _pageViewType of customDataView
         $customGroupId = $this->_customGroupId;
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('customGroupId', $customGroupId);
             $this->assign('ctype', $this->_contactType);
         }
         $this->assign('reachedMax', $reached);
         // custom group info : this consists of the field title of group fields
         $groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE);
         // field ids of fields in_selector for the custom group id provided
         $fieldIDs = array_keys($groupDetail[$customGroupId]['fields']);
         // field labels for headers
         $fieldLabels = $groupDetail[$customGroupId]['fields'];
         // from the above customGroupInfo we can get $this->_customGroupTitle
         $this->_customGroupTitle = $groupDetail[$customGroupId]['title'];
     }
     if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
         $options = array();
         $returnProperities = array('html_type', 'data_type', 'date_format', 'time_format', 'default_value', 'is_required');
         foreach ($fieldIDs as $key => $fieldID) {
             $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
             $param = array('id' => $fieldIDs[$key]);
             $returnValues = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
             if ($returnValues['data_type'] == 'Date') {
                 $dateFields[$fieldIDs[$key]] = 1;
                 $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
                 $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
                 $timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
             }
             $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
             if (!empty($optionValuePairs)) {
                 foreach ($optionValuePairs as $optionPairs) {
                     $options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
                 }
             }
             $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
             $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
             $options[$fieldIDs[$key]]['attributes']['is_required'] = !empty($returnValues['is_required']);
             $options[$fieldIDs[$key]]['attributes']['default_value'] = CRM_Utils_Array::value('default_value', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
         }
         // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
         $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
         if ($this->_pageViewType == 'profileDataView') {
             if (!empty($fieldIDs)) {
                 //get the group info of multi rec fields in listing view
                 $fieldInput = $fieldIDs;
                 $fieldIdInput = $fieldIDs[0];
             } else {
                 //if no listing fields exist, take the group title for display
                 $nonListingFieldIds = array_keys($multiRecordFields);
                 $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
                 $fieldIdInput = $singleField;
                 $singleField = array($singleField);
                 $fieldInput = $singleField;
             }
             $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
             $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
         }
         // $cgcount is defined before 'if' condition as enitiy may have no record
         // and $cgcount is used to build new record url
         $cgcount = 1;
         if ($result && !empty($result)) {
             $links = self::links();
             if ($this->_pageViewType == 'profileDataView') {
                 $pageCheckSum = $this->get('pageCheckSum');
                 if ($pageCheckSum) {
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:MultipleRecordFieldsListing.php


示例11: add

 /**
  * Add an Option Value.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Reference array contains the id.
  *
  *
  * @return CRM_Core_DAO_OptionValue
  */
 public static function add(&$params, &$ids)
 {
     // CRM-10921: do not reset attributes to default if this is an update
     //@todo consider if defaults are being set in the right place. 'dumb' defaults like
     // these would be usefully set @ the api layer so they are visible to api users
     // complex defaults like the domain id below would make sense in the setDefauls function
     // but unclear what other ways this function is being used
     if (empty($ids['optionValue'])) {
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
         $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
         $params['is_optgroup'] = CRM_Utils_Array::value('is_optgroup', $params, FALSE);
         $params['filter'] = CRM_Utils_Array::value('filter', $params, FALSE);
     } elseif (isset($params['value'])) {
         CRM_Core_BAO_CustomOption::updateValue($ids['optionValue'], $params['value']);
     }
     // action is taken depending upon the mode
     $optionValue = new CRM_Core_DAO_OptionValue();
     $optionValue->copyValues($params);
     if (!empty($params['is_default'])) {
         $query = 'UPDATE civicrm_option_value SET is_default = 0 WHERE  option_group_id = %1';
         // tweak default reset, and allow multiple default within group.
         if ($resetDefaultFor = CRM_Utils_Array::value('reset_default_for', $params)) {
             if (is_array($resetDefaultFor)) {
                 $colName = key($resetDefaultFor);
                 $colVal = $resetDefaultFor[$colName];
                 $query .= " AND ( {$colName} IN (  {$colVal} ) )";
             }
         }
         $p = array(1 => array($params['option_group_id'], 'Integer'));
         CRM_Core_DAO::executeQuery($query, $p);
     }
     // CRM-13814 : evalute option group id
     if (!array_key_exists('option_group_id', $params) && !empty($ids['optionValue'])) {
         $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $ids['optionValue'], 'option_group_id', 'id');
     } else {
         $groupId = $params['option_group_id'];
     }
     $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $groupId, 'name', 'id');
     if (in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups)) {
         $optionValue->domain_id = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID());
     }
     $optionValue->id = CRM_Utils_Array::value('optionValue', $ids);
     $optionValue->save();
     CRM_Core_PseudoConstant::flush();
     return $optionValue;
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:57,代码来源:OptionValue.php


示例12: updateSavedSearch

 /**
  * Update saved search for multi-select custom fields on DB upgrade
  *
  * @param CRM_Queue_TaskContext $ctx
  *
  * @return bool TRUE for success
  */
 public static function updateSavedSearch(CRM_Queue_TaskContext $ctx)
 {
     $sql = "SELECT id, form_values FROM civicrm_saved_search";
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
         $copy = $formValues = unserialize($dao->form_values);
         $update = FALSE;
         foreach ($copy as $field => $data_value) {
             if (preg_match('/^custom_/', $field) && is_array($data_value) && !array_key_exists("{$field}_operator", $formValues)) {
                 // Now check for CiviCRM_OP_OR as either key or value in the data_value array.
                 // This is the conclusive evidence of an old-style data format.
                 if (array_key_exists('CiviCRM_OP_OR', $data_value) || FALSE !== array_search('CiviCRM_OP_OR', $data_value)) {
                     // We have old style data. Mark this record to be updated.
                     $update = TRUE;
                     $op = 'and';
                     if (!preg_match('/^custom_([0-9]+)/', $field, $matches)) {
                         // fatal error?
                         continue;
                     }
                     $fieldID = $matches[1];
                     if (array_key_exists('CiviCRM_OP_OR', $data_value)) {
                         // This indicates data structure identified by jamie in the form:
                         // value1 => 1, value2 => , value3 => 1.
                         $data_value = array_keys($data_value, 1);
                         // If CiviCRM_OP_OR - change OP from default to OR
                         if ($data_value['CiviCRM_OP_OR'] == 1) {
                             $op = 'or';
                         }
                         unset($data_value['CiviCRM_OP_OR']);
                     } else {
                         // The value is here, but it is not set as a key.
                         // This is using the style identified by Monish - the existence of the value
                         // indicates an OR search and values are set in the form of:
                         // 0 => value1, 1 => value1, 3 => value2.
                         $key = array_search('CiviCRM_OP_OR', $data_value);
                         $op = 'or';
                         unset($data_value[$key]);
                     }
                     //If only Or operator has been chosen, means we need to select all values and
                     //so to execute OR operation between these values according to new data structure
                     if (count($data_value) == 0 && $op == 'or') {
                         $customOption = CRM_Core_BAO_CustomOption::getCustomOption($fieldID);
                         foreach ($customOption as $option) {
                             $data_value[] = CRM_Utils_Array::value('value', $option);
                         }
                     }
                     $formValues[$field] = $data_value;
                     $formValues["{$field}_operator"] = $op;
                 }
             }
         }
         if ($update) {
             $sql = "UPDATE civicrm_saved_search SET form_values = %0 WHERE id = %1";
             CRM_Core_DAO::executeQuery($sql, array(array(serialize($formValues), 'String'), array($dao->id, 'Integer')));
         }
     }
     return TRUE;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:65,代码来源:FourFive.php


示例13: autocomplete

 /**
  * Function to fetch the values
  */
 static function autocomplete()
 {
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('cfid', 'ogid', 'sigts'));
     if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['sigts'] + self::AUTOCOMPLETE_TTL || !$signer->validate($_REQUEST['sig'], $_REQUEST)) {
         CRM_Utils_System::civiExit();
     }
     $fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
     $optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
     $label = CRM_Utils_Type::escape($_GET['s'], 'String');
     $selectOption = CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
     $completeList = NULL;
     foreach ($selectOption as $id => $value) {
         if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
             echo $completeList = "{$value}|{$id}\n";
         }
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:21,代码来源:AJAX.php


示例14: 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


示例15: browse

 /**
  * Browse the listing
  *
  * @return void
  * @access public
  */
 function browse()
 {
     if ($this->_profileId) {
         $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
         $multiRecordFields = array();
         $fieldIDs = NULL;
         $result = NULL;
         $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
         $multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
         $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('gid', $this->_profileId);
         }
         $this->assign('reachedMax', $reached);
         if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
             $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
         }
     }
     if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
         $options = array();
         $returnProperities = array('html_type', 'data_type', 'date_format', 'time_format');
         foreach ($fieldIDs as $key => $fieldID) {
             $fieldIDs[$key] = CRM_Core_BAO_CustomField::getKeyID($fieldID);
             $param = array('id' => $fieldIDs[$key]);
             $returnValues = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
             $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
             if (!empty($optionValuePairs)) {
                 foreach ($optionValuePairs as $optionPairs) {
                     $options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
                 }
             }
             $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
             $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
             $options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
         }
         $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
         if (!empty($fieldIDs)) {
             //get the group info of multi rec fields in listing view
             $fieldInput = $fieldIDs;
             $fieldIdInput = $fieldIDs[0];
         } else {
             //if no listing fields exist, take the group title for display
             $nonListingFieldIds = array_keys($multiRecordFields);
             $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
             $fieldIdInput = $singleField;
             $singleField = array($singleField);
             $fieldInput = $singleField;
         }
         $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
         $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
         if ($result && !empty($result)) {
             $links = self::links();
             $pageCheckSum = $this->get('pageCheckSum');
             if ($pageCheckSum) {
                 foreach ($links as $key => $link) {
                     $links[$key] = $link['qs'] . "&cs=%%cs%%";
                 }
             }
             $linkAction = array_sum(array_keys($this->links()));
             foreach ($result as $recId => &$value) {
                 foreach ($value as $fieldId => &$val) {
                     if (is_numeric($fieldId)) {
                         $customValue =& $val;
                         $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
                         if (!$customValue) {
                             $customValue = "";
                         }
                         $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, 'id' => $this->_contactId, 'onPopupClose' => $this->_onPopupClose);
                         if ($pageCheckSum) {
                             $actionParams['cs'] = $pageCheckSum;
                         }
                         $value['action'] = CRM_Core_Action::formLink($links, $linkAction, $actionParams, ts('more'), FALSE, 'profile.multiValue.row', 'customValue', $fieldId);
                     }
                 }
             }
         }
     }
     $headers = array();
     if (!empty($fieldIDs)) {
         foreach ($fieldIDs as $fieldID) {
             $headers[$fieldID] = $customGroupInfo[$fieldID]['fieldLabel'];
         }
     }
     $this->assign('customGroupTitle', $this->_customGroupTitle);
     $this->assign('headers', $headers);
     $this->assign('records', $result);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:97,代码来源:MultipleRecordFieldsListing.php


示例16: setProfileDefaults

 /**
  * Function to set profile defaults
  *
  * @params int     $contactId      contact id
  * @params array   $fields         associative array of fields
  * @params array   $defaults       defaults array
  * @params boolean $singleProfile  true for single profile else false(batch update)
  * @params int     $componentId    id for specific components like contribute, event etc
  *
  * @return null
  * @static
  * @access public
  */
 static function setProfileDefaults($contactId, &$fi 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_BAO_CustomValue类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_BAO_CustomGroup类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap