Forum OpenACS Development: Re: Getting the group_id from the group_name

Collapse
Posted by Alex Kroman on
Here's the code. Thanks to leeldn for helping me out on IRC. If you pass in $group_name it will return true or false depending on if you are in that group for the subsite you are currently in.
set application_group_id [application_group::group_id_from_package_id -package_id [ad_conn subsite_id]]

set group_id [db_string get_group_id "SELECT g.group_id                                                                                    
                                          FROM acs_rels rels                                                                                   
                                          INNER JOIN composition_rels comp ON                                                                  
                                          rels.rel_id = comp.rel_id                                                                            
                                          INNER JOIN groups g ON rels.object_id_two = g.group_id                                               
                                          WHERE rels.object_id_one = :application_group_id AND                                                 
                                          g.group_name = :group_name" -default 0]

set group_member_p [group::member_p -user_id $user_id -group_id $group_id]