Member
Member
earthnutvt   2010-03-12, 22:29
#1

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.

Member
Member
kagutsuchi   2010-03-12, 23:45
#2

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).

Member
Member
earthnutvt   2010-03-13, 13:47
#3

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

Administrator
Administrator
acrylian   2010-03-13, 13:57
#4

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.

Member
Member
kagutsuchi   2010-03-13, 15:09
#5

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

Member
Member
sbillard   2010-03-13, 17:56
#6

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().

Member
Member
earthnutvt   2010-03-15, 13:53
#7

Thank you SO MUCH! I truly appreciate the assistance!

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.