Embedding

wijkkie

Joined: 2005-08-03
Posts: 78
Posted: Wed, 2011-01-12 22:00

Hello, i'm going to use Gallery2 and want it to embedd in php-fusion.

I dont want a vissible integration, but just when there is created an account in the CMS that the user is created in Gallery as well.

I've read different articles, but don't know where to start. can sombody help me with it?

Thanks.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-01-13 00:39
 
wijkkie

Joined: 2005-08-03
Posts: 78
Posted: Thu, 2011-01-13 13:10

Isn't there somebody who can make it for me. I don't have enough skills to make it my own.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-01-13 13:31

Creating a simple embed page is as easy as filling out my simple form.
But cross mapping users and handling user events between apps is something that would take considerable development time.
I'm the developer/maintainer of the Geeklog<->Gallery2 bridge which means I have a working knowledge of both appa, but I have never even laid eyes on php-fusion.

Seems were other discussions on the matter.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
wijkkie

Joined: 2005-08-03
Posts: 78
Posted: Thu, 2011-01-13 19:30

Yes okee i understand. I found some code i maybe can use.
but php-fusion has Double md5 hashed passwords, how can is use this in:

$args['hashmethod'] = 'md5';

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2011-01-13 20:12
 
wijkkie

Joined: 2005-08-03
Posts: 78
Posted: Fri, 2011-01-14 11:05

Hi

i've got found the following code and submutted the userdata of php-fusion.

It has input a new user in the database, but not with the same user_id as my CMS. in my CMS the user has id-> 1 and in Gallery it has -> 33

Quote:
<?php

/*
* This is an example of how G2 can be wrapped into your own website
* If you only want to embed G2 visually in your website, you don't need GalleryEmbed (so this
* approach is not necessarily what you want). But if you want to embed G2 in your website,
* including a unified user management, a single login etc., then this is the correct file to
* start with.
*/

/*
* runGallery() exits if G2 tells it to so (by isDone = true). It's important that you don't
* output any html / anything before you call runGallery (which calls
* GalleryEmbed::handleRequest), else, G2 won't work correctly.
* Reason: G2 does a lot of redirects. E.g. when you login, it redirects to the next page, etc.
* and redirects won't work if there was already some output before the redirect call.
*/
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

if (isset($data['bodyHtml'])) {
print <<<EOF

<<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>{$data['title']}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{$data['javascript']}
{$data['css']}
</head>

<body>
{$data['bodyHtml']}
</body>
</html>
EOF;
}

function runGallery() {
global $userdata;

require_once('foto/embed.php');

$data = array();

// XX if anonymous user, set g2 activeUser to null
$uid = $userdata['user_id'] = 0 ? '' : $userdata['user_id'];

// initiate G2
$ret = GalleryEmbed::init(array('g2Uri' => 'http://foto.rubensworld.nl/',
'embedUri' => '/main.php',
'activeUserId' => $uid));

$args['fullname'] = $userdata['user_name'];
$args['username'] = $userdata['user_name'];
$args['hashedpassword'] = $userdata['user_password'];
$args['hashmethod'] = 'md5';
$args['email'] = $userdata['user_email'];

$retcreate = GalleryEmbed :: createUser($uid, $args);

// user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
GalleryCapabilities::set('showSidebar', false);

// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();

// show error message if isDone is not defined
if (!isset($g2moddata['isDone'])) {
$data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
return $data;
}
// die if it was a binary data (image) request
if ($g2moddata['isDone']) {
exit; /* uploads module does this too */
}

// put the body html from G2 into the xaraya template
$data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

// get the page title, javascript and css links from the <head> html from G2
$title = ''; $javascript = array(); $css = array();

if (isset($g2moddata['headHtml'])) {
list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
$data['headHtml'] = $g2moddata['headHtml'];
}

/* Add G2 javascript */
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}

/* Add G2 css */
if (!empty($css)) {
foreach ($css as $style) {
$data['css'] .= "\n".$style;
}
}

// sidebar block
if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
$data['sidebarHtml'] = $g2moddata['sidebarHtml'];
}

return $data;
}

// End G2 integration code
?>

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-01-14 15:56

Gallery has an externalId which would be... you guessed it your CMS's userID.
Gallery cannot use your CMS's userID internally as it may conflict with an existing id.

You'll need to add the map entry so the two systems know who they are talking about.. something like:

    list($ret, $user) = GalleryCoreApi::fetchUserByUserName($userdata['user_name']);
    if($ret){
        print "user not found";
        return false;
    }
    $ret = GalleryEmbed::addExternalIdMapEntry($uid, $user->getId(), 'GalleryUser');
    if ($ret) {
        print 'Failed to add externalIdMap for usename ['.$userdata['user_name'].' Here is the error message from G2:'.$ret->getAsText();
        return false;
    }

when you create the user, you should check for an error or collision to know if he's already been created.

    $ret = GalleryEmbed :: createUser($uid, $args);
    if (($ret) && ($ret->getErrorCode() & ERROR_COLLISION)) {
        // you could do your mapping here
        return false;
    }

so when you initiate gallery you'll use your externalId like you did:

$ret = GalleryEmbed::init(array('g2Uri' => 'http://foto.rubensworld.nl/',
'embedUri' => '/main.php',
'activeUserId' => $uid

And gallery will have that mapped to a GalleryUser

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
wijkkie

Joined: 2005-08-03
Posts: 78
Posted: Fri, 2011-01-14 16:58

Hmm can't get a clue,

When i add

Quote:
$ret = GalleryEmbed :: createUser($uid, $args);
if (($ret) && ($ret->getErrorCode() & ERROR_COLLISION)) {
// you could do your mapping here
return false;
}

i get an empty page.
But i have an other question before i continue.

I do NOT want to embedd the gallery into my cms. I want them seperately. I only want the users t be the same and a link on my CMS to the Gallery. and sending the user with it!

isn't there a easier way to do it?