child_group_id = $params['child_group_id']; } if (array_key_exists('parent_group_id', $params)) { $dao->parent_group_id = $params['parent_group_id']; } $values = array(); if ($dao->find()) { while ($dao->fetch()) { $temp = array(); _civicrm_object_to_array($dao, $temp); $values[$dao->id] = $temp; } $values['is_error'] = 0; } else { return civicrm_create_error('No records found.'); } return $values; } /** * Creates group nesting record for given parent and child id. * Parent and child groups need to exist. * * @param array &$params parameters array - allowed array keys include: * {@schema Contact/GroupNesting.xml} * * @return array TBD * * @todo Work out the return value. */ function civicrm_group_nesting_create(&$params) { if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } require_once 'CRM/Contact/BAO/GroupNesting.php'; if (!array_key_exists('child_group_id', $params) && !array_key_exists('parent_group_id', $params) ) { return civicrm_create_error(ts('You need to define parent_group_id and child_group_id in params.')); } CRM_Contact_BAO_GroupNesting::add($params['parent_group_id'], $params['child_group_id']); // FIXME: CRM_Contact_BAO_GroupNesting requires some work $result = array('is_error' => 0); return $result; } /** * Removes specific nesting records. * * @param array &$params parameters array - allowed array keys include: * {@schema Contact/GroupNesting.xml} * * @return array TBD * * @todo Work out the return value. */ function civicrm_group_nesting_remove(&$params) { if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } if (!array_key_exists('child_group_id', $params) || !array_key_exists('parent_group_id', $params) ) { return civicrm_create_error(ts('You need to define parent_group_id and child_group_id in params.')); } require_once 'CRM/Contact/DAO/GroupNesting.php'; $dao = new CRM_Contact_DAO_GroupNesting(); $dao->copyValues($params); if ($dao->delete()) { $result = array('is_error' => 0); } return $result; }