add a role to mp_Roles during feature setup

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/24/2010 9:07:36 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

add a role to mp_Roles during feature setup

In my own feature I would like to add a new role to mp_Roles during my feature setup.
I'll then need to edit some Site Settings\Security\Permissions for the new group.

In my SchemaInstallScripts/mssql, all my features tables are created and all works fine.

I already do some table updates Where SiteID = 1 in my SchemaUpgradeScripts but I need to generate a new RoleGuid before I do the insert into mp_roles and I thought...  Someone else must be doing this type of thing already???

Can someone point in to existing mojoPortal code or share a code snippet for doing this

My Sites installs will always be Date\Sites\1

Thanks

Rick Hubka

11/16/2010 7:28:39 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: add a role to mp_Roles during feature setup

So here's what I did.  I'm sure this is not the best solution but it works. MSSQL only.

In my features SchemaUpgradeScripts folder, I added this create for the stored proc below in a config file:

CREATE PROCEDURE [dbo].[proc_roles_insert_at_setup]
AS
BEGIN
 DECLARE @RoleGuid	uniqueidentifier
       , @SiteGuid	uniqueidentifier
       , @SiteID    		int
       , @RoleName    nvarchar(50)
       
 SELECT TOP 1 @SiteGuid = SiteGuid
                    FROM mp_Sites
                    WHERE SiteID = 1
 
 SELECT @SiteID   = 1
       ,@RoleName = 'BizzDok Admin'
       ,@RoleGuid = NEWID()
  
  execute [dbo].[mp_Roles_Insert] @RoleGuid, @SiteGuid, @SiteID, @RoleName
  
  SELECT @RoleName = 'BizzDok User'
        ,@RoleGuid = NEWID()
  execute [dbo].[mp_Roles_Insert] @RoleGuid, @SiteGuid, @SiteID, @RoleName
END
GO

Then I execute that proc along with other custom SQL in another config file

EXECUTE proc_roles_insert_at_setup
GO

The stored proc [dbo].[mp_Roles_Insert] is a standard stored proc in mojoPortal

That gets me the 2 new Roles I wanted when mojoPortal installs.

 

You must sign in to post in the forums. This thread is closed to new posts.