Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Gallery 2.1 and vBulletin 3.5.X integration
Brent H's Avatar
Brent H
Join Date: Sep 2004
Posts: 162

Poprocks on toast, yo.

Phoenix, AZ
Show Printable Version Email this Page Subscription
Brent H Brent H is offline 03-31-2006, 10:00 PM

This tutorial will outline the steps needed to integrate your vBulletin 3.5.X and Menalto Gallery 2.1 installations. The original thread located here has become a little too scattered, and since it's original focus was on the Gallery 2.0 and vBulletin 3.0 series, I think it'd be beneficial to start this new thread so that the information is more easily found for the 3.5.X and 2.1 series.

Before we begin, you should be aware that this tutorial assumes that you'll be placing your gallery in the root directory for your forums. My directory structure looks a little like this:

public_html/Vbulletin Files
and
public_html/gallery2/Gallery Files

As long as your gallery folder is located within your root vBulletin directory, this should work just fine.

Step 1:
Install Menalto Gallery 2.1. Remember to upload the "gallery2" folder INSIDE your root vBulletin directory!

Step 2:
Create a new file containing the following, and save it as gallery2.php:
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''gallery'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'gallery2',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################

require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Gallery';
error_reporting(E_ALL );

$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');

// #######################################################################
// ###################### Begin G2 INTEGRATION CODE ######################
// #######################################################################

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

function 
runGallery() {
global 
$vbulletin$userinfo;
require_once(
'/home/paranorm/public_html/gallery2/embed.php');

$data = array();

// If it's an anonymous user, set the g2 activeUser to null
$uid $vbulletin->userinfo['userid'] = '' $vbulletin->userinfo['userid'];

// initiate G2
// You need to edit the following 4 lines to suit your VB3 & G2 installations
// This is set up for an install that looks like:
// public_html/VB/<vb files>
// public_html/gallery2/<gallery2 files>
// and also setup for a VB3 template name of 'gallery2'. If you have any
// differences, make those changes here!
// You might need to change 'loginRedirect' if you have your VB3 setup to
// where index.php is not the root page of VB3... Like if you've changed it
// to forums.php or something of the like.

$ret GalleryEmbed::init(array('embedUri' => '/gallery2.php',
'g2Uri' => 'http://www.paranormalis.com/gallery2/',
'loginRedirect' => 'index.php',
'activeUserId' => $uid));
if (
$ret)
{
if (
$ret->getErrorCode() & ERROR_MISSING_OBJECT)
{
// Check if there's no G2 user mapped to the activeUserId
$ret GalleryEmbed::isExternalIdMapped($uid'GalleryUser');
if (
$ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT))
{
// User not mapped, create G2 user now
// Get Arguments for the new user:
$args['fullname'] = $vbulletin->userinfo['username'];
$args['username'] = $vbulletin->userinfo['username'];
$args['hashedpassword'] = $vbulletin->userinfo['password'];
$args['hashmethod'] = 'md5';
$args['email'] = $vbulletin->userinfo['email'];
$args['language'] = $vbulletin->userinfo['lang_code'];
$args['creationtimestamp'] = $vbulletin->userinfo['joindate'];

$retcreate GalleryEmbed :: createUser($uid$args);
if (
$retcreate)
{
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) {
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 #######################
// #######################################################################

eval('print_output("' fetch_template('gallery2') . '");');

?>
(or download the attached gallery2.php)

Step 3:
Find and edit the following code to suit your site setup:
PHP Code:
 require_once('/home/paranorm/public_html/gallery2/embed.php'); 
and
PHP Code:
 $ret GalleryEmbed::init(array('embedUri' => '/gallery2.php',
'g2Uri' => 'http://www.yoursite.com/gallery2/',
'loginRedirect' => 'index.php'
Save and upload the file to your root vBulletin directory.

Step 4:
Create a new template in your style manager called gallery2 containing the following:
HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>$headinclude
  $data[headHtml]
</head>
<body>
$header
$navbar
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
  <tr>
    <td class="tcat">Gallery</td>
  </tr>
  <tr>
    <td class="alt1">$data[bodyHtml]</td>
  </tr>
</table>
$footer
</body>
</html>
And that's basically it! Your gallery should now be accessable via www.yoursite.com/gallery2.php or www.yoursite.com/forums/gallery2.php (depending on how you have it set up).

You can achieve further integration by using johnmont's plugins which will:
  1. Delete users from the Gallery when you delete them from the vBulletin control panel.
  2. Update user information in the gallery when they change their information in the User CP.
John has given me permission to post them The attached gallery-plugins.xml file will create two new plugins called Delete Gallery User and Update Gallery User. You'll need to edit both of these plugins after installation and change
PHP Code:
require_once('/home/paranorm/public_html/gallery2/embed.php''); 
(it's the very first line in both of them) to match your site setup.

Hopefully this tutorial sparks a little more interest in this area and we can get some additional people contributing solutions to achieve tighter integration :banana:

As the integration progresses, I'll update this thread to keep everything together and accessable.

Enjoy!
Attached Files
File Type: php gallery2.php (5.5 KB, 751 views)
File Type: xml gallery-plugins.xml (1.8 KB, 722 views)
Reply With Quote
  #212  
Old 12-29-2006, 07:37 PM
SilVert SilVert is offline
 
Join Date: Oct 2003
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by scan-pa View Post
Do you have your vB 3.6.4 usergroup permisions set in the gallery2.php file?
It should go after this line (aprox line 76)
'activeUserId' => $uid));

Add this line after:
----------------------------------------
if ($vbulletin->userinfo[usergroupid] == 5 or $vbulletin->userinfo[usergroupid] == 6 or $vbulletin->userinfo[usergroupid] == 7 or $vbulletin->userinfo[usergroupid] == 39 or $vbulletin->userinfo[usergroupid] == 43)
{
----------------------------------------

Change the number after the == to whatever vB usergroups ID# you want to allow Album & photo posting access to.

and add a } after this line of the 2nd. else statement to make 3 }

ex:
Should look like this (aprox line to add in area of line 123:

if ($ret) {
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;
}
}
} //<----- Add this } //

-------------------------------------------

With the owner admin account on gallery 2 be sure edit your guest, regestered user permisions for the main gallery page.


hope that helps.
this guy has the right idea! that code that you are talking about is the code that i contributed... i did not create the thread so i have no editing power over it

side note: a few weeks ago i edited Gallery2's site to point to MY gallery integration so that people know this project is still alive just to make you all aware


Quote:
Originally Posted by reverse1312 View Post
Hello All,

my question :

Would it be possible

- to have Gallery on one server and vB on another (to save bandwidth on the vB server ) and though just 1 login system ?

or

- to have Gallery and vB on the same server (which would share the same registration process) and store all the media files on another server ?

By other server I mean another domain

Thanks
i dont see why not, gallery and VBB on separate servers is probably do able as well as gallery and VBB on the same server, btu the image store on another server is easyer to do IMO...

gallery and VBB on another server: i think woudl be more complicated. you would have to point the integration script to the other server, im not sure how happy VBB/Gallery would be with this, but i dont see why it would not work

VBB and Gallery on the same, images on another: this is the easyer of the two to do(i think). when you install gallery just point the image store directory to the other server(or however your prefered method would be) and then go forth like normal. depending how gallery acts with this all woudl be fine. this question would be better directed at Gallery2.org though... they know the software much better than I. i can only guess as of to how it works




Quote:
Originally Posted by rjdpa View Post
I'm getting this error when trying to add a user in the VB Admin Control Panel after installing the plugins. I modified the paths and followed all of the directions...

User Manager

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/rjmdiam/public_html/olfaithful/forums/includes/class_dm_user.php(1657) : eval()'d code on line 10
i have never used the plugin and had it working. but all i can recommend is that you tripple check the paths and the variables they want.. aka absolute path and... the other path, whatever its name is
Reply With Quote
  #213  
Old 12-30-2006, 06:22 PM
Codeman05 Codeman05 is offline
 
Join Date: Oct 2002
Location: Tx
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a very strange problem. If you guys could help out that would be great.

So far this plugin has been working great. However, I recently noticed that Page 10 of the main album index does not work...everything else is fine.

If you go to page 10, here is the error you get
Quote:
Error (ERROR_MISSING_OBJECT) : Missing object for 4871

* in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 1852 (GalleryCoreApi::error)
* in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 109 (GalleryStorageExtras::_identifyEntities)
* in modules/core/classes/GalleryStorage.class at line 293 (GalleryStorageExtras::loadEntities)
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 82 (GalleryStorage::loadEntities)
* in modules/core/classes/GalleryCoreApi.class at line 2382 (GalleryEntityHelper_simple::loadEntitiesById)
* in modules/core/classes/GalleryTheme.class at line 1243 (GalleryCoreApi::loadEntitiesById)
* in themes/classic/theme.inc at line 118 (GalleryTheme::loadCommonTemplateData)
* in modules/core/classes/GalleryTheme.class at line 916 (ClassicTheme::showAlbumPage)
* in modules/core/classes/GalleryView.class at line 325 (GalleryTheme::loadTemplate)
* in main.php at line 386 (GalleryView::doLoadTemplate)
* in main.php at line 87
* in modules/core/classes/GalleryEmbed.class at line 192
* in /data/www/jeeps-offroad.com/www/image-hosting.php at line 124 (GalleryEmbed::handleRequest)
* in /data/www/site.com/www/image-hosting.php at line 50
* in /data/www/site.com/www/vbseo.php at line 846
* in /data/www/site.com/www/vbseo.php at line 3
I'm not sure what is causing this, and why it is only this one page that is effected. Any ideas?
Reply With Quote
  #214  
Old 01-04-2007, 01:50 PM
RobParker RobParker is offline
 
Join Date: Nov 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm having a bit of a strange problem and I was hoping someone could help.

Using this embedded in the latest VB.

The front page of the gallery works fine but when I go into an album to actually look at what's in it it seems to come out of embedded mode and is displayed full screen. It now no longer appears embedded despite the URL still being something like gallery2.php?g2_itemId=206.
Reply With Quote
  #215  
Old 01-10-2007, 08:28 PM
TheHeartSmasher TheHeartSmasher is offline
 
Join Date: Feb 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where are the demos, screenshots, etc. for this from the author in the main post.
Reply With Quote
  #216  
Old 01-25-2007, 02:14 PM
SilVert SilVert is offline
 
Join Date: Oct 2003
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Codeman05 View Post
I have a very strange problem. If you guys could help out that would be great.

So far this plugin has been working great. However, I recently noticed that Page 10 of the main album index does not work...everything else is fine.

If you go to page 10, here is the error you get


I'm not sure what is causing this, and why it is only this one page that is effected. Any ideas?
did you move or modify and of the gallery files? the embed script requires no manipulation of files other than the integration script.... and twekaing yoru gallery itself


Quote:
Originally Posted by RobParker View Post
I'm having a bit of a strange problem and I was hoping someone could help.

Using this embedded in the latest VB.

The front page of the gallery works fine but when I go into an album to actually look at what's in it it seems to come out of embedded mode and is displayed full screen. It now no longer appears embedded despite the URL still being something like gallery2.php?g2_itemId=206.
im not sure, but it seems like the URL Rewrite might be messing things up? have you looked into that?

Quote:
Originally Posted by TheHeartSmasher View Post
Where are the demos, screenshots, etc. for this from the author in the main post.
i am not the author, just a guy who supports it...
http://www.RacersDen.net/forum/gallery.php is my gallery... thats about the best i got for you...
Reply With Quote
  #217  
Old 02-04-2007, 06:05 AM
OpalCat's Avatar
OpalCat OpalCat is offline
 
Join Date: Mar 2002
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Pardon me for sounding like an idiot, but I'm about frothing at the mouth in frustration after spending over an hour on this, and searching here and at the Gallery site does NO good because it gets way too many search results, exactly zero of which have anything to do with answering my question. Namely: What the holy heck am I supposed to actually DO with the "gallery-plugins.xml" file? Keep in mind that this is also my first real attempt to use Gallery2 (been too happy with Gallery1 on my other sites for all these years) so if this is some incredibly well known process in G2, I don't know it because I haven't used G2 before.

I'll be over here in the corner whimpering and twitching, awaiting some kind soul's response --->

I am adding this gallery as part of upgrading vbulletin, and so this is all on a test server at the moment. Anyway, I have the thing installed and quasi-functional, but as soon as you click on an album, you are whisked out of the embedded environment. Why?

http://test.fathom.org/forums/gallery2.php
Reply With Quote
  #218  
Old 02-21-2007, 09:24 AM
All_Starzes All_Starzes is offline
 
Join Date: Jan 2007
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a big Problem.
I have install the vb Version 3.6.4 and Gallery 2.1

When i logged in as M?cke it gives the follow problem...

Code:
line: 98, Failed to create G2 user with extId [2152]. Here is the error message from G2:
Error (ERROR_STORAGE_FAILURE)

    * in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 317 (GalleryCoreApi::error)
    * in modules/core/classes/GalleryStorage.class at line 304 (GalleryStorageExtras::saveEntity)
    * in modules/core/classes/GalleryEntity.class at line 317 (GalleryStorage::saveEntity)
    * in modules/core/classes/GalleryUser.class at line 212 (GalleryEntity::save)
    * in modules/core/classes/GalleryEmbed.class at line 365 (GalleryUser::save)
    * in /var/www/web0/html/ni/gallery2.php at line 95 (GalleryEmbed::createUser)
    * in /var/www/web0/html/ni/gallery2.php at line 50
I think that is the collation.... the gallery works on utf8 and my board in ISO...
i dont know really...
I hope some people can help me!!!!
Reply With Quote
  #219  
Old 02-22-2007, 09:53 PM
cgray24 cgray24 is offline
 
Join Date: Dec 2004
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey guys,

Thanks for all the Great work and help here! I was able to install the embed and everything thing works.

The problem im having now is the same as others and the Gallery Remote doesnt connect with anything other than the admin account (the one im assuming was already in Gallery to begin with)

No other user, admin privileges or not, can get it to connect. It gives error

"Invalid username/password.

If your Gallery is embedded inside a CMS like PostNuke, you need to use the "native" (non-embedded) Gallery URL to log in, as well as the native Gallery user and password. You can test these by trying to go the native URL and trying to log in.
"

Since the users getting the error get it on the same URL that the admin user/pass works, im assuming this problem is because of the way vb has set the passwords or something in gallery.

My folder stucture is
www/forum/
www/forum/gallery

Im hoping someone smarter than me here has figured this out? Remote is a great desire for our needs, any help would be appreciated.
Reply With Quote
  #220  
Old 03-01-2007, 06:43 PM
Moon! Moon! is offline
 
Join Date: Feb 2007
Location: Out of this world
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much for putting this together, I am very pleased with the end results and how easy it was me to do.
Reply With Quote
  #221  
Old 03-05-2007, 12:15 PM
cthree cthree is offline
 
Join Date: Nov 2002
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is a bug in the first post, Step 2:

$uid = $vbulletin->userinfo['userid'] = 0 ? '' : $vbulletin->userinfo['userid'];

should be:

$uid = $vbulletin->userinfo['userid'] == 0 ? '' : $vbulletin->userinfo['userid'];
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09357 seconds
  • Memory Usage 2,410KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)bbcode_html
  • (4)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete