The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
MySql question - add "static" value to query_first
I'm creating a script which utilizes attachment.php to generate thumbnails for images in the attachment table. The problem is however that the attachments aren't associated with any thread, forum. They are easily identified though by having a postid of '4294967295'.
Now, if any attachment hasn't been moderated, attachment.php won't display the image because the script can't determine if the user has permission to view/moderate the attachment (due to following code in attachment.php): PHP Code:
The results for the query to get $attachmentinfo within attachment.php are shown in query.gif below. As you can see, $attachmentinfo['visible'] = '0' (image isn't yet moderated) and $attachmentinfo['forumid'] is empty (there's no associated forumid), therefore we get the error... There are however the hooks within the query for getting $attachmentinfo: [SQL] SELECT filename, attachment.postid, attachment.userid, attachmentid, " . ((!empty($vbulletin->GPC['thumb']) ? 'attachment.thumbnail AS filedata, thumbnail_dateline AS dateline, thumbnail_filesize AS filesize,' : 'attachment.dateline, SUBSTRING(filedata, 1, 2097152) AS filedata, filesize,')) . " attachment.visible, mimetype, thread.forumid, thread.threadid, thread.postuserid, post.visible AS post_visible, thread.visible AS thread_visible $hook_query_fields FROM " . TABLE_PREFIX . "attachment AS attachment LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype ON (attachmenttype.extension = attachment.extension) LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid) LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid) $hook_query_joins WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . " $hook_query_where [/SQL] Is it possible somehow to put a conditional into the query which assigns a specific forumid in the event that the attachment's postid = '4294967295'? Unfortunately there's no hook location after the query, only before ( attachment_start ) which leaves me to somehow utilize $hook_query_fields or $hook_query_joins or $hook_query_where. Any ideas??? |
#2
|
||||
|
||||
It might be easier to just have a separate script generate the thumbnails.
|
#3
|
||||
|
||||
I was thinking of that, just duplicating the attachment.php script and then modifying the query using COALESCE but I was hoping to avoid that
|
#4
|
||||
|
||||
You wouldn't have to duplicate attachment.php if all you want to do is create thumbnails. I could be a lot shorter (20-40 lines of code).
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|