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: 2307)

- 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,337
MyBB Compatibility: 1.4.x, 1.6.x, 1.8.x
Plugin License: GPLv3
Uploader: ZiNgA BuRgA
PK8 Offline
Junior Member
**
Posts: 13
Joined: Oct 2010
Post: #191
RE: XThreads
(01-17-2011 06:19 PM)ZiNgA BuRgA Wrote:  
(01-17-2011 03:14 PM)PK8 Wrote:  - Having a "Sortable" setting for thread fields and letting users sort threads by said thread field if the admin sets them to sortable.
It's in the development version now.  Admins don't have an option though - it's always enabled.
Ahh. Awesome. Smile

(01-17-2011 06:19 PM)ZiNgA BuRgA Wrote:  
(01-17-2011 03:14 PM)PK8 Wrote:  - I know there's filter options for user ids, post icon ids, mybb prefixes and last poster user ids but thoughts on adding sorting options for those?
MyBB has a sort by author.  I'm not sure exactly how to sort by the others though...
- post icon - simply sort by the ID or by the alternative text (you said ID - any particular reason for this?)
- prefixes - sort by ID or displayed text?
- lastposter will probably be by name rather than ID to be in line with MyBB's sort by author
No reason for the post icon IDs. I wasn't thinking about alt text at all when I was posting this. XD But yeah, sorting by alt text would work better.
- Prefixes: Displayed text.
- lastposter: Ah, alright. Smile

(01-17-2011 06:19 PM)ZiNgA BuRgA Wrote:  
(01-17-2011 03:14 PM)PK8 Wrote:  - Next newest/next oldest thread links which searches for a thread tagged with a certain thread field. Maybe the admins could customize how the next oldest/newest thread links could behave through showthread template editing.
I'll have to think of a system of how to make that work.
Do you have any suggestions on a more solid implementation?
I'm pretty awful at explaining myself so bear with me.

I was thinking the admins could customize the behavior of the next newest/next oldest links just like how they could customize the forumdisplays (particularly the thread bits). The admin could add whatever GET variables (s)he can to the next newest/next oldest links, and when clicked, the link would try to find the next thread that matches the variables and whatnot.

The easiest example I can think of for this would have to be User IDs. That would be perfect for forums which behaves like blogs, reviews and galleries. The URL could look a little something like this:
http://mybbhacks.zingaburga.com/showthread.php?tid=288&action=nextoldest&filterxt_uid=1
Thread ID
newest/oldest
Some XThread Filters. Perhaps the filtering there could be similar to that of the filtering in the forumdisplay pages.

Edit: That URL could try to find an older thread within the forum made by User ID 1.

(01-17-2011 06:19 PM)ZiNgA BuRgA Wrote:  
(01-17-2011 03:14 PM)PK8 Wrote:  - Turning XThread field input rows, checkboxes, select menus, options, radio buttons, textboxes and other input options into templates the admin can customize.
I had that idea too.  Just need to think of the best way to do it though.
Unfortunately, it could turn a little messy with templates...
Ah, got it. Ooh, wait a sec, how about letting just the input thread field row be customizable? Yeah? No? Edit (1/17/11, 1:51pm est): I didn't know that was already customizable. Sorry about that. -_-


Edit (1/17/11 1:41 est)
(01-18-2011 01:53 AM)RateU Wrote:  @ PK8: Just as information, maybe you can look at this topic:
http://mybbhacks.zingaburga.com/showthread.php?tid=635
There are some feature ideas by Yumi/ZiNgA BuRgA in that thread Smile

For the Sortable: Yeah, Yumi/ZiNgA BuRgA already added that feature for the next version. Even we can set it as default sort by.
Ahh. Checking that thread out now. Thanks, RateU. Biggrin
(This post was last modified: 01-21-2011 07:14 AM by PK8.)
01-18-2011 04:33 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #192
RE: XThreads
(01-18-2011 04:33 AM)PK8 Wrote:  Ah, got it. Ooh, wait a sec, how about letting just the input thread field row be customizable? Yeah? No?

Well, we can already do that a bit. Instead of inputting

{$tfinputrow['key']}

You input

{$tfinput['key']}

That way you just get the field that you want to build the template around.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 01-18-2011 04:43 AM by leefish.)
01-18-2011 04:42 AM
Visit this user's website Find all posts by this user Quote this message in a reply
clemens Offline
Junior Member
**
Posts: 5
Joined: Jan 2011
Post: #193
RE: XThreads
Wow, thanks for this great plugin for MyBB.

To further extend its reach, I'm trying to communicate from an external CMS with my forum through XThreads.

What is the best way to approach this through PHP? How can I update the threadfields of a thread of which I know the relevant IDs?

Is it easiest to do it through MySQL or is it better to do it via the API of XThreads?
(This post was last modified: 01-19-2011 06:24 AM by clemens.)
01-19-2011 06:22 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #194
RE: XThreads
There isn't really any XThreads APIs at the moment.
It depends on how you're already modifying threads.  If you're using the MyBB datahandler, it's best to go off that.
If you're just using SQL (and I presume some hacky workarounds to get the counters etc to work) then SQL is probably the easiest.

My Blog
01-19-2011 07:42 AM
Find all posts by this user Quote this message in a reply
clemens Offline
Junior Member
**
Posts: 5
Joined: Jan 2011
Post: #195
RE: XThreads
Thanks Zinga! I'll be doing a MySQL approach then, wasn't sure about the API. Would be an even awesommer addition to Xthread though Smile
01-19-2011 09:08 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #196
RE: XThreads
Hi there, back again with these downloads stats of mine. I have edited the xthreads_attach.php with the below code:

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
// connect to DB
	define('TABLE_PREFIX', $config['database']['table_prefix']);
	$db->connect($config['database']);
	$db->set_table_prefix(TABLE_PREFIX);
	$db->type = $config['database']['type'];
	$result = mysql_query("SELECT aid, tid , uid FROM mybb_xtattachments WHERE aid=".$aid);
	$attachment = mysql_fetch_assoc($result);
	$threadid = $attachment['tid'];
	$postuserid = $attachment['uid'];	
	$attach = $attachment['aid'];
	$timestamp = date("Ymd");
	// so we do all the above just to run an update query :P

	$sql = "UPDATE mybb_aggrdownloads SET counter = counter + 1 WHERE itemid=".$threadid." AND userid=".$postuserid." AND dateline=".$timestamp." AND type=".$attach;
	if ($_GET['debug'] == "1") { echo $sql."<br />"; }
	$result = mysql_query(mysql_real_escape_string($sql));
	if ($_GET['debug'] == "1") { var_dump($result)."<br />"; echo mysql_affected_rows($link)."<br />"; echo mysql_info($link); }
	if (mysql_affected_rows($link) == NULL || mysql_affected_rows($link) == false || mysql_affected_rows($link) == 0) {
        $sql = "INSERT INTO mybb_aggrdownloads (`itemid`, `userid`, `type`, `dateline`, `counter`) VALUES (".$threadid.", ".$postuserid.", ".$attach.", ".$timestamp.", 1)";
        if ($_GET['debug'] == "1") { echo $sql."<br />"; }
         mysql_query($sql);
	$db->write_query('UPDATE '.$db->table_prefix.'xtattachments SET downloads=downloads+1 WHERE aid='.intval($aid), 1);
	$db->close();
	unset($db, $GLOBALS['mybb']);
}


Its writing the data to a table (aggrdownloads) created via a plugin. However, as the query stands, its adding ALL the downloads of ALL the .aids. Unfortunately, this means it's counting views of the pictures which is not really of interest to me in this situation (I want to count the downloaded files - rar and zip). I tried filtering out the picture fields but that meant I ended up with all the picture fields turning into just text links.

At the moment I am doing a workaround where I query the data created above with a left join to the threadfields data table. It seems a pity to have to query a table I have created because the data is not specific enough, its extra workload on the DB for nothing.

Can you suggest how I can modify this query above so that I only get those fields that are my file uploads, but still have the pictures show on the forum?



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 01-19-2011 09:24 AM by leefish.)
01-19-2011 09:21 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #197
RE: XThreads
(01-19-2011 09:08 AM)clemens Wrote:  Thanks Zinga! I'll be doing a MySQL approach then, wasn't sure about the API. Would be an even awesommer addition to Xthread though Smile
Well, you're not even using the MyBB API, so...
As for SQL, you just modify the mybb_threadfields_data table.

@leefish I don't exactly understand what you mean.  What do you mean "its adding ALL the downloads of ALL the .aids"

My Blog
01-19-2011 06:48 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #198
RE: XThreads
Sorry to be unclear - say I have a thread with four attachments (aids). Three of those are pictures of the item, and one is a downloadable file (zip or rar). I want to JUST get the count of the downloadable file, rather than the count of all aids. When I tried to further refine that query it broke it. To be more precise, when I added the requirement that the aids I pulled via the above query had to have no thumbnail text (which is only true of non-picture attachments) then ALL the xthreads thumbnails (existing ones too) on the forum no longer showed the image, just the url.

The query is working (it gets the count, it updates the data based on date and thread, and all that good stuff) but it's inefficient in as much that for every downloadable file I have about 4 pictures. This means at most I only need about 20% of the data I am happily stuffing into this table in my db.

What I am hoping is that you can help me to exclude all the pictures from this query so that the database table (aggrdownloads) only has download data from the downloadable files, not pictures.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 01-19-2011 10:21 PM by leefish.)
01-19-2011 07:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
clemens Offline
Junior Member
**
Posts: 5
Joined: Jan 2011
Post: #199
RE: XThreads
(01-17-2011 06:19 PM)ZiNgA BuRgA Wrote:  Thanks for the ideas PK8 Smile

(01-17-2011 03:14 PM)PK8 Wrote:  - Having a "Sortable" setting for thread fields and letting users sort threads by said thread field if the admin sets them to sortable.
It's in the development version now.  Admins don't have an option though - it's always enabled.

(01-17-2011 03:14 PM)PK8 Wrote:  - I know there's filter options for user ids, post icon ids, mybb prefixes and last poster user ids but thoughts on adding sorting options for those?
MyBB has a sort by author.  I'm not sure exactly how to sort by the others though...
- post icon - simply sort by the ID or by the alternative text (you said ID - any particular reason for this?)
- prefixes - sort by ID or displayed text?
- lastposter will probably be by name rather than ID to be in line with MyBB's sort by author

(01-17-2011 03:14 PM)PK8 Wrote:  - Next newest/next oldest thread links which searches for a thread tagged with a certain thread field. Maybe the admins could customize how the next oldest/newest thread links could behave through showthread template editing.
I'll have to think of a system of how to make that work.
Do you have any suggestions on a more solid implementation?

(01-17-2011 03:14 PM)PK8 Wrote:  - Turning XThread field input rows, checkboxes, select menus, options, radio buttons, textboxes and other input options into templates the admin can customize.
I had that idea too.  Just need to think of the best way to do it though.
Unfortunately, it could turn a little messy with templates...
+1 on the sorting options. That would be close to a dream come true!

Will we be able to write our own sorting implementation? Or will you just cover the mainstream of sorting classes?

When is the development due for release? Biggrin hehe
01-19-2011 10:13 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #200
RE: XThreads
(01-19-2011 07:13 PM)leefish Wrote:  I want to JUST get the count of the downloadable file, rather than the count of all aids. When I tried to further refine that query it broke it.
Add a "where field='my_download'" to the query?

(01-19-2011 07:13 PM)leefish Wrote:  To be more precise, when I added the requirement that the aids I pulled via the above query had to have no thumbnail text (which is only true of non-picture attachments) then ALL the xthreads thumbnails (existing ones too) on the forum no longer showed the image, just the url.
I can't see how a select query or an update query on an unrelated table would modify XThreads behaviour...
What are you modifying exactly?

(01-19-2011 10:13 PM)clemens Wrote:  Will we be able to write our own sorting implementation? Or will you just cover the mainstream of sorting classes?
And how would one write their own sorting implementation?

My Blog
01-20-2011 08:38 PM
Find all posts by this user Quote this message in a reply


Forum Jump: