acs_user::demote_user (public)
acs_user::demote_user [ -user_id user_id ] [ -delete_portrait ]
Defined in packages/acs-tcl/tcl/community-core-procs.tcl
Demotes an ACS user to a person/party. If another table references the user and prevents deletion, all database changes made by demotion are rolled back. It is probably best for tables created in other packages to reference persons, parties, or acs_objects instead. This proc could be extended with an option to find all referenced tables and remove rows referencing this user.
- Switches:
- -user_id (optional)
- the user_id in the acs system that should be demoted.
- -delete_portrait (optional, boolean)
- Delete the portrait of the user
- Error:
- An error is thrown if user_id is not in the users table.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- demote_promote_a_user, demote_user_rolls_back
Source code: # # Make sure this user exists # set user_info [acs_user::get -user_id $user_id] if { [llength $user_info] == 0 } { error "This user does not exist." } db_transaction { # revoke permissions db_dml noxql { DELETE FROM acs_permissions WHERE grantee_id = :user_id } db_multirow -local rels noxql { SELECT rel_id FROM acs_rels WHERE rel_type = 'membership_rel' AND object_id_two = :user_id } template::multirow -local foreach rels { relation_remove $rel_id } db_dml noxql { DELETE FROM user_preferences WHERE user_id = :user_id } db_dml noxql { DELETE FROM users WHERE user_id = :user_id } # # Update object type. # db_dml update_object_type { UPDATE acs_objects SET object_type = 'person' WHERE object_id = :user_id } # # Remove the portrait on request. # if {$delete_portrait_p} { acs_user::erase_portrait -user_id $user_id } } # # Always flush the cache. It should not be necessary to flush the # person_info cache, since the "person" is still around. # acs_user::flush_cache -user_id $user_id # # All user's direct permissions have been revoked, flush the # permissions cache as well. # permission::cache_flush -party_id $user_id returnGeneric XQL file: packages/acs-tcl/tcl/community-core-procs.xql
PostgreSQL XQL file: packages/acs-tcl/tcl/community-core-procs-postgresql.xql
Oracle XQL file: packages/acs-tcl/tcl/community-core-procs-oracle.xql