|Posted: Fri, 2005-12-30 04:02|
Hi, maybe someone can help with this issue.
I'm toying around with an existing integration package and trying to avoid potential collision errors where a user exists in G2, but not in the embedding application during the integration and later the same user is created in the embedding application and a collision occurs when this user is externally mapped to gallery because it already exists as a gallery user.
After a couple weeks of digging through the G2 code, I finally came up with this piece of code, where $g2Id = the integer value of the user to be deleted in gallery. I finally got it running without errors, but nothing gets deleted as far as user items and the user itself.
Perhaps someone more knowledgeable with gallery could enlighten me as to how to go about deleting a G2 user from an external application without an existing external id mapping.
I hope this is the right place to post this and thanks for any insight!
list ($ret, $siteAdminGroupId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup'); if ($ret->isError()) die($ret->getAsHtml()); list ($ret, $adminUsers) = GalleryCoreApi::fetchUsersForGroup($siteAdminGroupId, 2); if ($ret->isError()) die($ret->getAsHtml()); if (empty($adminUsers)) die('No adminUsers were available'); $adminUsers = array_keys($adminUsers); if ($adminUsers == $g2Id && count($adminUsers) == 1) die('The only G2 admin cannot be deleted.'); $newOwnerId = ($adminUsers != $g2Id) ? $adminUsers : $adminUsers; list ($ret, $entityId) = GalleryCoreApi::loadEntitiesById($newOwnerId); if ($ret->isError()) die($ret->getAsHtml()); $gallery->setActiveUser($entityId); $ret = GalleryCoreApi::deleteUserItems($g2Id); if ($ret->isError()) die($ret->getAsHtml()); $ret = GalleryCoreApi::deleteEntityById($g2Id); if ($ret->isError()) die($ret->getAsHtml());