Building a my groups block

How does one build a 'my groups' block? I thought it would be an out of the box thingy. But it is not. On the channel the answer was DIY. So this is what I build. The code patterns below are the same. The use cases differently.
  1. Show my groups
  2. Add special node type immediately to a group. This is for speed
  3. Generate a node and redirect elsewhere. This is for speed and timeing usage.

My Groups

This is just looping through the group ids of the current user.
global $user; 

$items= array();
foreach( $user->og_groups as $gid => $group){
  $items[]= l( $group['title'], 'node/gids[]);
}
if( count( $cclinks)){
  echo theme('item_list', $items);
}

Add to group immediate

And this is a little niftier. An item is 'added' immediate to a group.
global $user; 

$cclinks= array();
foreach( $user->og_groups as $gid => $group){
  $items[]= l( 'New cdr for ' . $group['title'], 'node/add/cdr', array(), 'gids[]='. $gid );
}
if( count( $cclinks)){
  echo theme('item_list', $items);
}

Timer

A node is automaticly submitted. Using cclink, workflow_ng and node_factory. A workflow is defined for creating a cdr node automaticly. The node is added to the group.
global $user; 

$cclinks= array();
foreach( $user->og_groups as $gid => $group){
  $cclinks[]= l( 'Pickup ' . $group['title'], "cclinks/cclink1/$gid/$gid", array(), "destination=node/$gid" );
}
if( count( $cclinks)){
  echo theme('item_list', $cclinks);
}

workflow condition

This condition is in err. It was intended to check for a 'not changed' node belonging to the current user.
$sql = "select n.nid from {node} n where n.type='cdr' and n.uid = %d and n.created = n.changed";
$result = db_query( $sql, $user->uid);
$row = db_fetch_array( $result);
return (isset( $row) && isset($row['nid']))

workflow php action

This code is in err. og is not set yet. And that's exactly the discussion in the node_factory issue queue. How to set complex values. See especially How to create a node programmaticly.
$edit = node_factory_create_node( 'cdr');
node_factory_set_value( $edit, 'title', 'telefoon nummer');
//node_factory_set_value( $edit, 'uid', $user->uid);
//$og_group= array()
//$og_group[]= $node->nid;
//node_factory_set_value( $edit, 'og_group', $og_group);
$nid = node_factory_save_node( $edit);

Hangup

Next thing to do should be to 'hangup' the automaticly created node. I haven't build that yet. It should be something like a cclink to hangup the user related 'cdr'