Embedding & Integration

Arnoldjw
Arnoldjw's picture

Joined: 2004-05-16
Posts: 54
Posted: Wed, 2005-04-20 21:05

Session and Cookie corruption.

I hope this is the correct place to aske this. I'm working on a embedded page for Wordpress, and more info on my code is in that thread, but when I use the embeded user session info, and then visit my gallery2 installation, I have to clear my cookies.

Going through the embedded page allows me to Administrate from my embedded page, but destoys my sessions through the non embedded version.

Can gallery be embedded, and still accessable directly? Is there something I'm doing in my embedded page corrupting the sessions?

Thanks
John Arnold

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-04-20 22:24

Arnoldjw, you're doing nothing wrong and I this issue is widely known, perhaps even discussed in some topics here.
The problem has something to do with cookie paths. When embedded, the cookie path of the G2 cookies (GALLERYSID cookie) is different, probably higher, than the cookie path of G2 standalone cookies. I didn't think much about it, and i didn't solve it, but if you can resolve the issue of G2 running standalone and embedded and having no problems with cookies, please tell me how :)
- perhaps one can force the same cookie path for embedded and standalone
- perhaps one can select a specific cookie when retrieving cookie data (don't think so)

 
Arnoldjw
Arnoldjw's picture

Joined: 2004-05-16
Posts: 54
Posted: Tue, 2005-05-17 05:14

Are there any planned changes to the embedded image block options?

So the External Image Block options allow

g2_blocks * Pipe(|) separate list chosen from randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem
g2_show * Pipe(|) separated list chosen from title, date, views, owner, heading, fullSize; the value can also be none
g2_itemId Limit the item selection to the subtree of the gallery under the album with the given id; or the id of the item to display when used with specificItem block type
g2_maxSize Scale images to this maximum size
g2_linkTarget Add a link target (for example, to open links in a new browser window)
g2_itemFrame * Image frame to use around images
g2_albumFrame * Image frame to use around albums
( this is for the <?php @readfile('http//localhost/gallery2/main.php?g2_view=imageblockExternal&g2_blocks=randomImage&g2_show=title'); ?> found gallery2/main.php?g2_view=coreSiteAdmin&g2_subView=imageblockImageBlockSiteAdmin )

But the embedded image block options don't seem to limit. Adding an itemID without specificItem seems to error out.
The documentation doesn't mention g2_linkTarget, g2_itemFram, or g2_albumFrame.

Is it possible to use those other options with embedded image blocks?
Should itemId act as a limit when not used with specificItem while using the image block function in the embed class?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-05-17 05:27

Arnoldjw, see also http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=30288

and all options for the standalone imageblock should also apply for the embedded.
if there' s no documentation for all options in embedded, it's because the docs are lagging behind.
you should not get any errors, unless your usage left something important out.
could you post your getimageblock() usage?

 
Arnoldjw
Arnoldjw's picture

Joined: 2004-05-16
Posts: 54
Posted: Tue, 2005-05-17 15:28

If I pass:

Array
(
    [itemId] => 23
    [blocks] => |randomImage
    [show] => title|date|views
)

I get:

Array
(
    [0] =& GalleryStatus Object
        (
            [_stack] => 
            [_errorCode] => 0
            [_fileName] => Array
                (
                    [0] => 
                )

            [_lineNumber] => Array
                (
                    [0] => 
                )

            [_errorMessage] => 
        )

    [1] =& 

)

If I pass

Array
(
    [itemId] => 23
    [blocks] => specificItem
    [show] => title|date|views
)

It works I get an image.
Also the External Image Block is prefaced with g2_ so to use g2_linkTarget, g2_itemFrame, or g2_albumFrame I just drop the "g2_"?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-05-17 15:47

maybe remove the leading | in front of randomImage?

 
Arnoldjw
Arnoldjw's picture

Joined: 2004-05-16
Posts: 54
Posted: Tue, 2005-05-17 17:03

Set options to

Array
(
    [itemId] => 23
    [blocks] => randomImage
    [show] => title|date|views
)
Array
(
    [0] => GalleryStatus Object
        (
            [_stack] => 
            [_errorCode] => 0
            [_fileName] => Array
                (
                    [0] => 
                )

            [_lineNumber] => Array
                (
                    [0] => 
                )

            [_errorMessage] => 
        )

    [1] => 

)

and just an fyi the following works:

Array
(
    [itemId] =&amp; 23
    [blocks] =&amp; |specificItem
    [show] =&amp; title|date|views
)
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-05-17 17:13

Arnoldjw, status 0 = success...
don't you get the correct html?

 
Arnoldjw
Arnoldjw's picture

Joined: 2004-05-16
Posts: 54
Posted: Tue, 2005-05-17 17:15

The only html I get with the first setting randomImage is [1] =>

now maybe its randomImage, let me try an album.

Ok I goofed. randomImage breaks if you select an image item, but if the item id is an album it works. I just need to document this in the WordPress Plugin code.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2005-05-18 15:32

Has anybody embedded G2 in Geeklog yet?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-05-18 15:36

I don't think so. Wanna do it? :)

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2005-05-18 17:06

I may give it a shot, but I'd have to actually upgrade Geeklog first to make sure it works with the latest version...

 
Oldiesmann
Oldiesmann's picture

Joined: 2005-05-18
Posts: 151
Posted: Fri, 2005-05-20 17:22

I am planning to work on integrating SMF with Gallery 2. I don't have anything set up yet, but I will get something set up soon. :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-05-20 17:33
 
mykal

Joined: 2005-02-25
Posts: 37
Posted: Mon, 2005-05-23 01:16
Oldiesmann wrote:
I am planning to work on integrating SMF with Gallery 2. I don't have anything set up yet, but I will get something set up soon. :)

Great to see you over here. Ive been waiting (as I cant do it myself) for a SMF/G2 integration. Hope to see some results in the next few months.

 
Oldiesmann
Oldiesmann's picture

Joined: 2005-05-18
Posts: 151
Posted: Mon, 2005-05-23 13:42

Thanks for the links Valiant.

mykal - it will be at least a month before I really have much time to devote to this, but I hope I can do something. :)

 
ddman

Joined: 2004-10-24
Posts: 19
Posted: Mon, 2005-05-23 16:34

I would be interested in the progress of a geeklog integration and would also be willing to help... Very excited!!!

 
Imoq
Imoq's picture

Joined: 2004-09-08
Posts: 25
Posted: Mon, 2005-05-23 17:03

I see that now the integration with PostNuke is obsolete :(

What happened? Are there plans to continue that integration? I am running gallery 1.x with PostNuke but would like to upgrade to Gallery 2 once it gets out.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-23 17:19

Imoq, find a developer with interest in integrating G2 in postnuke. Without such a person, the integration will slowly fade more and more obsolete.

 
Imoq
Imoq's picture

Joined: 2004-09-08
Posts: 25
Posted: Mon, 2005-05-23 21:07

valiant:

I'll make a post in PostNuke forums, to see if a skilled developer is interested on this.

Thank you for your answer.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 20:42

Announcement:

Thanks to mindless' multisite+rewrite+embed change, everything should work now.

I tested an embedded (xaraya) multisite install, running the rewrite module and all java applets work, Gallery Remote too.*

The cookie fix (for those who lose sessions) will be in cvs in a week or so. We want some feedback on this change first before we commit the cookie change too.

*only if mode.embed.only is false in config.php

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-05-28 17:07

Announcement:

the fullInit => true parameter in GalleryEmbed::init() is needed if you want to call GalleryEmbed::getImageBlock().

Sorry for the back and forth, I forgot that GalleryInitSecondPass is needed to actually set the user to anonymous / activeUserId.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-05-29 16:25

Announcement:

The rewrite module takes now embedPath as embeddedLocation when embedPath is set.
This is useful in a very rare use case: virtual hosts.
Say example.com/emApp/ and domain.com/ point to the same emApp/G2 installation.
Then, during the embedded g2 rewrite configuration, embeddedPath is set to /emApp/ if it was accessed with the first virtual host and to / if it was accessed with the later vHost.
With this change, you can use embedded G2 with virtual Host and the rewrite module activated.
You have to set embedPath in the GalleryEmbed::init() call dynamically. First detect if you are in vHost 1 or 2 (or ...) and then set the embedPath in the ::init call accordingly.

 
yonie

Joined: 2005-02-21
Posts: 9
Posted: Mon, 2005-06-06 16:08

having troubles with getImageBlock since i upgraded to a build from 28th may (gallery2.2005-05-28-08-32-51.tar.gz). problem is still present in build from today (gallery2.2005-06-06-08-34-01.tar.gz). havent changed the code and it did work for weeks. after reading the above post, i added the fullInit => true parameter to the Init() but that didnt help. anyone know of other changes made that could cause problems now?

if anyone wants the actual code, mail me at: yonie at yonie.org

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-06-06 17:15

maybe the imageblock module was deactivated by the upgrade. go to site admin -> modules and make sure it's active.

 
yonie

Joined: 2005-02-21
Posts: 9
Posted: Mon, 2005-06-06 17:30

that would be nice :)

[update] you were right. the module was apparentely deactivated by some upgrade (i suppose at least) and upon reactivating it worked flawless.

maybe its a good idea to make getImageBlock put some error message in the response object instead of just nothing.

oh well, thanks for the help anyway, keep up the great work!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-06-06 17:34

yonie, i added the error message a few days ago. so if you're using the current nightly snapshot, you'd get an error when the imageblock is not active.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Thu, 2005-06-09 01:13

Thanks for this Valiant..

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-06-10 16:25

Announcement:

I recommend to all integration devs to either subsribe to this thread or to the devel mailinglist. I'll announce changes here and in the mailinglist in future.

We have to change the way we deal with cookies again. The current fix is uber-robust but it has a minor security flaw. It's open to session hijacking if you share your domain with other people.

The new fix is similar to what we had in beta 3. But in embedded G2, we append the GALLERYSID to all DownloadItem URLs. This is also not super secure, given that users like to copy'n'paste img urls to forums etc.
But you can define the cookie path in site admin -> general and then it won't append the GALLERYSID to downloaditem urls.

I'd recommend setting the cookie path during integration configuration time. When the integration gets installed, you could set the cookie path automatically with GalleryCoreApi::setPluginParam('module','core','cookie.path','/') (or a more secure/appropriate value).

The cookie change is not yet in cvs, but it will be in for beta 4.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sat, 2005-06-11 01:31

thanks Valiant, I will add your code to the WPG2 plug-in when it is ready..

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-06-11 01:50

Announcement:

Forgot about another change that will be in beta 4, also due to the cookie change:

GalleryEmbed::logout() now requires a param, similar to ::init.
Either embedPath or the current embedUri.

Sorry for that, but that's how it is. Security is more important than this param.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sat, 2005-06-11 12:18

It is a tad of an odd requirement, Valiant but knowing you, it would only be a requirement because you had to..

Will this change also effect GalleryEmbed::done() ?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-06-11 13:57

No, this does not affect GalleryEmbed::done().

It was required because with the new cookies, we set the path again dynamically.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-06-11 22:25

Announcement:

The cookie change is in. It's the core upgrade from 0.9.23 to 0.9.24.

- You'll have to add the embedPath param to GalleryEmbed::logout() of your integration.
- You don't have to, but i'd recommend setting the GalleryCoreApi::setPluginParam('module','core','cookie.path',$path) when you are setting up the integration. See the Site admin -> General view for more information on the cookie path, click on the + symbol to get a description.
- The constant G2_EMBED is deprecated and no longer exists or has a meaning. Check for GalleryUtilities::isEmbedded() if you need this information.
With GalleryDataCache::put('G2_EMBED', true, true); you can set embedded mode, if necessary. But this is done automatically when including embed.php anyway.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-07-15 09:59

Announcement:

The separate sidebar html is back! Kudos go to bharat for this one :)

But you have to change your integration code a little bit:
The new capability id is a little different:
To choose that the sidebar should not be displayed within the G2 bodyHtml, call this:
GalleryCapabilities::set('showSidebarBlocks', false);
To check if the sidebar html is available, check

$data = GalleryEmbed::handleRequest();
if (isset($data['sidebarBlocksHtml']) && !empty($data['sidebarBlocksHtml'])) {

$data['sidebarBlocksHtml'] is an array of blocks. This is an improvement over the old code if you want to do individual things with the blocks.
To just paste the whole sidebar somewhere, you could do this:

$html = '<div id="gsSidebar" class="gcBorder1">
' . join('', $data['sidebarBlocksHtml']) . '
</div>';

An alternative route we considered was having no sidebar capability at all. Each theme would either show a sidebar inside or not.
Then you could pick a g2 theme which doesn't show the sidebar in bodyHtml and render the sidebar blocks separately.
I guess in the long run, we will do something like this (e.g. you can administer the sidebar blocks in site admin -> theme, but they don't get rendered. You'd then call something like GalleryEmbed::getBlocks(array('sidebarBlocks')); after the handleRequest call.
But as I said, that's was an alternative which was not implemented right now. I'd still like to hear your opinions on this topic. You wouldn't have the feature to offer a "show sidebar inside" switch, but in the long run, themes that are tailored for your specific integration would be better, IMO.

 
msandersen

Joined: 2005-07-29
Posts: 13
Posted: Sun, 2005-07-31 15:25
valiant wrote:
GalleryEmbed::logout() now requires a param, similar to ::init.
Either embedPath or the current embedUri.

So, for PostNuke using pnGallery2, I found function g2logout() in pnGallery2helper.php and changed line 431 to read:
$ret = GalleryEmbed::logout('index.php?module=pnGallery2');

Is that right?

This thread mention pnGallery is out of date (it uses G2beta1); I installed beta 4 separately and got it all working, but are there any other changes from that version I need to look out for?

 
asmaloney
asmaloney's picture

Joined: 2005-07-31
Posts: 19
Posted: Sun, 2005-07-31 15:53

Hi all. I just thought I'd jump and and mention that I'm looking at the Gallery 2 integration for Geeklog.

When I have something useful/usable, I'll post here.

- Andy Maloney

[http://imol.gotdns.com]

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-07-31 16:52

msandersen, i just realized that it probably won't work with embedUri.
you should call it with GalleryEmbed::logout(array('embedPath' => '/'); assuming that your pnuke is installed in the site root.

 
msandersen

Joined: 2005-07-29
Posts: 13
Posted: Tue, 2005-08-02 10:34

So, the relative path from the Server root (DocRoot)? As in /path/to/gallery, in the form of an array?
GalleryEmbed::logout(array('embedPath' => '/path/to/gallery'); (or is that path/to/gallery/ )
as opposed to the actual URI /path/to/gallery/index.php

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-08-02 11:34

exactly, but ou just forgot a closing ).
GalleryEmbed::logout(array('embedPath' => '/path/to/gallery')); is correct.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-08-10 23:11

Announcement:

Since Beta 4, there's an issue with embedded G2 and HTTP headers.
We start sending the headers in G2, thus if the emApp wants to send headers after the handleRequest call, you'll get a php warning.

This will be addressed shortly. Just wanted to confirm the issue.

Update: fixed in cvs / tomorrows nightly snapshot.

 
ArcAiN6

Joined: 2005-09-02
Posts: 24
Posted: Sun, 2005-09-04 19:37

having some slight issues. i installed gallery2 into /home/httpd/vhosts/sinful-flesh.com/httpdocs/modules/gallery/
and followed the directions for changing things in the files to echo this dir instead of gallery2... everything seems to be working except i get some errors when i try to import users from phpnuke... errors are as follows:

Failed to create G2 user with extId [2]. Here is the error message from G2:
Error (ERROR_COLLISION)

* in modules/core/classes/GalleryUser.class at line 166 (gallerystatus::error)
* in modules/core/classes/GalleryEmbed.class at line 300 (galleryuser::create)
* in admin/index.php at line 320 (galleryembed::createuser)
* in admin/index.php at line 575
* in admin/index.php at line 609
* in /home/httpd/vhosts/sinful-flesh.com/httpdocs/admin/case/case.gallery2.php at line 55
* in /home/httpd/vhosts/sinful-flesh.com/httpdocs/admin.php at line 416

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-09-04 20:20

please visit nukedgallery.net for phpnuke / g2 issues.

 
asmaloney
asmaloney's picture

Joined: 2005-07-31
Posts: 19
Posted: Sat, 2005-09-10 17:27

I finally got around to the Geeklog integration... I have a version out with a couple of people to try - very very basic.

A suggestion: When the user removes the geeklog plugin, I have to clean up the database. It would be nice to have a field available in the g2_ExternalIdMap table to mark the g_externalId as coming from a specific emApp - it'd make cleaning up much easier.

I'm picturing a situation where you have one G2 installation and several emApps using it - how do you know which g_externalId are yours?

Perhaps I've misunderstood something and there is a way to do this?

- Andy

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-09-10 17:57

asmaloney, G2 doesn't work with several emApps using it.
Things get complicated rather quickly. e.g. what about user synchronization? if emApp1 synchronizes its set of users to g2, g2 and emApp1 are in sync'. Now comes emApp2, also synchronizing users to G2. Suddenly, G2 has more users than emApp1 or emApp2, which is not a satisfying state. After all, we wanted to have the user tables of the different applications in sync.

You could argue that this is up to the user. If he wants to deal with the implications of such a state or if he guarantees that emApp1 and emApp2 already have the same user set, let him do so.

Also, a g_emAppId attribute for each row in the externalIdMap wouldn't be a bad idea in general. There already have been a few occasions where it would have been easier if there was such an attribute.

I guess we'll add it some time after g 2.0.

 
asmaloney
asmaloney's picture

Joined: 2005-07-31
Posts: 19
Posted: Sat, 2005-09-10 18:07

valiant,

I guess I was thinking of the 'one-way' sync - mapping multiple emApp users into G2. So if I have a nuke installation and a geeklog installation [or even two different geeklog installations], they could draw on the same G2 installation by mapping their users into G2 and use a 'unique' id to identify their subset of users.

- Andy

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-09-10 18:49

a nuke and a geeklog installation on the same server? pretty uncommon, since both of them serve about the same purpose.
do you sync the two or are the two installs completely independent? and do the users have to login twice, with different or the same username?

 
asmaloney
asmaloney's picture

Joined: 2005-07-31
Posts: 19
Posted: Sat, 2005-09-10 19:24

No I'm not doing both nuke and geeklog at the moment - that was a what-if.

There are, however, several people who run multiple [independent] geeklog sites on the same server. Instead of managing multiple installations of G2 as well, it would be nice to have just one and have each GL installation have its own id for G2 external mapping.

If it's too complicated, no problemo. I just thought I'd throw it out as a suggestion.

- Andy

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-09-10 19:45

you'll end up with problems (user name collisions).
in g2, a username is unique.
the geeklog integration code could just choose username . rand() if there's a conflict and try again to create a g2 user, but that's not that nice.

and if there is a username collision, you don't know whether it is actually a new user or if it should be mapped to an existing user.

in the meantime, you can just add a prefix to all your externalIds.
when adding an externalIdMap entry from emApp1, tell g2 the externalId is 'emApp1_' . $realExternalId . that way, you accomplish the same as with a emAppId column.

but yes, I plan to add this emAppId column, but not right now.

 
asmaloney
asmaloney's picture

Joined: 2005-07-31
Posts: 19
Posted: Sat, 2005-09-10 20:03

Could probably use the same thing to get unique G2 user names: 'em_App1_' . $gl_user_name...

Anyway, thanks for the info.

- Andy