Do I have to manually create all the users ?
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
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 |
![]() |
there are 2 alternatives. 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 |
![]() |
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 |
![]() |
we strongly discourage from manually interacting with the database. 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. 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 |
![]() |
> 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. > When I started on this, I thought gallery would simply authenticate using the emApp's user list and cookie's? |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
valiant wrote:
> What user details can I use ? I mean I am expecting fudforums user table to not match gallery's. 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 ? 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? Ahh makes a whole lotta sense! Thanks for your time valiant |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
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 |
![]() |
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. |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
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 |
![]() |
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. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
- you forgot the "fullInit" argument in GalleryEmbed::init. always specify fullInit => true if it's not a simple handleRequest() call afterwards. |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
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: 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 |
![]() |
- 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. Quote:
See http://codex.gallery2.org/index.php/Gallery2:Embedding for more information on embedding / integration. |
|
EoN604
Joined: 2006-11-30
Posts: 8 |
![]() |
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!? |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
EoN604 You're starting there a separate discussion. Please create new forum topics for separate discussions, thanks. |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
I am still working on this integration. Getting there, slowly but surely........ |
|
littleking57
Joined: 2007-01-30
Posts: 1 |
![]() |
im looking to integrate fudforum and gallery2 as well, any updates? |
|
DaveQB
Joined: 2006-05-15
Posts: 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 |
![]() |
Thanks Guys /***********************************************/ 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, |
|
DaveQB
Joined: 2006-05-15
Posts: 13 |
![]() |
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 |
![]() |
austinnoronha wrote:
Thanks Guys Looks good. I feel in the 4 years I have tried to get this done, I have gone backwards So how did you use this code exactly austinnoronha? |
|