* @param string $subName
* @param bool $fromCache
* @param bool $onlySubType
+ * Only return specified subtype or return specified subtype + unrestricted fields.
+ * @param bool $returnAll
+ * Do not restrict by subtype at all. (The parameter feels a bit cludgey but is only used from the
+ * api - through which it is properly tested - so can be refactored with some comfort.)
*
* @return array
* The returned array is keyed by group id and has the custom group table fields
$subType = NULL,
$subName = NULL,
$fromCache = TRUE,
- $onlySubType = NULL
+ $onlySubType = NULL,
+ $returnAll = FALSE
) {
if ($entityID) {
$entityID = CRM_Utils_Type::escape($entityID, 'Integer');
WHERE civicrm_custom_group.is_active = 1
AND civicrm_custom_field.is_active = 1
AND civicrm_custom_group.extends IN ($in)
- AND civicrm_custom_group.extends_entity_column_value IS NULL
";
+ if (!$returnAll) {
+ $strWhere .= "AND civicrm_custom_group.extends_entity_column_value IS NULL";
+ }
}
$params = array();
$this->customGroupDelete($ids['custom_group_id']);
}
+ /**
+ * Test civicrm_activity_create() with valid parameters and custom data.
+ */
+ public function testActivityCreateCustomSubType() {
+ $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+ $this->callAPISuccess('CustomGroup', 'create', array(
+ 'extends_entity_column_value' => $this->test_activity_type_value,
+ 'id' => $ids['custom_group_id'],
+ 'extends' => 'Activity',
+ 'is_active' => TRUE,
+ ));
+ $params = $this->_params;
+ $params['custom_' . $ids['custom_field_id']] = "custom string";
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
+ $result = $this->callAPISuccess($this->_entity, 'get', array(
+ 'return.custom_' . $ids['custom_field_id'] => 1,
+ 'id' => $result['id'],
+ ));
+ $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']]);
+
+ $this->customFieldDelete($ids['custom_field_id']);
+ $this->customGroupDelete($ids['custom_group_id']);
+ }
+
/**
* Test civicrm_activity_create() with valid parameters and custom data.
*/