Forum OpenACS Q&A: Re: "Logged In?"-Datasource and Template

Collapse
Posted by Dirk Gomez on

You need to write

set some_variable_name [ad_get_user_info]

Collapse
Posted by Tim Adler on
Thanks Dirk!

Now, I'll go browsing through that procs...see what else I can use

;)
Dirk,

AFAIK you don't have to use set here. ad_get_user_info sets automatically $first_names, $last_name and $email.

I think the problem is that when you are just calling a proc (without doing anything with the return value), you're not supposed to use [ ] brackets around it. So this should be sufficient:

ad_get_user_info
That's it. Nothing more and you get the variables set.
Yep, works also...just tried that.

BTW, as we're all together here again 😉!
What does

ad_return_error
do (Where can I find a reference in the API). Cause it seems that this one is somehow messing up my desired result. Whenever there is no user_info (e.g not logged in) then the server doesn't respond anymore.

I plan to write to proc at the desired position again and leave out the operations in the catch block.

Tim,

Just use the search box in https://openacs.org/api-doc/ and you'll find the explanation for every proc in the system 😊 (in this case, https://openacs.org/api-doc/proc-view?proc=ad%5freturn%5ferror)

In fact that proc doesn't seem to fit too good in this situation, since it returns a http error if the user_id is not defined. You could get around this by doing something like this:

set user_id [ad_get_user_id]
if { $user_id != 0 } {
    ad_get_user_info
}

This blows away part of the handiness of this function, though. In general I don't understand why ad_get_user_info returns an http error in the first place. At least it narrows the use of it a lot. Maybe that's why e.g. the default index page of an oacs installation uses an ad hoc sql query to get the user info. I think there should definitely be an allround proc for this.