I think Developer58 is asking to only have the module available (show up in the list of modules) for a single portal. The MODULES table by itself will only tell if a module already is added to a page on a portal (or several pages and/or several portals). The MODULES table cannot prevent the module from showing up in the administrator's dropdown list of available modules across all portals. In other words, admin's from any portal could continue to see and add the module to DNN pages even after it has been added the first time. Your module can use the info in the MODULES table to prevent iself from executing if it is not the intitial instance of itself across all portals but you can't use the MODULES table to prevent the module from showing up in and being added to mutliple portals.
SOLUTION #1: HOST can use PREMUIM setting via DNN UI
If you are setting your modules up on DNN instances that you control, the easiest way to retrict use to one portal is to use the "PREMIUM" checkbox under the module's MODULE DEFINITON (available only to HOST accounts). Log in as host and go to HOST->MODULE DEFINITONS and check the edit box next to your (already installed) module. Check the "PREMIUM" box and then you can select which portal(s) can see and use the module.
SOLUTION #2: "PREMIUM" setting via module code
If you are going to distribute your module (i.e., you will not have control over the DNN instances where the module is installed), you can use the same "PREMIUM" trick from code: use the MODULES table to determine the first installed instance of your module and then update the appropriate ISPREMIUM value under DESKTOPMODULES table as well as remove extraneous entries of your module from DESKTOPMODULES. You'll want to perform the following steps each time your module is loaded:
- For the module you wish to restrict to run on a single portal: Have your module check the MODULES table and get the MODULEID and PORTALID of the entry with the lowest MODULEID value of all modules with a matching MODULEDEFID value that are also not marked as 'deleted' by the ISDELETED bit. (You may also want to verify that the current date falls within the STARTDATE and ENDDATE times, if defined.)
- Update the DESKTOPMODULES table to mark the module as ISPREMIUM. Make a note of your module's DESKTOPMODULEID.
- Under PORTALDESKTOPMODULES, add/update an entry with your module's DESKTOPMODULEID along with the approriate PORTALID value. Rmove any entries matching your module's DESKTOPMODULEID that do not have a PORTALID matching the ID of the portal(s) allowed to have your module.
SPECIAL NOTE: Moving the module to another portal
You'll need to include special instructions for your users on how remove the module from one portal and make the module available on another portal. The steps are: (1) delete the module from its current portal, (2) uncheck the module's "PREMIUM" setting under HOST->MODULE SETTINGS, (3) add the module to new portal. As soon as the module is added it will run the special "PREMIUM via code" steps outlined above and re-check the "PREMIUM" setting, locking it to the new portal.
-mamlin