I have embedded Gallery 2.3 into my Web site so that logging in is handled by my website procedure. This is geat and fantastic.
So, as the documentation points out, the line $gallery->setConfig('login', true) in the embedding file displays the login/logout and and account info links and leaving the line out does not display it.
My website doesn't monitor events so to keep synchronization between my Web site accounts and my G2 accounts is done on the fly. My methodology goes like this: If a Web site member goes to my gallery, G2 looks to see if there's an entry in the ExternalIdMap table, if there is log the guy into G2; if there isn't, create an embedded G2 account based on the web account info and log the guy into. It's simple, maybe a tad flimsy, but it works just fine.
*HOWEVER* if at some time later some account info is changed on my website (say the member changes the spelling of his name or or, more likely, his e-mail address) this information will not be recorded in G2.
Well, I *could* write a few lines in my web-site profile update page to update G2 at the same time and that wouldn't be hard but .... I don't want to. (I don't want to because, I want to keep my embedded programming clean so that the only places I have to worry about G2 {or any other embedded application} is in the G2 {or any embedded application} itself.) Now the G2 user can modify his by clicking on the "account" link. But I TURNED THAT OFF WHEN I TURNED OFF THE LOGIN LINK.
Q1)So is there a way to get the "account" link back without getting the login link back?
While I'm asking, I might as well ask if there are ways to configure what a user can reset?
Q2) Since embedding doesn't use the G2 password can I modify so the user can not reset the G2 password? Can I make is so that modifying his email address doesn't need a password?
As I write this I realize that I could simply not include a login link for my Web Site, leave the $gallery->setConfig('login', true) in the embedding file, and have a 'loginRedirect'=>{web login page} in the GalleryEmbed::init() call. Then the G2 login link will log the user into my Web site, good, the 'account' link will allow the user to modify his account, good, and the 'logout' link will log the G2 account out while leaving him logged into the Web Site so G2 will embed and log him right back in again, !BAD!...
Q3)Is there a 'logoutRedirect' value I can set?
Hmmmm.
Posts: 32
Know what?
Since it's only the user's full name and email address that I care about, it wouldn't be too unweildy to write a clause into the embedding page that will check these each time and update these two values if nescessary.
So never mind.
HOWEVER, if anyone wants to give me hints and pointers on how to write that ($user = $gallery->getActiveUser() gives me the active user but what class is the active user in? What methods can I call? How do I set his full name and email?) I'd be grateful but I'm going to look in the DOCs and see if I can figure it out.
Posts: 8339
having the $user already gives your all the user's info print_r($user) should show you all the user info.
look to modules/core/classes/GalleryUser.class
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 32
Thank you, I hope. I figured pretty quickly that I wanted to do something like:
$user = $gallery->getActiveUser();
if ($user->fullName != $member['first']." ".$member['last'])
$user->setFullName($member['first']." ".$member['last']);
if ($user->email != $member['email'])
$user->setEmail($member['email']);
But immediately I discovered that for some reason
$user = $gallery->getActiveUserId(); $user == 31 (which is as I'd expect)
BUT
$user = $gallery->getActiveUser(); $user = '' ???HUH????
So are you saying "$user" is a pre-defined variable (as $gallery seems to be)?
If not, do you have any idea why $gallery->getActiveUser() returns a null????
Posts: 8339
$user = $gallery->getActiveUser();
should at least return the guest user if you are not logged in.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 32
Here's my code. Any comment will be appreciated:
Okay, at this point we've initialize the G2 and set the active user id.
But is it possible that we've only set the id and *not* created the user?????
The next part of my code deals with checking whether my web user is in the proper groups. (On my web site a logged in member has 'status' that is one of the four terms-- 'admin', 'assoc member', 'member', or 'guest'-- perhaps 'guest' and 'member' were a poor choice of words as they mean completely different things in other context so keep in mind that $member['status'] == 'guest' just means that the logged-in *and* registered user of my web site has a characteristic called g-u-e-s-t. I want to make sure that if my web user is a g-u-e-s-t then as a G2 user he is put in a G2 group called 'visitors' but otherwise he is put in a group called 'full'. Again, perhaps not the best choice of terms.)
(With me so far?)
and *that* part of the code works just fine! (Which actually surprised me!!!)
But here's my current perplexity:
So... I'm trying to get the active user *before* I send the request. Is *that* the problem? I'm doing a bunch of crap with session ids. Is *that* the problem?
Or is it... I dunno ....
Posts: 32
NOW I GET IT!
Yes, active user isn't set until *after* the handle call (duh). Somehow I thought if I put my code after that handle call, it would go into effect untill after the page loaded. But I guess that's what the 'idDone' property is for, isn't it.
Posts: 8339
Yes, GalleryEmbed::done(); commits any GalleryEmbed methods.
this is my usual init:
First run we just get gallery running $full=false
Then after we figure out our user we re-init $full=true
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 8339
to check your user mapping:
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 32
Now I'm having trouble that
$user->setFullName($member['first']." ".$member['last']);
Doesn't seem to set the user's full name in the database. !!Argh!!
Because $gallery->activeUser is only the current instance of the user and not the permanent record of the user????
Posts: 8339
Did you call GalleryEmbed::done(); after?
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 32
Okay. I think I know whats going on.
I need to use GalleryEmbed::updateUser($uid, array('full_name'=>$real_full_name, 'email'=>$real_name));
*and* I need to do it *before* I handle the request.
*but* I don't know how to get the user's fullname, email, or anything from either the external or internal id, when the user isn't *yet* the active user.
So after much headache I've got this code that works!!!!!
Here it is (minus error handling):
The only thing is I really *don't* like requesting user update *every* time *any* user views *any* page just because I don't know how to check what a user's info is.
So, how do I get user info from an id either external or internal when the user is not the active user yet?
Oh, and thanks for your help. It's been a learning experience.
Posts: 32
No. Where should I do that?