Fixed Public & admin "forums/prefixes" action code is different

DragonByte Tech

Well-known member
Affected version
2.0.1
Sorry for the convoluted title, the other prefix issue I saw reminded me to report this.

Consider the following HTML code in a public template:

HTML:
                <xf:selectrow name="thread_node_id" value="{$product.thread_node_id}" id="js-dbtechEcommercePurchaseNodeList"
                              label="{{ phrase('dbtech_ecommerce_automatically_create_purchase_thread_in_forum') }}"
                              explain="{{ phrase('dbtech_ecommerce_if_selected_purchase_product_created_thread_posted_forum') }}">

                    <xf:option value="0">{{ phrase('(none)') }}</xf:option>
                    <xf:foreach loop="$forumOptions" value="$forum">
                        <xf:option value="{$forum.value}" disabled="{$forum.disabled}" label="{$forum.label}" />
                    </xf:foreach>
                </xf:selectrow>

                <xf:formrow label="{{ phrase('dbtech_ecommerce_automatically_created_purchase_thread_prefix') }}" rowtype="input">
                    <xf:js src="xf/prefix_menu.js" min="1" />
                    <xf:macro template="prefix_macros" name="select"
                        arg-type="thread"
                        arg-prefixes="{$threadPrefixes}"
                        arg-selected="{$product.thread_prefix_id}"
                        arg-name="thread_prefix_id"
                        arg-href="{{ link('forums/prefixes') }}"
                        arg-listenTo="#js-dbtechEcommercePurchaseNodeList" />
                </xf:formrow>

Selecting the "(none)" option will produce this:

1516205314949.webp

This is /Admin/Controller/Forum.php:
PHP:
    public function actionPrefixes(ParameterBag $params)
    {
        $this->assertPostOnly();

        $viewParams = [];

        $nodeId = $this->filter('val', 'uint');
        if ($nodeId)
        {
            /** @var \XF\Entity\Forum $forum */
            $node = $this->assertNodeExists($nodeId);
            $forum = $node->getDataRelationOrDefault();

            $viewParams['forum'] = $forum;
            $viewParams['prefixes'] = $forum->getPrefixesGrouped();
        }

        return $this->view('XF:Forum\Prefixes', 'public:forum_prefixes', $viewParams);
    }

This is /Pub/Controller/Forum.php

PHP:
    public function actionPrefixes(ParameterBag $params)
    {
        $this->assertPostOnly();

        $nodeId = $this->filter('val', 'uint');
        $forum = $this->assertViewableForum($nodeId);

        $viewParams = [
            'forum' => $forum,
            'prefixes' => $forum->getUsablePrefixes()
        ];
        return $this->view('XF:Forum\Prefixes', 'forum_prefixes', $viewParams);
    }

Can you please update the Pub code to match the Admin code, in terms of the $nodeId check?

Without that change, the fix for https://xenforo.com/community/threads/inline-moderation-thread-move-prefix-bug.140188/ is going to cause this popup over and over unless I implement my own action for this, should the purchase thread option not be desired.


Fillip
 
Last edited:
Back
Top Bottom