Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

2 Login & Register Panel in Sidebar

When I'm not logged into the site and access the form, I can see two login panels.

How disable a login panel?

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Let me explain what's happening here. The solution what to do is at the end of this text in case you are impatient, but giving some insights might help you understanding such errors better.

    In order to mimic a standard Vanilla page, I try to add all the modules that you can see "normally". There is an option you can use to sort those modules. It is the config setting "Modules.Vanilla.Panel". At line 87 I do a loop through those modules and add each module. But this config setting only determines the order. There is no way to really "know" which modules really are shown to your users. There could be additional modules provided by some plugins. And some might be duplicate.

    When I wrote the plugin, I had seen that the MeModule appeared twice. The name of the MeModule is - guess what - "MeModule". So I searched through the code for that term and found out that it is added in the default.master.tpl template. That means that it is part of every page and that's the reason why I have excluded it explicitly in the foreach loop.

    I obviously haven't tested that plugin when not logged in. Otherwise I would have seen that two "Howdy Stranger"s. But what to do to make it behave correctly?

    First you have to find out what you want to make disappear. If you inspect the html you'll find out that we're talking about a module which is in a div of class "GuestBox". So search the code for "GuestBox" and you'll find out that it is part of /applications/dashboard/views/modules/guest.php. When you have a little knowledge about Vanilla, you would assume that it is called by a file /applications/dashboard/modules/class.guestmodule.php and that file really exists! When you open that file you see that the name of the class inside is "GuestModule" (which shouldn't be a big surprise).

    Okay, now that we have the name of the module that misbehaves, we should be a little nosy why it behaves like that. So again we do a full text search through our code for "GuestModule". It does appear in several places, but there is only one file that is of interest for us: /applications/vanilla/controllers/class.vanillacontroller.php. Why, you ask? Look at the name of the function in the How To plugin where the modules are added: public function vanillaController_howToFormValidate_create($sender, $args) {. That means that we are creating a page which should inherit everything from the VanillaController. Back to where we found "GuestModule" in class.vanillacontroller.php you see that this module is added every time when a VanillaController gets initialized.

    When we add everything we find in the config, but some other modules are added by other controllers methods, we have two options:
    a) Inspect the source to find every module that we have to exclude. Tedious and error-prone.
    b) Change the loop where we add our modules and test if any of the modules to add are already present. Though this solution also is not able to detect modules added by the template, it should be able to handle all other duplicate modules.

            // Add modules.
            $modules = array_diff(
                    c('Modules.Vanilla.Panel'),  // The modules sort list from the config
                    array_keys($sender->Assets['Panel']), // All previously attached modules
                    array('MeModule') // The MeModule that we have to remove manually
            );
            foreach ($modules as $module) {
                $sender->addModule($module);
            }
    

    Either change it in your local copy or get the sources from the GitHub repo. I have not updated the plugin in the addons section yet.

    Thanks again for debugging my work! :)

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @Linc: I've seen that the MeModule once have been added via addModule() in some controllers, but that have been commented out and now the MeModule is part of the default template. Do you know the reason for that?
    Not that it is really annoying to me, but I'm always surprised if one thing is handled completely different than others.

Sign In or Register to comment.