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
  #182  
Old 10-10-2006, 06:23 PM
brvheart's Avatar
brvheart brvheart is offline
 
Join Date: Jul 2005
Posts: 477
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am having the issue of having created a user with the userid of 1 bumping with the one that VB has for me as an admin.

I am not clear on how to fix this even though I have been reading this thread all day

Could someone please give me a hand?
Reply With Quote
  #183  
Old 10-17-2006, 05:16 PM
SilVert SilVert is offline
 
Join Date: Oct 2003
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow, i go away for a month and i haev 500 questions

Quote:
Originally Posted by Codeman05
Still no luck, this is what I'm getting with the java upload...
"Upload error: Upload failed: 'user id: 5 doesn't have permission: core.addDataItem for item id: 22'."

Any suggestions?
can you post the code that you have inserted into the integration script? i will haev to look around in the code again to see if i can find the right code to pull..

Quote:
Originally Posted by GrandAmGuru
Ok, disregard my previous post. I have the gallery working fully outside the forum. When I view it from an embedded view, something is up with the style. I don't have all the navigation links like I do when I view outside the forum.

Check the screen caps below.


I known when I was monkeying around with it before it did this same thing, and I ended up completely removing and reinstalling. Could it possibly be a corrupted style or something?
the issue is realted to the URL REWRITE!!!! the rewrite does not play well with "embed mode". somebody said in this thread they had it working, but i haev yet to have it all working... remove all of the check boxes and add them in 1 by one... i only have 2 or 3 things workin with the rewrite....

Quote:
Originally Posted by fishhub
My installation completed and things work fine, except the link below user within VB once click on error comes out:->

You don't have permission to access /forum/gallery2/g2data/albums/xxxxx/ on this server.

Can any kind soul help? Thanks.
where is your path pointing?

give me this info:
webadress:
forum lacation:
gallery location:
where the integration file is:



Quote:
Originally Posted by xitrum
Hi all,

I follow instructions to install gallery2 on the same root folder as my forum and everything seems to work ok. I was able to upload and view images as standalone version:

http://<mydomain>/forum/gallery2/main.php

but when I switch to the embeded version:

http://<mydomain>/forum/gallery2.php

I don't see any thumbnails in my gallery? Any idea. TIA for you help.

-xitrum

PS. Gallery 2.1, VBB 3.6
im going to blame this one on the URL rewrite again.... try to uncheck everything, validate it all works, then check things one by one till they stop working...

right now, i bet that if you look at where the links point it is saying something like <site name> gallery/v/xxxx/xxxx. the key is that v. that is from the url rewrite. and the embed mode does not understand that very well...


Quote:
Originally Posted by Chet T16
Can anyone tell me what to remove from the gallery code posted so that it is a purely visual integration?
can you give me more detail on what you are looking for?

Quote:
Originally Posted by xitrum
================================================== ==
I found out that the path to images directory is not correct when using the
embeded gallery link. Images link shown:

http://<domainurl>/forum/images/galleryLogo_sm.gif

instead of:

http://<domainurl>/forum/gallery2/images/galleryLogo_sm.gif

where:

Forum installed at: http://<domainurl>/forum

Gallery2 installed at: http://<domainurl>/forum/gallery2

Can someone please shed some light on this issue? TIA.

-xitrum

i really hate to say this again.. but looks like URL rewrite... try disabling all of the rewrite and see if it works fine...
Reply With Quote
  #184  
Old 10-17-2006, 05:24 PM
GrandAmGuru's Avatar
GrandAmGuru GrandAmGuru is offline
 
Join Date: Jan 2002
Location: Cary, IL
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SilVert
the issue is realted to the URL REWRITE!!!! the rewrite does not play well with "embed mode". somebody said in this thread they had it working, but i haev yet to have it all working... remove all of the check boxes and add them in 1 by one... i only have 2 or 3 things workin with the rewrite....
I've gone and completely uninstalled the url rewrite module and the thumbnails work. As soon as I enable any portion of it. thumbs are gone. Either way it strips the navigation stuff and replaces it with basic text
Reply With Quote
  #185  
Old 10-17-2006, 05:32 PM
Chet T16 Chet T16 is offline
 
Join Date: Oct 2005
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SilVert

can you give me more detail on what you are looking for?
I'm using the gallery as a database for scans from magazines and newspapers etc so i only need 1 user to be able to upload and be admin, all of the other existing vB members only need access as a guest.

Since posting this question i have managed to get it working the way i wanted, even tho accounts are being created the users can't add or edit to the gallery. Originally i was importing users from phpBB and that was leading to admin conflicts etc
Reply With Quote
  #186  
Old 10-18-2006, 03:41 AM
xitrum's Avatar
xitrum xitrum is offline
 
Join Date: Feb 2004
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Silvert. I got my gallery working ok now. I think it's the path that's not correct. My only problem is that when the user access gallery2.php the first time. The embeded script create a user in the gallery2 database but the password isn't correct. Using the same password, user can't login to the standalone gallery. This is not a big deal since user can access the gallery after login to the forum.
Another note, is there a mod to display the most recent added albums or most view images, etc... I thought I saw it somewhere but couldn't find it. That would be a nice feature especially when you have a lot of nested albums.
Great mod and great work. Thanks a million.

-xitrum
Reply With Quote
  #187  
Old 10-18-2006, 12:18 PM
SilVert SilVert is offline
 
Join Date: Oct 2003
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chet T16
I'm using the gallery as a database for scans from magazines and newspapers etc so i only need 1 user to be able to upload and be admin, all of the other existing vB members only need access as a guest.

Since posting this question i have managed to get it working the way i wanted, even tho accounts are being created the users can't add or edit to the gallery. Originally i was importing users from phpBB and that was leading to admin conflicts etc
somewhere in this thread i put some code inplace that will only create user accounts if they are in X VBB group... if they are not in the group they will only view as guest

Quote:
Originally Posted by xitrum
Thanks Silvert. I got my gallery working ok now. I think it's the path that's not correct. My only problem is that when the user access gallery2.php the first time. The embeded script create a user in the gallery2 database but the password isn't correct. Using the same password, user can't login to the standalone gallery. This is not a big deal since user can access the gallery after login to the forum.
Another note, is there a mod to display the most recent added albums or most view images, etc... I thought I saw it somewhere but couldn't find it. That would be a nice feature especially when you have a lot of nested albums.
Great mod and great work. Thanks a million.

-xitrum
sure thing. sorry it took me so long to get back to you(been SLAMMED at work) if i even helped at all

the standalone password is explained somewhere. when VBB assignes the password it injevts "salt(<password>)" or something like that into the password. so it will work fine embed, but when you goto the standalone version, you would have to enter salt(insertpasswordhere). im 99% sure that is the right "frase" but i cant remember EXACLTY what it is. it has been documented somewhere. it might be in the gallery integration script for versions prior to 3.5(aka 3.0)

thereis somethign inside of gallery called ?imageblock? i think that allows you to view a random image etc. there is also a way to point to a gallery image or gallery via an external site. i have not messed with this at all, but i knwo it exists. now if it wil do the most recent images etc, i do not know. sorry, i dont have all the anwsers
Reply With Quote
  #188  
Old 10-20-2006, 04:08 AM
syclone13 syclone13 is offline
 
Join Date: Mar 2005
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just to jump in because I didn't see it noted elsewhere in the thread...

I installed everything and it is functioning just fine, images and all work, users are created in the gallery2 database, however the users dont seem to have any rights in gallery2. I can't figure out what group they are a part of in g2 as they dont seem to be listed as members of any of the groups that exist.

I have a barebones g2 install so I'm wondering if its some config options, some modules I didn't install or if I'm missing something.

The users viewing the embeded gallery get logged in as it shows their usernames in the view, but they just dont have access to upload or do anything beyond view the gallery.
Reply With Quote
  #189  
Old 10-20-2006, 03:03 PM
xitrum's Avatar
xitrum xitrum is offline
 
Join Date: Feb 2004
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe they are in "Registered User" group by default.
Reply With Quote
  #190  
Old 10-22-2006, 02:21 PM
Codeman05 Codeman05 is offline
 
Join Date: Oct 2002
Location: Tx
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SilVert
can you post the code that you have inserted into the integration script? i will haev to look around in the code again to see if i can find the right code to pull..
This what you want?

PHP Code:
require_once('/www/site/www/beta/embed.php');
$ret GalleryEmbed::init();

if (
$ret) {
//  echo $ret->getAsHtml();
}


// Set fullname based upon custom fields
$fullname=$this->existing['field13'] ." "$this->existing['field14'];


// Set the array for updating
$args['fullname']     =  $fullname 
$args['username']    = $this->existing['username']; 
$args['hashedpassword'] =   $this->existing['password']; 
$args['hashmethod'] =    'md5'
$args['email']       =   $this->existing['email']; 
$args['language']   =   $this->existing['lang_code']; 
$args['creationtimestamp']   =   $this->existing['joindate'];

//$this->existing['usergroupid'] 

// Get the userid
$uid $vbulletin->userinfo['userid'];

//$this->existing['userid']


$ret GalleryEmbed::isExternalIdMapped($uid,$args);

//Now if no user exists, we'll create one
//If user exists, we'll update existing user

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

 
$ret2 GalleryEmbed::createUser($uid,$args);

}else {

 
$ret2 GalleryEmbed::updateUser($uid,$args);

}


if (
$ret2) {

//  echo "ret2: ". $ret2->getAsHtml() ;

and this is the error I recieve using the java applet template:
Upload error: Upload failed: 'user id: 5 doesn't have permission: core.addDataItem for item id: 1007'.

I get the same error when trying to upload on 2 different user accounts

well, I don't know what I did, but it works now lol.

I do have another question though if anyone can help.

I have a couple of "premium usergroups" on our forum and I would like to be able to give them a larger quota in the gallery. Any suggestions on how to modify the creation/update scripts to get it to translate a forum groupID into the gallery group?
Reply With Quote
  #191  
Old 10-23-2006, 12:34 AM
Dimitrio Dimitrio is offline
 
Join Date: Aug 2006
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is not longer working or not working as intended.

When I am not logged as administrator, the page appears in blank. And when I am logged in as administrator, I get several errors.

Quote:
line: 98, Failed to create G2 user with extId [1]. Here is the error message from G2:
Error (ERROR_COLLISION)

* in modules/core/classes/GalleryUser.class at line 154 (gallerycoreapi::error)
* in modules/core/classes/GalleryEmbed.class at line 360 (galleryuser::create)
* in /home/veguild/public_html/forums/gallery2.php at line 95 (galleryembed::createuser)
* in /home/veguild/public_html/forums/gallery2.php at line 50
And yes installed the plugins, but they are not working.
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 07:54 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.04969 seconds
  • Memory Usage 2,426KB
  • 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_html
  • (5)bbcode_php
  • (12)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
  • (2)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