membership_rel::change_state (public)

 membership_rel::change_state -rel_id rel_id -state state

Defined in packages/acs-tcl/tcl/membership-rel-procs.tcl

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
Source code:
        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
        }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
<fullquery name="membership_rel::change_state.update_modifying_user">
    <querytext>
      
          update acs_objects set modifying_user = :user_id where object_id = :rel_id 
    
      </querytext>
</fullquery>
packages/acs-tcl/tcl/membership-rel-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: