MyBB Hacks

Full Version: XThreads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(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
(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.
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?
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.
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
Hi there, back again with these downloads stats of mine. I have edited the xthreads_attach.php with the below code:

PHP Code:
// 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?

(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"
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.
(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 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?
Reference URL's