Index: openacs-4/packages/acs-tcl/tcl/membership-rel-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/membership-rel-procs.tcl,v
diff -u -r1.8.12.1 -r1.8.12.2
--- openacs-4/packages/acs-tcl/tcl/membership-rel-procs.tcl	10 Sep 2015 08:21:57 -0000	1.8.12.1
+++ openacs-4/packages/acs-tcl/tcl/membership-rel-procs.tcl	26 Apr 2017 14:06:25 -0000	1.8.12.2
@@ -15,15 +15,9 @@
         Change the state of a membership relation
     } {
         db_transaction {
-
+            
             # We need the id of the user that we are changing state for
-            set rel_user_id [db_string select_rel_user_id { 
-                select u.user_id
-                from   acs_rels r,
-                users u
-                where  r.rel_id = :rel_id 
-                and    u.user_id = r.object_id_two
-            } -default {}]
+            set rel_user_id [get_user_id -rel_id $rel_id]
 
             # If user is being undeleted - remove him from the public group
             acs_user::get -user_id $rel_user_id -array user
@@ -109,6 +103,22 @@
         change_state -rel_id $rel_id -state "needs approval"
     }
 
+    ad_proc -public get_user_id {
+        {-rel_id:required}
+    } {
+        Return the user_id of a rel_id
+    } {
+        set user_id [db_string select_rel_user_id { 
+            select u.user_id
+            from   acs_rels r,
+            users u
+            where  r.rel_id = :rel_id 
+            and    u.user_id = r.object_id_two
+        } -default {}]
+        
+        return $user_id
+    }
+
 }
 
 # Local variables: