Welcome to DotNetNuke, where the official site provides zero documentation, and everything is learned from experiments, blogs, forums, and sites trying to sell you something.
I suggest going to the root DNN folder and opening the file / Install / Module / UsersOnline _05.01.00_Install.resources. This is just a zip archive renamed to .resources. Inside this archive is a packaged Users Online module, and in this example I'm going to go through.
If you already have your .DNN xml package created for your module, you need to add a new <component> entry so that DNN knows how to execute your SQL scripts during installation:
...snip... <components> <component type="Script"> <scripts> <basePath>DesktopModules\UsersOnline</basePath> <script type="Install"> <path>Providers\DataProviders\SqlDataProvider</path> <name>04.09.04.SqlDataProvider</name> <version>04.09.04</version> </script> <script type="Install"> <path>Providers\DataProviders\SqlDataProvider</path> <name>05.01.00.SqlDataProvider</name> <version>05.01.00</version> </script> <script type="UnInstall"> <path>Providers\DataProviders\SqlDataProvider</path> <name>Uninstall.SqlDataProvider</name> <version>05.01.00</version> </script> </scripts> </component> ...snip...
During module installation, DNN will execute the scripts entered here in the order of their version number. If the currently installed module has never been installed, it will go in the following order:
If the module has already been installed and updated (from 04.09.04), it skips the scripts of previous versions (if they have already been executed) and simply launches a new script on 05.01.00, which should be in the know. It is your responsibility to create your SQL scripts to support the built-in update mechanism.
There is also a "UnInstall" script that runs when the user disconnects the module. This allows you to clean up after your module.
Each SQL script contains the T-SQL commands needed to create your module schema, default data, stored procedures, etc. Here is a fragment of the OnlineUsers script module:
/************************************************************/ /***** SqlDataProvider *****/ /***** *****/ /***** *****/ /***** Note: To manually execute this script you must *****/ /***** perform a search and replace operation *****/ /***** for {databaseOwner} and {objectQualifier} *****/ /***** *****/ /************************************************************/ if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}DNNUOL_GetOnlineUsers]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE {databaseOwner}{objectQualifier}DNNUOL_GetOnlineUsers GO CREATE PROCEDURE {databaseOwner}{objectQualifier}DNNUOL_GetOnlineUsers @PortalID int, @IncludeHosts bit AS IF @IncludeHosts = 0 BEGIN SELECT UO.UserID, U.UserName, U.DisplayName, U.FirstName, U.LastName, U.FirstName + ' ' + U.LastName AS FullName FROM {databaseOwner}{objectQualifier}UsersOnline UO INNER JOIN {databaseOwner}{objectQualifier}Users U ON UO.UserID = U.UserID INNER JOIN {databaseOwner}{objectQualifier}UserPortals UP ON U.UserID = UP.UserID WHERE UO.PortalID = @PortalID AND UO.UserID = U.UserID AND UP.Authorised = 1 AND U.IsSuperUser = 0 -- Inner Join takes care of SU = 0, but for sanity. END ELSE BEGIN SELECT DISTINCT UO.UserID, U.UserName, U.DisplayName, U.FirstName, U.LastName, U.FirstName + ' ' + U.LastName AS FullName FROM {databaseOwner}{objectQualifier}UsersOnline UO INNER JOIN {databaseOwner}{objectQualifier}Users U ON UO.UserID = U.UserID, {databaseOwner}{objectQualifier}UserPortals UP WHERE UO.PortalID = @PortalID AND UO.UserID = U.UserID AND UP.Authorised = 1 END GO /************************************************************/ /***** SqlDataProvider *****/ /************************************************************/
Note the use of {databaseOwner} and {objectQualifier} before each table or procedure created in the database. These are tokens and are replaced at run time by the settings from the installation web.config file. You can usually assume that they will be replaced with "dbo". but if you sell your module or provide it to third parties for installation, you will need to support user owners and qualifiers.
Here are some additional resources: