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

- 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,336
MyBB Compatibility: 1.4.x, 1.6.x, 1.8.x
Plugin License: GPLv3
Uploader: ZiNgA BuRgA
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #421
RE: XThreads
(05-12-2011 03:55 PM)ZiNgA BuRgA Wrote:  
(05-12-2011 01:18 PM)leefish Wrote:  Ok, thank you. I will have a go at that, see what I come up with. Will I still be able to use the filters like in the forum display or would that require more files to be included? If so, which ones?
You'd have to manually build the query at this point.  There's no convenient XThreads function to do the job from memory.

Example:

PHP Code:
1
2
3
4
5
6
7
$query_add = '';
if($mybb->input['filtertf_pfcat']) $query_add .= ' AND tfd.pfcat="'.$db->escape_string($mybb->input['filtertf_pfcat']).'"';

...

// modify the query on portal.php which grabs threads
$db->query('SELECT ... '.$query_add);


Hi again, I have been working on this off and on, and I do have an operating page as far as display goes. I used the 2nd portal with pagination and using the portal_announcements/paging modifications (as in this post) from the Global templates as I was unable to get an image to show building my own query :/

I have added the query add as suggested by Zinga - I am filtering on a custom field - called prefix so I changed the query add to look for "prefix" as so:

PHP Code:
$query_add = '';
if($mybb->input['filtertf_prefix']) $query_add .= ' AND tfd.prefix="'.$db->escape_string($mybb->input['filtertf_prefix']).'"';


The page runs fine and looks good, but when I attempt to filter I get this mysql error:

Code:
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND tfd.prefix="Sims2"' at line 7
Query:
 SELECT p.pid, p.message, p.tid, tfd.prefix FROM mybb_posts p LEFT JOIN mybb_threads t ON (t.tid=p.tid) LEFT JOIN mybb_threadfields_data tfd ON (tfd.tid = t.tid) WHERE t.fid IN (7,14,22,28,53,55,73,78) AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid ORDER BY t.dateline DESC LIMIT 0, 18 AND tfd.prefix="Sims2"


My page is called browse.php and I have set up the filter as so:

HTML Code
			   	<tr><td class="thead"><strong>Game</strong></td></tr>
				<tr><td class="trow4"><a href="browse.php?"><span><strong>Both</strong></span></a></td></tr>
				<tr><td class="trow4 {$filters_set['prefix']['active']['Sims2']}"><a href="browse.php?&amp;filtertf_prefix=Sims2"><strong>Sims2</strong></a></td></tr>
				<tr><td class="trow4 {$filters_set['prefix']['active']['Sims3']}"><a href="browse.php?&amp;filtertf_prefix=Sims3"><strong>Sims3</strong></a></td></tr>


My custom thread field has two values, Sims2 or Sims3 and has a display formatting like so:

PHP Code:
Sims2{|}<a href="{$forumurl?}filtertf_prefix=Sims2"><span style="color: red;"><img src="http://www.leefish.nl/mybb/images/icons/sims2icon.png" alt="sims2" width="32px" height="32px"/></span></a>
Sims3{|}<img src="http://www.leefish.nl/mybb/images/icons/sims3icon.png" alt="sims3" width="32px" height="32px" />


So where am I going wrong? Live page is here:

http://www.leefish.nl/mybb/browse.php



[Image: leelink.gif]
MYBB1.6 & XThreads
07-09-2011 01:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #422
RE: XThreads
Could you post the full script of your browse.php file?

07-09-2011 02:46 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #423
RE: XThreads
Yes, here we go: It's probably full of redundant code, but one step at a time Smile

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: portal.php 5147 2010-07-30 23:18:16Z RyanGordon $
 */

define("IN_MYBB", 1);
define("IN_PORTAL", 1);
define('THIS_SCRIPT', 'browse.php');

// set the path to your forums directory here (without trailing slash)
$forumdir = "./";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

$templatelist = "portal_announcement,browseportal";
$templatelist .= ",multipage_prevpage,multipage_nextpage,multipage_page_current,multipage_page,multipage_start,multipage_end,multipage";

require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;


// Fetch the current URL
$browse_url = get_current_location();

	add_breadcrumb("Downloads", $mybb->settings['bburl']."/browse.php");

$mybb->settings['portal_announcementsfid'] = '7,14,22,28,53,55,73,78';
$mybb->settings['portal_numannouncements'] = '18';
$query_add = '';
if($mybb->input['filtertf_prefix']) $query_add .= ' AND tfd.prefix="'.$db->escape_string($mybb->input['filtertf_prefix']).'"';

$plugins->run_hooks("portal_start");


// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
	$unviewwhere = " AND fid NOT IN ($unviewable)";
}

// Get latest news announcements
// First validate announcement fids:
$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
	foreach($announcementsfids as $fid)
	{
		$fid_array[] = intval($fid);
	}
	$announcementsfids = implode(',', $fid_array);
}
// And get them!
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
    $forum[$forumrow['fid']] = $forumrow;

}
	
$pids = '';
$tids = '';
$comma = '';
$page = intval($mybb->input['page']);
if($page < 1) $page = 1;
$numann = $db->fetch_field($db->simple_select('threads', 'COUNT(*) AS numann', "fid IN (".$mybb->settings['portal_announcementsfid'].") AND visible='1' AND closed NOT LIKE 'moved|%'"), 'numann');
$perpage = intval($mybb->settings['portal_numannouncements']);
$multipage = multipage($numann, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1');
$query = $db->query("
	SELECT p.pid, p.message, p.tid, tfd.prefix
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	LEFT JOIN ".TABLE_PREFIX."threadfields_data tfd ON (tfd.tid = t.tid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
	ORDER BY t.dateline DESC 
	LIMIT ".(($page-1)*$perpage).", ".$perpage.
$query_add);


while($getid = $db->fetch_array($query))
{
	$pids .= ",'{$getid['pid']}'";
	$tids .= ",'{$getid['tid']}'";
	$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0{$pids})";

if(is_array($forum))
{
	foreach($forum as $fid => $forumrow)
	{
		$forumpermissions[$fid] = forum_permissions($fid);

	}
}

$icon_cache = $cache->read("posticons");

$announcements = '';
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT ".(($page-1)*$perpage).", ".$perpage
);
while($announcement = $db->fetch_array($query))
{

	$announcement['pid'] = $posts[$announcement['tid']]['pid'];
	$announcement['threadlink'] = get_thread_link($announcement['tid']);
	
	if($announcement['uid'] == 0)
	{
		$profilelink = htmlspecialchars_uni($announcement['threadusername']);
	}
	else
	{
		$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
	}
	
	if(!$announcement['username'])
	{
		$announcement['username'] = $announcement['threadusername'];
	}
	$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
	if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
	{
		$icon = $icon_cache[$announcement['icon']];
		$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
	}
	else
	{
		$icon = "&nbsp;";
	}

	$anndate = my_date($mybb->settings['dateformat'], $announcement['dateline']);
	$anntime = my_date($mybb->settings['timeformat'], $announcement['dateline']);
	$annname = $announcement['forumname'];
	
	$plugins->run_hooks("portal_announcement");

		
	eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
	unset($post);
}

$plugins->run_hooks("portal_end");

eval("\$browse = \"".$templates->get("browseportal")."\";");
output_page($browse);

?>



[Image: leelink.gif]
MYBB1.6 & XThreads
07-09-2011 02:48 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #424
RE: XThreads
Could you try this?

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: portal.php 5147 2010-07-30 23:18:16Z RyanGordon $
 */

define("IN_MYBB", 1);
define("IN_PORTAL", 1);
define('THIS_SCRIPT', 'browse.php');

// set the path to your forums directory here (without trailing slash)
$forumdir = "./";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

$templatelist = "portal_announcement,browseportal";
$templatelist .= ",multipage_prevpage,multipage_nextpage,multipage_page_current,multipage_page,multipage_start,multipage_end,multipage";

require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;


// Fetch the current URL
$browse_url = get_current_location();

	add_breadcrumb("Downloads", $mybb->settings['bburl']."/browse.php");

$mybb->settings['portal_announcementsfid'] = '7,14,22,28,53,55,73,78';
$mybb->settings['portal_numannouncements'] = '18';
$query_add = '';
if($mybb->input['filtertf_prefix']) $query_add .= ' AND tfd.prefix="'.$db->escape_string($mybb->input['filtertf_prefix']).'"';

$plugins->run_hooks("portal_start");


// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
	$unviewwhere = " AND fid NOT IN ($unviewable)";
}

// Get latest news announcements
// First validate announcement fids:
$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
	foreach($announcementsfids as $fid)
	{
		$fid_array[] = intval($fid);
	}
	$announcementsfids = implode(',', $fid_array);
}
// And get them!
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
    $forum[$forumrow['fid']] = $forumrow;

}
	
$pids = '';
$tids = '';
$comma = '';
$page = intval($mybb->input['page']);
if($page < 1) $page = 1;
$numann = $db->fetch_field($db->simple_select('threads', 'COUNT(*) AS numann', "fid IN (".$mybb->settings['portal_announcementsfid'].") AND visible='1' AND closed NOT LIKE 'moved|%'"), 'numann');
$perpage = intval($mybb->settings['portal_numannouncements']);
$multipage = multipage($numann, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1');
$query = $db->query("
	SELECT p.pid, p.message, p.tid
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
	ORDER BY t.dateline DESC 
	LIMIT ".(($page-1)*$perpage).", ".$perpage
);


while($getid = $db->fetch_array($query))
{
	$pids .= ",'{$getid['pid']}'";
	$tids .= ",'{$getid['tid']}'";
	$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0{$pids})";

if(is_array($forum))
{
	foreach($forum as $fid => $forumrow)
	{
		$forumpermissions[$fid] = forum_permissions($fid);

	}
}

$icon_cache = $cache->read("posticons");

$announcements = '';
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar, u.avatardimensions
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.tid IN (0{$tids}) AND t.visible='1' AND t.closed NOT LIKE 'moved|%'".$query_add."
	ORDER BY t.dateline DESC
	LIMIT ".(($page-1)*$perpage).", ".$perpage
);
while($announcement = $db->fetch_array($query))
{

	$announcement['pid'] = $posts[$announcement['tid']]['pid'];
	$announcement['threadlink'] = get_thread_link($announcement['tid']);
	
	if($announcement['uid'] == 0)
	{
		$profilelink = htmlspecialchars_uni($announcement['threadusername']);
	}
	else
	{
		$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
	}
	
	if(!$announcement['username'])
	{
		$announcement['username'] = $announcement['threadusername'];
	}
	$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
	if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
	{
		$icon = $icon_cache[$announcement['icon']];
		$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
	}
	else
	{
		$icon = "&nbsp;";
	}

	$anndate = my_date($mybb->settings['dateformat'], $announcement['dateline']);
	$anntime = my_date($mybb->settings['timeformat'], $announcement['dateline']);
	$annname = $announcement['forumname'];
	
	$plugins->run_hooks("portal_announcement");

		
	eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
	unset($post);
}

$plugins->run_hooks("portal_end");

eval("\$browse = \"".$templates->get("browseportal")."\";");
output_page($browse);

?>


07-09-2011 03:17 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #425
RE: XThreads
Hi RateU, the filter worked, but it exploded the pagination. I will try moving it AFTER the pagination.

EDIT:  ok, the moving after pagination exploded it. I know that Zinga's filter supports paginated results - I just don't know how.

On further clicking the edited query is now only calling the first page of results - filtered or not. I have an alternate version of browse.php which calls my own query (I prefer to use this as I can do more with it) but it has the same issue with the paging.

So, now updating the "problem" to "how can I use the tf_filters with paginated results?"


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 07-09-2011 04:13 AM by leefish.)
07-09-2011 03:25 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #426
RE: XThreads
Try this:

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: portal.php 5147 2010-07-30 23:18:16Z RyanGordon $
 */

define("IN_MYBB", 1);
define("IN_PORTAL", 1);
define('THIS_SCRIPT', 'browse.php');

// set the path to your forums directory here (without trailing slash)
$forumdir = "./";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

$templatelist = "portal_announcement,browseportal";
$templatelist .= ",multipage_prevpage,multipage_nextpage,multipage_page_current,multipage_page,multipage_start,multipage_end,multipage";

require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;


// Fetch the current URL
$browse_url = get_current_location();

	add_breadcrumb("Downloads", $mybb->settings['bburl']."/browse.php");

$mybb->settings['portal_announcementsfid'] = '7,14,22,28,53,55,73,78';
$mybb->settings['portal_numannouncements'] = '18';
$query_add = '';
if($mybb->input['filtertf_prefix']){
	$query_add .= ' AND tfd.prefix="'.$db->escape_string($mybb->input['filtertf_prefix']).'"';
	$qry = ' LEFT JOIN '.TABLE_PREFIX.'threadfields_data tfd ON (tfd.tid=t.tid)';
	$brl = '&amp;filtertf_prefix='.htmlspecialchars_uni($mybb->input['filtertf_prefix']).'';
}

$plugins->run_hooks("portal_start");


// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
	$unviewwhere = " AND fid NOT IN ($unviewable)";
}

// Get latest news announcements
// First validate announcement fids:
$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
	foreach($announcementsfids as $fid)
	{
		$fid_array[] = intval($fid);
	}
	$announcementsfids = implode(',', $fid_array);
}
// And get them!
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
    $forum[$forumrow['fid']] = $forumrow;

}
	
$pids = '';
$tids = '';
$comma = '';
$page = intval($mybb->input['page']);
if($page < 1) $page = 1;
$numann = $db->fetch_field($db->query("SELECT COUNT(*) AS numann FROM ".TABLE_PREFIX."threads t".$qry." WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'".$query_add.""), 'numann');
$perpage = intval($mybb->settings['portal_numannouncements']);
$multipage = multipage($numann, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1'.$brl);

$query = $db->query("
	SELECT p.pid, p.message, p.tid
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	LEFT JOIN ".TABLE_PREFIX."threadfields_data tfd ON (tfd.tid = t.tid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid".$query_add."
	ORDER BY t.dateline DESC 
	LIMIT ".(($page-1)*$perpage).", ".$perpage
);


while($getid = $db->fetch_array($query))
{
	$pids .= ",'{$getid['pid']}'";
	$tids .= ",'{$getid['tid']}'";
	$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0{$pids})";

if(is_array($forum))
{
	foreach($forum as $fid => $forumrow)
	{
		$forumpermissions[$fid] = forum_permissions($fid);

	}
}

$icon_cache = $cache->read("posticons");

$announcements = '';
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar, u.avatardimensions
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.tid IN (0{$tids}) AND t.visible='1' AND t.closed NOT LIKE 'moved|%'".$query_add."
	ORDER BY t.dateline DESC
	LIMIT 0, ".intval($mybb->settings['portal_numannouncements'])
);
while($announcement = $db->fetch_array($query))
{

	$announcement['pid'] = $posts[$announcement['tid']]['pid'];
	$announcement['threadlink'] = get_thread_link($announcement['tid']);
	
	if($announcement['uid'] == 0)
	{
		$profilelink = htmlspecialchars_uni($announcement['threadusername']);
	}
	else
	{
		$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
	}
	
	if(!$announcement['username'])
	{
		$announcement['username'] = $announcement['threadusername'];
	}
	$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
	if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
	{
		$icon = $icon_cache[$announcement['icon']];
		$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
	}
	else
	{
		$icon = "&nbsp;";
	}

	$anndate = my_date($mybb->settings['dateformat'], $announcement['dateline']);
	$anntime = my_date($mybb->settings['timeformat'], $announcement['dateline']);
	$annname = $announcement['forumname'];
	
	$plugins->run_hooks("portal_announcement");

		
	eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
	unset($post);
}

$plugins->run_hooks("portal_end");

eval("\$browse = \"".$templates->get("browseportal")."\";");
output_page($browse);

?>


(This post was last modified: 07-09-2011 04:30 AM by RateU.)
07-09-2011 04:30 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #427
RE: XThreads
Excellent - it works Smile

I shall write it up as an Xthreads layout for those who may want it. Most forum owners whose focus is not mybb/php (myself included) who want such things really don't have time to create this kind of thing - they are busy building their forum. So this should be a help (I hope)


[Image: leelink.gif]
MYBB1.6 & XThreads
07-09-2011 04:46 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Vapor Offline
Member
***
Posts: 115
Joined: Oct 2010
Post: #428
RE: XThreads
Hey xthreaders:

Receiving this error after a server move and re-installation of Xthreads....rather an upgrade.

Code:
1
2
3
4
5
6
MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1060 - Duplicate column name 'viewable_gids'
Query:
    ALTER TABLE `mybb_threadfields` ADD COLUMN ( `viewable_gids` varchar(255) not null default "", `unviewableval` text not null ) 


Anyone got any ideas?
Thanx


D3G Gaming Team - http://d3g.in

[Image: vapor_sig.png]
07-11-2011 01:46 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: #429
RE: XThreads
Did you remove your cache/xthreads.php file?  Ensure you've moved that over, otherwise the upgrader won't know your previous version.

My Blog
07-11-2011 08:06 AM
Find all posts by this user Quote this message in a reply
Vapor Offline
Member
***
Posts: 115
Joined: Oct 2010
Post: #430
RE: XThreads
Shit....i deleted my old site. All i had was an old .sql file backup Frown

D3G Gaming Team - http://d3g.in

[Image: vapor_sig.png]
07-11-2011 08:14 AM
Visit this user's website Find all posts by this user Quote this message in a reply


Forum Jump: