XThreads
Author Message
My Spiel
XThreads is one of my larger plugins which I have been working on for a while.  Originally planned to release it inline with MyBB 1.6, but who knows when that'll be out.  It perhaps doesn't include everything I wanted it to, but does have most of the things (plus I want to move onto other projects).

What does it do?
Take a look at RateU's forum for some nice ideas of what it can do.  I also have some more basic examples here of what can be done with XThreads.  I'm pretty sure there are many other applications of this plugin, but those examples just give you some simple ideas.

The basic idea is giving you the ability to define custom fields for your threads, and providing methods to give you a lot of flexibility with customising forums.

Warning: I'm not going to bother with "beta" labels and so on.  I've done some testing on this myself, but it's by no means extensive.  Use this at your own risk.

Installation Instructions: standard installation procedures apply - you can find them in the announcement here.
You may need to CHMOD the uploads/xthreads_ul/ folder to 0777 after uploading the files (probably won't though).

Upgrade Instructions: unless stated otherwise, the general procedure for upgrades is to simply upload the new files, then visit your AdminCP.  In there, you'll be presented with a notice to run the upgrade - just follow what it says from there on.

Usage Instructions: this is a complex plugin, and unfortunately, you're probably going to have to figure this out yourself, depending on what you want to achieve with this plugin.  HTML and CSS knowledge is strongly recommended; you should also be familiar with MyBB's template system.  Some demonstrations can be found here - hopefully these will give you a good idea of how things work.  I suggest looking at the thread descriptions example, as this is fairly easy to understand (IMO).  If you can understand how everything works, there, perhaps try out the gallery example.

Known conflicting plugins
- MyPlaza Turbo -
If you are using MyPlaza Turbo, note that the author decided to use a particularly odd method to implement certain functionality, practically destroying compatibility with any plugin which hooks into the forum add/edit routines.  I've included a patch to address this issue - you need to replace inc/myplaza/myplaza_admin_plugin.php with the following file (it's unlikely that this will be committed as the author has decided to discontinue development)

.php  myplaza_admin_plugin.php (Size: 56.27 KB / Downloads: 2417)

- PL9 Forum Icons -
Affects certain functionality.  See here for a solution.

- PHP in Templates, v1.4 or older -
Similar to PL9 Forum Icons - solution is just to update to the latest version.

- MyAdvertisements - (update: older versions only, later versions may not conflict)
Affects some thread functionality, see here for a solution.

- Group Post CSS -
See here http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=378&pid=59

All bug reports, suggestions, criticisms are appreciated (though I may not always implement suggestions) so please feel free to post them.
If you find this plugin useful, I would be grateful if you could give some token of appreciation for the work that has gone into this, and perhaps post some example usages you've come up with in the XThreads forum to help others get an idea of what can be achieve with this plugin (and for my own interest's sake Tongue).


Github: https://github.com/zingaburga/XThreads-MyBB-Plugin
Note: do NOT use the Github version, unless you know what you're doing
Changelogs: v1.10, v1.20, v1.21, v1.22, v1.23, v1.24, v1.25, v1.26, v1.27, v1.30, v1.31, v1.32, v1.337, v1.40, v1.41, v1.42, v1.43, v1.44, v1.45, v1.46, v1.47, v1.50, v1.51, v1.52, v1.53, v1.60, v1.61, v1.62, v1.63, v1.64, v1.65, v1.66, v1.67, v1.68
(This post was last modified: 12-25-2015 12:46 PM by ZiNgA BuRgA.)
Find all posts by this user
Quote this message in a reply
Download: xthreads-1.68.7z (114.53 KB)
Plugin Version: 1.68
Last Updated: 12-25-2015, 12:46 PM

Downloads: 8,437
MyBB Compatibility: 1.4.x, 1.6.x, 1.8.x
Plugin License: GPLv3
Uploader: ZiNgA BuRgA
Pirata Nervo Offline
Member
***
Posts: 235
Joined: Jan 2008
Post: #341
RE: XThreads
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
(This post was last modified: 03-26-2011 03:26 AM by Pirata Nervo.)
03-26-2011 03:25 AM
Find all posts by this user Quote this message in a reply
Pirata Nervo Offline
Member
***
Posts: 235
Joined: Jan 2008
Post: #342
RE: XThreads
Got it working!

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
		$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.

(This post was last modified: 03-26-2011 04:27 AM by Pirata Nervo.)
03-26-2011 04:07 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #343
RE: XThreads
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)

My Blog
(This post was last modified: 03-26-2011 08:32 AM by ZiNgA BuRgA.)
03-26-2011 08:28 AM
Find all posts by this user Quote this message in a reply
Pirata Nervo Offline
Member
***
Posts: 235
Joined: Jan 2008
Post: #344
RE: XThreads
Oh that makes sense. Thanks once more
03-26-2011 08:44 AM
Find all posts by this user Quote this message in a reply
jim7777 Offline
Junior Member
**
Posts: 41
Joined: Nov 2010
Post: #345
RE: XThreads
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
03-31-2011 07:50 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #346
RE: XThreads
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.

My Blog
03-31-2011 08:44 PM
Find all posts by this user Quote this message in a reply
jim7777 Offline
Junior Member
**
Posts: 41
Joined: Nov 2010
Post: #347
RE: Y Strings
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
04-01-2011 08:04 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #348
RE: Y Strings
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-02-2011 07:36 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #349
RE: XThreads
(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.

My Blog
04-02-2011 11:46 AM
Find all posts by this user Quote this message in a reply
jim7777 Offline
Junior Member
**
Posts: 41
Joined: Nov 2010
Post: #350
RE: XThreads
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
04-02-2011 02:15 PM
Find all posts by this user Quote this message in a reply


Forum Jump: