function shcaa_list_hope_groups($type, $showmap = 'true', $showchart = 'true')
{
    // create the city object
    $ca = new CityApi();
    $ca->debug = false;
    $ca->json = false;
    // set the args
    // args array can include
    /*
    	page = [1,2,3,4,...]
    	search = ["downtown" | etc] <- optional group name search
    	under_group_id = [ 1234 | etc ] <- defaults to church group's ID
    	group_types = ["CG" | "Service" | "Campus" | etc] <- defaults to all group types
    	include_inactive = [ true | false ] <- defaults to false
    	include_addresses = [ true | false ]
    	include_composition = [ true | false ]
    	include_user_ids = [ true | false ]
    */
    // cache the results
    // attempt to get cached request
    $transient_key = "_shcaa_hope_groups_feed";
    // If cached (transient) data are used, output an HTML
    // comment indicating such
    $cached = get_transient($transient_key);
    if (false !== $cached) {
        $mygrps = $cached;
    } else {
        // create array of the groups filtered by the args and include the tags - for the call to theCITY api
        $args = array();
        $args['group_types'] = 'Hope';
        $args['include_addresses'] = 'true';
        $groups = $ca->groups_index($args);
        $mygrps = array();
        $grps = $groups['groups'];
        $i = 0;
        foreach ($grps as $grp) {
            $mygrps[$i]['grp_id'] = $grp['id'];
            $mygrps[$i]['parentid'] = $grp['parent_id'];
            $mygrps[$i]['image'] = $grp['profile_pic'];
            $mygrps[$i]['name'] = $grp['name'];
            $mygrps[$i]['description'] = $grp['external_description'];
            $mygrps[$i]['neighborhood'] = $grp['nearest_neighborhood_name'];
            $mygrps[$i]['invite'] = $grp['default_invitation_custom_message'];
            $mygrps[$i]['cityurl'] = $grp['internal_url'];
            // address fields
            if (isset($grp['addresses'][0]) && !empty($grp['addresses'][0])) {
                $mygrps[$i]['add_name'] = $grp['addresses'][0]['friendly_name'];
                $mygrps[$i]['add_street'] = $grp['addresses'][0]['street'];
                $mygrps[$i]['add_street2'] = $grp['addresses'][0]['street2'];
                $mygrps[$i]['add_city'] = $grp['addresses'][0]['city'];
                $mygrps[$i]['add_state'] = $grp['addresses'][0]['state'];
                $mygrps[$i]['add_zipcode'] = $grp['addresses'][0]['zipcode'];
                $mygrps[$i]['add_longitude'] = $grp['addresses'][0]['longitude'];
                $mygrps[$i]['add_latitude'] = $grp['addresses'][0]['latitude'];
            }
            // Get Tags
            $tags = $ca->groups_tags_index($grp['id']);
            if ($tags) {
                foreach ($tags as $tag) {
                    if (is_array($tag)) {
                        $mygrps[$i]['mytags'] = array();
                        foreach ($tag as $el) {
                            $mygrps[$i]['mytags'][] = $el;
                        }
                        // end inner foreach
                    }
                    // end if
                }
                // end foreach
            }
            // end if tags
            // Get Users
            $users = $ca->groups_roles_index($grp['id']);
            if ($users) {
                foreach ($users as $user) {
                    if (is_array($user)) {
                        $mygrps[$i]['leaders'] = array();
                        $lc = 0;
                        foreach ($user as $usr) {
                            if ($usr['title'] == 'Leader') {
                                $mygrps[$i]['leaders'][$lc]['name'] = $usr['user_name'];
                                // get contact info
                                $userinfo = $ca->users_show($usr['user_id']);
                                $mygrps[$i]['leaders'][$lc]['phone'] = $userinfo['primary_phone'];
                                $mygrps[$i]['leaders'][$lc]['email'] = $userinfo['email'];
                                $mygrps[$i]['leaders'][$lc]['first'] = $userinfo['first'];
                                $mygrps[$i]['leaders'][$lc]['last'] = $userinfo['last'];
                                $mygrps[$i]['leaders'][$lc]['nickname'] = $userinfo['nickname'];
                                // group family members
                                $userfam = $ca->users_family_index($usr['user_id']);
                                $mygrps[$i]['leaders'][$lc]['fam_id'] = $userfam['external_id'];
                                $lc++;
                            }
                        }
                        // end inner foreach
                    }
                    // end if
                }
                // end foreach
            }
            // end if users
            $i++;
        }
        // end foreach
        //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $mygrps ); print_r('</pre>');
        set_transient($transient_key, $mygrps, 60 * 60 * 24 * 7);
        // seven days
    }
    // end if not cached
    $output = '';
    // group map output
    if ($showmap != 'false') {
        $output .= '<div class="hf-g-map"></div>';
        //output_google_map();
    }
    // group chart output
    if ($showchart != 'false') {
        $output .= '<table class="groupslist">';
        $output .= '<tr>
		  <th>Leader</th>
		  <th>Day/Time</th>
		  <th>Location</th>
		  <th>Contact</th>
		</tr>';
    } else {
        $output .= '<div class="groupslist">';
    }
    // end if showchart
    $cnt = 0;
    //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $mygrps ); print_r('</pre>');
    foreach ($mygrps as $grpkey => $mygrp) {
        $grp_id = $mygrp['grp_id'];
        // get the tags array and start making choices
        $dtags = $mygrp['mytags'];
        $meta = sh_find_groupmeta($dtags);
        $leaders = $mygrp['leaders'];
        // stuff from meta
        $hgtype = $meta['type'];
        $day = $meta['day'];
        $time = $meta['time'];
        $extras = $meta['extra'];
        // array
        // is kid friendly
        $prokid = 0;
        if (in_array('kid-friendly', $extras)) {
            $prokid = 1;
        }
        $name = $mygrp['name'];
        $name = str_replace('HG:', '', $name);
        //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $name ); print_r( '--<br />--' ); print_r( $meta); print_r('------------</pre>');
        // Leader information
        $ldrs = $mygrp['leaders'];
        $leaders = '<div class="leaders">';
        $famids = array();
        $leds = array();
        foreach ($ldrs as $k => $ldr) {
            // search the famids for previous use of same famid
            $key = array_search($ldr['fam_id'], $famids);
            if (is_numeric($key)) {
                $nnic = $ldrs[$key]['nickname'];
                $nfirst = $ldrs[$key]['first'];
                $nlast = $ldrs[$key]['last'];
                $phone = $ldrs[$key]['phone'];
                $email = $ldrs[$key]['email'];
                //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $key ); print_r('</pre>');
                $fn1 = isset($nnic) && !empty($nnic) ? $nnic : $nfirst;
                $fn2 = isset($ldr['nickname']) && !empty($ldr['nickname']) ? $ldr['nickname'] : $ldr['first'];
                $fullname = $fn1 . ' & ' . $fn2 . ' ' . $nlast;
                unset($leds[$key]);
            } else {
                $first = isset($ldr['nickname']) && !empty($ldr['nickname']) ? $ldr['nickname'] : $ldr['first'];
                $fullname = $first . ' ' . $ldr['last'];
                $phone = $ldr['phone'];
                $email = $ldr['email'];
            }
            // end if
            $leds[] = array('fullname' => $fullname, 'phone' => $phone, 'email' => $email);
            // store the fam id
            $famids[] = $ldr['fam_id'];
        }
        // end foreach
        // output
        $numled = count($leds);
        $lcntr = 1;
        foreach ($leds as $key => $led) {
            $leaders .= '<span class="leader">';
            $leaders .= $led['fullname'];
            $leaders .= '</span>';
            if ($numled !== $lcntr) {
                $leaders .= ', ';
            }
            $lcntr++;
        }
        $leaders .= '</div>';
        $neighborhood = $mygrp['neighborhood'];
        $neighborhood = str_replace('Neighborhood:', '', $neighborhood);
        $grpfriendname = $mygrp['add_name'];
        $grp_name = isset($grpfriendname) && !empty($grpfriendname) ? $grpfriendname : $neighborhood;
        // map coords
        $lng = $mygrp['add_longitude'];
        $lat = $mygrp['add_latitude'];
        // contact button
        $contactform = '<form id="hope-group-contact" action="/hope-group-contact">
							<input value="' . $grpkey . '" id="group" name="group" type="hidden">
							<input type="submit" value="Contact Leaders">
						</form>';
        unset($leds);
        // Allow output of only the hopegroup type requested in the shortcode, if parameter is there
        if ($showchart != 'false') {
            if ($type == 'ALL' || $type == $hgtype) {
                $output .= '<tr>';
                // name
                if (isset($leaders) && !empty($leaders)) {
                    $output .= '<td class="grp-name">' . $leaders . '</td>';
                }
                // Day - time
                if (isset($day) && !empty($day) && $day != 'TBD') {
                    $daytime = '<td class="grp-day">' . $day . ' ' . $time . '</div>';
                } else {
                    $daytime = '<td class="grp-day">To Be Determined</div>';
                }
                $output .= $daytime;
                // neighborhood
                if (isset($grp_name) && !empty($grp_name)) {
                    $output .= '<td class="grp-location">' . $grp_name . '</td>';
                }
                // contact
                $output .= '<td class="grp-contact">';
                $output .= $contactform;
                // stuff for the map markers
                $mleaders = html_entity_decode($name);
                $output .= '
			  <div class="marker" style="display:none;" data-lat="' . $lat . '" data-lng="' . $lng . '">
				  <div class="output">
					  <div class="mled">' . $mleaders . '</div>
					  <div class="mday">' . $day . ' ' . $time . '</div>
				  </div>
				  <div class="kids">' . $prokid . '</div>
				  <div class="zone">' . $hgtype . '</div>
			  </div>';
                $output .= '</td>';
                $output .= '</tr>';
            }
            // end if type
        } else {
            // end if showchart
            if (isset($day) && !empty($day) && $day != 'TBD') {
                $daytime = '<td class="grp-day">' . $day . ' ' . $time . '</div>';
            } else {
                $daytime = '<td class="grp-day">To Be Determined</div>';
            }
            $mleaders = html_entity_decode($name);
            $output .= '
			<div class="marker" style="display:none;" data-lat="' . $lat . '" data-lng="' . $lng . '">
				<div class="output">
					<div class="mled">' . $mleaders . '</div>
					<div class="mday">' . $day . ' ' . $time . '</div>
				</div>
				<div class="kids">' . $prokid . '</div>
				<div class="zone">' . $hgtype . '</div>
			</div>';
        }
    }
    // end foreach
    if ($showchart != 'false') {
        $output .= '</table>';
    } else {
        $output .= '</div>';
    }
    return $output;
}
background-color:#E0EEEE;
}
</style>
<title>Test Users Family Index</title>
</head>

<body>
<?php 
require_once 'test-util.php';
require_once dirname(__FILE__) . '/../lib/ca-main.php';
echo '<h1>users_family_index</h1>';
echo '<div class="apitest">';
$ca = new CityApi();
$ca->debug = true;
$ca->json = true;
$userid = 238801;
$results = $ca->users_family_index($userid);
echo "<h2>results:</h2>{$results}";
echo '<h2>var_dump results:</h2>';
var_dump($results);
echo '<h2>Formatted JSON results: </h2>';
echo '<pre>';
echo format_json($results);
echo '</pre>';
echo '</div>';
?>

</body>

</html>