I receive this error whenever I want to create users or groups.
Init load: DB Error: InitLdUserGroup: DB Error: CreateGroup: Error (ERROR_STORAGE_FAILURE)
* in modules/core/classes/GalleryStorage.class at line 477 (gallerycoreapi::error)
* in modules/core/classes/Gallery.class at line 223 (mysqlstorage::search)
* in modules/core/classes/GalleryGroup.class at line 102 (gallery::search)
* in modules/core/classes/GalleryEmbed.class at line 496 (gallerygroup::create)
* in /srv/www/hpmanage/modul/g2mng/classes/gallery.inc at line 220 (galleryembed::creategroup)
* in /srv/www/hpmanage/modul/g2mng/classes/gallery.inc at line 148 (galleryw::creategroup)
* in /srv/www/hpmanage/modul/g2mng/g2_overview.inc at line 81 (galleryw::initldusergrp)
* in /srv/www/hpmanage/index.php at line 271
My question: How to get more precise info about the error
Explanation of system used and wrapper created
System runs on debian etch with apache2 2.2.3-3.3, mysql 5 5.0.32-3, php4 4.4.4-8
Multiple client homepages and one management homepage where the clients hompage data is mapped in
In client homepage gallery is installed multisite (<client url>/g2/). Installation works OK
In management homepage gallery wrapper is called by index.php?page=g2_overview&mpath=g2mng
wrapper script (interesting snippet)
//--require_once(/g2/embed.php');--//
define('GALLERY_CONFIG_DIR', $client->document_root.'g2');
require "/usr/share/gallery2/embed.php";
require_once($hpm->modul->work_path."classes/gallery.inc");
//check if init load needs doing
if($client->pluginIsInitLoad('g2mng'))
if($client->isError($res=galleryw::initLdUserGrp($client->hp_db,$client->hpm_db))){
$hpm->gui->addError('Init load: '.$res->getMessage());
return;
}
wrapper class galleryw (interesting snippets)
/*
* fullInit do a full init for gallery2
* return error object
*/
function fullInit()
{
return GalleryEmbed::init(array(
'embedUri'=>'/index.php?page=g2_overview&mpath=g2mng',
'g2Uri'=>$_SESSION[hp_url].'/g2/',
'activeUserId'=>'',
'fullInit'=>TRUE));
}
/**
* IinitLdUsersGrp initial load of users, groups and group membership of users from hpmanage to gallery
* it assumes that only the users admin, guest reg-user have been ceated by gallery2. Only users from emapp are added to gallery users
* Parmeter $db db-object of client database
* $dbm db-object of hpmanage database
* $init argument array as used in GalleryEmbed::init($init)
* return error object
*/
function initLdUserGrp(&$db,&$dbm)
{
//--load users of hpmanage--//
//get all users of client homepage
$sql="SELECT id,user_id FROM tgroup_member where member=1";
if($db->isError($group_members=$db->getAll($sql))) return $group_members;
//get all users that are sysadmin
$sql="SELECT * FROM tadmin WHERE admin_type IN ('Sys_Admin','Web_Support')";
if($db->isError($admin_members=$dbm->getAll($sql))) return $admin_members;
//--add all system users that have access to client homepage--//
foreach($admin_members as $am){
$found=FALSE;
foreach($group_members as $gm)
if(($gm[id]==3)&&($gm[user_id]==$am[user_id])){
$found=TRUE;
break;
}
if(!$found)$group_members[]=array('id'=>3,'user_id'=>$am[user_id]);
}
//--map the g2 internal admin to an external user--//
//initialize
$ret=galleryw::fullInit();
if(isset($ret))return $db->throwError('Init:'.$ret->getAsHtml());
// get all hpmanage to g2 mappings
list ($ret, $mapsByExternalId) = GalleryEmbed::getExternalIdMap('externalId');
if ($ret) return $db->throwError('CheckExternalMap: '.$ret->getAsHtml());
if(!isset($mapsByExternalId[admin])){
//get g2 admin group id
list ($ret, $adminGroupId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
if ($ret) return $db->throwError('Get Admin Group: '.$ret->getAsHtml());
// get existing g2 admins
list ($ret, $adminList) = GalleryCoreApi::fetchUsersForGroup($adminGroupId);
if ($ret) return $db->throwError('Get Admin User: '.$ret->getAsHtml());
$adminId = key($adminList);
$ret = GalleryEmbed::addExternalIdMapEntry("admin", $adminId, 'GalleryUser');
if ($ret) $db->throwError('Map admin to external user: '.$ret->getAsHtml());
}
GalleryEmbed::done(); //finish transaction
if(count($group_members)>0){
foreach($group_members as $gr_user)
if($db->isError($res=galleryw::createUser($gr_user[user_id]))) return $db->throwError("Error creating g2 user ".$res->getMessage());
}
//--load groups of hpmanage--//
//get all groups except everybody, registeredUsers
$sql="SELECT * FROM tgroup WHERE id > 2";
if($db->isError($groups=$db->getAll($sql))) return $groups;
if(count($groups)>0)
foreach($groups as $group){
//echo"add group ".$group[id].'<br>';
if($db->isError($res=galleryw::createGroup($db,$group[id],$group[group_name])))
return $db->throwError("InitLdUserGroup: ".$res->getMessage());
}
//--map users to groups--//
$sql="SELECT *FROM tgroup_member where user_id > 2";
if($db->isError($group_members=$db->getAll($sql)))return $db->throwError("Error reading group members");
if(count($group_members)>0){
foreach($group_members as $grp_member)
if($db->isError($res=galleryw::addUserToGroup($db,$grp_member[user_id],$grp_member[id])))
return $db->throwError("Error adding users to group ".$res->getMessage());
}
//--set status !pluginIsInitLoad to false--//
//is set to true when gallery is added to client homepage
$sql="UPDATE tplugin SET init=1 WHERE id='g2mng'";
if($db->isError($res=$db->query($sql))) return $db->throwError('update status pluginInitLoad: '.$res->getMessage());
}
/**
* createUser creates a new user. Assumes that no users can be added in gallery2 appart from the initial ones
* parameter $user_id id of user in hpmanage
* returns error object
*/
function createUser($user_id)
{
$hpm_db = dbClass::connectToDB(HPM_DBN);
//initialize
$ret=galleryw::fullInit();
if(isset($ret))return $hpm_db->throwError('Init:'.$ret->getAsHtml());
//check if user exists
$ret=GalleryEmbed::isExternalIdMapped($user_id,'GalleryUser');
if(isset($ret)&& $ret->getErrorCode()& ERROR_MISSING_OBJECT){
//get user parameters
$sql="SELECT * FROM tuser WHERE user_id=$user_id";
if($hpm_db->isError($user=$hpm_db->getRow($sql))) return $user;
$user_arg=array('username'=> (string)$user_id,'fullname'=>$user[first_name].' '.$user[last_name],'hashedpassword'=>$user[passwd],'hashmethod'=>'md5','email'=>$user[user_email]);
//echo"add user id:".$user_id.' user_name '.$user_arg[username].'<br>';
echo"createUser: ".$user_id." username ".$user_arg[username]."<br>";
$user_ret=GalleryEmbed::createUser($user_id,$user_arg);
}
GalleryEmbed::done(); //finish transaction
if(isset($user_ret))return $hpm_db->throwError('CreateUser: '.$user_ret->getAsHtml());
}
Any help is appreciated
Christian Sager