Hi all, I know there are a lot of topics about user integration. But I feel I just don't fit in one of the exactly.
I have 2 servers with a application. One is a non-PHP server with a DB running a CMS, the other is the PHP Gallery server.
If I create a user in the CMS I want to be able to create it, at that moment, in Gallery. Is that it possible to do that with 2 different servers? How safe is it/can it be?
I hope someones understand my question and can give me hint about safety of the script.
<?php
$emAppUserId ='something3';
$emAppGroup ='Fotobeheer';
$g2_Config['path'] = dirname(__FILE__) . '/';
require_once( $g2_Config['path'] . 'embed.php');
$ret = GalleryEmbed::init(array('fullInit' => 'true',
'activeUserId' => $emAppUserId));
if ($ret) {
/* Error! */
/* Did we get an error because the user doesn't exist in g2 yet? */
$ret2 = GalleryEmbed::isExternalIdMapped($emAppUserId, 'GalleryUser');
if ($ret2 && $ret2->getErrorCode() & ERROR_MISSING_OBJECT) {
/* The user does not exist in G2 yet. Create in now */
$args=array('email' => 'test@test.com',
'fullname' => 'W. Something',
'password' => '1234567',
'username' => 'something3'
);
$ret3 = GalleryEmbed::createUser($emAppUserId,$args);
$ret = GalleryEmbed::done();
if ($ret3) {
echo "Gallery user creation ERROR.";
print $ret2->getAsHtml(); exit;
} else {
echo "user successfully created";
}
}
}else{
/*Do nothing*/
echo "User already exists";
}
if ($ret)
{
print $ret->getAsHtml();
}
?>
ps. the [php] block is not working! Doesn't give a color to the code it just resizes the font to HUGE
Posts: 1378
Sorry no can do, you cannot have Gallery2 and your CMS on different servers, the Gallery2 Security framework will reject the embedded API call unless it is from the same server.
The closest I seen to this functionality is the remote RFC (Gallery2 Remote) which is more for remote image retrieval, not for User Creation.
Some more info
http://codex.gallery2.org/Gallery2:Embedding:Event-Based_Loose-Coupled_Integration
http://codex.gallery2.org/Gallery2:Embedding:Integration_Aspects
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, WPG2 Downloads, WPG2 Documentation