I am trying to make a plugin, and have hit a problem. The purpose of the plugin is to show a list on the usercp for the Xthreads files users have added on leefish (my site)
I have this query which works fine - it shows the list of uploaded files only on the userCP of the person who has uploaded them
function downloadsonucp_run()
{
global $db, $mybb, $templates, $theme, $lang, $my_last_threads;
$lang->load("downloadsonucp");
}
if($mybb->settings['downloadsonucp_showlastthreads'] == "1")
{
$mdxquery = $db->query("
SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, f.*, i.*, i.name AS iconname,
t.dateline AS threaddate, f.name AS forumname
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
WHERE t.uid = '".$mybb->user['uid']."'
AND t.visible = '1'
AND a.field = 'fupload'
GROUP BY t.tid
ORDER BY threaddate DESC
");
but I need to add more variables to the list after the where - like this
function downloadsonucp_run()
{
global $db, $mybb, $templates, $theme, $lang, $my_last_threads;
$lang->load("downloadsonucp");
}
if($mybb->settings['downloadsonucp_showlastthreads'] == "1")
{
$mdxquery = $db->query("
SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, f.*, i.*, i.name AS iconname,
t.dateline AS threaddate, f.name AS forumname
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
WHERE t.uid = '".$mybb->user['uid']."'
AND t.visible = '1'
AND a.field = 'fupload'
OR a.field = 'fupload2'
OR a.field = 'fupload3'
GROUP BY t.tid
ORDER BY threaddate DESC
");
But as soon as I add that OR in the query then the list becomes visible on ALL UCPs..... so I think I may need an array in there, but I don't know how to do that. Can anyone help?