Index: openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp	30 Mar 2006 16:01:45 -0000	1.1
@@ -0,0 +1,21 @@
+<master>
+
+
+<table border="0">
+<tr>
+  <td>
+  <formtemplate id="choose_role"></formtemplate>
+  </td>
+  <td>
+     <if @role@ not eq 0>
+       <include src="imsld-groups">
+    </if>  
+  </td>
+  </tr>
+  <tr>
+    <if @group_instance@ not eq 0>
+      <include src="imsld-role-members">
+    </if> 
+</tr>
+</table>
+
Index: openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,39 @@
+# /packages/imsld/www/admin/imsls-admin-roles.tcl
+
+ad_page_contract {
+    Admin the users assigned to a role
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    role:optional
+    {group_instance 0}
+    imsld_id
+    members_list:optional
+} 
+
+#get roles list
+set roles_list [imsld::roles::get_list_of_roles -imsld_id $imsld_id]
+set roles_list_names [imsld::roles::get_roles_names -roles_list $roles_list] 
+
+set lista [list]
+lappend lista [list "Select a role..." 0]
+
+for {set order 0} {$order < [llength $roles_list] } {incr order} {
+    set lista_item [list [lindex $roles_list_names $order] [lindex [lindex $roles_list $order] 0]]
+    lappend lista $lista_item
+}
+
+ad_form -name choose_role -action imsld-admin-roles -export {imsld_id} -form {
+               {role:integer(select) {label "Select a role"} 
+               {options "$lista"} 
+               }
+} -on_request {
+     if {[info exists role]} {
+         set role $role
+     }
+}
+
+if {![info exists role]} {
+    set role 0
+}
Index: openacs-4/packages/imsld/www/admin/imsld-create-instance.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-create-instance.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-create-instance.adp	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<p>Select parent for the new instance</p>
+<if @flag@ not nil>
+    <listtemplate name="possible_parents"></listtemplate>
+</if>
+
Index: openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,49 @@
+# /packages/imsld/www/admin/imsld-create-instance.tcl
+
+ad_page_contract {
+    Create a instance of a role
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    {user_id:multiple "0"}
+    role
+    imsld_id
+    parent_group_id:optional
+}
+
+db_1row get_imsld_role_info {}
+set number_of_groups [llength [db_list get_related_groups {}]]
+
+set return_url [export_vars -base imsld-admin-roles {{role $role} {imsld_id $imsld_id} }]
+
+if { !([string eq $number_of_groups "0"] || [string eq $create_new_p  "t"] ) } {
+
+        set mensaje "<p>Current Unit of Learning does not allow creation of multiple instances of this role.</p>
+            <a href=\"$return_url\">Go back</a>"
+    ad_return_complaint 1 $mensaje
+    ad_script_abort
+}
+
+if {[info exist parent_group_id] } {
+    set new_instance [imsld::roles::create_instance -role_id $role -parent_group_id $parent_group_id]
+    ad_returnredirect [export_vars -base imsld-admin-roles {{role $role} {imsld_id $imsld_id} {group_instance $new_instance}}]
+} elseif { ![db_0or1row has_role_parent_p {}] } {
+    set new_instance [imsld::roles::create_instance -role_id $role]
+    ad_returnredirect [export_vars -base imsld-admin-roles {{role $role} {imsld_id $imsld_id} {group_instance $new_instance}}]
+} else {
+    set flag on
+    template::list::create \
+        -name possible_parents \
+        -multirow possible_parents \
+        -elements {
+            parent_name {
+                label "Parent role instances"
+                link_url_col link_to 
+            }
+        }
+    db_multirow -extend {link_to} possible_parents get_possible_parents_list {} {
+        set link_to [export_vars -base imsld-create-instance {role imsld_id {parent_group_id $parent_id}}]
+    }
+}
+
Index: openacs-4/packages/imsld/www/admin/imsld-create-instance.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-create-instance.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-create-instance.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<queryset>
+	<fullquery name="get_imsld_role_info">
+		<querytext>
+        select max_persons,min_persons,create_new_p,match_persons_p
+        from imsld_roles
+        where role_id=:role
+		</querytext>
+	</fullquery>
+
+	<fullquery name="get_related_groups">
+		<querytext>
+        select ar.object_id_two as groups
+        from acs_rels ar,
+             imsld_rolesi iri
+        where ar.object_id_one=iri.item_id
+              and iri.role_id=:role
+              and ar.rel_type='imsld_role_group_rel'
+		</querytext>
+	</fullquery>
+	<fullquery name="get_possible_parents_list">
+		<querytext>
+        select g.group_name as parent_name,
+               g.group_id as parent_id
+        from groups g,
+             imsld_rolesi iri,
+             acs_rels ar 
+        where iri.role_id=:role
+              and ar.object_id_one=iri.parent_role_id 
+              and ar.rel_type='imsld_role_group_rel' 
+              and g.group_id=ar.object_id_two
+        </querytext>
+	</fullquery>
+
+	<fullquery name="has_role_parent_p">
+		<querytext>
+            select role_id
+            from imsld_roles
+            where role_id=:role
+                  and parent_role_id>0
+        </querytext>
+	</fullquery>
+
+    
+</queryset>
+
Index: openacs-4/packages/imsld/www/admin/imsld-delete-instance.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-delete-instance.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-delete-instance.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,18 @@
+# /packages/imsld/www/admin/imsld-delete-instance.tcl
+
+ad_page_contract {
+    Delete a instance of a role
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    role
+    imsld_id
+    group_id
+}
+
+
+db_1row get_rel_id {}
+relation_remove $rel_id
+imsld::roles::delete_instance -group_id $group_id
+ad_returnredirect [export_vars -base imsld-admin-roles {{role $role} {imsld_id $imsld_id} {group_instance 0}}]
Index: openacs-4/packages/imsld/www/admin/imsld-delete-instance.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-delete-instance.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-delete-instance.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<queryset>
+	<fullquery name="get_rel_id">
+		<querytext>
+        select ar.rel_id 
+        from acs_rels ar,
+             imsld_rolesi iri
+        where ar.object_id_one=iri.item_id
+              and iri.role_id=:role
+              and object_id_two=:group_id
+              and rel_type='imsld_role_group_rel'
+		</querytext>
+	</fullquery>
+
+</queryset>
+
Index: openacs-4/packages/imsld/www/admin/imsld-groups.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-groups.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-groups.adp	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,3 @@
+
+<blockquote><listtemplate name="role_groups"></listtemplate></blockquote>
+
Index: openacs-4/packages/imsld/www/admin/imsld-groups.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-groups.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-groups.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,44 @@
+# /packages/imsld/www/admin/imsld-groups.tcl
+
+ad_page_contract {
+    Show the list of available groups and manage them
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    imsld_id
+    {group_instance 0}
+    role:optional
+}
+set lista [list [list "Select a group..." 0]]
+set lista_aux [lindex [db_list_of_lists get_groups_list {}] 0]
+lappend lista $lista_aux
+
+
+    set actions [list "Create new" [export_vars -base imsld-create-instance {imsld_id role}] "Create a new group"]
+
+template::list::create \
+    -name role_groups \
+    -multirow role_groups \
+    -key role_groups \
+    -actions $actions \
+    -elements {
+        group_name {
+           label {Group name}
+           link_url_col {manage_roles}
+        }
+        delete {
+            label {}
+            display_template {@role_groups.delete;noquote@} 
+        }
+    }
+
+
+db_multirow -extend { manage_roles delete } role_groups get_groups_list {} {
+    set manage_roles [export_vars -base imsld-admin-roles {imsld_id role {group_instance $group_id}}]
+    set delete "<a href=\"[export_vars -base "imsld-delete-instance" { imsld_id role group_id }]\"><img src=\"/resources/acs-subsite/Delete16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete\"></a>"
+   
+}
+
+
+
Index: openacs-4/packages/imsld/www/admin/imsld-groups.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-groups.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-groups.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<queryset>
+	<fullquery name="get_groups_list">
+		<querytext>
+        select group_name,group_id
+        from groups
+        where group_name like ('%' || :role || '%')
+		</querytext>
+	</fullquery>
+</queryset>
Index: openacs-4/packages/imsld/www/admin/imsld-new-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new-2.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/imsld/www/admin/imsld-new-2.tcl	22 Feb 2006 16:09:39 -0000	1.7
+++ openacs-4/packages/imsld/www/admin/imsld-new-2.tcl	30 Mar 2006 16:01:46 -0000	1.8
@@ -57,7 +57,9 @@
 }
 
 ns_write "</blockquote>"
-# jump to the front page
-ad_progress_bar_end -url [dotlrn_community::get_community_url $community_id]
 
+#get imslds ang jump to admin members page
+set imsld_id [db_list get_imslds_from_manifest {}]
+ad_progress_bar_end -url [export_vars -base imsld-admin-roles {imsld_id}]
 
+
Index: openacs-4/packages/imsld/www/admin/imsld-new-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new-2.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-new-2.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<queryset>
+	<fullquery name="get_imslds_from_manifest">
+		<querytext>
+        select ii.imsld_id 
+        from imsld_cp_organizationsi icoi,
+             imsld_imslds ii 
+        where icoi.item_id=ii.organization_id 
+              and icoi.manifest_id = :manifest_id
+		</querytext>
+	</fullquery>
+</queryset>
+
Index: openacs-4/packages/imsld/www/admin/imsld-role-add-members.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-add-members.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-add-members.adp	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,4 @@
+<master>
+
+@user_id@
+@lista@
Index: openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,29 @@
+#/packages/imsld/www/admin/imsld-role-add-members.tcl
+
+ad_page_contract {
+    Asign users assigned to an specified group
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    user_id:multiple
+    members_list
+    group_instance
+    role
+    imsld_id
+} 
+
+#only set required variables
+   foreach user $user_id {
+
+        if {[string eq "-1" [lsearch $members_list $user]]} {
+            #remove user from list
+            lappend members_list $user
+
+        }
+   }
+   ad_returnredirect [export_vars -base imsld-admin-roles {imsld_id role group_instance members_list}]
+
+
+   
+
Index: openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,85 @@
+#/packages/imsld/www/admin/imsld-role-add-members.tcl
+
+ad_page_contract {
+    Confirm membership changes made on role instances
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    members_list
+    group_instance
+    role
+    imsld_id
+} 
+
+#check conditions and set the database
+set role_info [imsld::roles::get_role_info -role_id $role]
+
+set max_persons [lindex $role_info 0]
+set min_persons [lindex $role_info 1]
+set match_persons_p [lindex $role_info 3]
+
+set return_url [export_vars -base imsld-admin-roles {role imsld_id group_instance members_list}]
+set return_url2 [export_vars -base imsld-admin-roles {role imsld_id group_instance}]
+
+
+if {![string eq "-1" [lsearch $members_list 0]] } {
+    set members_list [lreplace [lsort -integer -decreasing $members_list] end end]
+
+}
+if { ![string eq "" $min_persons] && ([llength $members_list] < $min_persons)} {
+        set mensaje "<p>Number of members does not reach the minimum allowed number of users for this role.
+                       There must be at least $min_persons members.</p>
+                       <a href=\"$return_url\">Go back</a>"
+        ad_return_complaint 1 $mensaje
+        ad_script_abort
+}
+
+if {![string eq "" $max_persons] && ([llength $members_list] > $max_persons)} {
+        set mensaje "<p>Number of members exceded the allowed number for this role.
+                       You must not select more than $max_persons members.</p>
+                       <a href=\"$return_url\">Go back</a>"
+        ad_return_complaint 1 $mensaje
+        ad_script_abort
+}
+
+#FIXME: falta comprobar match_persons_p
+if {![string eq "t" $match_persons_p]} {
+    #get not-allowed users
+    set not_allowed [db_list other_subroles_members {}]
+        
+    if {[llength $not_allowed]} {
+
+        set not_allowed_name [list]
+        foreach role_notallowed $not_allowed {
+            lappend not_allowed_name [acs_user::get_element -user_id $role_notallowed -element name]
+        }
+        ns_log Notice "nombres: $not_allowed_name"
+        set parent_role [imsld::roles::get_parent_role -role_id $role]
+        set parent_role_name [imsld::roles::get_roles_names -roles_list [list [list $parent_role 0]]]
+
+        ns_log Notice "padre $parent_role_name"
+        
+        set mensaje "<p>Members $not_allowed_name are already members of other subroles of role $parent_role_name.</p>
+                     <p>Current UoL does not allow to include them in more than one subroles of the role.</p>
+                       <a href=\"$return_url\">Go back</a>"
+        ad_return_complaint 1 $mensaje
+        ad_script_abort
+    }
+}
+
+set previous_members_list [group::get_members -group_id $group_instance]
+
+foreach user $previous_members_list {
+    if {[string eq "-1" [lsearch $members_list $user]]} {
+        group::remove_member -user_id $user -group_id $group_instance
+    }
+}
+
+foreach member $members_list {
+    if {[string eq "-1" [lsearch $previous_members_list $member]]} {
+        group::add_member -user_id $member -group_id $group_instance
+    }
+    
+}
+ad_returnredirect $return_url2
Index: openacs-4/packages/imsld/www/admin/imsld-role-confirm.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-confirm.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-confirm.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+ <queryset>
+    <fullquery name="other_subroles_members">
+		<querytext>
+        select gmm.member_id 
+        from imsld_roles ir1, 
+             imsld_rolesi ir2,
+             acs_rels ar,
+             group_member_map gmm 
+        where ir1.role_id=:role and 
+              ir1.parent_role_id=ir2.parent_role_id and 
+              ir2.role_id!=ir1.role_id and 
+              ar.object_id_one=ir2.item_id and 
+              ar.rel_type='imsld_role_group_rel' and 
+              gmm.group_id=ar.object_id_two and
+              member_id in ([join $members_list ","])
+        group by member_id
+        </querytext>
+	</fullquery>
+</queryset>
+
Index: openacs-4/packages/imsld/www/admin/imsld-role-members.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-members.adp	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,15 @@
+
+
+  <td>
+<h1>Not members</h1>
+<listtemplate name="asign_not_members"></listtemplate>
+  </td>
+  <td>
+<h1>Group members</h1>
+ <listtemplate name="asign_members"></listtemplate> 
+  </td>
+  <td>
+  <formtemplate id="confirm"></formtemplate>  
+  </td>
+
+  
Index: openacs-4/packages/imsld/www/admin/imsld-role-members.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-members.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,99 @@
+# /packages/imsld/www/admin/imsld-role-members.tcl
+
+ad_page_contract {
+    Asign users assigned to an specified group
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    role:optional
+    {group_instance 0}
+    imsld_id
+    members_list:optional
+} 
+
+if {![string eq $group_instance "0"] && [db_0or1row has_role_parent_p {}]} {
+    if {![info exist members_list]} {
+        set members_list [db_list get_members_list_2 {}]
+    }
+    if {![llength $members_list]} {
+       set members_list 0 
+    }
+    set not_members_list [db_list get_not_members_list_2 {}]
+    if {![llength $not_members_list]} {
+       set not_members_list 0 
+    }
+  
+    
+} else {
+     if {![info exist members_list]} {
+        set members_list [db_list get_members_list {}]
+    }
+
+    if {![llength $members_list]} {
+       set members_list 0 
+    }
+
+    set not_members_list [db_list get_not_members_list {}]
+    if {![llength $not_members_list]} {
+       set not_members_list 0 
+    }
+   
+}
+
+
+
+if {![db_0or1row get_group_name {}]} {
+    set group_name "No group selected"
+#    set create_instance_url [export_vars -base imsld-create-instance {{imsld_id $imsld_id} {role $role}}]
+    set create_instance_url imsld-create-instance 
+    set bulk_actions "{Create new instance} $create_instance_url {Create a new instance of a role}"
+    set bulk_actions_not "{Create new instance} $create_instance_url {Create a new instance of a role}"
+    set bulk_action_export_vars "{imsld_id} {role}"
+} else {
+    set bulk_actions "{<------} {imsld-role-remove-members} {Remove selected members from the group}"
+    set bulk_actions_not "{------->} {imsld-role-add-members} {Add selected members to the group}"
+                     
+    set bulk_action_export_vars "{group_instance} {role} {imsld_id} {members_list}"
+}
+
+
+template::list::create \
+    -name asign_members \
+    -multirow asign_members \
+    -key user_id \
+    -elements {
+        username {
+           label {User name}
+        }
+        type {
+            label {User Type}
+       }
+    } \
+    -bulk_actions "$bulk_actions"\
+    -bulk_action_export_vars "$bulk_action_export_vars"
+
+#set orderby [template::list::orderby_clause -orderby -name asign_members]
+#if {[string equal $orderby ""]} {
+#    set orderby " order by username asc"
+#}
+
+template::list::create \
+    -name asign_not_members \
+    -multirow asign_not_members \
+    -key user_id \
+    -elements {
+        username {
+           label {User name}
+        }
+        type {
+            label {User Type}
+       }
+    } \
+    -bulk_actions "$bulk_actions_not"\
+    -bulk_action_export_vars "$bulk_action_export_vars"
+
+db_multirow asign_members get_users_list {}
+db_multirow asign_not_members get_not_users_list {}
+
+ad_form -name confirm -action imsld-role-confirm -export {imsld_id role group_instance members_list}
Index: openacs-4/packages/imsld/www/admin/imsld-role-members.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-members.xql	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<queryset>
+
+	<fullquery name="get_group_name">
+		<querytext>
+        select group_name 
+        from groups
+        where group_id=:group_instance
+        </querytext>
+	</fullquery>
+ 
+    <fullquery name="get_members_list">
+		<querytext>
+        select gmm.member_id
+        from group_member_map gmm,
+             acs_users_all aua
+        where  aua.user_id=gmm.member_id 
+               and gmm.group_id=:group_instance 
+		</querytext>
+	</fullquery>
+
+    <fullquery name="get_not_members_list">
+		<querytext>
+        select aua.user_id
+        from acs_users_all aua
+        where user_id > 0
+              and not (user_id in ([join $members_list ","]))
+		</querytext>
+	</fullquery>  
+
+    
+    <fullquery name="get_members_list_2">
+		<querytext>
+        select gmm.member_id
+        from group_member_map gmm
+        where group_id=:group_instance
+              and container_id=:group_instance
+		</querytext>
+	</fullquery>
+
+    
+    <fullquery name="get_not_members_list_2">
+		<querytext>
+        select gmm.member_id
+        from group_member_map gmm
+        where container_id=:parent_instance
+              and not (member_id in ([join $members_list ","]))
+		</querytext>
+	</fullquery>  
+    
+<fullquery name="get_users_list">
+		<querytext>
+        select dut.type as type,
+               aua.username,
+               aua.first_names,
+               aua.last_name,
+               aua.user_id
+        from dotlrn_user_types dut,
+             group_member_index gmi,
+             acs_users_all aua
+        where dut.group_id=gmi.group_id 
+              and gmi.member_id=aua.user_id 
+              and aua.user_id in ([join $members_list ","]);
+		</querytext>
+	</fullquery>
+
+    <fullquery name="get_not_users_list">
+		<querytext>
+        select dut.type as type,
+               aua.username,
+               aua.first_names,
+               aua.last_name,
+               aua.user_id
+        from dotlrn_user_types dut,
+             group_member_index gmi,
+             acs_users_all aua
+        where dut.group_id=gmi.group_id 
+              and gmi.member_id=aua.user_id 
+              and aua.user_id in ([join $not_members_list ","]);
+		</querytext>
+	</fullquery>
+
+    <fullquery name="has_role_parent_p">
+		<querytext>
+             select object_id_one as parent_instance
+             from acs_rels 
+             where object_id_two=:group_instance
+                   and rel_type='composition_rel'
+        </querytext>
+	</fullquery>
+
+    
+</queryset>
Index: openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,3 @@
+<master>
+
+@user_id@
Index: openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl	30 Mar 2006 16:01:46 -0000	1.1
@@ -0,0 +1,29 @@
+#/packages/imsld/www/admin/imsld-role-add-members.tcl
+
+ad_page_contract {
+    Remove members from an specified group
+    
+    @author lfuente@it.uc3m.es
+    @creation-date Mar 2006
+} {
+    user_id:multiple
+    members_list
+    group_instance
+    role
+    imsld_id
+ 
+} 
+#only set required variables
+   set temp_list [list]
+   foreach member $members_list {
+
+        if {[string eq "-1" [lsearch $user_id $member]]} {
+            #remove user from list
+            lappend temp_list $member
+        }
+   }
+   ad_returnredirect [export_vars -base imsld-admin-roles {imsld_id role group_instance {members_list $temp_list}}]
+
+
+   
+
Index: openacs-4/packages/imsld/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/imsld/www/admin/index.tcl	1 Feb 2006 15:20:47 -0000	1.4
+++ openacs-4/packages/imsld/www/admin/index.tcl	30 Mar 2006 16:01:46 -0000	1.5
@@ -50,6 +50,10 @@
             display_template {@imslds.delete_template;noquote@} 
             link_html { title "[_ imsld.Delete_IMS_LD]" }
         }
+        manage {
+            label {}
+            display_template {@imslds.manage;noquote@} 
+        }
     }
 
 set orderby [template::list::orderby_clause -orderby -name imslds]
@@ -61,7 +65,7 @@
 set community_id [dotlrn_community::get_community_id]
 set cr_root_folder_id [imsld::cr::get_root_folder -community_id $community_id]
 
-db_multirow  -extend { delete_template } imslds  get_imslds {
+db_multirow  -extend { delete_template manage} imslds  get_imslds {
     select imsld.imsld_id,
     coalesce(imsld.title, imsld.identifier) as imsld_title,
     cr3.item_id,
@@ -76,9 +80,13 @@
     and cr2.live_revision = ico.organization_id
     and cr3.item_id = imsld.item_id
 } {
+
     if { [empty_string_p $live_revision] } {
         set delete_template "<span style=\"font-style: italic; color: red; font-size: 9pt;\">Deleted</span> <a href=[export_vars -base "index" { {set_imsld_id_live $item_id} }]>[_ imsld.Make_it_live]</a>"
+        set manage none
     } else {
         set delete_template "<a href=\"[export_vars -base "imsld-delete" { imsld_id return_url }]\"><img src=\"/resources/acs-subsite/Delete16.gif\" width=\"16\" height=\"16\" border=\"0\"></a>"
+        set manage "<a href=\"[export_vars -base "imsld-admin-roles" {imsld_id $imsld_id}]\">Manage Members</a>"
+ 
     }
 }