How to get all group content from group? I am using OG, Flag and Rules module. I would like to do like this.

When a user click Flag links in Group (name is follow_group) then all group content of that group will be flagged as following.

For now, i'm stuck at getting all group content of specific group. Is there a way to get group content of current group?
All the contents are associated in og_membership table. If you can get the gid (group node id), then it will be easier to get the content associated with that group.

$og_contents = db_select('og_membership', 'ogm')
-&gt;fields('ogm', array('etid'))
-&gt;condition('ogm.gid', $gid, '=')
-&gt;condition('ogm.entity_type', 'node', '=')
-&gt;execute()
-&gt;fetchAll();