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


PHP CRM_Core_BAO_CustomField::moveField方法代码示例

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


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

示例1: testMoveField

 /**
  * Move a custom field from $groupA to $groupB. Make sure that data records are
  * correctly matched and created.
  */
 public function testMoveField()
 {
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
     $this->assertTrue($countriesByName['ANDORRA'] > 0);
     $groups = array('A' => Custom::createGroup(array('title' => 'Test_Group A', 'name' => 'test_group_a', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)), 'B' => Custom::createGroup(array('title' => 'Test_Group B', 'name' => 'test_group_b', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)));
     $fields = array('countryA' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryB' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryC' => Custom::createField(array(), array('groupId' => $groups['B']->id, 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country')));
     $contacts = array('alice' => Contact::createIndividual(array('first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']->id => $countriesByName['ANDORRA'], 'custom_' . $fields['countryB']->id => $countriesByName['BARBADOS'])), 'bob' => Contact::createIndividual(array('first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']->id => $countriesByName['AUSTRIA'], 'custom_' . $fields['countryB']->id => $countriesByName['BERMUDA'], 'custom_' . $fields['countryC']->id => $countriesByName['CHAD'])), 'carol' => Contact::createIndividual(array('first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']->id => $countriesByName['CAMBODIA'])));
     // Move!
     CRM_Core_BAO_CustomField::moveField($fields['countryB']->id, $groups['B']->id);
     // Group[A] no longer has fields[countryB]
     $errorScope = CRM_Core_TemporaryErrorScope::useException();
     try {
         $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}");
         $this->fail('Expected exception when querying column on wrong table');
     } catch (PEAR_Exception $e) {
     }
     $errorScope = NULL;
     // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} is null", array(1 => array($contacts['alice'], 'Integer'), 3 => array($countriesByName['BARBADOS'], 'Integer')));
     // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['bob'], 'Integer'), 3 => array($countriesByName['BERMUDA'], 'Integer'), 4 => array($countriesByName['CHAD'], 'Integer')));
     // Carol: Group[B] still has fields[countryC] but did not get fields[countryB]
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} is null\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['carol'], 'Integer'), 4 => array($countriesByName['CAMBODIA'], 'Integer')));
     Custom::deleteGroup($groups['A']);
     Custom::deleteGroup($groups['B']);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:30,代码来源:CustomFieldTest.php

示例2: upgrade_1105

 public function upgrade_1105()
 {
     $this->ctx->log->info('Applying update 1105');
     $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_group_id', array('labelColumn' => 'name'));
     $customFieldID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', 'Is_Visa_Required', 'id', 'name');
     $customGroupID = array_search('Extended_Demographics', $groups);
     if ($customFieldID && $customGroupID) {
         CRM_Core_BAO_CustomField::moveField($customFieldID, $customGroupID);
         $result = civicrm_api3('CustomField', 'get', array('sequential' => 1, 'name' => 'Is_Visa_Required'));
         $weight = $result['values']['weight'];
         //fix the weight so that the field is next to nationality
         $fieldValues['custom_group_id'] = $customGroupID;
         CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $weight, 2, $fieldValues);
         $params = array('sequential' => 1, 'id' => $result['id'], 'is_active' => 1, 'html_type' => 'Radio', 'data_type' => 'Boolean', 'weight' => 2);
         $result = civicrm_api3('CustomField', 'create', $params);
     }
     return TRUE;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:18,代码来源:Upgrader.php

示例3: postProcess

 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     CRM_Core_BAO_CustomField::moveField($this->_srcFID, $this->_dstGID);
     $dstGroup = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_dstGID, 'title');
     $srcUrl = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_dstGID}");
     CRM_Core_Session::setStatus(ts("%1 has been moved to the custom set <a href='%3'>%2</a>.", array(1 => $this->_srcFieldLabel, 2 => $dstGroup, 3 => $srcUrl)));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:13,代码来源:MoveField.php

示例4: testMoveField

 /**
  * Move a custom field from $groupA to $groupB.
  *
  * Make sure that data records are correctly matched and created.
  */
 public function testMoveField()
 {
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
     $this->assertTrue($countriesByName['Andorra'] > 0);
     $groups = array('A' => $this->customGroupCreate(array('title' => 'Test_Group A', 'name' => 'test_group_a', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)), 'B' => $this->customGroupCreate(array('title' => 'Test_Group B', 'name' => 'test_group_b', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)));
     $groupA = $groups['A']['values'][$groups['A']['id']];
     $groupB = $groups['B']['values'][$groups['B']['id']];
     $countryA = $this->customFieldCreate(array('custom_group_id' => $groups['A']['id'], 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL));
     $countryB = $this->customFieldCreate(array('custom_group_id' => $groups['A']['id'], 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL));
     $countryC = $this->customFieldCreate(array('custom_group_id' => $groups['B']['id'], 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL));
     $fields = array('countryA' => $countryA['values'][$countryA['id']], 'countryB' => $countryB['values'][$countryB['id']], 'countryC' => $countryC['values'][$countryC['id']]);
     $contacts = array('alice' => $this->individualCreate(array('first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']['id'] => $countriesByName['Andorra'], 'custom_' . $fields['countryB']['id'] => $countriesByName['Barbados'])), 'bob' => $this->individualCreate(array('first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']['id'] => $countriesByName['Austria'], 'custom_' . $fields['countryB']['id'] => $countriesByName['Bermuda'], 'custom_' . $fields['countryC']['id'] => $countriesByName['Chad'])), 'carol' => $this->individualCreate(array('first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']['id'] => $countriesByName['Cambodia'])));
     // Move!
     CRM_Core_BAO_CustomField::moveField($fields['countryB']['id'], $groupB['id']);
     // Group[A] no longer has fields[countryB]
     $errorScope = CRM_Core_TemporaryErrorScope::useException();
     try {
         $this->assertDBQuery(1, "SELECT {$fields['countryB']['column_name']} FROM " . $groupA['table_name']);
         $this->fail('Expected exception when querying column on wrong table');
     } catch (PEAR_Exception $e) {
     }
     $errorScope = NULL;
     // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groupB['table_name']}\n            WHERE entity_id = %1\n            AND {$fields['countryB']['column_name']} = %3\n            AND {$fields['countryC']['column_name']} is null", array(1 => array($contacts['alice'], 'Integer'), 3 => array($countriesByName['Barbados'], 'Integer')));
     // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groupB['table_name']}\n            WHERE entity_id = %1\n            AND {$fields['countryB']['column_name']} = %3\n            AND {$fields['countryC']['column_name']} = %4", array(1 => array($contacts['bob'], 'Integer'), 3 => array($countriesByName['Bermuda'], 'Integer'), 4 => array($countriesByName['Chad'], 'Integer')));
     // Carol: Group[B] still has fields[countryC] but did not get fields[countryB]
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groupB['table_name']}\n            WHERE entity_id = %1\n            AND {$fields['countryB']['column_name']} is null\n            AND {$fields['countryC']['column_name']} = %4", array(1 => array($contacts['carol'], 'Integer'), 4 => array($countriesByName['Cambodia'], 'Integer')));
     $this->customGroupDelete($groups['A']['id']);
     $this->customGroupDelete($groupB['id']);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:36,代码来源:CustomFieldTest.php


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