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


PHP CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype方法代码示例

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


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

示例1: postProcess

 /**
  * Process the form.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
         if (!empty($this->_subtypes)) {
             $subtypesToBeRemoved = array_diff($this->_subtypes, array_intersect($this->_subtypes, $params['extends'][1]));
             CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($this->_id, $subtypesToBeRemoved);
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom set , so lets set the created_id
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)), ts('Saved'), 'success');
     } else {
         // Jump directly to adding a field if popups are disabled
         $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add';
         $url = CRM_Utils_System::url("civicrm/admin/custom/group/field{$action}", 'reset=1&new=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse'));
         CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", array(1 => $group->title)), ts('Saved'), 'success');
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
     // prompt Drupal Views users to update $db_prefix in settings.php, if necessary
     global $db_prefix;
     $config = CRM_Core_Config::singleton();
     if (is_array($db_prefix) && $config->userSystem->is_drupal && module_exists('views')) {
         // get table_name for each custom group
         $tables = array();
         $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $tables[$result->table_name] = $result->table_name;
         }
         // find out which tables are missing from the $db_prefix array
         $missingTableNames = array_diff_key($tables, $db_prefix);
         if (!empty($missingTableNames)) {
             CRM_Core_Session::setStatus(ts("To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the db_prefix array in your settings.php file: '%1'.", array(1 => implode(', ', $missingTableNames))), ts('Note'), 'info');
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:57,代码来源:Group.php

示例2: testCRM19133

 /**
  * Unit test to ensure that removing any subtype from CustomGroup's
  * extend_for setting, won't delete any custom data of contact
  *
  * Success expected
  */
 public function testCRM19133()
 {
     $customGroupName = md5(microtime());
     $subtypesToPreserve = array($this->student, $this->parent);
     // Create custom group that extends student and parent subtype
     $apiParams = array('title' => $customGroupName, 'extends' => array('Individual', $subtypesToPreserve), 'is_active' => TRUE);
     $result = civicrm_api3('customGroup', 'create', $apiParams);
     $customGroupId = $result['id'];
     // Create desired custom field
     $apiParams = array('debug' => 1, 'custom_group_id' => $result['id'], 'label' => $customGroupName, 'html_type' => 'Text', 'data_type' => 'String', 'is_active' => TRUE);
     $result = civicrm_api3('custom_field', 'create', $apiParams);
     $customFieldId = $result['id'];
     // Create contact of subtype parent and student
     $params = array('first_name' => 'Anne', 'last_name' => 'Grant', 'contact_type' => 'Individual', 'contact_sub_type' => array($this->student, $this->parent));
     $contact = CRM_Contact_BAO_Contact::add($params);
     // Record custom value for desired customGroup
     $this->callAPISuccess('CustomValue', 'create', array('entity_id' => $contact->id, 'custom_' . $customFieldId => 'value 1'));
     // Subtype to be removed from customGroup setting
     $subtypesToBeRemoved = array($this->student);
     CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($customGroupId, $subtypesToBeRemoved, $subtypesToPreserve);
     // Check with correct value to assert that custom data is not deleted
     $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'value 1'));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals($contact->id, $result['id']);
     //Check with incorrect custom value that our previous assertion was correct
     $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'wrong value'));
     $this->assertEquals(0, $result['count']);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:34,代码来源:ContactTest.php


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