View Single Post
  #1430  
Old 06-29-2008, 01:39 AM
jdelasko's Avatar
jdelasko jdelasko is offline
 
Join Date: Jan 2007
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm posting the complet code for the block below just in case someone here can figure out how to make this work with a seperate photopost database. Hope you zoints guys don't mind, but this is my only hope of getting this working. I don't know enough about mysql to do it myself.

I'm also running Photopost 6.1, so this block probably hase more problems than just the database issue

===================Block code below =========================================



# photopost album
# 1.0.2
# mtgmaster (themtgmaster@gmail.com)
# http://lol.zoints.com/
#
# Displays a members photos
class user_photopost_album extends z_module
{
# Set the maximum amount of images any users are allowed to display
var $max_images = 7;
# Set your photopost db table prefix here
var $pp_prefix = 'pp_';
# Set your full url to the photopost directory, with no trailing slash
var $pp_dir = 'http://www.majorleaguetalk.com/photopost';
# Set categories you don't want to be displayed, separated with commas eg. '2,500,501'
var $dis_cats = '';

function contents()
{
$content = $this->content;
$vbulletin = $this->_zoints->external->vbulletin;
$userinfo = $this->_zoints->external->load_user($this->zuser);

# If limit hasnt been set or is over the admin set maximum, set it to the admin max
if(empty($content['max_pics']) OR $content['max_pics'] > $this->max_images)
{
$limit_sql = 'LIMIT ' . $this->max_images;
}
# Otherwise, let them set it
else
{
$limit_sql = 'LIMIT ' . $content['max_pics'];
}

# Generate the sql to get rid of some cateories
if(!empty($this->dis_cats))
{
$categories = explode(',', $this->dis_cats);
if(is_array($categories))
{
foreach($categories as $cat)
{
$cat_sql .= 'AND cat<>' . $cat . ' ';
}
}
else
{
$cat_sql = ' AND cat<>' . $this->dis_cats . ' ';
}
}

# Get all photos the user has
$sql = "
SELECT * FROM " . $this->pp_prefix . "photos
WHERE userid=" . $this->zuser . "
AND approved=1
" . $cat_sql . "
ORDER BY date DESC
" . $limit_sql . "
";
$getphotos = $vbulletin->db->query_read($sql);
$html .= '<div class="' . $this->style['pmain1'] . '" style="padding: 0;">';

# Does the user have any photos?
if ($vbulletin->db->num_rows($getphotos))
{
# Display the top of the table
$html .= '<table border="0" width="100%">
<tr>
<td width="100" align="center" class="phead">
Image
</td>';
# Display the details?
if(!$content['details'])
{
$html .= ' <td class="phead">
Details
</td>';
}
$html .= ' </tr>';

# loop and display all that have been fetched from the DB
while($photo = $vbulletin->db->fetch_array($getphotos))
{
# Display image cell
$html .= '
<tr>
<td width="100" align="center" class="' . $this->style['pmain1'] . '">
<a href="' . $this->pp_dir . '/showphoto.php?photo=' . $photo['id'] . '">
<img src="' . $this->pp_dir . '/data/' . $photo['cat'] . '/thumbs/' . $photo['bigimage'] . '" />
</a>
</td>';
# Display the image details?
if(!$content['details'])
{
$html .= '
<td class="' . $this->style['pmain1'] . '" valign="top" style="font-size: 80%;">';
# photo name
$html .= '<div><a href="' . $this->pp_dir . '/showphoto.php?photo=' . $photo['id'] . '">' . htmlspecialchars($photo['title']) . '</a></div>';
# File size in KB
$html .= '<div>Filesize: ' . number_format($photo['filesize'] / 1024, 2) . ' KB</div>';
# Date uploaded
$html .= '<div>Date: ' . $this->_zoints->external->date($photo['date'], $this->_zoints->external->get_date_format()) . '</div>';
# Dimensions
$html .= '<div>Dimensions: ' . $photo['width'] . 'x' . $photo['height'] . '</div>';
# Views
$html .= '<div>Views: ' . $photo['views'] . '</div>';
# Rating
$html .= '<div>Rating: ' . $photo['rating'] . '</div>';
$html .= ' </td>';
}
$html .= '</tr>';
}
$html .= '</table>';
$html .= '<div class="' . $this->style['pmain1'] . '" style="text-align: center;">
<a href="' . $this->pp_dir . '/showgallery.php?cat=500&ppuser=' . $this->zuser . '">View all of ' . $userinfo['username'] . '\'s photos</a>
</div>';
}
# Nope, tell them they have none
else
{
$html .= '<div class="' . $this->style['pmain1'] . '" style="text-align: center;">' . $userinfo['username'] . ' doesn\'t have any photos</div>';
}
if($this->powner)
{
$html .= '<div class="' . $this->style['pmain1'] . '" style="text-align: center;">
<a href="' . $this->pp_dir . '/uploadphoto.php">Upload pictures</a>
</div>';
}
$vbulletin->db->free_result($getphotos);

$html .= '</div>';
return $html;
}

function update($content)
{
return $content;
}

function edit()
{
$content = $this->content;
if($content['max_pics'] AND $content['max_pics'] < $this->max_images)
{
$limit = htmlspecialchars($content['max_pics']);
}
else
{
$limit = $this->max_images;
}
$html .= '<div class="pmain1">';

# Disable description checkbox
$html .= 'Disable image details? ';
$html .= '<input type="checkbox" name="mod[content][details]" ' . ($content['details'] ? 'checked="checked"': '') . ' /> <br />';
# Max pictures textbox
$html .= 'Max pictures to display ';
$html .= '<input type="text" name="mod[content][max_pics]" value="' . $limit . '" size="5" /> ';
$html .= '<span style="font-size: 7pt; color: #848484;">(max ' . $this->max_images . ' allowed)</span> ';

$html .= '</div>';

return $html;
}
}
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01307 seconds
  • Memory Usage 1,791KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete