• Publicity: Public Only All

membership-rel-procs.tcl

Manage Membership Relations

Location:
packages/acs-tcl/tcl/membership-rel-procs.tcl
Created:
2002-03-15
Author:
yon <yon@openforce.net>
CVS Identification:
$Id: membership-rel-procs.tcl,v 1.15 2024/09/11 06:15:48 gustafn Exp $

Procedures in this file

Detailed information

membership_rel::approve (public)

 membership_rel::approve -rel_id rel_id

Approve a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::approve membership_rel::approve test_ad_proc_change_state_member->membership_rel::approve membership_rel::change_state membership_rel::change_state (public) membership_rel::approve->membership_rel::change_state

Testcases:
ad_proc_change_state_member

membership_rel::ban (public)

 membership_rel::ban -rel_id rel_id

Ban a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::ban membership_rel::ban test_ad_proc_change_state_member->membership_rel::ban membership_rel::change_state membership_rel::change_state (public) membership_rel::ban->membership_rel::change_state

Testcases:
ad_proc_change_state_member

membership_rel::change_state (public)

 membership_rel::change_state -rel_id rel_id -state state

Change the state of a membership relation

Switches:
-rel_id (required)
-state (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::change_state membership_rel::change_state test_ad_proc_change_state_member->membership_rel::change_state test_auth_authentication_implementations auth_authentication_implementations (test acs-authentication) test_auth_authentication_implementations->membership_rel::change_state acs_magic_object acs_magic_object (public) membership_rel::change_state->acs_magic_object acs_user::flush_cache acs_user::flush_cache (public) membership_rel::change_state->acs_user::flush_cache acs_user::get acs_user::get (public) membership_rel::change_state->acs_user::get ad_conn ad_conn (public) membership_rel::change_state->ad_conn db_dml db_dml (public) membership_rel::change_state->db_dml acs_user::change_state acs_user::change_state (public) acs_user::change_state->membership_rel::change_state auth::local::authentication::MergeUser auth::local::authentication::MergeUser (private) auth::local::authentication::MergeUser->membership_rel::change_state membership_rel::approve membership_rel::approve (public) membership_rel::approve->membership_rel::change_state membership_rel::ban membership_rel::ban (public) membership_rel::ban->membership_rel::change_state membership_rel::delete membership_rel::delete (public) membership_rel::delete->membership_rel::change_state

Testcases:
auth_authentication_implementations, ad_proc_change_state_member

membership_rel::delete (public)

 membership_rel::delete -rel_id rel_id

Delete a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::delete membership_rel::delete test_ad_proc_change_state_member->membership_rel::delete membership_rel::change_state membership_rel::change_state (public) membership_rel::delete->membership_rel::change_state

Testcases:
ad_proc_change_state_member

membership_rel::expire (public)

 membership_rel::expire -rel_id rel_id

Expire a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::expire membership_rel::expire test_ad_proc_change_state_member->membership_rel::expire membership_rel::change_state membership_rel::change_state (public) membership_rel::expire->membership_rel::change_state

Testcases:
ad_proc_change_state_member

membership_rel::get (public)

 membership_rel::get -rel_id rel_id

Return the user_id of a rel_id

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 membership_rel::get_group_id membership_rel::get_group_id (public) membership_rel::get membership_rel::get membership_rel::get_group_id->membership_rel::get membership_rel::get_user_id membership_rel::get_user_id (public) membership_rel::get_user_id->membership_rel::get packages/acs-subsite/www/members/member-state-change.tcl packages/acs-subsite/ www/members/member-state-change.tcl packages/acs-subsite/www/members/member-state-change.tcl->membership_rel::get db_1row db_1row (public) membership_rel::get->db_1row

Testcases:
No testcase defined.

membership_rel::get_group_id (public)

 membership_rel::get_group_id -rel_id rel_id

Return the group_id of a rel_id

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 membership_rel::get membership_rel::get (public) membership_rel::get_group_id membership_rel::get_group_id membership_rel::get_group_id->membership_rel::get

Testcases:
No testcase defined.

membership_rel::get_user_id (public)

 membership_rel::get_user_id -rel_id rel_id

Return the user_id of a rel_id

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 membership_rel::change_state membership_rel::change_state (public) membership_rel::get_user_id membership_rel::get_user_id membership_rel::change_state->membership_rel::get_user_id membership_rel::get membership_rel::get (public) membership_rel::get_user_id->membership_rel::get

Testcases:
No testcase defined.

membership_rel::reject (public)

 membership_rel::reject -rel_id rel_id

Reject a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::reject membership_rel::reject test_ad_proc_change_state_member->membership_rel::reject membership_rel::change_state membership_rel::change_state (public) membership_rel::reject->membership_rel::change_state

Testcases:
ad_proc_change_state_member

membership_rel::unapprove (public)

 membership_rel::unapprove -rel_id rel_id

Unapprove a membership relation

Switches:
-rel_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_proc_change_state_member ad_proc_change_state_member (test acs-tcl) membership_rel::unapprove membership_rel::unapprove test_ad_proc_change_state_member->membership_rel::unapprove membership_rel::change_state membership_rel::change_state (public) membership_rel::unapprove->membership_rel::change_state

Testcases:
ad_proc_change_state_member
[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    Manage Membership Relations

    @author yon (yon@openforce.net)
    @creation-date 2002-03-15
    @cvs-id $Id: membership-rel-procs.tcl,v 1.15 2024/09/11 06:15:48 gustafn Exp $
}

namespace eval membership_rel {

    d_proc -public change_state {
        {-rel_id:required}
        {-state:required}
    } {
        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 [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
            if { $user(member_state) eq "deleted" && $state eq "approved" } {
                group::remove_member \
                    -group_id [acs_magic_object the_public] \
                    -user_id $rel_user_id
            }

            set valid_states {
                "approved"
                "banned"
                "rejected"
                "deleted"
                "needs approval"
                "merged"
                "expired"
            }

            if {$state in $valid_states} {
                db_dml update_state {
                    update membership_rels set
                      member_state = :state
                    where rel_id = :rel_id
                }

                if {$state eq "deleted"} {
                    # Add user to public group - see bug 1468
                    group::add_member \
                        -no_perm_check \
                        -group_id [acs_magic_object the_public] \
                        -user_id $rel_user_id
                }
            }

            # Record who changed the state
            # This will trigger an update of the acs_objects.modified_date column.
            # We use this in the ApprovalExpiration feature to make sure that a user isn't
            # bumped back to needs_approval right after an administrator has approved them,
            # even if the user doesn't log in the meantime.

            if { [ns_conn isconnected] } {
                set user_id [ad_conn user_id]
            } else {
                set user_id ""
            }
            db_dml update_modifying_user {}
        }

        if { $rel_user_id ne "" } {
            acs_user::flush_cache -user_id $rel_user_id
        }
    }

    d_proc -public approve {
        {-rel_id:required}
    } {
        Approve a membership relation
    } {
        change_state -rel_id $rel_id -state "approved"
    }

    d_proc -public ban {
        {-rel_id:required}
    } {
        Ban a membership relation
    } {
        change_state -rel_id $rel_id -state "banned"
    }

    d_proc -public reject {
        {-rel_id:required}
    } {
        Reject a membership relation
    } {
        change_state -rel_id $rel_id -state "rejected"
    }

    d_proc -public delete {
        {-rel_id:required}
    } {
        Delete a membership relation
    } {
        change_state -rel_id $rel_id -state "deleted"
    }

    d_proc -public unapprove {
        {-rel_id:required}
    } {
        Unapprove a membership relation
    } {
        change_state -rel_id $rel_id -state "needs approval"
    }

    d_proc -public expire {
        {-rel_id:required}
    } {
       Expire a membership relation
    } {
        change_state -rel_id $rel_id -state "expired"
    }

    d_proc -public get {
        {-rel_id:required}
    } {
        Return the user_id of a rel_id
    } {
        db_1row select_rel_id {
            select u.user_id, r.object_id_one as group_id
            from   acs_rels r,
            users u
            where  r.rel_id = :rel_id
            and    u.user_id = r.object_id_two
        }
        return [list user_id $user_id group_id $group_id]
    }

    d_proc -public get_user_id {
        {-rel_id:required}
    } {
        Return the user_id of a rel_id
    } {
        return [dict get [get -rel_id $rel_id] user_id]
    }

    d_proc -public get_group_id {
        {-rel_id:required}
    } {
        Return the group_id of a rel_id
    } {
        return [dict get [get -rel_id $rel_id] group_id]
    }

}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: