Index: openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 26 Nov 2003 22:47:11 -0000 1.11 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 3 Dec 2003 23:38:27 -0000 1.12 @@ -170,13 +170,14 @@ and m.rel_id = mr.rel_id and m.group_id = (select acs.magic_object_id('registered_users') from dual) and m.container_id = m.group_id + and m.rel_type = 'membership_rel' and mr.member_state = 'approved' and u.email_verified_p = 't'; -- faster simpler view -- does not check for registered user/banned etc -create view all_users +create or replace view acs_users_all as select pa.*, pe.*, u.* from parties pa, persons pe, users u @@ -200,7 +201,8 @@ and m.group_id = mo.object_id and mo.name = 'registered_users' and m.rel_id = mr.rel_id -and m.container_id = m.group_id; +and m.container_id = m.group_id +and m.rel_type = 'membership_rel'; ----------------------------------- Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 26 Nov 2003 22:47:11 -0000 1.23 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 3 Dec 2003 23:38:27 -0000 1.24 @@ -155,6 +155,7 @@ and amo.name = 'registered_users' and m.group_id = amo.object_id and m.container_id = m.group_id + and m.rel_type = 'membership_rel' and mr.member_state = 'approved' and u.email_verified_p = 't'; @@ -179,6 +180,7 @@ and amo.name = 'registered_users' and m.group_id = amo.object_id and m.rel_id = mr.rel_id + and m.rel_type = 'membership_rel' and m.container_id = m.group_id; Index: openacs-4/packages/acs-subsite/lib/subsites.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/lib/subsites.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-subsite/lib/subsites.tcl 28 Oct 2003 13:33:47 -0000 1.7 +++ openacs-4/packages/acs-subsite/lib/subsites.tcl 3 Dec 2003 23:38:27 -0000 1.8 @@ -1,10 +1,5 @@ -if { [string equal [ad_conn package_url] "/"] } { - set pretty_name [_ acs-subsite.community] - set pretty_plural [_ acs-subsite.communities] -} else { - set pretty_name [_ acs-subsite.subcommunity] - set pretty_plural [_ acs-subsite.subcommunities] -} +set pretty_name [_ acs-subsite.subsite] +set pretty_plural [_ acs-subsite.subsites] set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin -party_id [ad_conn untrusted_user_id]] if { $admin_p } { @@ -19,7 +14,7 @@ -elements { instance_name { label "[_ acs-subsite.Name]" - link_url_col url + link_url_eval "$name/" } num_members { label "\# [_ acs-subsite.Members]" @@ -28,61 +23,33 @@ } -set subsites [list] -set package_ids [list] +set subsite_node_id [subsite::get_element -element node_id] -foreach url [site_node::get_children -package_key acs-subsite -node_id [subsite::get_element -element node_id]] { - array unset node - array set node [site_node::get_from_url -url $url -exact] +set user_id [ad_conn user_id] - if { [permission::permission_p -object_id $node(object_id) -privilege read -party_id [ad_conn untrusted_user_id]] } { - # TODO - set edit_url {} - if { [permission::permission_p -object_id $node(object_id) -privilege admin] } { - set edit_url {} - } - lappend subsites [list \ - $node(instance_name) \ - $node(node_id) \ - $node(name) \ - $node(object_id) \ - $node(url)] - lappend package_ids $node(object_id) - } +db_multirow subsites select_subsites { + select p.package_id, + p.instance_name, + n.node_id, + n.name, + (select count(*) + from application_groups ag, + group_approved_member_map m + where ag.package_id = p.package_id + and m.rel_type = 'membership_rel' + and m.group_id = ag.group_id) as num_members + from site_nodes n, + apm_packages p + where n.parent_id = :subsite_node_id + and p.package_id = n.object_id + and p.package_key = 'acs-subsite' + and exists (select 1 + from all_object_party_privilege_map perm + where perm.object_id = p.package_id + and perm.privilege = 'read' + and perm.party_id = :user_id) + order by upper(instance_name) } -array set num_members [list] -if { [llength $package_ids] > 0 } { - db_foreach num_members " - select ag.package_id, - count(member_id) as n_members - from application_groups ag, - group_approved_member_map m - where ag.package_id in ('[join $package_ids "','"]') - and m.group_id = ag.group_id - group by ag.package_id - " { - set num_members($package_id) [lc_numeric $n_members] - } -} -# Sort them by instance_name -set subsites [lsort -index 0 $subsites] -multirow create subsites instance_name node_id name package_id url num_members - -foreach elm $subsites { - set package_id [lindex $elm 3] - if { ![info exists num_members($package_id)] } { - set num_members($package_id) {} - } - - multirow append subsites \ - [lindex $elm 0] \ - [lindex $elm 1] \ - [lindex $elm 2] \ - [lindex $elm 3] \ - [lindex $elm 4] \ - $num_members($package_id) -} - Index: openacs-4/packages/acs-subsite/www/members/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/index.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-subsite/www/members/index.tcl 11 Nov 2003 09:51:48 -0000 1.12 +++ openacs-4/packages/acs-subsite/www/members/index.tcl 3 Dec 2003 23:38:27 -0000 1.13 @@ -25,8 +25,6 @@ # only to ban/delete them. set main_site_p [string equal [site_node::get_url -node_id [ad_conn node_id]] "/"] -set rel_type "membership_rel" - set user_id [ad_conn user_id] set show_member_list_to [parameter::get -parameter "ShowMembersListTo" -default 2] @@ -66,28 +64,22 @@ } set member_state_options [list] -db_foreach select_member_states { - select mr.member_state as state, - count(mr.rel_id) as num_members - from membership_rels mr, - acs_rels r - where r.rel_id = mr.rel_id - and r.object_id_one = :group_id - group by mr.member_state -} { +db_foreach select_member_states {} { lappend member_state_options \ [list \ [group::get_member_state_pretty -member_state $state] \ $state \ [lc_numeric $num_members]] } +db_1row pretty_roles {} + template::list::create \ -name "members" \ -multirow "members" \ - -key rel_id \ -row_pretty_plural "members" \ -page_size 50 \ + -page_flush_p t \ -page_query_name members_pagination \ -actions $actions \ -elements { @@ -104,32 +96,39 @@ label "[_ acs-subsite.Role]" display_template { @members.rel_role_pretty@ + } + } + rel_role_action { + label {} + display_template { - (#acs-subsite.Make_administrator#) + #acs-subsite.Make_administrator# - (#acs-subsite.Make_member#) + #acs-subsite.Make_member# } } member_state_pretty { label "[_ acs-subsite.Member_State]" + } + member_state_change { + label {} display_template { - @members.member_state_pretty@ - (#acs-subsite.Approve#) + #acs-subsite.Approve# - (#acs-subsite.Reject#) + #acs-subsite.Reject# - (#acs-subsite.Ban#) + #acs-subsite.Ban# - (#acs-subsite.Delete#) + #acs-subsite.Delete# - (#acs-subsite.Remove#) + #acs-subsite.Remove# } } @@ -151,10 +150,6 @@ label "[_ acs-subsite.Email]" orderby "u.email" } - rel_role { - label "[_ acs-subsite.Role]" - orderby "role.pretty_name" - } } @@ -172,20 +167,22 @@ delete_url make_admin_url make_member_url + rel_role_pretty } -unclobber members members_select {} { - set rel_role_pretty [lang::util::localize $rel_role_pretty] + if { $member_admin_p > 0 } { + set rel_role_pretty [lang::util::localize $admin_role_pretty] + } else { + set rel_role_pretty [lang::util::localize $member_role_pretty] + } set member_state_pretty [group::get_member_state_pretty -member_state $member_state] if { $admin_p } { switch $member_state { approved { - switch $rel_role { - member { - set make_admin_url [export_vars -base make-admin { rel_id }] - } - admin { - set make_member_url [export_vars -base make-member { rel_id }] - } + if { $member_admin_p == 0 } { + set make_admin_url [export_vars -base make-admin { user_id }] + } else { + set make_member_url [export_vars -base make-member { user_id }] } if { $main_site_p } { set ban_url [export_vars -base member-state-change { rel_id {member_state banned} }] Index: openacs-4/packages/acs-subsite/www/members/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/index.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/www/members/index.xql 10 Nov 2003 17:32:15 -0000 1.1 +++ openacs-4/packages/acs-subsite/www/members/index.xql 3 Dec 2003 23:38:27 -0000 1.2 @@ -11,6 +11,7 @@ membership_rels mr, cc_users u where r.object_id_one = :group_id + and r.rel_type = 'membership_rel' and mr.rel_id = r.rel_id and u.user_id = r.object_id_two [template::list::filter_where_clauses -and -name "members"] @@ -19,35 +20,57 @@ + + + select admin_role.pretty_name as admin_role_pretty, + member_role.pretty_name as member_role_pretty + from acs_rel_roles admin_role, acs_rel_roles member_role + where admin_role.role = 'admin' + and member_role.role = 'member'; + + + + select r.rel_id, u.user_id, u.first_names || ' ' || u.last_name as name, u.email, - r.rel_type, - rt.role_two as rel_role, - role.pretty_name as rel_role_pretty, - mr.member_state + mr.member_state, + (select count(*) + from rel_segment_party_map + where rel_type = 'admin_rel' + and group_id = :group_id + and party_id = u.user_id) as member_admin_p from acs_rels r, membership_rels mr, - cc_users u, - acs_rel_types rt, - acs_rel_roles role + cc_users u where r.object_id_one = :group_id and mr.rel_id = r.rel_id + and r.rel_id = mr.rel_id and u.user_id = r.object_id_two - and rt.rel_type = r.rel_type - and role.role = rt.role_two [template::list::filter_where_clauses -and -name "members"] [template::list::page_where_clause -and -name "members" -key "r.rel_id"] [template::list::orderby_clause -orderby -name "members"] - + + + + select mr.member_state as state, + count(mr.rel_id) as num_members + from membership_rels mr, acs_rels r + where r.rel_id = mr.rel_id + and r.object_id_one = :group_id + and r.rel_type = 'membership_rel' + group by mr.member_state + + + Index: openacs-4/packages/acs-subsite/www/members/make-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/make-admin.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/www/members/make-admin.tcl 28 Aug 2003 09:41:41 -0000 1.2 +++ openacs-4/packages/acs-subsite/www/members/make-admin.tcl 3 Dec 2003 23:38:27 -0000 1.3 @@ -1,48 +1,19 @@ ad_page_contract { Make administrators. } { - {rel_id:multiple ""} + {user_id:multiple ""} } set group_id [application_group::group_id_from_package_id] -ad_require_permission $group_id "admin" +permission::require_permission -object_id $group_id -privilege "admin" -db_1row group_info { - select group_name, join_policy - from groups - where group_id = :group_id -} - -set create_p [group::permission_p -privilege create $group_id] - -if { [string equal $join_policy "closed"] && !$create_p} { - ad_return_forbidden "Cannot make admin members" "I'm sorry, but you're not allowed to make admin members in this group" - ad_script_abort -} - db_transaction { - foreach one_rel_id $rel_id { - db_1row select_rel_info { - select rel_type as existing_rel_type, - object_id_two as user_id - from acs_rels - where rel_id = :one_rel_id - } - - if { [string equal $existing_rel_type "admin_rel"] } { - # Already an admin, skip - continue - } - - set member_state [group::default_member_state -join_policy $join_policy -create_p $create_p] - - # Delete the old relation - relation_remove $one_rel_id - - # Add the new relation - set rel_id [relation_add -member_state $member_state "admin_rel" $group_id $user_id] - + foreach one_user_id $user_id { + group::add_member \ + -group_id $group_id \ + -user_id $one_user_id \ + -rel_type "admin_rel" } } on_error { ad_return_error "Error creating the relation" "We got the following error message while trying to create this relation:
$errmsg
" Index: openacs-4/packages/acs-subsite/www/members/make-member.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/make-member.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/www/members/make-member.tcl 28 Aug 2003 09:41:41 -0000 1.2 +++ openacs-4/packages/acs-subsite/www/members/make-member.tcl 3 Dec 2003 23:38:27 -0000 1.3 @@ -1,51 +1,20 @@ ad_page_contract { Make ordinary members. } { - {rel_id:multiple ""} + {user_id:multiple ""} } set group_id [application_group::group_id_from_package_id] -ad_require_permission $group_id "admin" +permission::require_permission -object_id $group_id -privilege "admin" -db_1row group_info { - select group_name, join_policy - from groups - where group_id = :group_id -} - -set create_p [group::permission_p -privilege create $group_id] - -if { [string equal $join_policy "closed"] && !$create_p} { - ad_return_forbidden "Cannot make admin members" "I'm sorry, but you're not allowed to make admin members in this group" - ad_script_abort -} - # TODO: -# Check if you're making yourself an non-admin +# Check if you're making yourself an non-admin? db_transaction { - foreach one_rel_id $rel_id { - db_1row select_rel_info { - select rel_type as existing_rel_type, - object_id_two as user_id - from acs_rels - where rel_id = :one_rel_id - } - - if { [string equal $existing_rel_type "membership_rel"] } { - # Already a member, skip - continue - } - - set member_state [group::default_member_state -join_policy $join_policy -create_p $create_p] - - # Delete the old relation - relation_remove $one_rel_id - - # Add the new relation - set rel_id [relation_add -member_state $member_state "membership_rel" $group_id $user_id] - + foreach one_user_id $user_id { + db_1row get_rel_id {} + relation_remove $rel_id } } on_error { ad_return_error "Error creating the relation" "We got the following error message while trying to create this relation:
$errmsg
" Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-subsite/www/members/make-member.xql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-subsite/www/members/member-invite.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/member-invite.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/www/members/member-invite.tcl 10 Nov 2003 12:36:20 -0000 1.3 +++ openacs-4/packages/acs-subsite/www/members/member-invite.tcl 3 Dec 2003 23:38:27 -0000 1.4 @@ -67,9 +67,18 @@ group::add_member \ -group_id $group_id \ -user_id $user_id \ - -rel_type $rel_type + -rel_type membership_rel + + # DRB: This is a bandaid-patch to make relseg usage consistent with the + # older parts of the toolkit. Relsegs need reworking but until then... + if { ![string equal $rel_type membership_rel] } { + group::add_member \ + -group_id $group_id \ + -user_id $user_id \ + -rel_type $rel_type + } } { - form set_error user_serach user_id "Error adding user to community: $errmsg" + form set_error user_search user_id "Error adding user to community: $errmsg" global errorInfo ns_log Error "Error adding user $user_id to community group $group_id: $errmsg\n$errorInfo" break