Forum OpenACS Q&A: Response to users and "~user" apache emulation

Collapse
Posted by Todd Gillespie on
proc tilde_to_user_filter {} {
    set tilde_user_name [lindex [ns_conn urlv] 0]
    set user_name [url_decode [string range $tilde_user_name 2 end]]
    set db [ns_db gethandle] 
    set user_id [database_to_tcl_string $db "select user_id from users 
	where screen_name = '[DoubleApos $user_name]'"]
    ns_db releasehandle $db
    ns_returnredirect "/shared/community-member.tcl?user_id=$user_id"
}

ns_registerproc GET /~* tilde_to_user_filter
This is easy to do with AOLserver, but not so much with OpenACS. Reason why is because there is some functional overlap between screen_name, email, and first_names + last_name; at least in terms of which is the valid name to use as ~user. Also, since usernames can have spaces & other unix- and url-forbidden characters, a user typing "somesite.org/~user" will have to type URL encodings, like "todd g" as "somesite.org/~todd%20g". Not very pleasing unto the eye and tongue.