I'm trying to do on-the-fly user creation via an external PHP script. At the same time I would like to add the user to a predefined G2 group (e.g. "TRIAL"). From the threads I've read so far my understanding is this:
1. We need to specificy an External Username (in addition to the G2UserName) for every G2 User that we create (which are identical in my case).
2. Likewise, we need to specificy an External Groupname mapping to an internal G2 Groupname, ONLY IF we intend to map my newly created user to that G2 Group. i.e. there is NO WAY for me to assign an externally created user (via the Embed API) to an existing G2 group, without going through this process.
Are these assumptions correct?
Assuming they are, I tried to create a external group ("TRIAL") mapping to an existing G2 group ("TRIAL"), but it returned me the following error:
Quote:
ERROR: Unable to create group [TRIAL]
Error (ERROR_COLLISION)
* in modules/core/classes/GalleryGroup.class at line 109 (GalleryGroup::error)
* in modules/core/classes/GalleryEmbed.class at line 495 (GalleryGroup::create)
* in www/g2api.php at line 107 (GalleryEmbed::createGroup)
* in www/g2groupcreate.php at line 5
My code looks like this:
Quote:
# CREATE EXT GROUP TO g2 Group mapping
function g2creategroup ($ext_groupname,$g2_groupname) {
$ret = GalleryEmbed::init(array('g2Uri' => '/var/www/myalbum.sg/gallery2',
'embedUri' => '/main.php',
'activeUserId' => '',
'fullInit' => true));
$ret = GalleryEmbed::createGroup($ext_groupname,$g2_groupname);
GalleryEmbed::done();
if ($ret) {
print "ERROR: Unable to create group [$ext_groupname] <br>";
print $ret->getAsHtml();
exit;
} else {
echo("creted group $ext_groupname <br>");
};
}
The fuction is basically called by :
g2creategroup('TRIAL','TRIAL');
Is there something I did wrong?
Posts: 15
I may have seem to have answered my own question. It seems that when I create an external group, the 'internal' G2 group name must not already exist. I could remove the internal group and recreate it from the Embed script. However this may be a problem is the existing g2group already has many members in it.
Is there another way to associate an exernally created user with an internal g2 group?
Posts: 8339
Hope this helps
-s
FlashYourWeb and Your Gallery
Posts: 15
Thanks. I will try that.
Is there a way to use the GroupName instead of the numeric group ID?
Posts: 8339
there is GalleryCoreApi::fetchGroupByGroupName
-s
FlashYourWeb and Your Gallery
Posts: 15
Thanks suprsidr. I've decided to just re-create my groups.