vB3 + G2

whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 00:04

hello!

i was hoping to get a little help integrating G2 into VB3 (vbulletin 3.0.7)

i've read through this post:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=28480&highlight=vbulletin

and the docs/EMBEDDING

and have put a dent in the process (i think! ;) )

here's what i have so far:

[img]http://www.cvreefers.org/modules/gallery/albums/whodah_misc/VB3_and_G2_01.jpg[/img]

as you can see, in the upper right corner, i'm logged onto VB3 as 'whodah'.

between the HR tags are the variables i'm passing to the embeded G2 script. my code is as follows:

		$ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
				    'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => $bbuserinfo['username']));

i am calling

$data[javascript]
$data[bodyHtml]

but am not calling

$data['title']
$data['headHtml']
$data['css']

as you can see, the gallery system is being called ok, even matches the layout (css/colors/etc) of the VB3 forums.

but it still see's me as 'GUEST'...

i do have seperate VB3 and G2 user tables...

oh, and my paths are:
public_html/VB/
and
public_html/gallery2/

the user 'whodah' can in fact log on (w/ the same password) to VB3 and G2 independently.

any ideas?

i was wondering if i could do this as a test logged in as 'whodah' under VB3:

		$ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
				    'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => 'whodah'));

(note the forced 'activeUserId' as 'whodah' and not a variable...)

i did try it, but G2 then errors out. (if this is relevant and the error is needed, lmk and i'll post it!) but i'm not even sure if that logic is correct.

ty very much! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-04-23 00:25

- use embedPath in the init call, see other examples
- it's better to use id / uid instead of username as activeUserId
- if you set any activeUserId different from null / empty string, you first have to map this user to a G2 user or create this user in G2.

see the mambo or the WP or the phpnuke threads for this topic.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 00:38
valiant wrote:
- it's better to use id / uid instead of username as activeUserId

if i did this, i'd need to use the same users table for G2 as i do for VB3, correct?

that or do some MAJOR synching as listed in the docs at all times?

(i.e. if whodah = uid 5 in G2, but uid 13 in VB3)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-04-23 00:48
whodah wrote:
valiant wrote:
- it's better to use id / uid instead of username as activeUserId

if i did this, i'd need to use the same users table for G2 as i do for VB3, correct?

no

Quote:
that or do some MAJOR synching as listed in the docs at all times?

(i.e. if whodah = uid 5 in G2, but uid 13 in VB3)

use GalleryEmbed::createUser for VB3 users that don't exist in G2, GalleryEmbed::isexternalIdmapped() and GalleryCoreApi::fetchuserbyusername if you are not sure if they already exist in G2, GalleryEmbed::addexternalIdmap if the user exists in G2, but is not already mapped to the corresponding VB3 user (i.e. map admin with admin user). etc.
you'll have to map the id of the VB3 user to the G2 user anyway, there's no way around it.

see the other embedding threads, wp, phpnuke, mambo, ... on how to do these things.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 06:15

ok, here is what i have so far in it's entirety...

the VB3 variables are:

$bbuserinfo['userid'] = VB3 int, i.e.: 17
$bbuserinfo['username'] = VB3 string name, i.e.: whodah
$bbuserinfo['lang_code'] = VB3 string code, i.e.: en (although i'm guessing i could omit this and just leave it null)
$bbuserinfo['joindate'] = VB3 php timestamp int, i.e.: 1075737219

all of this is stripped from various other integrations. still a no go... same as the above screenshot. i see the concept, i just cannot get it to work... any pointers at this stage in the game? :)

$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

function runGallery() {
    require_once('../gallery2/embed.php');
    
		$data = array();
	
    // if anonymous user, set g2 activeUser to null
    $uid = null;
 
    // initiate G2 
		// $bbuserinfo['userid'] = vBulletin numeric user number
		$ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
				    'embedPath' => '/gallery2',
						'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => $bbuserinfo['userid']));
   /*
	  if (!$ret->isSuccess()) {
      $data['bodyHtml'] = $ret->getAsHtml();
      return $data;
    }
		*/
            if ($ret->isError()) 
            { 
               if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) 
               { 
                 // check if there's no G2 user mapped to the activeUserId 
                 $ret = GalleryEmbed::isExternalIdMapped($bbuserinfo['userid'], 'GalleryUser'); 
                 if ($ret->isError() && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) 
                 { 
                     // user not mapped, map create G2 user now 
                           // Get Arguments for the new user: 
                           $args['fullname']     =   $bbuserinfo['username']; 
                           $args['username']    = $bbuserinfo['username']; 
                           $args['hashedpassword'] =   $bbuserinfo['password']; 
                           $args['hashmethod'] =    'md5'; 
                           $args['email']       =   $bbuserinfo['email']; 
                           $args['language']   =   $bbuserinfo['lang_code']; 
                           $args['creationtimestamp']   =   $$bbuserinfo['joindate']; 
                            
                           $retcreate = GalleryEmbed :: createUser($bbuserinfo['userid'], $args); 
                           if (!$retcreate->isSuccess()) 
                           { 
                              echo 'Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml(); 
                              return false; 
                           } 
                            
                           if (!g2addexternalMapEntry($bbuserinfo['username'], $bbuserinfo['userid'], 0)) 
                           { 
                                return false; 
                           } 
                            
                           // Full G2 reinit with the new created user 
                           $ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
                                              				    'embedPath' => '/gallery2',
                                              						'relativeG2Path' => '../gallery2',
                                              				    'loginRedirect' => 'index.php',
                                              				    'activeUserId' => $bbuserinfo['userid']));
                 } 
                 else 
                 { 
                     echo 'G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
                 } 
             } 
             else 
             { 
                 echo 'G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
             } 
           } 

    // user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
    GalleryCapabilities::set('showSidebar', false);

    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
      $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
      return $data;
    }
    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) {
      exit; /* uploads module does this too */
    }
   
    // put the body html from G2 into the xaraya template 
    $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

    // get the page title, javascript and css links from the <head> html from G2
    $title = ''; $javascript = array();	$css = array();
 
    if (isset($g2moddata['headHtml'])) {
      list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
	  $data['headHtml'] = $g2moddata['headHtml'];
    }
    
    /* Add G2 javascript  */
    if (!empty($javascript)) {
      foreach ($javascript as $script) {
	     $data['javascript'] .= "\n".$script;
      }
    }

    /* Add G2 css  */
    if (!empty($css)) {
      foreach ($css as $style) {
	     $data['css'] .= "\n".$style;
      }
    }

    // sidebar block
    if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
      $data['sidebarHtml'] = $g2moddata['sidebarHtml'];
    }
    
    return $data;
} 

ty! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-04-23 07:34

replace

                           if (!g2addexternalMapEntry($bbuserinfo['username'], $bbuserinfo['userid'], 0))
                           {
                                return false;
                           }
                           
                           // Full G2 reinit with the new created user
                           $ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
                                                              'embedPath' => '/gallery2',
                                                                'relativeG2Path' => '../gallery2',
                                                              'loginRedirect' => 'index.php',
                                                              'activeUserId' => $bbuserinfo['userid'])); 

by

$ret = GalleryEmbed::checkActiveUser($bbuserinfo['userid']);
if ($ret->isError()) {
    print $ret->getAsHtml();
    return false;
}

the reason: GalleryEmbed::createUser() does two things:
1. create a G2 user with the $args details you provide
2. create the map with addexternalMapEntry

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 16:19

made the change, thx!

woohoo!!!! had my first successful sync!!!!

u know what was slowin me down?

in function runGallery, the nifty line of:

global $bbuserinfo;

<rolls eyes>

i've got some cleaning up of code to do, inserted a lot of dummy test users and output statements. but more to come soon! :)

thx valiant!

:)

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 22:27

the latest: having pw problems... i think it might be on the VB3 site atm. i think i'm feeding G2 the user's pw plus the salt of VB3... thus when a user attempts to log on to standalone G2, they cannot authenticate.

i hope to know more soon!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-04-23 22:58

whodah, the salt was added after the initial GalleryEmbed design. i have to look into that, but not now :/ for now. but actually, it works for me in my xaraya integration.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sat, 2005-04-23 23:27

ah, i just confirmed that that is what it was/is!

can you clarify a bit for me on the xaraya integration? i.e. you've toyed w/ some salt added to the G2 enbeding w/ xaraya and it's working is what i think you mean?

(but not ready, i caught that part! :) )

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-24 00:17

i've never handled the salt. just used the API methods. don't know why it works, don't know why it should work, never thought about it, lol. sorry for my ignorance, i will look into it sometime in the future.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 00:33

ah! gotcha!

no need to apologize, u've helped immensly :)

allllll righty then!

i think i'm there minus a couple quirks...

first, a link! the VB3/G2 is currently not live. still in testing:
http://www.cvreefers.org/VB/gallery2.php

second off, a *quick* question... here's my latest code. if u see the line w/ the comment of:

Quote:
i don't think i need this next line?!

well.. the comment explains it, heh! i dont' think i need that line... it shows up if a user has already been mapped and are a return visit. it does not show up if it's a first time visit. and when it does show up for return visits, it returns (GALLERY_SUCCESS)

so i'm thinking either:
a) i get rid of that line
b) on the line:

if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) 

i add something like

& not GALLERY_SUCCESS

i'd have to lookup the syntax on solution b, but wanted to see whatcha thought?

// Begin G2 integration code
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

function runGallery() {
    global $bbuserinfo;
		require_once('../gallery2/embed.php');
    
		$data = array();
	
    // if anonymous user, set g2 activeUser to null
		$uid = null;
 
    // initiate G2 
		$ret = GalleryEmbed::init(array('embedUri' => 'whodah_testtemplate.php',
				    'embedPath' => '/VB',
						'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => $bbuserinfo['userid']));
						
    if ($ret->isError()) 
        { 
           if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) 
           { 
             // check if there's no G2 user mapped to the activeUserId 
             $ret = GalleryEmbed::isExternalIdMapped($bbuserinfo['userid'], 'GalleryUser'); 
             if ($ret->isError() && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) 
             { 
                 // user not mapped, map create G2 user now 
                 // Get Arguments for the new user: 
                 $args['fullname']     =   $bbuserinfo['username']; 
                 $args['username']    = $bbuserinfo['username']; 
                 $args['hashedpassword'] =   $bbuserinfo['password']; 
                 $args['hashmethod'] =    'md5'; 
                 $args['email']       =   $bbuserinfo['email']; 
                 $args['language']   =   $bbuserinfo['lang_code']; 
                 $args['creationtimestamp']   =   $bbuserinfo['joindate']; 
                  
                 $retcreate = GalleryEmbed :: createUser($bbuserinfo['userid'], $args); 
                 if (!$retcreate->isSuccess()) 
                 { 
                    echo '<HR>line: '.__LINE__.', Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml(); 
                    return false; 
                 } 
								$ret = GalleryEmbed::checkActiveUser($bbuserinfo['userid']); 
                if ($ret->isError()) { 
                    print $ret->getAsHtml(); 
                    return false; 
                } 
             } 
             else 
             { 
                 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
             } 
         } 
         else 
         { 
             // i don't think i need this next line?!
						 //echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
         } 
       } 

    // user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
    GalleryCapabilities::set('showSidebar', false);

    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
      $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
      return $data;
    }
    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) {
      exit; /* uploads module does this too */
    }
   
    // put the body html from G2 into the xaraya template 
    $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

    // get the page title, javascript and css links from the <head> html from G2
    $title = ''; $javascript = array();	$css = array();
 
    if (isset($g2moddata['headHtml'])) {
      list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
	  $data['headHtml'] = $g2moddata['headHtml'];
    }
    
    /* Add G2 javascript  */
    if (!empty($javascript)) {
      foreach ($javascript as $script) {
	     $data['javascript'] .= "\n".$script;
      }
    }

    /* Add G2 css  */
    if (!empty($css)) {
      foreach ($css as $style) {
	     $data['css'] .= "\n".$style;
      }
    }

    // sidebar block
    if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
      $data['sidebarHtml'] = $g2moddata['sidebarHtml'];
    }
    
    return $data;
} 

// End G2 integration code

third off - the VB3 salt'ed passwords as mentioned above... this isn't a huge deal to me, i'm tempted to disable G2 standalone anyways... but to complete the integration for others who are reading this, it's an issue as of this timestamp.

fourth off - i gotta research how to turn off those 'a href - img' borders, heh!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-24 01:01

// if anonymous user, set g2 activeUser to null
$uid = null;

then you use the bb[userid] as activeUserId. so the $uid = null; statement isn't used?
you should do something like
$uid = condition_that_user_is_guest ? '' : $bbuser['userid'];

and then activeUserId => $uid

at "
i don't think i need this next line?! ":
yes you need to print the error there and return false, because this else case is GalleryEMbed::init returned an error, but the error was not MISSING_OBJECT, but some other unknown error. i.e. you know nothing about the error, you know only, that G2 doesn't work ok at the moment. -> return false.

image borders? do you include the $css of G2 in VB3? just checked, no you don't. you should...
and if you just want to disable image borders:
addd img style:none in the the css of your page.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 03:38

heya!

i was wondering on the $uid issue...

image borders: by not including G2's css files, i got to 'cheat' as G2 instantly matched VB3... but, as per your advice to enable it, i'm guessing there are other issues i could come across too?

of course the true solution would be to enable it and then setup my G2 css to match the VB3 css (or vice versa, heh!)

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 05:22

ok, re-enabled $data[css] (which of course fixes up the 'a href img' border issue), uncommented that line that i had commented out (the error return - i swear it was producing weird results before, but seems to be behaving fine now! probably my mind was mis-behaving, heh!), and fixed several $uid vs. $bbuserinfo['userid'] issues...

the link once again:
http://www.cvreefers.org/VB/gallery2.php

and the running code:

// Begin G2 integration code
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

function runGallery() {
    global $bbuserinfo;
		require_once('../gallery2/embed.php');
    
		$data = array();
	
    // if anonymous user, set g2 activeUser to null
		$uid = $bbuserinfo['userid'] = 0 ? '' : $bbuserinfo['userid']; 
 
    // initiate G2 
		$ret = GalleryEmbed::init(array('embedUri' => 'gallery2.php',
				    'embedPath' => '/VB',
						'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => $uid));
						
    if ($ret->isError()) 
        { 
           if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) 
           { 
             // check if there's no G2 user mapped to the activeUserId 
             $ret = GalleryEmbed::isExternalIdMapped($uid, 'GalleryUser'); 
             if ($ret->isError() && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) 
             { 
                 // user not mapped, map create G2 user now 
                 // Get Arguments for the new user: 
                 $args['fullname']     =   $bbuserinfo['username']; 
                 $args['username']    = $bbuserinfo['username']; 
                 $args['hashedpassword'] =   $bbuserinfo['password']; 
                 $args['hashmethod'] =    'md5'; 
                 $args['email']       =   $bbuserinfo['email']; 
                 $args['language']   =   $bbuserinfo['lang_code']; 
                 $args['creationtimestamp']   =   $bbuserinfo['joindate']; 
                  
                 $retcreate = GalleryEmbed :: createUser($uid, $args); 
                 if (!$retcreate->isSuccess()) 
                 { 
                    echo '<HR>line: '.__LINE__.', Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml(); 
                    return false; 
                 } 
								$ret = GalleryEmbed::checkActiveUser($uid); 
                if ($ret->isError()) { 
                    print $ret->getAsHtml(); 
                    return false; 
                } 
             } 
             else 
             { 
                 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
             } 
         } 
         else 
         { 
						 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
         } 
       } 

    // user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
    GalleryCapabilities::set('showSidebar', false);

    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
      $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
      return $data;
    }
    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) {
      exit; /* uploads module does this too */
    }
   
    // put the body html from G2 into the xaraya template 
    $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

    // get the page title, javascript and css links from the <head> html from G2
    $title = ''; $javascript = array();	$css = array();
 
    if (isset($g2moddata['headHtml'])) {
      list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
	  $data['headHtml'] = $g2moddata['headHtml'];
    }
    
    /* Add G2 javascript  */
    if (!empty($javascript)) {
      foreach ($javascript as $script) {
	     $data['javascript'] .= "\n".$script;
      }
    }

    /* Add G2 css  */
    if (!empty($css)) {
      foreach ($css as $style) {
	     $data['css'] .= "\n".$style;
      }
    }

    // sidebar block
    if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
      $data['sidebarHtml'] = $g2moddata['sidebarHtml'];
    }
    
    return $data;
} 

// End G2 integration code

whatcha think? ready for prime time? :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-24 10:27

you still need to return false after

 else
             {
                 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml();
return false; // here !!
             }
         }
         else
         {
                   echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml();
return false; // here !!
         } 

and not putting javascript into the <head> part of your embedded pages will result in a embedded G2, where you can't use the slideshow and you can't use site admin -> maintenance description and numerous other things.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 15:52

d'oh! u mentioned the 'return false' part, and i thought i had, oops!

css: ahhh, gotcha!

ok, added those return false statements...

funny you should mention slideshow....

one of my users who was testing the site last night tried to do the slideshow and i'm getting a lot of code spit out (and it was not working...) our users really like the slideshow - we use it for coral growth sequences!

i was including data[javascript] and data[css] seperatly as at first i didn't want the css...

but replacing those w/ data[headHtml] (especially since css is being included properly now) solved the problem!

:)

the latest code, i think i'm almost near a 'valiant approved' status! heehee!

// Begin G2 integration code
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

function runGallery() {
    global $bbuserinfo;
		require_once('../gallery2/embed.php');
    
		$data = array();
	
    // if anonymous user, set g2 activeUser to null
		$uid = $bbuserinfo['userid'] = 0 ? '' : $bbuserinfo['userid']; 
 
    // initiate G2 
		$ret = GalleryEmbed::init(array('embedUri' => 'gallery2.php',
				    'embedPath' => '/VB',
						'relativeG2Path' => '../gallery2',
				    'loginRedirect' => 'index.php',
				    'activeUserId' => $uid));
						
    if ($ret->isError()) 
        { 
           if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) 
           { 
             // check if there's no G2 user mapped to the activeUserId 
             $ret = GalleryEmbed::isExternalIdMapped($uid, 'GalleryUser'); 
             if ($ret->isError() && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) 
             { 
                 // user not mapped, map create G2 user now 
                 // Get Arguments for the new user: 
                 $args['fullname']     =   $bbuserinfo['username']; 
                 $args['username']    = $bbuserinfo['username']; 
                 $args['hashedpassword'] =   $bbuserinfo['password']; 
                 $args['hashmethod'] =    'md5'; 
                 $args['email']       =   $bbuserinfo['email']; 
                 $args['language']   =   $bbuserinfo['lang_code']; 
                 $args['creationtimestamp']   =   $bbuserinfo['joindate']; 
                  
                 $retcreate = GalleryEmbed :: createUser($uid, $args); 
                 if (!$retcreate->isSuccess()) 
                 { 
                    echo '<HR>line: '.__LINE__.', Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml(); 
                    return false; 
                 } 
								$ret = GalleryEmbed::checkActiveUser($uid); 
                if ($ret->isError()) { 
                    print $ret->getAsHtml(); 
                    return false; 
                } 
             } 
             else 
             { 
                 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
             		 return false;
						 } 
         } 
         else 
         { 
						 echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); 
         		 return false;
				 } 
       } 

    // user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
    GalleryCapabilities::set('showSidebar', false);

    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
      $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
      return $data;
    }
    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) {
      exit; /* uploads module does this too */
    }
   
    // put the body html from G2 into the xaraya template 
    $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

    // get the page title, javascript and css links from the <head> html from G2
    $title = ''; $javascript = array();	$css = array();
 
    if (isset($g2moddata['headHtml'])) {
      list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
	  $data['headHtml'] = $g2moddata['headHtml'];
    }
    
    /* Add G2 javascript  */
    if (!empty($javascript)) {
      foreach ($javascript as $script) {
	     $data['javascript'] .= "\n".$script;
      }
    }

    /* Add G2 css  */
    if (!empty($css)) {
      foreach ($css as $style) {
	     $data['css'] .= "\n".$style;
      }
    }

    // sidebar block
    if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
      $data['sidebarHtml'] = $g2moddata['sidebarHtml'];
    }
    
    return $data;
} 

// End G2 integration code

if this gets the final 'stamp of aproval', should i post the entire solution in this thread or start a new thread?

thanks once again for the help valiant!!! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-24 16:12

excellent work whodah!

only a minor thing:
- you have now 2 <title> tags in your html. One is set by VB, one is set by G2
if possible, use a VB function to set the title, i.e. don't create your own <title> tags

- It would be great if you could post your VB3 integration as a tar or zip archive to the forums (attach file). I guess the above code is not the whole thing. i.e. you have to add the $css and $javascript variable to the VB3 templates/output. Either include also this other file or add some instructions on how to do this manually.

With your permission, I'd be very glad to add this a) to the Embed & Integration topic and to the gallery cvs repository.

- Sidenote: you should remove the all css code from the VB3 template and include it as a css file. You can save a lot of bandwidth that way.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 17:21

sweet, thanks valiant!

the dual title tags were a function of me including data[title] and data[headhtml]... data[title] is now removed!

both a) and b) are fine w/ me!

i was typing out a readme.txt w/ a step-by-step when i realized i was about to post some VB3 code publicly which is not permitted by VB's license agreement...

so i was thinking that i could post a how-to on vbulletin.org (which would require a licensed account to view the VB3 code itself) and then reference that in a readme.txt file along w/ the embedded open-source G2 code zipped up and posted here and on the cvs.

does that sound reasonable to you?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-24 17:26

I see. Of course we want to conform with the license. I'd add just a link to the vbulletin.org page where the users can get the integration/code/readme in the G2 list of integrations.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-04-24 17:51

that'll work!

ok, the latest posted code on this thread is what i'm running, and a link to the instructions on the VB side of things is here:

http://www.vbulletin.org/forum/showthread.php?p=645237

does that suffice w/ whatcha need valiant? :)

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Wed, 2005-05-04 05:13

hello!

now that we've been using it a while, i've come across a few things...

a) mod_rewrite - when i setup mod_rewrite, it works for the standalone, but not the embedded. from what i understand, there are changes in the current CVS that address this?

b) the left-hand menu does not show up in the embedded G2. did i miss a call or is this by design? i.e. if a user has permissions to upload to one album, as i see it, they have to navigate to the parent album and then use the drop-down box to 'add item' to their album.

thanks! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-05-04 08:17

a) true, url rewrite should work in standalone & embedded now.

b) Perhaps you set GalleryCapabilities::something.. which disables the sidebar. This must be somwhere in your code.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Wed, 2005-05-04 15:56

b) very good - and quite obvious... it is in my code. i completely overlooked that. thx!

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Tue, 2005-05-10 05:26

heya!

another question ;)

i think our users are just not going to be able to use Gallery Remote... i've been reading that there are issues w/ G2 Remote and embedded gallery (and the upload applet for that matter) and unfortunatly w/ the VB3 salt ordeal, our users cannot simply point to the non-embedded G2 as their pw's won't work...

does that sound right or am i overlooking something?

thx! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-05-10 05:30

sounds about right.
the embedded G2/GR issue should be fixed by the final release, but i don't know when exactly.
and the pw hash salt thing, i've still not looked into, sorry.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Fri, 2005-05-20 21:10

heya valiant!

just thought i'd let you (others) know that i've installed G2b3, enabled/setup the mod_rewrite module, copied the .htaccess file out of my G2 base dir and put it into my vB base dir, and it's workin!

we can now use bbcode [ i m g ] tags out of our gallery install again!

w00t!

thx! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-05-20 21:25

great (and it will be even easier with the multisite+rewrite+embed+cookie change that will in be cvs soon).

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-05-23 04:08

i spoke a bit too soon on the mod_rewrite... it is 'working', however the embedded links take me to the standalone G2.

i'm not strong in mod_rewrite. think you could help me out? i've researched on the forums and docs, and i don't see the solution... (if it's there, i'd greatly appreciate it if you could point it out too! :) )

i was trying to follow this, but just not making the right connections...
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=29534&highlight=modrewrite+embed%2A

i figured our .htaccess in the vB3 root directory somehow has to call our embeded G2 page, but i'm guessing it is not...

here's our setup:
forums in root web directory:
/var/www/html/

G2 in directory:
/var/www/html/gallery2/

our G2 embedded file is:
/var/www/html/gallery2.php

and lastly, our vB .htaccess file looks like this:

# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /./gallery2/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !main.php?
    RewriteRule .   -   [L]


    RewriteCond %{REQUEST_URI} !main.php?
    RewriteRule ^v/$   /./gallery2/main.php?g2_view=core:ShowItem   [QSA,L]

    RewriteCond %{REQUEST_URI} !main.php?
    RewriteRule ^d/([0-9]+)-([0-9]+)/([^\/]+)$   /./gallery2/main.php?g2_view=core:DownloadItem&g2_itemId=$1&g2_serialNumber=$2   [QSA,L]

    RewriteCond %{REQUEST_URI} !main.php?
    RewriteRule ^v/(.+)$   /./gallery2/main.php?g2_view=core:ShowItem&g2_path=$1   [QSA,L]

</IfModule>

# END Url Rewrite section

here's the link to our embeded G2 if ya need it to see the link structure that the current .htaccess is producing:
http://www.cvreefers.org/gallery2.php

thx a ton, again! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-23 10:16

no, i don't know much about mod_rewrite. let's wait 'til mindless commits his changes.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Fri, 2005-05-27 01:07

heya valiant! were the changes just commited that are talked about in this thread what you were referring to?

http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=29915&start=15

if so - i'll CVS our gallery and give it a shot!

thx! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-05-27 06:56

sure. maybe it isn't in the anonymous cvs yet. it's all in core version 0.9.20.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Fri, 2005-06-03 16:39

heya!

running core 0.9.22 now. i've got URL Rewrite enabled.

i'm not sure if this question should be here or on 'G2 Support' but it does involve the vB3 integration, so figured i'd keep it here! feel free to redirect me if necessary and i'll post in the other forum.

the question is this:
our integration file is: www.domain.com/gallery2.php and we can enter the gallery via that link just fine.

when URL Rewrite is enabled on the integration, would you expect our URLs to look something like:
www.domain.com/gallery2.php?blah=blah&blah2=blah2 etc..
or
www.domain.com/v/albumname
or perhaps even something different...

the reason i ask: the URL Rewrite works! but sets up our links the 2nd way. when done the 2nd way, all of our relative path links from vB3 are 'broken'.

I can redo the relative path links to hard coded links if necessary - but i'm wondering if i have it setup right before doing so?

thanks!! :)

btw: w/ URL Rewrite in place on this core, our users are able to surf around, upload, etc. in the integrated G2 w/out getting logged out! woohoo! ty ty! :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-06-03 16:49

this is the normal url format:
www.domain.com/gallery2.php?blah=blah&blah2=blah2
and this is the short url format:
www.domain.com/v/albumname

what is broken? got an example?

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Fri, 2005-06-03 17:11

sure!

visit:
http://www.cvreefers.org/gallery2.php and note the top of the page:
the site logo works
then mouseover the link 'FAQ' and notice it's:
http://www.cvreefers.org/faq.php?

then click any of the albums. say the first one, the POTM album. now notice that the url is:
http://www.cvreefers.org/v/POTM/
and note that the site logo is a broken image. then mouse over FAQ once again at the top to see it points to:
http://www.cvreefers.org/v/POTM/faq.php

which to me looks like mod_rewrite is simply applying the rules to those links/images too.

thoughts?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-06-03 17:38

i see now the problem. but i'd say vbulletin does the wrong thing.
the urls get rewritten correctly but vB somehow doesn't use the correct mechanism to generated new urls. it generates new urls based on the original request uris instead of the rewritten uris.
as i don't know vB at all (and i won't take a look at it, it's closed source which they could then use against me), i can't help you there.

maybe the vB guys know more if vB can handle mod_rewrite etc.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Fri, 2005-06-03 18:08

cool - if G2 is working correctly then i'll investigate it on the VB3 end and/or hardcode the header/footer links.

thx! :)

 
Zoren

Joined: 2005-06-19
Posts: 11
Posted: Mon, 2005-07-25 05:35

First, I'd like to thank Whodah & Valliant for their work on this. Looks very promising. I like what you've done on your aquatic site whodah. I would like to ask a couple of questions regarding your integration of G2 & VB3. Is it currently working in a stable manner for you? Did you work out all of the errors and other technical issues you had posted about?

I am interested in combining G2 & VB for a community portal. I want to offer a forum and member galleries. I wanted to know how memberships between the two work. I'd like to be able to make the forum freely accessable to anyone that registers. I would like to have the gallery uploading available to paying members only. I would want the gallery viewable to all unless they are restricted by the gallery member. I want to charge for the galleries to help pay for server resources and limit thier use to some extent. Can you have the usernames sync for both the forum and gallery but limit the gallery to paying members only?

Thanks in advance for your consideration on this.

Zoren

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-07-25 15:03
Zoren wrote:
First, I'd like to thank Whodah & Valliant for their work on this. Looks very promising. I like what you've done on your aquatic site whodah.

you're welcome! :)

Zoren wrote:
I would like to ask a couple of questions regarding your integration of G2 & VB3. Is it currently working in a stable manner for you? Did you work out all of the errors and other technical issues you had posted about?

yup - there's a couple 'known' issues i havn't fixed yet. i had to hardcode the links in the upper navigational bar as the mod_rewrite 'breaks' them when you are using short url's in G2. i realized the other day that i need to hard code the bottom links as well. i also need to hard code the 'login' form at the top. so the same issue as hard codeing the links in the top nav bar, i just overlooked a few.

the only other known issue is that w/ vB's SALT on passwords, the passwords do not match between G2 and vB. thus the users MUST login via vB and G2 will mooch off that session. you cannot go to your non-embedded installation of G2 and login unfortunatly.

as far as i know, that's the only issue at this time.

even the java applets work! :)

note: i'm using a nightly build greater than the alpha 3 release to get this to work. but i'm not using G2b4 which i see is now on the site as of a few days prior to this posting! :) presumably all will be well, but i've yet to test it in G2b4.

Zoren wrote:
I am interested in combining G2 & VB for a community portal. I want to offer a forum and member galleries. I wanted to know how memberships between the two work.

your vB users are 'pushed' to being G2 users via the integration script. via this mechanism, you won't have any non-vB members in your G2 install. vB members need to visit a G2 page (any page) to get their G2 username setup. it'll do it on their first vB logged-in session automagically.

Zoren wrote:
I'd like to be able to make the forum freely accessable to anyone that registers. I would like to have the gallery uploading available to paying members only. I would want the gallery viewable to all unless they are restricted by the gallery member.

notta problem. in essence that's how we do it but for different reasons. basically, users don't have permissions to upload anywhere until you grant them permissions in G2. anyone can view them (unless u restrict the permissions otherwise)

Zoren wrote:
I want to charge for the galleries to help pay for server resources and limit thier use to some extent.

not sure how to do that... maybe there's a quota system in G2? dunno... never looked into that...

Zoren wrote:
Can you have the usernames sync for both the forum and gallery but limit the gallery to paying members only?

as answered above: absolutly! :)

HTH!

 
Zoren

Joined: 2005-06-19
Posts: 11
Posted: Mon, 2005-07-25 20:10

Thanks for the detailed and quick response whodah. I really appreciate it.

G2 & VB look like they may work for this purpose. It appears that I would have the membership controls that I need. As far as charging for gallery access, I hope to do this through VB's built in payment processor. It integrates with the payment processor I use, authorize.net. G2 has a quota system that can limit how much disk space users are alloted. I will have to keep an eye on bandwidth manually. An issue that comes to mind relates to how vb handles the payment processing. I think there may have to be multiple levels of membership. I don't have vb yet and don't know if this is an option. One level of membership would allow use of the forums and the other use of the gallery. If all else failed, I could purchase another vb license and keep the forum and galleries separate.

One last question. Is this something that a non programmer could do? I can alter code if I know what needs modified where. Are the instructions available at the vb forum for registered users? Thanks again for your work on this.

Zoren

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-07-25 20:39
Zoren wrote:
One last question. Is this something that a non programmer could do? I can alter code if I know what needs modified where. Are the instructions available at the vb forum for registered users? Thanks again for your work on this.

yes, and yes! :D

due to vB's proprietary code (i.e. it's not free), the G2 integration code/instructions is posted on vB's site in which u have to have a vB license to view.

kinda funny mixing gallery's free code w/ vB's co$stly code, but we figured this was the best route to avoid violating vB's user and copyright agreements.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-07-25 21:01

whodah, could you post the links to the vb integration download, perhaps also to a demo (your site).
i forgot to add your integration to the list of integrations :/

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-07-25 21:56

sure!

vB3 integration code is located here:
http://www.vbulletin.org/forum/showthread.php?p=645237

(as a point of interest: you have to have an account on vbulletin.org to view it - which means you have to have a vB license to view it to stay in compliance w/ vB's EUA)

and a sample integration is here:
http://www.cvreefers.org/gallery2.php

 
4cstr

Joined: 2005-12-13
Posts: 1
Posted: Wed, 2005-12-14 16:02

Will gallery work with the new vB 3.5 upgrade?

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Thu, 2005-12-22 13:24

heya!

a little tweaking is needed on the vB side of things... see the vB link in this thread for the solution. due to vB licensing issues, we can only post the G2 code side of things here...

i've not yet migrated to 3.5.x, but plan to in the very near future! however, on that thread, others have it working in 3.5.x! :)

here's the link again for your convinience:
http://www.vbulletin.org/forum/showthread.php?p=645237

9 x G1
3 x G2

 
tokenyank

Joined: 2005-12-27
Posts: 1
Posted: Tue, 2005-12-27 15:19

I know it has been asked and answered, but I would very VERY much like to see the usersystem's integrated for vB3.5.x.

I'm not too bothered with random image blocks or the like as that can all come later, but the usersystem is uber-important.

If this can't be done, I'll have to go to Coppermine (*shudder*) as my gallery solution and I really don't want to do that! :D

There is this: Vbulletin Application Connector -
http://www.vbulletin.org/forum/showthread.php?t=103069&page=1&pp=15&highlight=api

Unfortanatly, I do not know about coding to make this work with vB/G2... Perhaps someone with more knowledge in G2's code base could use the SOAP api and make this integration? (if there is a God)

 
SilVert

Joined: 2006-03-12
Posts: 9
Posted: Mon, 2006-03-20 19:28

i have posted the code on VBulletin.org on what needs to be done to get it to work(not just replace this replace this, i posted the whole PHP file).

Zoren - i am trying to do exactly what you want. i have a thread in this section asking about that right now. i will post my code on vb.org when i have it working, if i ever do ;)

Thanks Whodah and valiant for all the help so far! hopefully this will be a gallery i STICK WITH this time(im on gallery number 3 at this point ;))

 
defcon_420

Joined: 2006-03-31
Posts: 6
Posted: Fri, 2006-03-31 06:45

anyone got G2.1 imbedded with vb 3.0.x yet?

 
SilVert

Joined: 2006-03-12
Posts: 9
Posted: Mon, 2006-05-15 19:49
defcon_420 wrote:
anyone got G2.1 imbedded with vb 3.0.x yet?

i think sadly all the work now is on 3.5.x and above....
http://www.vbulletin.org/forum/showthread.php?t=111931

 
fabianv

Joined: 2007-08-17
Posts: 6
Posted: Fri, 2007-08-17 18:36

Hey guys.. I was wondering if there was a very simple and elegant solution to simply embed 10 thumbnails of 78px x 78px in vbulletins forumhome template (most recent submissions). Thats the only integration I need. :)

Your help would be greatly appreciated!

 
Riccardo83

Joined: 2007-09-08
Posts: 5
Posted: Sat, 2007-09-08 13:49

wouldnt it just be nice if some clever guy posted a how to integrate into vb 3.6.8 ?????????????