List own user threads from specific forum in menu
#5
Please notice, my first post in this thread is from january 2020, where I wrote nothing about a "plugin", but a "code". Later he made me an plugin out of it (SvePu), which is mentioned in my second post. So, I have no idea how you put my second post together with my first post this way, but anway. SvePu is helping with the developement of many plugins, like the thank you plugin. Here is the finished plugin!

<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.");
}

$plugins->add_hook("global_start", "meineextras_headermenu_threadlist");

function meineextras_info()
{
    return array(
        "name"          => "Meine Extra Funktionen",
        "description"   => "Spezielle Fuktionen für mein Forum",
        "website"       => "https://x-invest.net/forum/",
        "author"        => "SvePu",
        "authorsite"    => "https://www.mybb.de/forum/user-10549.html",
        "version"       => "1.0",
        "codename"      => "meineextras",
        "compatibility" => "18*"
    );
}

function meineextras_activate()
{
    global $db;

    $query_add = $db->simple_select("settinggroups", "COUNT(*) as disporder");
    $disporder = $db->fetch_field($query_add, "disporder");

    $setting_group = array(
        'name' => 'meineextras',
        "title" => "Meine Extra Funktionen",
        "description" => "Einstellungen für meine extra Funktionen",
        'disporder' => $disporder+1,
        'isdefault' => 0
    );

    $gid = $db->insert_query("settinggroups", $setting_group);

    $setting_array = array(
        'meineextras_headermenu_fids' => array(
            'title' => "Foren Themen-Liste Kopfmenübereich",
            'description' => "Wähle die Foren aus, aus denen die Themen für den Kopfmenübereich gelistet werden.",
            'optionscode' => 'forumselect',
            'value' => '',
            'disporder' => 1
            ),
        'meineextras_headermenu_limit' => array(
            'title' => "Limit Themen-Liste Kopfmenübereich",
            'description' => "Wähle die maximale Anzahl an Themen aus, die in der Liste gezeigt werden sollen. (0 deaktiviert das Limit)",
            'optionscode' => 'numeric \nmin=0',
            'value' => 0,
            'disporder' => 2
            )
        );

    foreach($setting_array as $name => $setting)
    {
        $setting['name'] = $name;
        $setting['gid'] = $gid;
        $db->insert_query('settings', $setting);
    }

    rebuild_settings();

}

function meineextras_deactivate()
{
    global $db;
    $query = $db->simple_select("settinggroups", "gid", "name='meineextras'");
    $gid = $db->fetch_field($query, "gid");
    if(!$gid)
    {
        return;
    }
    $db->delete_query("settinggroups", "name='meineextras'");
    $db->delete_query("settings", "gid=$gid");
    rebuild_settings();
}

function meineextras_headermenu_threadlist()
{
    global $mybb, $db, $headermenu_threadlist;
    $headermenu_threadlist = "";
    if(!$mybb->user['uid'] || $mybb->settings['meineextras_headermenu_fids'] == "")
    {
        return;
    }

    $where = "uid = '{$mybb->user['uid']}' AND visible=1 AND closed NOT LIKE 'moved|%'";
    if($mybb->settings['meineextras_headermenu_fids'] != "-1")
    {
        $where .= " AND fid IN ({$mybb->settings['meineextras_headermenu_fids']})";
    }

    $options = array(
        'order_by' => 'dateline',
        'order_dir' => 'DESC'
    );
    if($mybb->settings['meineextras_headermenu_limit'] > 0)
    {
        $options['limit'] = (int)$mybb->settings['meineextras_headermenu_limit'];
    }

    $query = $db->simple_select("threads", "tid, subject", $where, $options);
    $count = $db->num_rows($query);
    if($count > 0)
    {
        $headermenu_threadlist = "<strong>Vorstellungen</strong>";
        while($result = $db->fetch_array($query))
        {
            $headermenu_threadlist .= "<a href=" . get_thread_link($result['tid']) . ">" . htmlspecialchars_uni($result['subject']) . "</a>";
        }
        $headermenu_threadlist .= "";
    }
}


Remember that this plugin is not showing ALL threads of a user IN the dropdown menu, but all thread from specific forums.

If you still think, it is bad coding, you can make it better any time you want. Wink
Reply


Messages In This Thread
RE: List own user threads from specific forum in menu - by skrilaxrev - 2021-06-20, 08:51 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)