I have a website with a Gallery2 install and a blog. The blog actually pulls content from an IPB blog on another site I host. The problem with this setup is that anyone wanting to comment on my blog would have to find the other site and register there, then find my blog there and comment on it. Obviously not the best setup!
I want to move the blog contents from the IPB forum to my website, and I'd like to use Gallery to handle all the login/authentication stuff, so they don't have to have two accounts. I need advice on how to do the following:
- Make the blog know when someone is logged into the Gallery (probably easy via a cookie or something)
- Make the blog know who is logged into the Gallery
Once I figure out how to do that, I think I can handle the rest.
Thanks for any input!
Posts: 8339
much easier the other way around, but... http://codex.gallery2.org/Gallery2:Embedding#Visual_vs._Functional_Integration
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 33
By "the other way around" do you mean write my own authentication system and use that for Gallery?
Posts: 8339
gallery has a built-in externalId for identifying users from a blog/cms the way you want would require you to write a way for your blog to identify and check permissions for gallery users.
does your blog not already have some auth system?
http://www.google.com/search?q=gallery2+ipb brings up some helpful stuff.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 33
Yep, but like I said, that blog is on a totally different site (which happens to be hosted on the same machine) and I don't want users to have to register on that site. Also, I might not host that site forever, so eventually I'll want to move my blog to my own website. Might as well start now rather than do all this twice.
Posts: 33
Ok, I'm still trying to figure out whether or not a user is logged into my gallery when they're on my sites main index page. I followed a tip in this post, but $userID always seems to equal 5, no matter who is (or isn't) logged in.
I'd ultimately like to somehow capture all the user info (username, Id, etc) on my main index page. Any ideas?
Posts: 8339
Ok, so what I'm doing here is first checking for the GALLERYSID cookie:
$currentSession = (isset($_COOKIE['GALLERYSID']) && $_COOKIE['GALLERYSID'] !='TMP_SESSION_ID_DI_NOISSES_PMT')?true : false;
If false, I display my login link which pops a login form.
else if true, I ajax query another script for the user:
userActions.php
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 33
I used the info out of your useractions.php, and I get a nice long string with things like the username, full name, hashed password, email, etc. I guess I just need to figure out how to chop it up and pull out the pieces I want. If this was ColdFusion, it would be a piece of cake for me. I'll have to figure out how to do it in PHP, which I'm pretty much a novice in.
The string seems to go "item":"value", so I think I probably need to make an array out of it. Looks like it's time to hit the man pages :p
Thanks for the pointers.
Posts: 8339
you don't need to json_encode if you're not returning for ajax.
$user = $gallery->getActiveUser(); gets you all you need, the user object and then you can use the built-in getters like: $user->getUserName(); and $user->getFullName() ...
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryUser.html#sec-method-summary
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 33
Aha, there we go. I have a nice array-looking thing now, but I can't figure out how to extract the data. I tried $user['userName'] but I get a blank. I think there's some sort of while loop that I'm missing or something. When I do a print_r() on the variable, I can see all the data, but I just can't seem to get to it.
Posts: 8339
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 33
lol well yes! That's very useful, if only I knew how to make it work. I think I have a syntax problem or am missing an in-between step. There isn't a sample of how to go from point a to point b.