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


PHP CRM_Core_BAO_CustomField::create方法代码示例

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


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

示例1: testGetFields

 public function testGetFields()
 {
     $customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
     $fields = array('label' => 'testFld1', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup['id']);
     CRM_Core_BAO_CustomField::create($fields);
     $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.');
     $fields = array('label' => 'testFld2', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup['id']);
     CRM_Core_BAO_CustomField::create($fields);
     $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.');
     $this->customGroupDelete($customGroup['id']);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:11,代码来源:CustomFieldTest.php

示例2: testGetDisplayedValues

 public function testGetDisplayedValues()
 {
     $customGroup = Custom::createGroup(array(), 'Individual');
     $fields = array('label' => 'testCountryFld1', 'data_type' => 'Country', 'html_type' => 'Select Country', 'is_active' => 1, 'default_value' => 1228, 'custom_group_id' => $customGroup->id);
     $customField1 = CRM_Core_BAO_CustomField::create($fields);
     $customFieldID1 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
     $options = array();
     $options[$customFieldID1]['attributes'] = array('label' => 'testCountryFld1', 'data_type' => 'Country', 'html_type' => 'Select Country');
     $display = CRM_Core_BAO_CustomField::getDisplayValue($fields['default_value'], $customFieldID1, $options);
     $this->assertEquals('UNITED STATES', $display, 'Confirm Country display Name');
     Custom::deleteGroup($customGroup);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:12,代码来源:CustomFieldTest.php

示例3: testGetFields

 public function testGetFields()
 {
     $customGroup = Custom::createGroup(array(), 'Individual');
     $fields = array('label' => 'testFld1', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup->id);
     $customField1 = CRM_Core_BAO_CustomField::create($fields);
     $customFieldID1 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
     $fields = array('label' => 'testFld2', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup->id);
     $customField2 = CRM_Core_BAO_CustomField::create($fields);
     $customFieldID2 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
     $getCustomFields = array();
     $getCustomFields = CRM_Core_BAO_CustomField::getFields('Individual', TRUE, TRUE);
     //$this->assertEquals( 'testFld1',  $getCustomFields[$customFieldID1][0], 'Confirm First Custom field label' );
     //$this->assertEquals( 'testFld2',  $getCustomFields[$customFieldID2][0], 'Confirm Second Custom field label' );
     Custom::deleteGroup($customGroup);
 }
开发者ID:vincent1892,项目名称:civicrm-core,代码行数:15,代码来源:CustomFieldTest.php

示例4: civicrm_api3_custom_field_create

/**
 * Create a 'custom field' within a custom field group.
 * We also empty the static var in the getfields
 * function after deletion so that the field is available for us (getfields manages date conversion
 * among other things
 *
 * @param $params array  Associative array of property name/value pairs to create new custom field.
 *
 * @return Newly API success object
 *
 * @access public
 *
 * @example CustomFieldCreate.php
 * {@getfields CustomField_create}
 * {@example CustomFieldCreate.php 0}
 *
 */
function civicrm_api3_custom_field_create($params)
{
    // Array created for passing options in params
    if (isset($params['option_values']) && is_array($params['option_values'])) {
        foreach ($params['option_values'] as $key => $value) {
            $params['option_label'][$key] = $value['label'];
            $params['option_value'][$key] = $value['value'];
            $params['option_status'][$key] = $value['is_active'];
            $params['option_weight'][$key] = $value['weight'];
        }
    }
    $values = array();
    $customField = CRM_Core_BAO_CustomField::create($params);
    _civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]);
    _civicrm_api3_custom_field_flush_static_caches();
    return civicrm_api3_create_success($values, $params, 'custom_field', $customField);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:34,代码来源:CustomField.php

示例5: testCreateWithCustomData

 /**
  * Create() method with custom data.
  */
 public function testCreateWithCustomData()
 {
     $contactId = $this->individualCreate();
     //create custom data
     $customGroup = $this->customGroupCreate(array('extends' => 'Contribution'));
     $customGroupID = $customGroup['id'];
     $customGroup = $customGroup['values'][$customGroupID];
     $fields = array('label' => 'testFld', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroupID);
     $customField = CRM_Core_BAO_CustomField::create($fields);
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => NULL, 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww322323', 'invoice_id' => '22ed39c9e9ee6ef6031621ce0eafe6da70', 'thankyou_date' => '20080522');
     $params['custom'] = array($customField->id => array(-1 => array('value' => 'Test custom value', 'type' => 'String', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroupID, 'table_name' => $customGroup['table_name'], 'column_name' => $customField->column_name, 'file_id' => NULL)));
     $contribution = CRM_Contribute_BAO_Contribution::create($params);
     // Check that the custom field value is saved
     $customValueParams = array('entityID' => $contribution->id, 'custom_' . $customField->id => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($customValueParams);
     $this->assertEquals('Test custom value', $values['custom_' . $customField->id], 'Check the custom field value');
     $this->assertEquals($params['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id for Conribution.');
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:22,代码来源:ContributionTest.php

示例6: civicrm_api3_custom_field_create

/**
 * Create a 'custom field' within a custom field group.
 *
 * We also empty the static var in the getfields
 * function after deletion so that the field is available for us (getfields manages date conversion
 * among other things
 *
 * @param array $params
 *   Array per getfields metadata.
 *
 * @return array
 *   API success array
 */
function civicrm_api3_custom_field_create($params)
{
    // Array created for passing options in params.
    if (isset($params['option_values']) && is_array($params['option_values'])) {
        $weight = 0;
        foreach ($params['option_values'] as $key => $value) {
            // Translate simple key/value pairs into full-blown option values
            if (!is_array($value)) {
                $value = array('label' => $value, 'value' => $key, 'is_active' => 1, 'weight' => $weight);
                $key = $weight++;
            }
            $params['option_label'][$key] = $value['label'];
            $params['option_value'][$key] = $value['value'];
            $params['option_status'][$key] = $value['is_active'];
            $params['option_weight'][$key] = $value['weight'];
        }
    }
    $values = array();
    $customField = CRM_Core_BAO_CustomField::create($params);
    _civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]);
    _civicrm_api3_custom_field_flush_static_caches();
    return civicrm_api3_create_success($values, $params, 'CustomField', $customField);
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:36,代码来源:CustomField.php

示例7: civicrm_api3_custom_field_create

/**
 * Create a 'custom field' within a custom field group.
 * We also empty the static var in the getfields
 * function after deletion so that the field is available for us (getfields manages date conversion
 * among other things
 *
 * @param $params array  Associative array of property name/value pairs to create new custom field.
 *
 * @return Newly API success object
 *
 * @access public
 *
 * @example CustomFieldCreate.php
 * {@getfields CustomField_create}
 * {@example CustomFieldCreate.php 0}
 *
 */
function civicrm_api3_custom_field_create($params)
{
    if (!CRM_Utils_Array::value('option_type', $params)) {
        if (CRM_Utils_Array::value('id', $params)) {
            $params['option_type'] = 2;
        } else {
            $params['option_type'] = 1;
        }
    }
    // Array created for passing options in params
    if (isset($params['option_values']) && is_array($params['option_values'])) {
        foreach ($params['option_values'] as $key => $value) {
            $params['option_label'][$key] = $value['label'];
            $params['option_value'][$key] = $value['value'];
            $params['option_status'][$key] = $value['is_active'];
            $params['option_weight'][$key] = $value['weight'];
        }
    }
    $customField = CRM_Core_BAO_CustomField::create($params);
    civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
    _civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]);
    return civicrm_api3_create_success($values, $params, 'custom_field', $customField);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:40,代码来源:CustomField.php

示例8: testDeleteContact

 /**
  * Test case for deleteContact( ).
  */
 public function testDeleteContact()
 {
     $contactParams = $this->contactParams();
     $customGroup = $this->customGroupCreate();
     $fields = array('label' => 'testFld', 'data_type' => 'String', 'html_type' => 'Text', 'custom_group_id' => $customGroup['id']);
     $customField = CRM_Core_BAO_CustomField::create($fields);
     $contactParams['custom'] = array($customField->id => array(-1 => array('value' => 'Test custom value', 'type' => 'String', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroup['id'], 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'], 'column_name' => $customField->column_name, 'file_id' => NULL)));
     //create contact
     $contact = CRM_Contact_BAO_Contact::create($contactParams);
     $contactId = $contact->id;
     //delete contact permanently.
     CRM_Contact_BAO_Contact::deleteContact($contactId, FALSE, TRUE);
     //Now check DB for location elements.
     //Now check DB for Address
     $this->assertDBNull('CRM_Core_DAO_Address', $contactId, 'id', 'street_address', 'Database check, Address deleted successfully.');
     //Now check DB for Email
     $this->assertDBNull('CRM_Core_DAO_Email', $contactId, 'id', 'email', 'Database check, Email deleted successfully.');
     //Now check DB for Phone
     $this->assertDBNull('CRM_Core_DAO_Phone', $contactId, 'id', 'phone', 'Database check, Phone deleted successfully.');
     //Now check DB for Mobile
     $this->assertDBNull('CRM_Core_DAO_Phone', $contactId, 'id', 'phone', 'Database check, Mobile deleted successfully.');
     //Now check DB for IM
     $this->assertDBNull('CRM_Core_DAO_IM', $contactId, 'id', 'name', 'Database check, IM deleted successfully.');
     //Now check DB for openId
     $this->assertDBNull('CRM_Core_DAO_OpenID', $contactId, 'id', 'openid', 'Database check, openId deleted successfully.');
     // Check that the custom field value is no longer present
     $params = array('entityID' => $contactId, 'custom_' . $customField->id => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals(CRM_Utils_Array::value("custom_" . $customField->id, $values), '', 'Verify that the data value is empty for contact ' . $contactId);
     $this->assertEquals($values['is_error'], 1, 'Verify that is_error = 0 (success).');
     //Now check DB for contact.
     $this->assertDBNull('CRM_Contact_DAO_Contact', $contactId, 'id', 'sort_name', 'Database check, contact deleted successfully.');
     $this->quickCleanup(array('civicrm_contact', 'civicrm_note'));
     $this->customGroupDelete($customGroup['id']);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:38,代码来源:ContactTest.php

示例9: postProcess

 /**
  * Process the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $dataTypeKey = $this->_defaultDataType[0];
         $params['data_type'] = self::$_dataTypeKeys[$this->_defaultDataType[0]];
         $params['html_type'] = self::$_dataToHTML[$this->_defaultDataType[0]][$this->_defaultDataType[1]];
     } else {
         $dataTypeKey = $params['data_type'][0];
         $params['html_type'] = self::$_dataToHTML[$params['data_type'][0]][$params['data_type'][1]];
         $params['data_type'] = self::$_dataTypeKeys[$params['data_type'][0]];
     }
     //fix for 'is_search_range' field.
     if (in_array($dataTypeKey, array(1, 2, 3, 5))) {
         if (!CRM_Utils_Array::value('is_searchable', $params)) {
             $params['is_search_range'] = 0;
         }
     } else {
         $params['is_search_range'] = 0;
     }
     $filter = 'null';
     if ($dataTypeKey == 11 && CRM_Utils_Array::value('filter_selected', $params)) {
         if ($params['filter_selected'] == 'Advance' && trim(CRM_Utils_Array::value('filter', $params))) {
             $filter = trim($params['filter']);
         } elseif ($params['filter_selected'] == 'Group' && CRM_Utils_Array::value('group_id', $params)) {
             $filter = 'action=lookup&group=' . implode(',', $params['group_id']);
         }
     }
     $params['filter'] = $filter;
     // fix for CRM-316
     $oldWeight = NULL;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('custom_group_id' => $this->_gid);
         if ($this->_id) {
             $oldWeight = $this->_values['weight'];
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $oldWeight, $params['weight'], $fieldValues);
     }
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     //store the primary key for State/Province or Country as default value.
     if (strlen(trim($params['default_value']))) {
         switch ($params['data_type']) {
             case 'StateProvince':
                 $fieldStateProvince = $strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_state_province\n WHERE LOWER(name) = '{$fieldStateProvince}'\n    OR abbreviation = '{$fieldStateProvince}'";
                 $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
             case 'Country':
                 $fieldCountry = $strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_country\n WHERE LOWER(name) = '{$fieldCountry}'\n    OR iso_code = '{$fieldCountry}'";
                 $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
         }
     }
     // The text_length attribute for Memo fields is in a different input as there
     // are different label, help text and default value than for other type fields
     if ($params['data_type'] == "Memo") {
         $params['text_length'] = $params['note_length'];
     }
     // need the FKEY - custom group id
     $params['custom_group_id'] = $this->_gid;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $customField = CRM_Core_BAO_CustomField::create($params);
     // reset the cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.', array(1 => $customField->label)), ts('Saved'), 'success');
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another custom field.'), '', 'info');
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/add', 'reset=1&action=add&gid=' . $this->_gid));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:92,代码来源:Field.php

示例10: crm_create_custom_field

/**
 * Defines 'custom field' within a group.
 *
 * @param $custom_group object Valid custom_group object
 *
 * @param $params       array  Associative array of property name/value pairs to create new custom field.
 *
 * @return Newly created custom_field object
 *
 * @access public 
 *
 */
function crm_create_custom_field(&$custom_group, $params)
{
    _crm_initialize();
    if (!is_array($params)) {
        return _crm_error("params is not an array ");
    }
    if (!isset($custom_group->id)) {
        return _crm_error("group id is not set in custom_group object");
    }
    $params['custom_group_id'] = $custom_group->id;
    $error = _crm_check_required_fields($params, 'CRM_Core_DAO_CustomField');
    if (is_a($error, 'CRM_Core_Error')) {
        return $error;
    }
    require_once 'CRM/Core/BAO/CustomField.php';
    $customField = CRM_Core_BAO_CustomField::create($params);
    return $customField;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:30,代码来源:CustomGroup.php

示例11: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $dataTypeKey = $this->_defaultDataType[0];
         $params['data_type'] = self::$_dataTypeKeys[$this->_defaultDataType[0]];
         $params['html_type'] = self::$_dataToHTML[$this->_defaultDataType[0]][$this->_defaultDataType[1]];
     } else {
         $dataTypeKey = $params['data_type'][0];
         $params['html_type'] = self::$_dataToHTML[$params['data_type'][0]][$params['data_type'][1]];
         $params['data_type'] = self::$_dataTypeKeys[$params['data_type'][0]];
     }
     //fix for 'is_search_range' field.
     if (in_array($dataTypeKey, array(1, 2, 3, 5))) {
         if (!CRM_Utils_Array::value('is_searchable', $params)) {
             $params['is_search_range'] = 0;
         }
     } else {
         $params['is_search_range'] = 0;
     }
     // fix for CRM-316
     $oldWeight = null;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('custom_group_id' => $this->_gid);
         if ($this->_id) {
             $oldWeight = $this->_values['weight'];
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $oldWeight, $params['weight'], $fieldValues);
     }
     //store the primary key for State/Province or Country as default value.
     if (strlen(trim($params['default_value']))) {
         switch ($params['data_type']) {
             case 'StateProvince':
                 $fieldStateProvince = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_state_province \n WHERE LOWER(name) = '{$fieldStateProvince}' \n    OR abbreviation = '{$fieldStateProvince}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
             case 'Country':
                 $fieldCountry = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_country\n WHERE LOWER(name) = '{$fieldCountry}' \n    OR iso_code = '{$fieldCountry}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
         }
     }
     // need the FKEY - custom group id
     $params['custom_group_id'] = $this->_gid;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $customField = CRM_Core_BAO_CustomField::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.', array(1 => $customField->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 custom field.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=add&gid=' . $this->_gid));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Field.php

示例12: civicrm_custom_field_create

/**
 * Defines 'custom field' within a group.
 *
 *
 * @param $params       array  Associative array of property name/value pairs to create new custom field.
 *
 * @return Newly created custom_field id array
 *
 * @access public 
 *
 */
function civicrm_custom_field_create($params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error("params is not an array ");
    }
    if (!CRM_Utils_Array::value('custom_group_id', $params)) {
        return civicrm_create_error("Missing Required field :custom_group_id");
    }
    if (!CRM_Utils_Array::value('label', $params)) {
        return civicrm_create_error("Missing Required field :label");
    }
    if (!CRM_Utils_Array::value('option_type', $params)) {
        if (CRM_Utils_Array::value('id', $params)) {
            $params['option_type'] = 2;
        } else {
            $params['option_type'] = 1;
        }
    }
    $error = _civicrm_check_required_fields($params, 'CRM_Core_DAO_CustomField');
    if (is_a($error, 'CRM_Core_Error')) {
        return civicrm_create_error($error->_errors[0]['message']);
    }
    // Array created for passing options in params
    if (isset($params['option_values']) && is_array($params['option_values'])) {
        foreach ($params['option_values'] as $key => $value) {
            $params['option_label'][$value['weight']] = $value['label'];
            $params['option_value'][$value['weight']] = $value['value'];
            $params['option_status'][$value['weight']] = $value['is_active'];
            $params['option_weight'][$value['weight']] = $value['weight'];
        }
    }
    require_once 'CRM/Core/BAO/CustomField.php';
    $customField = CRM_Core_BAO_CustomField::create($params);
    $values['customFieldId'] = $customField->id;
    if (is_a($customField, 'CRM_Core_Error') && is_a($column, 'CRM_Core_Error')) {
        return civicrm_create_error($customField->_errors[0]['message']);
    } else {
        return civicrm_create_success($values);
    }
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:52,代码来源:CustomGroup.php

示例13: upgrade_4203

 /**
    * Example: Run an upgrade with a query that touches many (potentially
    * millions) of records by breaking it up into smaller chunks.
    *
    * @return TRUE on success
    * @throws Exception
   public function upgrade_4203() {
     $this->ctx->log->info('Planning update 4203'); // PEAR Log interface
 
     $minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
     $maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
     for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
       $endId = $startId + self::BATCH_SIZE - 1;
       $title = ts('Upgrade Batch (%1 => %2)', array(
         1 => $startId,
         2 => $endId,
       ));
       $sql = '
         UPDATE civicrm_contribution SET foobar = whiz(wonky()+wanker)
         WHERE id BETWEEN %1 and %2
       ';
       $params = array(
         1 => array($startId, 'Integer'),
         2 => array($endId, 'Integer'),
       );
       $this->addTask($title, 'executeSql', $sql, $params);
     }
     return TRUE;
   } // */
 public function upgrade_1104()
 {
     $this->ctx->log->info('Applying update 1104');
     $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_group_id', array('labelColumn' => 'name'));
     $cgid = array_search('Immigration', $groups);
     $cfId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', 'Sponsor_Certificate_number', 'id', 'name');
     if ($cgid && !$cfId) {
         $cfparams = array('custom_group_id' => $cgid, 'name' => 'Sponsor_Certificate_number', 'label' => 'Sponsor\'s Certificate number', 'html_type' => 'Text', 'data_type' => 'String', 'default_value' => '', 'weight' => 34, 'is_active' => 1);
         $cfresult = CRM_Core_BAO_CustomField::create($cfparams);
         $cfId = $cfresult->id;
     }
     if ($cfId) {
         $ufgroups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
         $ufid = array_search('hrvisa_tab', $ufgroups);
         $eufId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', 'custom_' . $cfId, 'id', 'field_name');
         if (!$eufId && $ufid) {
             $ufparams = array('field_name' => 'custom_' . $cfId, 'field_type' => 'Individual', 'visibility' => 'User and User Admin Only', 'label' => 'Sponsor\'s Certificate number', 'is_searchable' => 0, 'is_active' => 0, 'uf_group_id' => $ufid, 'is_multi_summary' => 1, 'is_active' => 0, 'is_required' => 0, 'in_selector' => 0);
             $ufresult = civicrm_api3('uf_field', 'create', $ufparams);
         }
     }
     return TRUE;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:51,代码来源:Upgrader.php


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