Hello , Everyone
I have changed gallery2 plugin & snipet
/**
* Gallery Plugin for MODx
* Written by Raymond Irving, Sept 2005
* Modyfied by Hisanori Muramoto, Feb, 2007
* Integrates Gallery2 with MODx
*
* Events:
* OnWebChangePassword,OnWebDeleteUser,OnWebSaveUser,OnWebLogout,OnWebLogin
*
* Version: 1.1
*
*/
$e = &$modx->event;
# build mod path
$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
# include main class
include_once $modpath."g2cms.base.class.inc.php";
$g2base = new G2CMS_Base();
// include Gallery API
require_once($g2base->g2Path.'embed.php');
$ret = GalleryEmbed::init(array(
'embedUri' => $g2base->embedUri,
'g2Uri' => $g2base->g2Uri
));
if ($ret) {
$modx->logEvent(0,2,$ret->getAsHtml(),'Gallery');
exit;
}
// Event switch
switch($e->name) {
case "OnWebLogin":
$ret = GalleryEmbed::login($modx->getLoginUserName());
if ($ret) {
$modx->logEvent(0,2,"Error has occured when login by ($username)<br /><br />".$ret->getAsHtml(),'Gallery');
}
break;
case "OnWebLogout":
$ret = GalleryEmbed::logout(array(
'embedUri' => $g2base->embedUri
));
if ($ret) {
$modx->logEvent(0,2,"Error has occured when logout by ($username)".$ret->getAsHtml(),'Gallery');
}
break;
case "OnWebSaveUser":
$uid = $username;
$args = array(
'username' => $username,
'fullname' => $userfullname,
'email' => $useremail,
'hashmethod' => 'md5',
'hashedpassword' => md5($userpassword)
);
if($mode=="new") {
$ret = GalleryEmbed::createUser($uid,$args);
if ($ret) {
$modx->logEvent(0,2,"Unable to create Gallery user account ($username)<br /><br />".$ret->getAsHtml(),"Gallery");
}
}
else if($mode=="upd"){
$uid=($oldusername ? $oldusername:$username);
if(GalleryEmbed::isExternalIdMapped($uid,'GalleryUser')==null) {
$ret = GalleryEmbed::updateUser($uid,$args);
if ($ret) {
$modx->logEvent(0,2,"Unable to update Gallery user account ($username)<br /><br />".$ret->getAsHtml(),"Gallery");
}
}
}
break;
case "OnWebChangePassword":
if(GalleryEmbed::isExternalIdMapped($username,'GalleryUser')==null) {
$ret = GalleryEmbed::updateUser($username,array(
'username'=>$username,
'password'=>$userpassword,
));
if ($ret) {
$modx->logEvent(0,2,"Unable to update Gallery user ($username) password<br /><br />".$ret->getAsHtml(),"Gallery");
}
}
break;
case "OnWebDeleteUser":
if(strpos(strtolower($ondel),'delete')!==false) {
if(GalleryEmbed::isExternalIdMapped($username,'GalleryUser')==null) {
$ret = GalleryEmbed::deleteUser($username);
if ($ret) {
$modx->logEvent(0,2,"Unable to update Gallery user ($username) password<br /><br />".$ret->getAsHtml(),"Gallery");
}
}
}
break;
default:
return;
break;
}
<?php
/**
* Gallery Module Snippet for MODx
* Created by Raymond Irving, Sept 2005
* Modyfied by Hisanori Muramoto, Feb, 2007
* Integrates Gallery2 with MODx
*
* Depends on Gallery Module
*
* Version: 1.1
*/
# build mod path
$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
# include main class
include_once $modpath."g2cms.base.class.inc.php";
$gb = new G2CMS_Base();
require_once($gb->g2Path.'embed.php');
$ret = GalleryEmbed::init(array(
'embedUri' => $gb->embedUri,
'g2Uri' => $gb->g2Uri
));
if ($ret) {
echo $ret->getAsHtml();
exit;
}
$uname = $modx->getLoginUserName();
if ($uname) {
// check is id map already exists
if(GalleryEmbed::isExternalIdMapped($uname,'GalleryUser')) {
$user = GalleryCoreApi::fetchUserByUserName($uname);
if ($user[1]->_id>0) {
// add id map
$ret = GalleryEmbed::addExternalIdMapEntry($uname, $user[1]->_id, 'GalleryUser');
}
}
}
GalleryEmbed::checkActiveUser($uname);
GalleryCapabilities::set('showSidebarBlocks', true);
$g2data = GalleryEmbed::handleRequest();
list($title, $css, $javascript) = GalleryEmbed::parseHead($g2data['headHtml']);
// setup header tags
$header = '';
foreach($css as $c) $modx->regClientCSS($c);
foreach($javascript as $j) $modx->regClientStartupScript($j);
return $g2data['bodyHtml'];
?>
I have been to no use "ActiveUserId" in GalleryEmbed::init().Because I think there is a case which not mapped between ExternalId and G2Id.
And I modified the problems of OnWebSaveUser , OnWebDeleteUser.(There were some dusts in code ex. ";" .

)
But ! I had an error on gallery2 snipet called page when I login by Weblogin.
I saw the event log in MODx manager,
Error has occured when login by (muramoto)
Error (ERROR_STORAGE_FAILURE)
* in modules/core/classes/GalleryStorage.class at line 476 (GalleryCoreApi::error)
* in modules/core/classes/Gallery.class at line 223 (GalleryStorage::search)
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 136 (Gallery::search)
* in modules/core/classes/GalleryCoreApi.class at line 2424 (GalleryEntityHelper_simple::loadEntityByExternalId)
* in modules/core/classes/GalleryEmbed.class at line 254 (GalleryCoreApi::loadEntityByExternalId)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php(724) : eval()’d code at line 42 (GalleryEmbed::login)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 724
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 2289 (DocumentParser::evalPlugin)
* in /var/www/html/modx/assets/snippets/weblogin/weblogin.processor.inc.php at line 398 (DocumentParser::invokeEvent)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php(748) : eval()’d code at line 86
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 748
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 837 (DocumentParser::evalSnippet)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 979 (DocumentParser::evalSnippets)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 1173 (DocumentParser::parseDocumentSource)
* in /var/www/html/modx/manager/includes/document.parser.class.inc.php at line 1087 (DocumentParser::prepareResponse)
* in /var/www/html/modx/index.php at line 144 (DocumentParser::executeParser)
But The Gallery2 snipet page is crrectly read in login.
help me!! :’( :’( I want to fix the error.

To nicpan
I cannot login directly to the gallery2 page ( /gallery2/main.php) by using weblogin event....
Insert a "’activeUserId’ => $modx->getLoginUserName() " , but not solved.
(But can login gallery2 snipet page by weblogin)