DNNCommunity / DNN.Vendors

The Vendors module project allows admins to manage Vendor relationships and add Advertising banners to their site.
MIT License
7 stars 10 forks source link

Two Vendor Menu Items in Persona Bar -> Manage #29

Closed Andy9999 closed 3 years ago

Andy9999 commented 3 years ago

When logging in as host user, you will find two entries with the same name for the "Vendors" module. One for the host and one for admin pointing to the corresponding URLs. I don't know if this is possible, but maybe they can have two different names, like "Vendors (Host)" and "Vendors (Portal)" or something like that.

Not a big issue, but maybe it is not a lot of effort. With the "old" DNN, before PersonaBar, this wasn't an issue because there was a host and an admin menu, but in PersonaBar it seems both is merged.

Also this is only visible if logging in as a host user. At first I was wondering a bit why there are two entries and thought maybe something is corrupted with our installation.

valadas commented 3 years ago

Oh, vendors is a very old module, it has not been part of the core for quite a few versions :) I would just delete those pages if unused, that being said, if still used, you can rename them to your liking such as:

I do believe the Vendors extension still works though, but we cannot handle all possible scenarios of pages removal in the core for all the modules that could or could not be there before IMO. If I am wrong and someone has a plan to do this, feel free to comment and I'll be glad to reopen...

Andy9999 commented 3 years ago

OK.....seems like it is hardcode into the VendorController file to add one menu command to "Host" and another one to the "Admin" menu:`

var hostPage = Upgrade.AddHostPage("Vendors",
                                                    "Manage vendor accounts, banner advertising and affiliate referrals within the portal.",
                                                     "~/Icons/Sigma/Vendors_16X16_Standard.png",
                                                    "~/Icons/Sigma/Vendors_32X32_Standard.png",
                                                    true);

                            //Add module to page
                            Upgrade.AddModuleToPage(hostPage, moduleDefinition.ModuleDefID, "Vendors", "~/Icons/Sigma/Vendors_32X32_Standard.png", true);

                            //Add Module to Admin Page for all Portals
                            Upgrade.AddAdminPages("Vendors",
                                                    "Manage vendor accounts, banner advertising and affiliate referrals within the portal.",
                                                    "~/Icons/Sigma/Vendors_16X16_Standard.png",
                                                    "~/Icons/Sigma/Vendors_32X32_Standard.png",
                                                    true,
                                                    moduleDefinition.ModuleDefID,
                                                    "Vendors",
                                                    "~/Icons/Sigma/Vendors_32X32_Standard.png",
                                                    true);

Persona bar is somehow backwards compatible with this.

Don't know if it's worth fixing it then. Removing it, like you said, is probably the better option then. Am too lazy to try and build it. Nobody seems to use banners anymore and we will throw the banner out during a theme update soon.

I have no clue how the menu commands end up in the PersonaBarMenu table, but this is where the menu items are stored.

So I ran this to find the two menu items and their Ids: select * from PersonaBarMenu where Resourcekey='Vendors'

And this to update them: Update PersonaBarMenu set Resourcekey='Global Vendors' where MenuId=[MenuId of first one] Update PersonaBarMenu set Resourcekey='Site Vendors' where MenuId=[MenuId of second one]

:)

PS: Backup your DB before making such changes.

valadas commented 3 years ago

I have no clue how the menu commands end up in the PersonaBarMenu table In order to be backwards compatible the Persona Bar just lists former Admin/Host pages if it finds any. But yeah, I guess we could add add an IUpgreadable interface that would look at the DNN version if if it's 9.x.x we can ensure those pages have the proper name. However we cannot know if the module was originally installed before 9.x.x or not, soooo that means that code would have to run on all upgrades thus preventing admins to have a custom page name or having the admin controls on some other page as they prefer (say to allows a marketing guy to handle that without giving him full admin rights).

So IMO the fix would be worst than the workaround of just manually renaming those pages...

Andy9999 commented 3 years ago

Update: Yes, I agree. I tried renaming the pages and that didn't work. ~~I also checked the Tabs and TabModule pages, where AddAdminPages and AddHostPages should add some rows. But there were none. ~~ Ah, this code just added the pages, nothing more, nothing less. Maybe DNN converts Admin and Host pages automatically to PersonaBar menu entries or something like that. Then I tried building the module changing it in there and upgrading it, but that didn't work either. Finally I found it in the table above and renaming it there was successful.~~ Just realized you replied above inline. LOL. I found the pages, that the code I first thought was responsible for it does add as children of the "Admin" and "Hosts" pages. Anyways, hacking it into the PersonaBars menu table is OK for now. Thank you for the insights.