MyBB Hacks

Full Version: XThreads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Thanks zinga, it made things clearer now.

My problem is the thumbnails part (not getting the attachments), I cannot find how XThreads gets them. I know the last field in the table must be unserialized but what is the correct way to make an URL out of a thumbnail generated by XThreads?

Edit:
I believe I've just found it.

xthreads_get_xta_url(...) ? I'll try it in a minute Tongue
Got it working!

PHP Code:
		$xta_cache = array();
		$query = $db->simple_select('xtattachments', '*', 'tid IN ('.implode(',', $ts).')');
		while($xta = $db->fetch_array($query))
			$xta_cache[$xta['aid']] = $xta;
		
		$db->free_result($query);
	
		if (!empty($xta_cache))
		{
			// let's fake thumbnail info
			$ti = array();
			$ti['fileimgthumbs'] = array('90x90');
			
			foreach ($xta_cache as $a)
			{
				$a['url'] = xthreads_get_xta_url($a);
				
				if($a['thumbs'])
					$a['thumbs'] = unserialize($a['thumbs']);
				if(isset($a['thumbs']['orig']))
					$a['dims'] =& $a['thumbs']['orig'];
				xthreads_sanitize_disp_set_blankthumbs($a, $ti);
				
				$latest_looks .= "<tr><td><img src=\"{$a['url']}/thumb90x90\" width=\"{$a['thumbs']['90x90']['w']}\" height=\"{$a['thumbs']['90x90']['h']}\" /></td></tr>";
			}
		}
		else
			$latest_looks .= '<tr><td>'.$lang->lookssystem_no_looks.'</td></tr>';


Thanks for your help zinga.

Edit:
random question, why does this happen: when you set order_by to tid,dateline (when querying threads) and set an order_dir to desc, it queries in ascending order, if you remove dateline it will query by descending order as specified (no idea why this happens since dateline field has the correct values, bigger tids have bigger datelines).

The same happens to xattachments with uploadtime.

Query run by MyBB:

Code:
SELECT * FROM d1_xtattachments WHERE tid IN (9,8,5) ORDER BY tid,uploadtime DESC


I can confirm the same behaviour when running the query myself.

Quote:

Code:
ORDER BY tid,uploadtime DESC

That's order by tid (ASC by default), followed by uploadtime DESC.  So it will order by tid in ascending order if the two correlate with each other.
You probably want tid DESC, uploadtime DESC
(if you're wondering about MyBB's simple_select, you'll need to stick that in the order and not use the order_dir)
Oh that makes sense. Thanks once more
Can I ask if XThread can get the user who edited a specific thread field?
Like for example, a thread field can only be edited by moderators, I want to get what is the username of that moderator who edit that thread field and only an administrator or the same moderator can edit/delete that threadfield.. specifically, a text box / multi line textbox

just like this plugin:: http://mods.mybb.com/view/modnotice-1-3 but my problem is it applies to all forums

if it is ok, can you make it on the next version?? if there is no possible thing to do it
The last person to edit the post will be displayed as per what MyBB does by default.
It doesn't make sense to put it on a thread field level because editing the thread will be edit the thread fields.

Otherwise, it sounds like you're trying to impose some rather complicated permissions on who can edit the field, which XThreads won't support.
Unless I'm understanding you incorrectly as I cannot see the relationship with the ModNotice plugin.
first.. i freakinly read your post since its kinda out of this world.. but i get it now
[and on the second thought, its April fools]

hmm my suggestion somewhat relates to ModNotice because its really like what ModNotice will do, but inlined to XThread fields the only thing that is special is that it will get what is the username of the user who added that message and ofc, that message isn't editable by anyone except the admins and the one who edit that field. Other users in the usergroup who can edit the same field will not overwrite what the recent user posted but the new user who posted will just add his own message to the list..
this is somewhat related to uhmm, replying/commenting the specific post Biggrin but not to the thread itself
I would like to ask a question, Yumi:

Right now, I have more than 150 (I think - forgot the exact number) custom thread fields in the demo forum. Gladly, I don't have any problem at all. Sometimes I'm thinking about how many custom thread fields can be hold by MySQL? Or, what factors influencing the number custom thread fields can be created?
(04-01-2011 08:04 PM)jim7777 Wrote: [ -> ]hmm my suggestion somewhat relates to ModNotice because its really like what ModNotice will do, but inlined to XThread fields the only thing that is special is that it will get what is the username of the user who added that message and ofc, that message isn't editable by anyone except the admins and the one who edit that field. Other users in the usergroup who can edit the same field will not overwrite what the recent user posted but the new user who posted will just add his own message to the list..
this is somewhat related to uhmm, replying/commenting the specific post Biggrin but not to the thread itself
Okay, I took a look at the plugin.  The thing works because it's a completely different edit page (and effectively duplicates the "Last edited by" function).  XThreads integrates thread fields into the standard edit page so it doesn't make sense to do it in XThreads (and thus, cannot be done).
If you don't require a freeform field, you could use moderation tools to get moderators to set the field to a certain value (including their username).
Otherwise, if you really want to, you could set up a special "last edited by" field, only editable by moderators, and hide it on the edit/newthread page (using a <input type="hidden"> field instead).  This will "work" but be aware that info can be forged (but if you trust your moderators, they won't do this).

(04-02-2011 07:36 AM)RateU Wrote: [ -> ]Right now, I have more than 150 (I think - forgot the exact number) custom thread fields in the demo forum. Gladly, I don't have any problem at all. Sometimes I'm thinking about how many custom thread fields can be hold by MySQL? Or, what factors influencing the number custom thread fields can be created?
XThreads itself doesn't put any hard limits, but as you've realised, you could overflow the MySQL row length (which is about 64KB I believe), and the fact that all threadfields are stored in cache which gets loaded on every MyBB page load (so consumes more memory).  There may also be a slight slowdown as XThreads goes through filtering out thread fields that do not apply to the current forum, but I wouldn't consider this much of an issue.
For table row, XThreads will use:
  • varchar(255) for option button and non-multivalued select inputs
  • native data type if specified (eg int/float)
  • varchar(1024) for other inputs with filtering enabled
  • text for anything else
So clearly, the filtered textual fields will consume the most space.  So your primarily limit will probably be how many fields can be filtered on, though this can be increased if you either specify a non-textual datatype, or it's a option button/select input.

As for memory, 20 fields here use about 14.16KB according to what MyBB says about the datacache.  As this is serialised content, it probably consumes more in practice.  If we assume 1 field consumes 1KB in cache, then 150 will consume around 150KB, assuming only one instance of it is put in memory.  I'd say that's probably not a huge amount, especially considering the amount of code MyBB loads, though I'd probably say it's significant.  Maybe I'll have a think about whether that can be optimised a bit.
If you don't require a freeform field, you could use moderation tools to get moderators to set the field to a certain value (including their username).
Otherwise, if you really want to, you could set up a special "last edited by" field, only editable by moderators, and hide it on the edit/newthread page (using a <input type="hidden"> field instead).  This will "work" but be aware that info can be forged (but if you trust your moderators, they won't do this).

can you give some little samples of these 2 Biggrin esp the mod tools, i don't get it
Reference URL's