Index: openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl,v diff -u -N -r1.18 -r1.19 --- openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 2 Dec 2008 17:26:35 -0000 1.18 +++ openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 17 Jun 2009 08:00:01 -0000 1.19 @@ -158,8 +158,12 @@ } { @param roles_list the list of roles to get the name } { - if {[info exist run_id]} { - set groups [db_list get_community_related_groups {}] + if {[exists_and_not_null run_id]} { + if {[exists_and_not_null role_id]} { + set groups [db_list get_community_role_related_groups {}] + } else { + set groups [db_list get_community_related_groups {}] + } } else { set groups [db_list get_related_groups {}] } @@ -467,3 +471,24 @@ return $groups } + +ad_proc -public imsld::roles::get_active_role { + -run_id:required + -user_id:required +} { + Return the active role for a given user in a given run. +} { + db_1row get_active_role { + select iruns.active_role_id as active_role + from imsld_run_users_group_rels iruns, + acs_rels ar, + imsld_run_users_group_ext iruge + where iruge.run_id=:run_id + and ar.object_id_one=iruge.group_id + and ar.object_id_two=:user_id + and ar.rel_type='imsld_run_users_group_rel' + and ar.rel_id=iruns.rel_id + } + return $active_role +} +