Exemple #1
0
function makeForumList($fieldname, $selectedID)
{
    global $loguserid, $loguser;
    $pl = $loguser['powerlevel'];
    if ($pl < 0) {
        $pl = 0;
    }
    $rCats = Query("SELECT id, name FROM {categories} ORDER BY corder, id");
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat;
    }
    $rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id");
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['catid']][] = $forum;
    }
    $theList = '';
    foreach ($cats as $cid => $cat) {
        if (empty($fora[$cid])) {
            continue;
        }
        $cname = $cat['name'];
        $theList .= '			<optgroup label="' . htmlspecialchars($cname) . '">
' . mfl_forumBlock($fora, $cid, $selectedID, 0) . '			</optgroup>
';
    }
    return "<select id=\"{$fieldname}\" name=\"{$fieldname}\">{$theList}</select>";
}
Exemple #2
0
function makeForumListing($parent, $page = 0)
{
    global $loguserid, $loguser;
    $pl = $loguser['powerlevel'];
    if ($pl < 0) {
        $pl = 0;
    }
    $lastCatID = -1;
    $firstCat = true;
    $rFora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\tc.name cname,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew,\n\t\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\tLEFT JOIN {categories} c ON c.id=f.catid\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=f.lastpostuser\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ' AND ' . ($parent == 0 ? 'f.catid>0 ' : 'f.catid={1}') . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY c.corder, c.id, f.forder, f.id", $loguserid, -$parent, $page);
    if (!NumRows($rFora)) {
        return;
    }
    $rSubfora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ' AND ' . ($parent == 0 ? 'f.catid<0' : 'f.catid!={1}') . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id", $loguserid, -$parent);
    $subfora = array();
    while ($sf = Fetch($rSubfora)) {
        $subfora[-$sf['catid']][] = $sf;
    }
    $rMods = Query("SELECT m.forum, u.(_userfields) FROM {forummods} m LEFT JOIN {users} u ON m.user=u.id");
    $mods = array();
    while ($mod = Fetch($rMods)) {
        $mods[$mod['forum']][] = getDataPrefix($mod, "u_");
    }
    $theList = "";
    while ($forum = Fetch($rFora)) {
        $skipThisOne = false;
        $bucket = "forumListMangler";
        include "./lib/pluginloader.php";
        if ($skipThisOne) {
            continue;
        }
        if ($firstCat || $forum['catid'] != $lastCatID) {
            $theList .= format("\n\t\t" . ($firstCat ? '' : '</tbody></table>') . "\n\t<table class=\"outline margin\">\n\t\t<tbody>\n\t\t\t<tr class=\"header1\">\n\t\t\t\t<th style=\"width:32px;\"></th>\n\t\t\t\t<th>{0} <a href=\"#\" id=\"cat_{1}_lolz\"{3}>[expand]</a></th>\n\t\t\t\t<th style=\"width:75px;\">" . __("Threads") . "</th>\n\t\t\t\t<th style=\"width:50px;\">" . __("Posts") . "</th>\n\t\t\t\t<th style=\"min-width:150px; width:15%;\">" . __("Last post") . "</th>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tbody id=\"cat_{1}\"{2}>\n", $parent == 0 ? $forum['cname'] : 'Subforums', $forum['catid'], $_COOKIE['catstate'][$forum['catid']] ? ' style="display:none;"' : '', $_COOKIE['catstate'][$forum['catid']] ? '' : ' style="display:none;"');
            $lastCatID = $forum['catid'];
            $firstCat = false;
        }
        $newstuff = 0;
        $NewIcon = "";
        $localMods = "";
        $subforaList = '';
        $newstuff = $forum['ignored'] ? 0 : $forum['numnew'];
        $ignoreClass = $forum['ignored'] ? " class=\"ignored\"" : "";
        if ($newstuff > 0) {
            $NewIcon = "<img src=\"" . resourceLink("img/status/new.png") . "\" alt=\"New\"><br>" . gfxnumber($newstuff);
        }
        if (isset($mods[$forum['id']])) {
            foreach ($mods[$forum['id']] as $user) {
                $localMods .= UserLink($user) . ", ";
            }
        }
        if ($localMods) {
            $localMods = "<br /><small>" . __("Moderated by:") . " " . substr($localMods, 0, -2) . "</small>";
        }
        if (isset($subfora[$forum['id']])) {
            foreach ($subfora[$forum['id']] as $subforum) {
                $link = actionLinkTag($subforum['title'], 'forum', $subforum['id']);
                if ($subforum['ignored']) {
                    $link = '<span class="ignored">' . $link . '</span>';
                } else {
                    if ($subforum['numnew'] > 0) {
                        $link = '<img src="' . resourceLink('img/status/new.png') . '" alt="New"/> ' . $link;
                    }
                }
                $subforaList .= $link . ', ';
            }
        }
        if ($subforaList) {
            $subforaList = "<br /><small>" . __("Subforums:") . " " . substr($subforaList, 0, -2) . "</small>";
        }
        if ($forum['lastpostdate']) {
            $user = getDataPrefix($forum, "lu_");
            $lastLink = "";
            if ($forum['lastpostid']) {
                $lastLink = actionLinkTag("&raquo;", "post", $forum['lastpostid']);
            }
            $lastLink = format("<span class=\"nom\">{0}<br />" . __("by") . " </span>{1} {2}", formatdate($forum['lastpostdate']), UserLink($user), $lastLink);
        } else {
            $lastLink = "----";
        }
        $postcountmsg = '';
        if ($forum['ignoreposts']) {
            $postcountmsg = '<br><small>(posts in this forum aren\'t counted in users\' postcounts)</small>';
        }
        $theList .= "\n\t\t<tr class=\"cell1\">\n\t\t\t<td class=\"cell2 threadIcon newMarker\">\n\t\t\t\t{$NewIcon}\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<h4 {$ignoreClass}>" . actionLinkTag($forum['title'], "forum", $forum['id']) . "\n\t\t\t\t</h4>\n\t\t\t\t<span {$ignoreClass}>\n\t\t\t\t\t{$forum['description']}\n\t\t\t\t\t{$localMods}\n\t\t\t\t\t{$subforaList}\n\t\t\t\t\t{$postcountmsg}\n\t\t\t\t</span>\n\t\t\t</td>\n\t\t\t<td class=\"center cell2\">\n\t\t\t\t{$forum['numthreads']}\n\t\t\t</td>\n\t\t\t<td class=\"center cell2\">\n\t\t\t\t{$forum['numposts']}\n\t\t\t</td>\n\t\t\t<td class=\"smallFonts center\">\n\t\t\t\t{$lastLink}\n\t\t\t</td>\n\t\t</tr>";
    }
    write("\n\t{0}\n\t</tbody>\n</table>\n", $theList);
}
Exemple #3
0
function makeForumListing($parent)
{
    global $loguserid, $loguser;
    $pl = $loguser['powerlevel'];
    if ($pl < 0) {
        $pl = 0;
    }
    $lastCatID = -1;
    $rFora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\tc.name cname,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew,\n\t\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\tLEFT JOIN {categories} c ON c.id=f.catid\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=f.lastpostuser\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ' AND ' . ($parent == 0 ? 'f.catid>0' : 'f.catid={1}') . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY c.corder, c.id, f.forder, f.id", $loguserid, -$parent);
    if (!NumRows($rFora)) {
        return;
    }
    $rSubfora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ' AND ' . ($parent == 0 ? 'f.catid<0' : 'f.catid!={1}') . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id", $loguserid, -$parent);
    $subfora = array();
    while ($sf = Fetch($rSubfora)) {
        $subfora[-$sf['catid']][] = $sf;
    }
    $theList = "";
    $firstCat = true;
    while ($forum = Fetch($rFora)) {
        $skipThisOne = false;
        $bucket = "forumListMangler";
        include "./lib/pluginloader.php";
        if ($skipThisOne) {
            continue;
        }
        if ($firstCat || $forum['catid'] != $lastCatID) {
            $lastCatID = $forum['catid'];
            $firstCat = false;
            $theList .= format("\n\t\t" . ($firstCat ? '' : '</tbody></table>') . "\n\t<table class=\"outline margin\">\n\t\t<tbody>\n\t\t\t<tr class=\"header1\">\n\t\t\t\t<th>{0}</th>\n\t\t\t\t<th style=\"min-width:150px; width:15%;\">" . __("Last post") . "</th>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tbody>\n", $parent == 0 ? $forum['cname'] : 'Subforums');
        }
        $newstuff = 0;
        $NewIcon = "";
        $subforaList = '';
        $newstuff = $forum['ignored'] ? 0 : $forum['numnew'];
        $ignoreClass = $forum['ignored'] ? " class=\"ignored\"" : "";
        if ($newstuff > 0) {
            $NewIcon = "<img src=\"" . resourceLink("img/status/new.png") . "\" alt=\"New!\"/>";
        }
        if (isset($subfora[$forum['id']])) {
            foreach ($subfora[$forum['id']] as $subforum) {
                $link = actionLinkTag($subforum['title'], 'forum', $subforum['id']);
                if ($subforum['ignored']) {
                    $link = '<span class="ignored">' . $link . '</span>';
                } else {
                    if ($subforum['numnew'] > 0) {
                        $link = '<img src="' . resourceLink('img/status/new.png') . '" alt="New!"/> ' . $link;
                    }
                }
                $subforaList .= $link . ', ';
            }
        }
        if ($subforaList) {
            $subforaList = "<br />" . __("Subforums:") . " " . substr($subforaList, 0, -2);
        }
        if ($forum['lastpostdate']) {
            $user = getDataPrefix($forum, "lu_");
            $lastLink = "";
            if ($forum['lastpostid']) {
                $lastLink = actionLinkTag("&raquo;", "post", $forum['lastpostid']);
            }
            $lastLink = format("<span class=\"nom\">{0}<br />" . __("by") . " </span>{1} {2}", formatdate($forum['lastpostdate']), UserLink($user), $lastLink);
        } else {
            $lastLink = "----";
        }
        $theList .= "\n\t\t<tr class=\"cell1\">\n\t\t\t<td>\n\t\t\t\t<h4 {$ignoreClass}>" . $NewIcon . ' ' . actionLinkTag($forum['title'], "forum", $forum['id']) . "\n\t\t\t\t</h4>\n\t\t\t\t<span {$ignoreClass} class=\"nom\" style=\"font-size:80%;\">\n\t\t\t\t\t{$forum['description']}\n\t\t\t\t\t{$subforaList}\n\t\t\t\t</span>\n\t\t\t</td>\n\t\t\t<td class=\"cell0 smallFonts center\">\n\t\t\t\t{$lastLink}\n\t\t\t</td>\n\t\t</tr>";
    }
    write("\n\t\t{0}\n\t</tbody>\n</table>\n", $theList);
}
Exemple #4
0
function ForumJump()
{
    global $fid, $loguserid, $loguser;
    $pl = $loguser['powerlevel'];
    if ($pl < 0) {
        $pl = 0;
    }
    $rCats = Query("SELECT id, name FROM {categories} WHERE 1 ORDER BY corder, id");
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat['name'];
    }
    $rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id");
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['catid']][] = $forum;
    }
    $theList = '';
    foreach ($cats as $cid => $cname) {
        if (empty($fora[$cid])) {
            continue;
        }
        $theList .= '			<optgroup label="' . htmlspecialchars($cname) . '">
' . fj_forumBlock($fora, $cid, $fid, 0) . '			</optgroup>
';
    }
    echo "\n\t<label>\n\t\t" . __("Forum Jump:") . "\n\t\t<select onchange=\"document.location=this.options[this.selectedIndex].value;\">\n\t\t\t{1}\n\t\t\t{$theList}\n\t\t\t</optgroup>\n\t\t</select>\n\t</label>";
}