Index: openacs-4/packages/acs-subsite/tcl/group-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-subsite/tcl/group-procs.tcl 3 Oct 2003 10:14:30 -0000 1.9 +++ openacs-4/packages/acs-subsite/tcl/group-procs.tcl 10 Oct 2003 16:35:03 -0000 1.10 @@ -248,6 +248,15 @@ return [list approved "needs approval" banned rejected deleted] } +ad_proc -public group::get_member_state_pretty { + {-member_state:required} +} { + Returns the pretty-name of a member state. +} { + regsub -all { } $member_state {_} member_state + return [_ acs-kernel.member_state_$member_state] +} + ad_proc -public group::get_join_policy_options {} { Returns a list of valid join policies in a format suitable for a form builder drop-down. } { Index: openacs-4/packages/acs-subsite/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/index.adp,v diff -u -r1.14 -r1.15 --- openacs-4/packages/acs-subsite/www/index.adp 10 Oct 2003 09:02:18 -0000 1.14 +++ openacs-4/packages/acs-subsite/www/index.adp 10 Oct 2003 16:35:03 -0000 1.15 @@ -10,10 +10,10 @@ - Join community + Join community - Request membership + Request membership Index: openacs-4/packages/acs-subsite/www/members/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/index.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/www/members/index.adp 10 Oct 2003 09:02:18 -0000 1.3 +++ openacs-4/packages/acs-subsite/www/members/index.adp 10 Oct 2003 16:35:03 -0000 1.4 @@ -3,9 +3,18 @@ @page_title@ - + + + + + +
+ + + +
-

@title@

-Sorry, but you are not allowed to view the members list. +

@title@

+ Sorry, but you are not allowed to view the members list.
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.6 -r1.7 --- openacs-4/packages/acs-subsite/www/members/index.tcl 10 Oct 2003 10:40:19 -0000 1.6 +++ openacs-4/packages/acs-subsite/www/members/index.tcl 10 Oct 2003 16:35:03 -0000 1.7 @@ -7,6 +7,12 @@ } { {member_state "approved"} {orderby "name,asc"} +} -validate { + member_state_valid -requires { member_state } { + if { [lsearch [group::possible_member_states] $member_state] == -1 } { + ad_complain "Invalid member_state" + } + } } set page_title "Members" @@ -41,81 +47,172 @@ } set actions {} -set bulk_actions {} -if { $admin_p } { - set bulk_actions { - "Remove" member-remove "Remove the checked members from this group" - "Make administrator" make-admin "Make checked members administrators of this group" - "Make normal member" make-member "Make checked administrators normal of this group" - } -} - if { $admin_p || [parameter::get -parameter "MembersCanInviteMembersP" -default 0] } { set actions { "Invite" member-invite } } # TODO: Pagination -set show_partial_email_p [expr $user_id == 0] +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 +} { + lappend member_state_options \ + [list \ + [group::get_member_state_pretty -member_state $state] \ + $state \ + $num_members] +} + list::create \ -name "members" \ -multirow "members" \ -key rel_id \ -row_pretty_plural "members" \ - -bulk_actions $bulk_actions \ -actions $actions \ -elements { name { label "Name" link_url_eval {[acs_community_member_url -user_id $user_id]} - orderby "lower(u.first_names || ' ' || u.last_name)" } email { label "Email" - link_url_eval {mailto:$email} + link_url_col email_url link_html { title "Send email to this user" } - orderby "u.email" - hide_p {$show_partial_email_p} } - email_partial { + rel_role { + label "Role" + display_template { + @members.rel_role_pretty@ + + (Make administrator) + + + (Make member) + + } + } + member_state_pretty { + label "Member State" + display_template { + @members.member_state_pretty@ + + (Approve) + + + (Reject) + + + (Ban) + + + (Delete) + + + (Remove) + + } + } + } -filters { + member_state { + label "Member State" + values $member_state_options + where_clause { + mr.member_state = :member_state + } + has_default_p 1 + } + } -orderby { + name { + label "Name" + orderby "lower(u.first_names || ' ' || u.last_name)" + } + email { label "Email" orderby "u.email" - hide_p {[expr $show_partial_email_p == 0]} } rel_role { label "Role" - display_col rel_role_pretty orderby "role.pretty_name" } } # Pull out all the relations of the specified type -db_multirow -extend { email_partial } members relations_query " +set show_partial_email_p [expr $user_id == 0] + +db_multirow -extend { + email_url + member_state_pretty + remove_url + approve_url + reject_url + ban_url + delete_url + make_admin_url + make_member_url +} -unclobber members relations_query " 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 + role.pretty_name as rel_role_pretty, + mr.member_state from acs_rels r, membership_rels mr, cc_users u, acs_rel_types rt, acs_rel_roles role where r.object_id_one = :group_id and mr.rel_id = r.rel_id - and mr.member_state = 'approved' 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::orderby_clause -orderby -name "members"] " { set rel_role_pretty [lang::util::localize $rel_role_pretty] - set email_partial [string replace $email \ - [expr [string first "@" $email]+3] end "..."] + 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 }] + } + } + set remove_url [export_vars -base member-remove { rel_id }] + } + "needs approval" { + set approve_url [export_vars -base member-state-change { rel_id { member_state approved } }] + set remove_url [export_vars -base member-remove { rel_id }] + } + "rejected" - "deleted" - "banned" { + set approve_url [export_vars -base member-state-change { rel_id { member_state approved } }] + set remove_url [export_vars -base member-remove { rel_id }] + } + } + } + + if { [ad_conn user_id] == 0 } { + set email [string replace $email \ + [expr [string first "@" $email]+3] end "..."] + } else { + set email_url "mailto:$email" + } } Index: openacs-4/packages/acs-subsite/www/members/member-state-change.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/member-state-change.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/www/members/member-state-change.tcl 10 Oct 2003 16:35:03 -0000 1.1 @@ -0,0 +1,15 @@ +ad_page_contract { + Change member state +} { + {rel_id:multiple ""} + {member_state:notnull} +} + +ad_require_permission $rel_id "admin" + +membership_rel::change_state \ + -rel_id $rel_id \ + -state $member_state + +ad_returnredirect [export_vars -base . { member_state }] +ad_script_abort Index: openacs-4/packages/acs-subsite/www/register/user-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/user-join.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-subsite/www/register/user-join.tcl 10 Oct 2003 13:32:01 -0000 1.6 +++ openacs-4/packages/acs-subsite/www/register/user-join.tcl 10 Oct 2003 16:35:03 -0000 1.7 @@ -132,10 +132,18 @@ } } - if {[string equal $join_policy "needs approval"]} { - set member_state "needs approval" - } else { + if { [permission::permission_p -object_id $group_id -privilege "admin"] } { set member_state "approved" + if { [string equal $rel_type "membership_rel"] } { + # If they already have admin, bump them to an admin_rel + set rel_type "admin_rel" + } + } else { + if { [string equal $join_policy "needs approval"] } { + set member_state "needs approval" + } else { + set member_state "approved" + } } set rel_id [relation_add -form_id join -member_state $member_state $rel_type $group_id $party_id]