Is there a way to easily integrate the users table from VB2 into Gallery2?
We currently have it working with coppermine but to be honest, i hate it.
Our whole site is Smarty based but uses VB2 as a backend for the users table, is there a way i can easily integrate gallery2 into our new site or is it something that i will have to sit tight and hope for.
We are working on VB3 but to be honest, the newer features of it dont warrent the upgrade when we have spent a long time working on this new site.
We already have our own login script which works from VB's to set a site wide user session, is there a way to use the users table from VB in gallery 2 with relative ease enabling login / logout via the same sessions?
Many thanks
Rowan
Posts: 32509
rowan_gurn, have you read the first post of this topic? there's some info and links.
please read docs/EMBEDDING and take a look at GalleryEmbed in embed.php.
short answer: it should be quite simple, let us know where you have problems. if you have questions, please create a new topic. thanks.
edit: i split the topic from the Integration & Embedding thread.
Posts: 5
so if im right all i do is include embed.php in my login / logout scripts, then set the functions
onlogout
$ret = GalleryEmbed::logout();
on login
1) The input array for the GalleryEmbed::init() call must also contain:
'embedSessionString' => {key=value}, 'gallerySessionId' => {value}
(omit gallerySessionId when the value is not yet known)
2) After the init() call:
$gallerySessionId = GallerEmbed::getSessionId();
{store value in emApp's session}
Ive read on the forums its not best to keep the data in sync but to keep it as one user table, is that correct? If so how do i do that?
If not i take i just run the sync commands on login / profile update / blah blah wherever i need to and then thats it? Set the session to time out as it says in the document and off i go?
if thats so then il bloody well have a go at it sometime.
Posts: 32509
it really depends on the kind of wrapper you build.
if you create a wrapper file, like all other integrations for G2 that exist at the moment, then you don't need to call logout and login.
1. method: create a new basefile/wrapper for G2, it can have any filename and is usually not in the same directory as main.php of gallery2.
include('some/path/embed.php');
$ret = GalleryEmbed::init(array('embedUri' => ..., 'embedPath' => ..., 'relativeG2Path' => ..., 'activeUserId' => $vb2UserId));
list($ret, $data) = GalleryEmbed::handleRequest();
$print out html from $data['bodyHtml'], $data['headHtml'], see docs/EMBEDDING
that's it. of course you should handle errors ($ret->isError()).
2. method: Without a wrapper. You need to synchronize login and logout.
logout:
include('some/path/embed.php');
GalleryEmbed::logout();
login:
GalleryEmbed::login, or GalleryEmbed::init, ...
In your case, it seems both methods would be equivalent. the first method is much more powerful.
The part that requires most of the work is actually synchronizing the users. Each time a user is created/updated/deleted in VB2, it needs to be created in G2 too. i.e. you have to modify VB to make this possible (just call GalleryEmbed::createUser(array(userdata,...));).
@sessions:
why do you want to pass the sessionIds? don't you use cookies with VB? if you use cookies with VB, there's no need to handle sessionIds specially. G2 creates its own cookies, even if it is embedded.
@one user table:
that's a concept we call "tight embedding". we did evaluations on this method and it would require too many changes to at least one of the applications. therefore, you just call synchronization commands as approapriate, i.e. if a user is created in VB2.
actually, you only have to synchronize these events:
- create/update/delete user in VB2, that's it.
G2 in embedded mode doesn't let you create users via G2, therefore there are is no synchronization needed in the direction G2->VB2.
Posts: 5
Is a wrapper essentially like you would say as an example, an iframe is wrapped in that page? Or a VB page is wrapped in its header and footer? As in i make a PHP page then the gallery appears in it on the wrapped page, in the headers and footers?
Youll have to forgive my ignorance, ive got plenty of experience with smarty / vbulletin / PHPBB certain bits of PHP but ive never used Gallery, only coppermine (or as we call it rottenswine, ive converted it to CSS layout instead of tables, as much as i can - a fair effort) so i reckon i could probably knock something up, just trying to work out the scripting for this but it seems fairly stright forward.
Im just uploading it now for a good play with it. Il let you know how i get on. :S
Posts: 5
Ps thanks for splitting the thread, as someone with a 2.5million post VB i should know better, sorry mate
Posts: 32509
@wrapper: from the Emedding & Integration topic first post:
the usual entry point of all G2 pages is main.php (index.php redirects to main.php). the wrapper file i mentioned is the new entry point when G2 is embedded.
i don't know if VB2 has modules. if it has and if they are accessed like "index.php?module=modulename", then this wrapper would be the file that is called when the VB2 url is like index.php?module=gallery.
that's just an example, you can do pretty everything.
what the wrapper does...
- call GalleryEmbed::init -> by this VB2 says G2 what the userId of the active user is (authentication=login, session management) and it starts the G2 routines.
- call GalleryEmbed::handleRequest() -> tell G2 to check the post/get vars, handle requests and generate the resulting html.
- then you can put the generated html in VB2 templates or just output it if VB2 has no templating engine. if it has templates, then you would fill a single template variable with the bodyHtml which was returned in GalleryEmbed::handleRequest.
It also returns headHtml, html code that should go into the <head> part of a page (css, javascript, title).
ps: iframes / frames are really a bad design. sure, it's done quickly, but many problems arise with the use of frames (and iframes are frames, essentially).
Posts: 5
Yeh i know about Frames mate dont worry ;)
Is there a way to get it to pass out smarty templates? I heard it was based on these so it would be good for us if it was cos im pretty good at that!
VB2 does use templates but they are shit to use, we use Smarty for the whole site (that isnt the message board) using XHTML and CSS
Im guessing i just make a page which works on said with id accessing the new script il make.
I was thinking it would have its own templates to edit after i made the login bit, thats what we did with coppermine.
Posts: 32509
G2 uses smarty templates. you can edit / create your own G2 smarty templates (.tpl files).
GalleryEmbed::handleRequest returns the evaluated smarty templates, i.e. the final html.
i suggest you edit/create G2 templates and fill the resulting html into other templates of your application.