2

I'm using the EE Discussion module (3.1.8) under EE 2.5.2 and when I submit certain forms, say from the 'Ignore' template for example, the form submits and processes fine, but the returned page shows this error:

Error
The following errors were encountered You are not authorized to perform this action

The form posts to this URL:

http://www.macobserver.com/tmo/forums/do_ignore_member/47211/

There is almost NO documentation for the Discussion Forum module so I'm not sure even what controls the form or the message.

The ignore form template code I'm using is:

{form_declaration}
<div class="fm-header-wrapper">
    <h3>{lang:ignore_member_confirmation}</h3>
</div>

<div class="fm-message">
    {if member_is_ignored}
        <p class="fm-notice">{lang:already_ignored}</p>
    {/if}

    {if member_not_ignored}
        <p>
            <label for="fm-ignore-member">
                {lang:ignore_member}: <strong>{name}</strong>
            </label>
            <input type='radio' name='action' value='ignore' checked="checked" id="fm-ignore-member" />
        </p>
    {/if}
    {if member_is_ignored}
        <p>
            <label for="fm-unignore-member">
                {lang:unignore_member}: <strong>{name}</strong>
            </label>
            <input type='radio' name='action' value='unignore' checked="checked" id="fm-unignore-member" />
        </p>
    {/if}
    <p class="fm-submit">
        <input type="submit" name="submit" class="submit" value="{lang:submit}" />
    </p>
</div>
</form>

UPDATE I did some more digging on this and it seems that what is adding the duplicate info to the redirected URL is some lines in the /system/expressionengine/modules/forum/mod.forum_core.php code. Specifically in the 'do_ignore_member' function at line 8481

$return = str_replace('/'.$this->trigger, '', $this->EE->session->tracker[2]);

The $this->EE->session->tracker[2] variable is used on the next line and passed to the redirect call using a $this->forum_path($return); call. The forum_path method checks for the site basepath and then adds the URI value if one is passed in.

/**
 * Compiles a path string
 */
public function forum_path($uri = '')
{
    if ($this->basepath == '')
    {
        $this->_forum_set_basepath();
    }

    return $this->EE->functions->remove_double_slashes($this->basepath.$uri.'/');
}

UPDATE #2 So from my testing I think what is going on here is that the 'needle' value on the str_replace() is incorrect. EE adds a beginning slash '/' to the trigger word and then searches the $this->EE->session->tracker[2] value for that value and removes it. The trouble is, at least from what I can see, is that the $this->EE->session->tracker[2] value does NOT have a leading '/' so no match is found. I think the fix would be to change the line 8481 in the /system/expressionengine/modules/forum/mod.forum_core.php file from:

$return = str_replace('/'.$this->trigger, '', $this->EE->session->tracker[2]);

to:

$return = str_replace($this->trigger, '', $this->EE->session->tracker[2]);

This seems to fix the trouble for me, but I ask. Is this a truly a bug that needs this fix or am I just missing another configuration setting someplace?

  • OK. I found the problem, but I still don't know what is causing it. Looks like on the redirect EE is appending an extra '/forums' to the landing URL. So after using the 'ignore' link in a thread (say thread ID 123) and submitting the form EE is attempting to redirect back to the thread at the URL: http://dev.macobserver.com/tmo/forums/forums/viewthread/123 The appropriate URL would be: http://dev.macobserver.com/tmo/forums/viewthread/123 Which doesn't return the error. I checked mu setting and for 'FORUM URL' I have '/tmo/forums/' and for Forum Triggering Word it's 'forums' – Adam Christianson Nov 29 '12 at 23:58
  • 1
    If I had to guess I'd say there's a good chance that this is down to a bug in the forum module. Are you able to post a link to a public page that demonstrates the problem? – Dom Stubbs Nov 30 '12 at 13:20
1

Try removing 'forums/' from the "forum url" setting...

So '/tmo/forums/' becomes '/tmo/'. You might have to remove the trailing slash as well.

  • Yeah, I had tried that and the odd thing is that it doesn't seem to make a difference what value I put in there. The URL still redirects the same. – Adam Christianson Nov 30 '12 at 17:47
  • Figured this one out. For that path to be used you need to be sure to set the $env_config['use_forum_url'] = 'y'; hidden config variable. Unfortunately still doesn't 100% resolve my issue because when I enable that then my form POST urls are missing the /forums bit since it's not set. If I add /forums to the "forum url" setting I again get duplicate /forums because the $this->EE->session->tracker[2] value also contains the /forums bit. This is feeling more like an EE bug – Adam Christianson Nov 30 '12 at 19:26
  • Try a different forum trigger word just for kicks... Also, are you using the most recent version of the Forum module? – Anna_MediaGirl Nov 30 '12 at 19:48
  • Yeah, changing the keyword just breaks the forum which would be expected. I'm on version 3.1.8 of the forum module. latest is 3.1.9, so I may try updating. Although in looking at the lines in question in the mod.forum_core.php they seem to be the same in both versions, so if it is indeed a bug then I don't think it's fixed. – Adam Christianson Nov 30 '12 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.