예제 #1
0
/**
 * This API will give list of the groups for particular contact 
 * Particualr status can be sent in params array
 * If no status mentioned in params, by default 'added' will be used
 * to fetch the records
 * 
 * @param  array $params  name value pair of contact information
 *
 * @return  array  list of groups, given contact subsribed to
 */
function civicrm_group_organization_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameter is not an array'));
    }
    if (empty($params)) {
        return civicrm_create_error('No input parameter present');
    }
    if (!array_key_exists('organization_id', $params) && !array_key_exists('group_id', $params)) {
        return civicrm_create_error(ts('at least one of organization_id or group_id is a required field'));
    }
    require_once 'CRM/Contact/DAO/GroupOrganization.php';
    $dao = new CRM_Contact_DAO_GroupOrganization();
    if (array_key_exists('organization_id', $params)) {
        $dao->organization_id = $params['organization_id'];
    }
    if (array_key_exists('group_id', $params)) {
        $dao->group_id = $params['group_id'];
    }
    $dao->find();
    $values = array();
    _civicrm_object_to_array($dao, $values);
    return civicrm_create_success($values);
}
 static function &retrieve($groupID, &$defaults)
 {
     $dao = new CRM_Contact_DAO_GroupOrganization();
     $dao->group_id = $groupID;
     if ($dao->find(true)) {
         $defaults['group_organization'] = $dao->id;
         $defaults['organization_id'] = $dao->organization_id;
     }
 }