Posted: Tue Mar 29, 2005 2:15 pm Post subject: Re: Gallery2 Support at NukedGallery.net
Hi dari, i'm the main author of the G2-Phpnuke module.
I just would like to thank you for your excellent website, and your amazing support. It really helps a lot !
We actually finish the basic features of the modules, except we have not yet setup a dynamic synch mapping between G2 and phpnuke account !
Basically it means, each time a new user register phpnuke, he won't be recognize automatically by G2...
It's now what i'm fully focus on, and we hope to have it soon.
Anyway, if you have any questions concerning the module, it would be a pleasure to answer as far as i can. Your website helps me so much with G1, it's the less i can do !
Joined: Mar 03, 2003 Posts: 6287 Location: Washington Township, NJ, USA
Posted: Tue Mar 29, 2005 2:25 pm Post subject: Re: Gallery2 Support at NukedGallery.net
Thanks for the kind words, and it was no trouble at all fixing the CSS issue
I've been looking here [sourceforge.net] for the hooks for syncing up users...
also, the current admin hack that is available fails on large user databases (such as the one here). I'm working on a hack to separate large databases into 100-user sections so the import does not fail.
Posted: Thu Mar 31, 2005 6:03 pm Post subject: Re: Gallery2 Support at NukedGallery.net
I have a first working code for the user creation on the fly !
See it on G2 dev forum...
By the way, thanks for your concern about the database, as you could imagine i don't have access to a thousand users DB... (and certainly not with my website... )
It's always good to know someone is really testing it in real production situation.
Could you tell me more, i assume this is a Max execution time or Memory exceded Error, no ?
That MOD breaks the tables up into chunks of 100, which is probably what should be done for our situation. If you're not a php wiz, I can extract the relevant pieces of code for you, as I had to customize this MOD for my forums anyway.
essentially, it just sets the $start variable as a GET variable in the HTTP request, and uses that to increment 100 posts. With a little modification, the same logic can be applied to the phpNuke user database. The important thing to do is have the page refresh after each block of 100 users, since that kicks off another execution of the loop, and thus gets around the max execution time error. It also gives the user some notification of progress.
// TODO: if the map exists, just update the user data
if (isset ($mapsbyexternalid[$nukeuser_id])) {
$outputtext .= $nukeuser_uname.' (this user already exists in g2)<br/>';
}
else {
// Get Arguments for the new user:
$args['fullname'] = $nukeuser_name;
$args['name'] = $nukeuser_uname;
$args['username'] = $nukeuser_uname;
$args['hashedpassword'] = $nukeuser_cryptpass;
$args['hashmethod'] = 'md5';
$args['email'] = $nukeuser_email;
$args['language'] = $g2nukeuser_lang;
$args['creationtimestamp'] = $regphpusertimestamp;
$ret = GalleryEmbed :: createUser($nukeuser_id, $args);
if (!$ret->isSuccess()) {
g2_message('Failed to create G2 user with extId ['.$nukeuser_id.']. Here is the error message from G2: <br />'.$ret->getAsHtml());
return false;
}
if (!g2addexternalMapEntry($nukeuser_uname, $nukeuser_id, 0)) {
return false;
}
else {
$outputtext .= $nukeuser_uname.' (added to g2 users)<br/>';
}
}
}
}
if($nextpage == 1) {
$outputtext = ($i-2)." users imported...";
// need the proper refresh code here....
}
Posted: Mon Apr 04, 2005 2:56 pm Post subject: Re: Gallery2 Integration Development
Thanks to your help, i managed to finish a fully working version.
As you can notice the code had changed from the function you started of, it will also update user now, and the multiple pass by page is working fine.
Code: ›
/*********************************************************/
/* Init G2 API */
/* Exports phpnuke users to g2 and */
/* Initial user/group management synchronization. */
/* Output: False if error
/* user info text to display if success */
/*********************************************************/
define("NB_USER_TO_EXPORT_BY_PASS", 3);
function g2_phpnukeTog2UserExport()
{
global $db, $user_prefix,$Phpnuke2G2Lang;
// init G2 transaction, load G2 API, if not already done so
if (!init())
{
return false;
}
// Load all existing phpnuke <-> G2 mappings
list ($ret, $mapsbyentityid, $mapsbyexternalid) = g2getallexternalIdmappings();
if (!$ret)
{
return false;
}
// Map the ExternalmapId "admin" to the last phpnuke admin account found
// TODO: Mapping for multiple admins
list ($ret, $adminGroupId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
if ($ret->isError())
{
g2_message('Enable to fetch the admin group. Here is the error message from G2: <br />'.$ret->getAsHtml());
return false;
}
list ($ret, $adminList) = GalleryCoreApi::fetchUsersForGroup($adminGroupId, 5);
if ($ret->isError())
{
g2_message('Enable to fetch a member in the admin group. Here is the error message from G2: <br />'.$ret->getAsHtml());
return false;
}
foreach ($adminList as $adminId => $adminName)
{
}
if (!isset ($mapsbyexternalid["admin"]))
{
if (!g2addexternalMapEntry("admin", $adminId, 0))
{
return false;
}
$outputtext .="Admin account create<br/><br/>";
}
// TODO: Update of the admin account if it already exists
// Export all standard phpnuke users (except anonymous: id=1) to G2 defaut group
// --- dari addon (multiple pass)
$sql = "SELECT count(*) AS ucount FROM ".$user_prefix."_users";
$user_count = $db->sql_fetchrow($db->sql_query($sql));
$nextpage = 0;
// Get Arguments for the new user:
$args['fullname'] = $nukeuser_name;
$args['username'] = $nukeuser_uname;
$args['hashedpassword'] = $nukeuser_cryptpass;
$args['hashmethod'] = 'md5';
$args['email'] = $nukeuser_email;
$args['language'] = $g2nukeuser_lang;
$args['creationtimestamp'] = $regphpusertimestamp;
// if the map exists, just update the user data
if (isset ($mapsbyexternalid[$nukeuser_id]))
{
$ret = GalleryEmbed :: updateUser($nukeuser_id, $args);
if (!$ret->isSuccess())
{
g2_message('Failed to update G2 user with extId ['.$nukeuser_id.']. Here is the error message from G2: <br />'.$ret->getAsHtml());
return false;
}
else
{
$outputtext .= $nukeuser_uname.' (has been updated)<br/>';
}
}
// else we create the user
else
{
$ret = GalleryEmbed :: createUser($nukeuser_id, $args);
if (!$ret->isSuccess())
{
g2_message('Failed to create G2 user with extId ['.$nukeuser_id.']. Here is the error message from G2: <br />'.$ret->getAsHtml());
return false;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum