PDA

View Full Version : Integration with vBulletin - Add a link to a user's Photopost Gallery


iRO Wiki
01-31-2008, 10:00 PM
Edit: I no longer use photopost, so this mod is no longer supported!


After noticing a few people wanting a working version of this, I decided to release what I did to make it work! This is the first time I've done anything like this, go easy on me. ;)

This Mod helps "advertise" your PhotoPost gallery on your forums. It will allow you to place "View Gallery" links into the postbit_legacy, the dropdown menu when you click a user's name, and on your profile page. The postbit links will only appear when people actually have photos uploaded. The profile page will display the number of photos uploaded (you could put that on the postbit as well with some code changes).

This is similar to several different mods already out there, except this has been tweaked and confirmed to work on 3.6.8.

The Mod is made up of template changes and a cron script upload. The cron script is designed for the case of the VB and PP databases being seperate, but should work if they are in the same database, just edit the proper fields.

This mod also assumes you are not using search engine friendly URL's. If you are, you can edit the code to reflect it.


Before doing ANYTHING backup your database, I'm not responsible for data loss!

Step One

Using Execute SQL Query in the ACP, run the following as a manual query, making sure to adjust for your table prefix and rename the field if needed:

ALTER TABLE `vb_user` ADD `photos` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'


Step Two

Download the attached gallery.php and edit it to reflect your database details and table prefixes.

Step Three

Upload the edited gallery.php to your /includes/cron/ folder.

Step Four

Create a new scheduled task in your ACP:

Varname: gallery_check
Title: Gallery Check
Description: Updates the photo field in vb_users
Day of week: *
Day of month: *
Hour: *
Minute: 1 16 31 46 - -
Active: Yes
Log Entries: No
Filename: ./includes/cron/gallery.php
Product: vBulletin
vBulletin Default: No

Step Five

Add a new phrase:

Phrase Type: GLOBAL
Product: vBulletin
Varname: pp_gallery
Text: Gallery

Step Six

Template edits! First off, the profile page.

Edit MEMBERINFO and insert the following code wherever you would like it, AFTER editing the URL to match your site. I placed mine inbetween Posts and Referrals.

<fieldset class="fieldset">
<legend>$vbphrase[pp_gallery]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td>
Images: <strong>$post[photos]</strong><br> <a href="http://yoursitegoeshere.com/showgallery.php?cat=500&amp;ppuser=$post[userid]">View $userinfo[username]'s Gallery</a>
</td>
</tr>
</table>
</fieldset>

Edit postbit_legacy (not sure if the same code works or not in postbit).

This is the code for the dropdown menu:

<if condition="$post['photos']">
<tr><td class="vbmenu_option"><a href="http://yoursitegoeshere.com/showgallery.php?cat=500&ppuser=$post[userid]">View $post[username]'s Photo Gallery </a></td></tr>
</if>

This is the code for "View Gallery" link in the postbit_legacy:

<if condition="$post['photos']"><div><a href="http://yoursitegoeshere.com/showgallery.php?cat=500&amp;ppuser=$post[userid]">View Gallery</a></div><br></if>


After all that, you should be set.


Changelog:

.5 - First Release
.75 - Fixed issue with "logging" line and the cron not properly updating vb's user table when the user no longer had photos

Subah
02-01-2008, 02:32 AM
Thank you :)

dutchbb
02-01-2008, 02:55 AM
Thanks , very usefull mod/integration and working without problems :)

Prince
02-03-2008, 03:54 PM
thanks, nice work.

xcesiv
02-05-2008, 11:49 PM
sounds like a really good mod and would love to install it, but cant seem to work on the SWL query.

ALTER TABLE `vb_user` ADD `photos` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'

What part of this has to be changed

iRO Wiki
02-06-2008, 06:54 AM
What is the error you are getting? Also, what is the prefix for your vb tables?

dutchbb
02-13-2008, 03:17 PM
Hm it's not removing the icon when the user has removed all of his pictures in his gallery. The cron task is set correctly though.

Can you confirm/solve this issue?

Thank you

iRO Wiki
02-14-2008, 09:23 PM
I'll try testing that out!

MediaHound
02-17-2008, 11:11 PM
Awesome! The way I was doing it before would show the link regardless if the member had uploaded photos. Very smooth work here, kudos.

MediaHound
02-17-2008, 11:34 PM
OK so I ran the cron manually as I didn't want to wait for it.
I realized I needed to remove the vb_ table prefix you used.
Once I did that and I ran it, I got this error
Fatal error: Call to undefined function log_cron_action() in /home/mysite/public_html/includes/cron/gallery.php on line 44

MediaHound
02-17-2008, 11:40 PM
Anyway, it's working. I checked some threads and it's got the link for those with pics and no link for those without! Awesome, lets hope it holds up. I still wonder about that error but hey if it works and its not leaking memory or causing some other tax or strain, what do I care!
Good job, thanks for piecing this mod together!

dutchbb
02-18-2008, 05:42 AM
I'll try testing that out!
Thank-you

iRO Wiki
02-22-2008, 04:47 PM
Solved both issues! I simply commented out the "log cron action" line since we should have it set to not log anyway.

To fix the issue with it not updating properly once all of a user's photos have been deleted:


Find this line:


$link2 = mysql_connect ('localhost', 'VBmysqlusername', 'VBmysqlpassword') or die ('I cannot connect to the database. Forum');
mysql_select_db ("VBdatabasename") or die ('could not connect: ' .mysql_error());

NOTE: Your line will be different as you will have already edited in your account infos.

Move the entire line of code above this line:

while($row = mysql_fetch_array( $result ))



Then, between the $link2 and while lines, add this:

mysql_query("Update vb_user SET photos = '0';");



The final code should look like this:


$result = mysql_query("Select userid, user, Count(*) AS num FROM pp_photos Group BY userid;")
or die(mysql_error());

$link2 = mysql_connect ('localhost', 'VBmysqlusername', 'VBmysqlpassword') or die ('I cannot connect to the database. Forum');
mysql_select_db ("VBdatabasename") or die ('could not connect: ' .mysql_error());

mysql_query("Update vb_user SET photos = '0';");

while($row = mysql_fetch_array( $result ))


I have updated the attachment in the first post if you'd like to use that to compare instead.

Let me know if you have any questions or problems!

MediaHound
02-22-2008, 07:48 PM
Thanks, just did the fix manually and also commented out the last line so it now looks like this:

// log_cron_action("gallery task updated", $nextitem);

Regards

marin
03-29-2008, 02:50 PM
Thanks for this great MOD.
It works also on Vbulletin 3.7.0 RC1 + PhotoPost PHP Pro v6.02.

Just insted of MEMBERINFO i edited the MEMBERINFO_block_statistics and instead of postbit_legacy i added the code to postbit.

Regards, Marin

littleginsu
04-18-2008, 06:29 AM
I am not able to get the links to show up in the drop-down menu or in the user info found in the posts..? The link on the user info page shows up, but the postbit edits don't appear to be working for me.. any suggestions? Thanks!

Basit
04-18-2008, 09:56 AM
Installed and working without any problem

Link: http://www.hallagulla.com/urdu

Thanks

iRO Wiki
04-19-2008, 04:39 AM
I am not able to get the links to show up in the drop-down menu or in the user info found in the posts..? The link on the user info page shows up, but the postbit edits don't appear to be working for me.. any suggestions? Thanks!

Do you use postbit, or postbit_legacy?

littleginsu
04-26-2008, 05:24 AM
Did I use (or edit)? I tried both (one at a time) and neither produced a link :(

Do you use postbit, or postbit_legacy?

littleginsu
05-18-2008, 09:10 PM
Anyone has any advice why I cannot get the links to work correct?

iRO Wiki
06-09-2008, 06:43 PM
Yeah sorry, I had to forsake online life for RL the past month due to issues, I'll get to your issue asap!

htscpl
07-04-2008, 01:00 PM
Great mod but to get the link to work in the profile block I had to change the $post[userid] to $userinfo[userid]

<fieldset class="fieldset">
<legend>$vbphrase[pp_gallery]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td>
Images: <strong>$post[photos]</strong><br> <a href="http://yoursitegoeshere.com/showgallery.php?cat=500&amp;ppuser=$userinfo[userid]">View $userinfo[username]'s Gallery</a>
</td>
</tr>
</table>
</fieldset>

littleginsu
07-21-2008, 06:12 PM
I got it to work in the user's profile and the pop-up menu.. anyone know where the link needs to be added in order to show up in the user info which is in their replies (I am using vBulletin 3.7)

LoriW
10-11-2008, 09:58 PM
I believe I have this right but when I click the link to view the gallery I get a 404 error page -

The requested URL /showgallery.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

What could be causing this?