Do I have to manually create all the users ?

DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Wed, 2006-09-27 07:45

Having a tough time to get Gallery2 embedded into my FUDForum. We have 93 users in the forum and just setting up the Gallery.

I have read through the info on how to embed into another app, but it sems a little over my head [I do a little programming, but never touched php]

From what I have read, I have to create all 93 users from my forum in Gallery2. Manually is the most obvious, but perhaps a script to do it all from the database side.

Any info on how to embed Gallery2 into a forum, thats a little more dumbed down then the current documentation, would be appreciated

[been trying to get this done for 6mths now]

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-09-27 08:55

there are 2 alternatives.
a) (not that sexy) do the "on-the-fly" user creation as described in the docs. each time a signed in fudforum user clicks on the embedded g2, it checks whether the user already exists in g2 and if not, GalleryEmbed::createUser(...) creates it.

b) write a script to import your 93 existing fudforum users in a loop and call GalleryEmbed::createUser(...) in the loop. additionally, you need to add some code in fudforum such that each time a user gets created, GalleryEmbed::createUser(...) is called as well.

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Wed, 2006-09-27 12:59

What does GalleryEmbed::createUser(...)" mean ? Thats a function in the php code of gallery ? So you need to make a php script file and call it from you browser to execute anything you write to achieve this task ? Whats a good way to get stdout and stderr from the execution of the php file ?

Could you just do the "copying" of users over in some SQL code ? I mean all the info is kept in the DB.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-09-27 13:46

we strongly discourage from manually interacting with the database.
there are no guarantees from us about the sql schema. and our schema isn't the easiest one to code for, you could easily forget important stuff.

thus, yes, use the Gallery API which is in PHP.

create a php script that includes gallery's embed.php and then use GalleryEmbed::init() and GalleryEmbed::createUser() etc.
please look at other forum posts and at documentation -> embedding / integration -> writing a new integration -> an entry file -> download the sample wrapper.

you can call php scripts from the command line too. if you do a print or echo in php, it goes to stdout.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-10-13 01:17

> What user details can I use ? I mean I am expecting fudforums user table to not match gallery's.

http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodcreateUser

shows which params it expects.

> And then I need to edit fudforum to create a user in gallery when a user is created ?

yes, you need to create all existing fudforum users in g2 with createUser.
and then, each time a user registers in fudforum, you need to call createUser too.
please ask in the fudforum.org forum how, fudforum is also built for integration, it should be straight forward.

> When I started on this, I thought gallery would simply authenticate using the emApp's user list and cookie's?
it does. but authentication is not the same as user management.
once a user exists in both application, you can just call GalleryEmbed::init with the right activeUserId (the one that fudforum has authenticated) and then call handleRequest() and you're done.

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Fri, 2006-10-13 02:14
valiant wrote:
> What user details can I use ? I mean I am expecting fudforums user table to not match gallery's.

http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodcreateUser

shows which params it expects.

Cheers.

PS so you use little => to assign vars when calling a mthod in PHP ?

valiant wrote:
> And then I need to edit fudforum to create a user in gallery when a user is created ?

yes, you need to create all existing fudforum users in g2 with createUser.
and then, each time a user registers in fudforum, you need to call createUser too.
please ask in the fudforum.org forum how, fudforum is also built for integration, it should be straight forward.

Yeah indeed it is, he's done a great with it! It has an API and all, I wish I had a clue to use it :)

valiant wrote:
> When I started on this, I thought gallery would simply authenticate using the emApp's user list and cookie's?
it does. but authentication is not the same as user management.
once a user exists in both application, you can just call GalleryEmbed::init with the right activeUserId (the one that fudforum has authenticated) and then call handleRequest() and you're done.

Ahh makes a whole lotta sense! :)

Thanks for your time valiant

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Wed, 2006-10-18 04:18

How would I grab all the info stored in the Gallery DB about a user if given the UID ?

I see a class called GalleryUser but haven't found any examples of how to use its methods. Or even what its methods are.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-10-18 17:32

no, g2 probably doesn't use the same password hashing algorithm. you can put your hashed fudforum password in g2, but it won't be of any use.
g2 doesn't check passwords when it's integrated. fudforum does the auth.

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Fri, 2006-10-20 10:27

My ultimate aim is to have certain users able to view certain sections of the gallery and other users see other parts only. I understand that these groups that are in FudForum won't be translated into Gallery2, but I can create groups in Gallery2 to manually re-assign these groups/perms in Gallery2, correct ?

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Fri, 2006-10-20 14:01

So let me clarify my readings.

To create a new user in Gallery2, and after extracting the relevant details from the FudForum database I must:

1. include embed.php

2. Call GalleryEmbed::init() like so..

          $ret = GalleryEmbed::init(array('g2Uri' => '/gallery2/', 
				    'embedUri' => '/main.php',
				    'activeUserId' => $uid));

Do I put the new users ID in activeuserId ?

3. Call GalleryEmbed:createUser() like so...

          $ret = GalleryEmbed::createUser(array('username' => 'ted', 
                                        'email' => 'something@somehere', 
                                        'fullname' => 'Ted Bruschi'))

4. Then complete the transaction with ...

       GalleryEmbed::done()

Of course I would use variables to input the user data with a foreach loop to automate this.
Is this correct ?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2006-10-22 14:56

- you forgot the "fullInit" argument in GalleryEmbed::init. always specify fullInit => true if it's not a simple handleRequest() call afterwards.
- don't specify $uid in init() if you know that the user doesn't exist in g2 yet
- your createUser call lacks the $uid from fudforum. i assume you know how to interpret these docs:
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodcreateUser
- don't forget the error checking (always check $ret)
- else it looks good

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Sun, 2006-10-22 23:26
valiant wrote:
- you forgot the "fullInit" argument in GalleryEmbed::init. always specify fullInit => true if it's not a simple handleRequest() call afterwards.

No, didn't forget, just didn't know :)

How do I know if its a simple handleRequest() or not ? I mean when do I use that ? When I need to push out the results of the API use back to the user in the form of an HTML page ?

valiant wrote:
- don't specify $uid in init() if you know that the user doesn't exist in g2 yet

Cool. That answers that question. Thanks.

valiant wrote:
- your createUser call lacks the $uid from fudforum. i assume you know how to interpret these docs:
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodcreateUser

Thats what I used to construct my little code; so answer "no" to your question.

So it should be like so:

          $ret = GalleryEmbed::createUser($externalUID , array('username' => 'ted', 
                                        'email' => 'something@somehere', 
                                        'fullname' => 'Ted Bruschi'))
valiant wrote:
- don't forget the error checking (always check $ret)

Good point. Thanks.

So just add this code to print out any data from the call:

    if ($ret) {
      $data['bodyHtml'] = $ret->getAsHtml();
      return $data;

Or simply echo out $ret for this situation but use the more involved error handling code in the Sample Wrapper script for when I add code to the User Register page in Fudforum for Gallery2?

valiant wrote:
- else it looks good

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-10-23 09:21

- how you deal with errors is up to your own application. g2 gives you the option to detect errors by checking $ret and acting on it.
- your new version of the createUser call looks good.
- http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html explains when to call fullInit or not.
quoting:

Quote:
See http://codex.gallery2.org/index.php/Gallery2:Embedding for more information on embedding / integration.
Three interaction modes:
1) GalleryEmbed::init(array(..)) followed by GalleryEmbed::handleRequest()
2) GalleryEmbed::init(array(.., 'fullInit' => true)) followed by other GalleryEmbed/G2 calls, end with GalleryEmbed::done() <-- REQUIRED
3) Single GalleryEmbed::logout(array(..)) call

All of these methods should be accessed in a static sense, ie: GalleryEmbed::handleRequest();

 
EoN604

Joined: 2006-11-30
Posts: 8
Posted: Sat, 2006-12-02 07:40

IMO, CREATING THE USERS in the gallery database, is NOT a good solution. It's making redundant data, and de-centralising it which is a BIG no-no.

A MUCH, MUCH, MUCH better way would be to have a method in Gallery2 API that is something like loginUser(<ALL required details for valid user object creation>), so that you can MANUALLY log in the user from the centralised user table (which in my case resides outside gallery). Someone, PLEASE PLEASE tell me this is possible?! Anyone!? :) Any help would be greatly appreciated.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2006-12-02 14:00

EoN604

You're starting there a separate discussion. Please create new forum topics for separate discussions, thanks.
And a short answer: We've experimented with several approaches and what you describe is not a viable solution. I can explain it in detail if you want, in a separate topic.

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Sun, 2006-12-03 00:32

I am still working on this integration. Getting there, slowly but surely........

 
littleking57

Joined: 2007-01-30
Posts: 1
Posted: Wed, 2007-01-31 01:32

im looking to integrate fudforum and gallery2 as well, any updates?

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Wed, 2007-01-31 02:13

I have moved house and then have been away, so nothing from me. I am going to be getting back into this soon [this week I hope] and I am sure I will have more questions before I complete this.

I'll share what I have got so far once I get back into it and work out where I was up to with it.

 
austinnoronha

Joined: 2007-10-09
Posts: 3
Posted: Wed, 2007-10-24 13:56

Thanks Guys
It was a great help , i too was creating a new user from MYSQL Query but after reading this i have solved my tensions...
My code is almost the same , here it is , but i still don't understand why we have to give an external id or the first arg i.e. user12,
could you help me out with it ,or is it something that i have to define....?



/***********************************************/

GalleryEmbed::init(array('fullInit' => true),
			$gallery2_dir.'index.php?module=gallery2',
			'.',
			$gallery2_dir.'index.php');

$args=array('email' => 'aol@aol.com',
			'fullname' => 'a_nasty',
			'password' => '1234', 
			'username' => 'fake2'
			);

GalleryEmbed::createUser('user12',$args);
$ret = GalleryEmbed::done();
if ($ret) {
echo "Gallery user creation ERROR.";
print $ret->getAsHtml(); exit;
} else {
echo "user successfully created";
}


/***********************************************/

I hope this could help anyone , but if there is a mistake don't hesitate to reply....

Best regards,
Austin :)

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Thu, 2008-03-20 07:14

Hi guys,

Have we got any further on this ?

I need to get this finished, so looking to pick up this project, hardly used php before though, so that makes it harder.

 
DaveQB

Joined: 2006-05-15
Posts: 13
Posted: Mon, 2010-04-19 23:18
austinnoronha wrote:
Thanks Guys
It was a great help , i too was creating a new user from MYSQL Query but after reading this i have solved my tensions...
My code is almost the same , here it is , but i still don't understand why we have to give an external id or the first arg i.e. user12,
could you help me out with it ,or is it something that i have to define....?



/***********************************************/

GalleryEmbed::init(array('fullInit' => true),
			$gallery2_dir.'index.php?module=gallery2',
			'.',
			$gallery2_dir.'index.php');

$args=array('email' => 'aol@aol.com',
			'fullname' => 'a_nasty',
			'password' => '1234', 
			'username' => 'fake2'
			);

GalleryEmbed::createUser('user12',$args);
$ret = GalleryEmbed::done();
if ($ret) {
echo "Gallery user creation ERROR.";
print $ret->getAsHtml(); exit;
} else {
echo "user successfully created";
}


/***********************************************/

I hope this could help anyone , but if there is a mistake don't hesitate to reply....

Best regards,
Austin :)

Looks good. I feel in the 4 years I have tried to get this done, I have gone backwards :). I can't even follow what I was talking about in this thread.
I need to re-familiarise myself with this again.

So how did you use this code exactly austinnoronha?