MCP module missing forum id for mode sections

Discussion forum for MOD Writers regarding MOD Development.
Locked
docpify
Registered User
Posts: 2
Joined: Thu May 07, 2015 11:09 pm

MCP module missing forum id for mode sections

Post by docpify »

Hello,

To enable my moderators to do some simple administrative tasks on subforums (create/rename), I have made a custom MCP module. The first part I made, to create subforums, worked just fine, but when I started adding another mode for renaming forums, I found that the mode links in the control panel do not include an f value, so the forum id is lost when navigating, making my code inoperable.

My info/mcp_subforum.php: https://ghostbin.com/paste/gwne8
My mcp_subforum.php: https://ghostbin.com/paste/qhx5g

I have cleared the cache multiple times as well, but I am unable to get the f parameter added to these mode links. It works fine for the default modules, and I can not see what they do different..

I have been searching for the answers with no luck, and the code involved is too opaque for me to be able to follow, so I hope someone on here will be able to help!

-- Cheers, Morten
User avatar
AmigoJack
Registered User
Posts: 5774
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: MCP module missing forum id for mode sections

Post by AmigoJack »

The module class checks for _module_* functions and calls them, i.e. /includes/functions_module.php:

Code: Select all

            // Function for building 'url_extra'
            $url_func = '_module_' . $row['module_basename'] . '_url';

            // Function for building the language name
            $lang_func = '_module_' . $row['module_basename'] . '_lang';

            // Custom function for calling parameters on module init (for example assigning template variables)
            $custom_func = '_module_' . $row['module_basename'];
The MCP can append the forum ID to every URI because /mcp.php has:

Code: Select all

function _module_main_url($mode, &$module_row)
{
    return extra_url();
}

function _module_logs_url($mode, &$module_row)
{
    return extra_url();
}

function _module_ban_url($mode, &$module_row)
{
    return extra_url();
}

function _module_queue_url($mode, &$module_row)
{
    return extra_url();
}

function _module_reports_url($mode, &$module_row)
{
    return extra_url();
}

function extra_url()
{
    global $forum_id, $topic_id, $post_id, $report_id, $user_id;

    $url_extra = '';
    $url_extra .= ($forum_id) ? "&f=$forum_id" : '';
    $url_extra .= ($topic_id) ? "&t=$topic_id" : '';
    $url_extra .= ($post_id) ? "&p=$post_id" : '';
    $url_extra .= ($user_id) ? "&u=$user_id" : '';
    $url_extra .= ($report_id) ? "&r=$report_id" : '';

    return $url_extra;
}

You must create your own function in there, i.e.:

Code: Select all

function _module_subforum_url($mode, &$module_row)
{
    return extra_url();
}
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
docpify
Registered User
Posts: 2
Joined: Thu May 07, 2015 11:09 pm

Re: MCP module missing forum id for mode sections

Post by docpify »

Thanks a lot, that fixed it!
Locked

Return to “[3.0.x] MOD Writers Discussion”