ZenphotoCMS Forum
Pulling user cookie in image template - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Pulling user cookie in image template (/thread-6764.html)



Pulling user cookie in image template - earthnutvt - 2010-03-12

I'm setting up a "Favorites" function where people can save images as their "favorite". To do this, I need to pull a user variable (either username or id) in the image template. (This would obviously only pull if someone was logged in.) Is there a way to do this? Thanks! I tried various different variables from elsewhere in the script, but none of them seemed to work.




Pulling user cookie in image template - kagutsuchi - 2010-03-12

You should use the global variable $_zp_current_admin_obj, which is an instance of the currently logged in admin object. From that, you can use the class methods of this object (Zenphoto_Administrator found in lib-auth.php) to grab whatever information you need.

I should also mention that if the current user is not logged in, $_zp_current_admin_obj will be null (if I remember correctly).




Pulling user cookie in image template - earthnutvt - 2010-03-13

I searched the entire script for $_zp_current_admin_obj and Zenphoto_Administrator, and found neither one. What am I missing?




Pulling user cookie in image template - acrylian - 2010-03-13

Well, the global variable kagutsuchi meant is $_zp_current_admin. The class he referred to is Zenphoto_Authority but that is only in the nightly build due to a change of authorization handling.




Pulling user cookie in image template - kagutsuchi - 2010-03-13

Ohh, sorry, I forgot that isn't in 1.2.9. acrylian is right.




Pulling user cookie in image template - sbillard - 2010-03-13

Let me make sure that everything is clear to you.

With Zenphoto 1.2.9 and previous there is a global array named$_zp_current_admin. There are indices for id and for user so you could get either to put in the template but I would recommend against the id and for the user element.

However, once Zenphoto 1.3 is released, this variable will no longer exist as we are moving user references to an object model. With Zenphoto 1.3 you would have to change your theme to use the object method $_zp_durrent_admin_obj->getUser().




Pulling user cookie in image template - earthnutvt - 2010-03-15

Thank you SO MUCH! I truly appreciate the assistance!