|
|
|
|
www.bensantiago.com Joined: 5/15/2006
Posts: 264
|
|
|
I am trying to add custom permissions to my module. I tested my code within a page's Load() event, and the code adds the permissions perfectly, so I know that isn't my problem. It just seems that I can't get the UpgradeModule() event to fire. Can anyone help me figure out why I can't get my code to fire on an initial module install? I have the following code/settings:
SQLDataProvider Filename: 01.00.00.SqlDataProvider
DNN File:
<package name="MyModule" type="Module" version="01.00.00">
<script type="Install">
<path>Providers\DataProviders\SqlDataProvider</path>
<name>01.00.00.SqlDataProvider</name>
<version>01.00.00</version>
</script>
<script type="UnInstall">
<path>Providers\DataProviders\SqlDataProvider</path>
<name>Uninstall.SqlDataProvider</name>
<version>01.00.00</version>
</script>
AssemblyInfo File:
<Assembly: AssemblyVersion("01.00.00.*")>
<Assembly: AssemblyFileVersion("01.00.00.*")>
Public Function UpgradeModule(ByVal Version As String) As String Implements DotNetNuke.Entities.Modules.IUpgradeable.UpgradeModule
'***************************************
' Perform Operation Based On Version Number
'***************************************
Select Case Version
Case "01.00.00"
'***************************************
' Initial Install...
' Create Custom Module Permissions
'***************************************
Me.InitializeModulePermissions()
End Select
'***************************************
' Return Version Number
'***************************************
Return Version
End Function
Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
|
|
|
|
| |
|
|
|
|
www.cathal.co.uk Joined: 4/9/2003
Posts: 9676
|
|
|
I dont see a businesscontroller class definition so thats probably the issue -however there is a much easier way to do this by adding custom permissions in the module definition - http://www.dotnetnuke.com/Resources/Wiki/Page/Manifest-Module-Component.aspx
Buy the new Professional DNN7: Open Source .NET CMS Platform book
Amazon US
|
|
|
|
| |
|
|
|
www.bensantiago.com Joined: 5/15/2006
Posts: 264
|
|
|
Cathal,
I actually did have a businessControllerClass definition inside the DNN file, the default that was defined when the project was created. However, looking at your link, I didn't have the supportedFeatures section defined. Not sure if that was the problem, I am going to rework my source to the method in the link you provided and post my results.
However, even though it is much simpler to add the custom permissions into the DNN file directly (which I am in the process of doing), when the Module first installs, I need it to define some default module settings. If I can get UpgradeModule() to fire as it's supposed to, I'd be able to write my code there. But the problem I am having is that I can't get a reference to the current Module's ID within the FeatureController class. Is there a way within this class to get the ModuleID, that way I can then use the UpdateModuleSettings() found within the ModuleController class.
Thanks!
Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
|
|
|
|
| |
|
|
|
www.wesnetdesigns.com Joined: 2/18/2005
Posts: 3253
|
|
|
Ben,
In addition to having a <businessControllerClass> node in your manifest, have you included the necessary <upgradeVersionsList> node with a comma separated list of version(s) for which IUpgradable.UpgradeModule is to be called?
Please see this Wiki entry for more information on the <eventMessage> section of the manifest:
http://www.dotnetnuke.com/Resources/W...
and this blog post for more information on the <upgradeVersiionsList> node in particular:
http://www.dotnetnuke.com/Resources/W...
In regards to defining default module settings you cannot do so in an implementation of UpgradeModule in your business controller class. At the time of installing or upgrading a module there is no ModuleID as one does not exist until a module is added to a page. Instead when your module loads you can check if any module setting or tabmodule settings have been set and save (using UpdateModuleSettings or UpdateTabModuleSettings) the default values. Alternatively when your module needs a particular setting value you can check if the settings key exists in the Settings hashtable. If it does exist then return the previously saved value - if it does not exist return a default value. In modules which have more than a few settings I always prefer to create a Configuration class which when instantiated in the module's Init or Load event handlers loads all of the module settings into strongly typed properties and either handles the settings pre-configuration when the module is first placed on a page or provides defaults for settings not previously saved.
Take a look at most of the more involved "core" modules to see how that is done. I know that some of the project's I've created or contributed to in the Extensions Forge take this approach: Gallery, Feedback, ContentDejour for example.
Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
|
|
|
|
| |
|
|
|
www.bensantiago.com Joined: 5/15/2006
Posts: 264
|
|
|
William,
Thanks for the information, although the two links you posted were to the same page, I am assuming that was a typo?
Ok, I have moved all my current items to other areas and have them working. HOWEVER...I still need to understand how to implement the UPGRADEMODULE process for future reference. I have the following DNN entries:
<package name="ModuleName" type="Module" version="01.00.02">
.
.
.
<businessControllerClass>MyCompany.Modules.ModuleName.Components.FeatureController</businessControllerClass>
<supportedFeatures>
<supportedFeature type="Upgradeable" />
</supportedFeatures>
.
.
.
<eventMessage>
<processorType>DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke</processorType>
<processorCommand>UpgradeModule</processorCommand>
<attributes>
<businessControllerClass>MyCompany.Modules.ModuleName.Components.FeatureController</businessControllerClass>
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
<upgradeVersionsList>01.00.02</upgradeVersionsList>
</attributes>
</eventMessage>
.
.
.
In my FeatureController class I have the UpgradeModule() function. Inside it I have the following code:
'***************************************
' Perform Operation Based On Version Number
'***************************************
Select Case Version
Case "01.00.02"
'***************************************
' DRIVER: Test Code
'***************************************
StringToFile("Upgrade Successful", "C:\DNNUpgradeText.txt")
End Select
'***************************************
' Return Version Number
'***************************************
Return Version
But after I install the new module...the text file I expect to see on the server's C:\ is not there...
Any ideas????
Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
|
|
|
|
| |