当前位置: 首页>>代码示例>>C#>>正文


C# PermissionController.GetPermissionByCodeAndKey方法代码示例

本文整理汇总了C#中DotNetNuke.Security.Permissions.PermissionController.GetPermissionByCodeAndKey方法的典型用法代码示例。如果您正苦于以下问题:C# PermissionController.GetPermissionByCodeAndKey方法的具体用法?C# PermissionController.GetPermissionByCodeAndKey怎么用?C# PermissionController.GetPermissionByCodeAndKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Security.Permissions.PermissionController的用法示例。


在下文中一共展示了PermissionController.GetPermissionByCodeAndKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GivenThereIsAPageCalled

        public void GivenThereIsAPageCalled(string pageName, Table permissions)
        {
            var reset = false;
            var tabController = new TabController();
            var tab = tabController.GetTabByName(pageName, PortalId);
            if (tab == null)
            {
                tab = new TabInfo
                {
                    TabName = pageName,
                    PortalID = 0
                };
                tab.TabID = tabController.AddTab(tab);
                foreach (var row in permissions.Rows)
                {
                    var roleId = -1;
                    var roleController = new RoleController();
                    if (row[0] == "All Users")
                    {
                        roleId = -1;
                    }
                    else
                    {
                        var role = roleController.GetRoleByName(PortalId, row[0]);
                        if (role == null)
                        {
                            if (roleController.GetRoleByName(Null.NullInteger, row[0]) == null)
                            {
                                role = new RoleInfo { RoleName = row[0], RoleGroupID = Null.NullInteger };
                                roleId = roleController.AddRole(role);
                            }
                        }
                    }
                    var permissionController = new PermissionController();
                    var permission = permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", row[1]);
                    var tabPermission = new TabPermissionInfo
                    {
                        PermissionID = 3,
                        TabID = tab.TabID,
                        AllowAccess = true,
                        RoleID = roleId
                    };
                    tab.TabPermissions.Add(tabPermission);
                }

                tabController.UpdateTab(tab);
                reset = true;
            }
            Page = tab;
            if (reset)
            {
                Config.Touch();
            }
        }
开发者ID:biganth,项目名称:Curt,代码行数:54,代码来源:PageSteps.cs

示例2: ensureFolderExists

 public static void ensureFolderExists(int portalId)
 {
     FolderMappingInfo fm = FolderMappingController.Instance.GetFolderMapping(portalId, "Secure");
     if (!FolderManager.Instance.FolderExists(portalId, IMAGE_FOLDER + "/"))
     {
         IFolderInfo f1 = FolderManager.Instance.AddFolder(fm, IMAGE_FOLDER);
         DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
         DotNetNuke.Security.Permissions.PermissionController pc = new DotNetNuke.Security.Permissions.PermissionController();
         DotNetNuke.Security.Permissions.PermissionInfo w = (DotNetNuke.Security.Permissions.PermissionInfo)pc.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "WRITE")[0];
         FolderManager.Instance.SetFolderPermission(f1, w.PermissionID, rc.GetRoleByName(portalId, "Accounts Team").RoleID);
     }
 }
开发者ID:powertochange-org,项目名称:acReimbursements,代码行数:12,代码来源:Filesystem.cs

示例3: checkFolderPermissions

 public static void checkFolderPermissions(int PortalId, IFolderInfo theFolder, int theUserId, List<UserInfo> approvers)
 {
     // Get the write permission
     PermissionController pc = new PermissionController();
     PermissionInfo w = (PermissionInfo)pc.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "WRITE")[0];
     // Get a list of all the folderPermissions we currently have
     FolderPermissionCollection folderPermissions = theFolder.FolderPermissions;
     // Set up the first permission
     FolderPermissionInfo permission = new FolderPermissionInfo();
     // Set up some default values for the permission
     initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
     // Set the user id to be this user
     permission.UserID = theUserId;
     // Add folder permissions, with a check for duplicates.
     // This duplicate check (the 'True' parameter) will classify this as a "duplicate" if this permission
     // has the same PermissionID, UserID, and RoleID as a pre-existing one, and not add it if it is a duplicate
     folderPermissions.Add(permission, true);
     // Get all the possible approvers for this reimbursement
     try
     {
         foreach (var approver in approvers)
         {
             // Create a new permission for this approver
             permission = new FolderPermissionInfo();
             // Initialize all the variables
             initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
             // Set the userid to the approver's id
             permission.UserID = approver.UserID;
             // Add permission for approver
             folderPermissions.Add(permission, true);
         }
     }
     catch { }
     // Finally, add permissions for the accounts team:
     try
     {
         permission = new FolderPermissionInfo();
         // Initialize new folder permission
         initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
         // Set the role ID
         DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
         permission.RoleID = rc.GetRoleByName(PortalId, "Accounts Team").RoleID;
         folderPermissions.Add(permission, true);
     }
     catch { }
     // Once we're finished adding these folder permissions, save it all
     FolderPermissionController.SaveFolderPermissions(theFolder);
 }
开发者ID:powertochange-org,项目名称:acReimbursements,代码行数:48,代码来源:Filesystem.cs

示例4: UpgradeToVersion601

        private static void UpgradeToVersion601()
        {
            //List module needs to be available to Portals also
            var pkg = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DotNetNuke.Lists");
            if (pkg != null)
            {
                //List package is no longer a system package
                pkg.IsSystemPackage = false;
                PackageController.Instance.SaveExtensionPackage(pkg);

                //List desktop module is no longer premium or admin module
                var desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(pkg.PackageID);
                desktopModule.IsAdmin = false;
                desktopModule.IsPremium = false;
                DesktopModuleController.SaveDesktopModule(desktopModule, false, true);

                var permissionController = new PermissionController();
                ArrayList permissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY");
                if (permissions.Count == 1)
                {
                    var permission = permissions[0] as PermissionInfo;
                    if (permission != null)
                    {
                        foreach (PortalInfo portal in PortalController.Instance.GetPortals())
                        {
                            //ensure desktop module is not present in the portal
                            var pdmi = DesktopModuleController.GetPortalDesktopModule(portal.PortalID, desktopModule.DesktopModuleID);
                            if (pdmi == null)
                            {
                                //Parse the permissions
                                var deployPermissions = new DesktopModulePermissionCollection();
                                var deployPermission = new DesktopModulePermissionInfo { PermissionID = permission.PermissionID, AllowAccess = true, RoleID = portal.AdministratorRoleId };
                                deployPermissions.Add(deployPermission);

                                //Add Portal/Module to PortalDesktopModules
                                DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, true);
                            }
                        }
                    }
                }
            }
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:42,代码来源:Upgrade.cs

示例5: AddNewModule

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a New Module to a Pane
        /// </summary>
        /// <param name="align">The alignment for the Modue</param>
        /// <param name="desktopModuleId">The Id of the DesktopModule</param>
        /// <param name="permissionType">The View Permission Type for the Module</param>
        /// <param name="title">The Title for the resulting module</param>
        /// <param name="paneName">The pane to add the module to</param>
        /// <param name="position">The relative position within the pane for the module</param>
        /// <history>
        /// 	[cnurse]	01/11/2008  documented
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
        {
            TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
            var objPermissionController = new PermissionController();
            try
            {
                DesktopModuleInfo desktopModule;
                if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule))
                {
                    throw new ArgumentException("desktopModuleId");
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
            int UserId = -1;
            if (Request.IsAuthenticated)
            {
                UserInfo objUserInfo = UserController.Instance.GetCurrentUserInfo();
                UserId = objUserInfo.UserID;
            }
            foreach (ModuleDefinitionInfo objModuleDefinition in
                ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.Initialize(PortalSettings.PortalId);
                objModule.PortalID = PortalSettings.PortalId;
                objModule.TabID = PortalSettings.ActiveTab.TabID;
                objModule.ModuleOrder = position;
                if (String.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                if (objModuleDefinition.DefaultCacheTime > 0)
                {
                    objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
                    if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger)
                    {
                        ModuleInfo defaultModule = ModuleController.Instance.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
                        if (defaultModule != null)
                        {
                            objModule.CacheTime = defaultModule.CacheTime;
                        }
                    }
                }
                switch (permissionType)
                {
                    case ViewPermissionType.View:
                        objModule.InheritViewPermissions = true;
                        break;
                    case ViewPermissionType.Edit:
                        objModule.InheritViewPermissions = false;
                        break;
                }
				
                //get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                //get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View)
                    {
						//Don't need to explicitly add View permisisons if "Same As Page"
                        continue;
                    }
					
                    //get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    //loop through the system module permissions
                    int j;
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        PermissionInfo objSystemModulePermission;
                        objSystemModulePermission = (PermissionInfo) arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT")
                        {
							//Only Page Editors get View permissions if "Page Editors Only"
                            continue;
//.........这里部分代码省略.........
开发者ID:rjallepalli,项目名称:PIX_CMS,代码行数:101,代码来源:ControlPanelBase.cs

示例6: OnImportClick

        protected void OnImportClick(object sender, EventArgs e)
        {
            try
            {
                if (cboTemplate.SelectedItem == null || cboTemplate.SelectedValue == "None_Specified")
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyFile", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    return;
                }
                if (optMode.SelectedIndex == -1)
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyMode", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    return;
                }
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + cboFolders.SelectedValue + cboTemplate.SelectedValue);

                var tabNodes = new List<XmlNode>();
                foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes)
                {
                    tabNodes.Add(tabNode);
                }
                if (tabNodes.Count == 0)
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NoTabsInTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    return;
                }

                TabInfo objTab;
                if (optMode.SelectedValue == "ADD")
                {
                    if (string.IsNullOrEmpty(txtTabName.Text))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyName", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }

                    //New Tab
                    objTab = new TabInfo {PortalID = PortalId, TabName = txtTabName.Text, IsVisible = true};
                    if (cboParentTab.SelectedItem != null)
                    {
                        objTab.ParentId = Int32.Parse(cboParentTab.SelectedItem.Value);
                    }
                    objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
                    int tabID = TabController.GetTabByTabPath(objTab.PortalID, objTab.TabPath, Null.NullString);
                    var objTabs = new TabController();

                    //Check if tab exists
                    if (tabID != Null.NullInteger)
                    {
                        TabInfo existingTab = objTabs.GetTab(tabID, PortalId, false);
                        if (existingTab != null && existingTab.IsDeleted)
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                        }
                        else
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        }
                        return;
                    }

                    int positionTabID = Int32.Parse(cboPositionTab.SelectedItem.Value);

                    var pc = new PermissionController();

                    var permission = pc.GetPermissionByCodeAndKey("SYSTEM_TAB", "VIEW");
                    if (permission.Count > 0)
                    {
                        var pid = ((PermissionInfo)permission[0]).PermissionID;
                        objTab.TabPermissions.Add(new TabPermissionInfo { PermissionID = pid, AllowAccess = true, RoleID = 0 });
                    }

                    permission = pc.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");
                    if (permission.Count > 0)
                    {
                        var pid = ((PermissionInfo)permission[0]).PermissionID;
                        objTab.TabPermissions.Add(new TabPermissionInfo { PermissionID = pid, AllowAccess = true, RoleID = 0 });
                    }

                    var objEventLog = new EventLogController();
                    if (rbInsertPosition.SelectedValue == "After" && positionTabID > Null.NullInteger)
                    {
                        objTab.TabID = objTabs.AddTabAfter(objTab, positionTabID);
                    }
                    else if (rbInsertPosition.SelectedValue == "Before" && positionTabID > Null.NullInteger)
                    {
                        objTab.TabID = objTabs.AddTabBefore(objTab, positionTabID);
                    }
                    else
                    {
                        objTab.TabID = objTabs.AddTab(objTab);
                    }
                    objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED);

                    //Update Tab properties from template - for the first tab only
                    objTab = TabController.DeserializeTab(tabNodes[0], objTab, PortalId, PortalTemplateModuleAction.Replace);

                    var exceptions = string.Empty;
                    //Create second tabs onwards. For firs tab, we like to use tab details from text box, for rest it'll come from template
//.........这里部分代码省略.........
开发者ID:rcedev,项目名称:evans-software-solutions,代码行数:101,代码来源:Import.ascx.cs

示例7: DeserializeModulePermissions

        private static void DeserializeModulePermissions(XmlNodeList nodeModulePermissions, int portalId, ModuleInfo module)
        {
            var permissionController = new PermissionController();
            foreach (XmlNode node in nodeModulePermissions)
            {
                string permissionKey = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissionkey");
                string permissionCode = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissioncode");
                string roleName = XmlUtils.GetNodeValue(node.CreateNavigator(), "rolename");
                int roleID = int.MinValue;
                switch (roleName)
                {
                    case Globals.glbRoleAllUsersName:
                        roleID = Convert.ToInt32(Globals.glbRoleAllUsers);
                        break;
                    case Globals.glbRoleUnauthUserName:
                        roleID = Convert.ToInt32(Globals.glbRoleUnauthUser);
                        break;
                    default:
                        var role = TestableRoleController.Instance.GetRole(portalId, r => r.RoleName == roleName);
                        if (role != null)
                        {
                            roleID = role.RoleID;
                        }
                        break;
                }
                if (roleID != int.MinValue)
                {
                    int permissionID = -1;
                    ArrayList permissions = permissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);
                    for (int i = 0; i <= permissions.Count - 1; i++)
                    {
                        var permission = (PermissionInfo)permissions[i];
                        permissionID = permission.PermissionID;
                    }

                    //if role was found add, otherwise ignore
                    if (permissionID != -1)
                    {
                        var modulePermission = new ModulePermissionInfo
                        {
                            ModuleID = module.ModuleID,
                            PermissionID = permissionID,
                            RoleID = roleID,
                            AllowAccess = Convert.ToBoolean(XmlUtils.GetNodeValue(node.CreateNavigator(), "allowaccess"))
                        };

                        // do not add duplicate ModulePermissions
                        bool canAdd = !module.ModulePermissions.Cast<ModulePermissionInfo>()
                                                    .Any(mp => mp.ModuleID == modulePermission.ModuleID
                                                            && mp.PermissionID == modulePermission.PermissionID
                                                            && mp.RoleID == modulePermission.RoleID
                                                            && mp.UserID == modulePermission.UserID);
                        if (canAdd)
                        {
                            module.ModulePermissions.Add(modulePermission);
                        }
                    }
                }
            }
        }
开发者ID:rajeshvar,项目名称:Dnn.Platform,代码行数:60,代码来源:ModuleController.cs

示例8: ParseModulePermissions

        private void ParseModulePermissions( XmlNodeList nodeModulePermissions, int PortalId, int ModuleID )
        {
            RoleController objRoleController = new RoleController();
            RoleInfo objRole = null;
            ModulePermissionCollection objModulePermissions = new ModulePermissionCollection();
            ModulePermissionController objModulePermissionController = new ModulePermissionController();
            PermissionController objPermissionController = new PermissionController();
            PermissionInfo objPermission = null;
            ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection();
            int PermissionID = 0;
            ArrayList arrPermissions = null;
            int i = 0;
            string PermissionKey = null;
            string PermissionCode = null;
            string RoleName = null;
            int RoleID = 0;
            bool AllowAccess = false;

            foreach( XmlNode node in nodeModulePermissions )
            {
                PermissionKey = XmlUtils.GetNodeValue( node, "permissionkey", "" );
                PermissionCode = XmlUtils.GetNodeValue( node, "permissioncode", "" );
                RoleName = XmlUtils.GetNodeValue( node, "rolename", "" );
                AllowAccess = XmlUtils.GetNodeValueBoolean( node, "allowaccess", false );

                RoleID = int.MinValue;
                if( RoleName == Globals.glbRoleAllUsersName )
                {
                    RoleID = Convert.ToInt32( Globals.glbRoleAllUsers );
                }
                else if( RoleName == Globals.glbRoleUnauthUserName )
                {
                    RoleID = Convert.ToInt32( Globals.glbRoleUnauthUser );
                }
                else
                {
                    objRole = objRoleController.GetRoleByName( PortalId, RoleName );
                    if( objRole != null )
                    {
                        RoleID = objRole.RoleID;
                    }
                }
                if( RoleID != int.MinValue )
                {
                    PermissionID = -1;
                    arrPermissions = objPermissionController.GetPermissionByCodeAndKey( PermissionCode, PermissionKey );

                    for( i = 0; i < arrPermissions.Count; i++ )
                    {
                        objPermission = (PermissionInfo)( arrPermissions[i] );
                        PermissionID = objPermission.PermissionID;
                    }

                    // if role was found add, otherwise ignore
                    if( PermissionID != -1 )
                    {
                        ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
                        objModulePermission.ModuleID = ModuleID;
                        objModulePermission.PermissionID = PermissionID;
                        objModulePermission.RoleID = RoleID;
                        objModulePermission.AllowAccess = Convert.ToBoolean( XmlUtils.GetNodeValue( node, "allowaccess", "false" ) );
                        objModulePermissionController.AddModulePermission( objModulePermission );
                    }
                }
            }
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:66,代码来源:PortalController.cs

示例9: AddModulePermission

 private static void AddModulePermission(ModulePermissionCollection permissions, string key, int roleId)
 {
     var permissionController = new PermissionController();
     var permission = (PermissionInfo)permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", key)[0];
     var modulePermission = new ModulePermissionInfo { PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true };
     permissions.Add(modulePermission);
 }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:7,代码来源:PermissionTests.cs

示例10: GiveTranslatorRoleEditRights

        /// <summary>
        /// Gives the translator role edit rights.
        /// </summary>
        /// <param name="localizedTab">The localized tab.</param>
        /// <param name="users">The users.</param>
        public void GiveTranslatorRoleEditRights(TabInfo localizedTab, Dictionary<int, UserInfo> users)
        {
            var roleCtrl = new RoleController();
            var permissionCtrl = new PermissionController();
            ArrayList permissionsList = permissionCtrl.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");

            string translatorRoles =
                PortalController.GetPortalSetting(
                    string.Format("DefaultTranslatorRoles-{0}", localizedTab.CultureCode), localizedTab.PortalID, "");
            foreach (string translatorRole in translatorRoles.Split(';'))
            {
                if (users != null)
                {
                    foreach (UserInfo translator in roleCtrl.GetUsersByRoleName(localizedTab.PortalID, translatorRole))
                    {
                        users[translator.UserID] = translator;
                    }
                }

                if (permissionsList != null && permissionsList.Count > 0)
                {
                    var translatePermisison = (PermissionInfo)permissionsList[0];
                    string roleName = translatorRole;
                    RoleInfo role = TestableRoleController.Instance.GetRole(localizedTab.PortalID,
                                                                            r => r.RoleName == roleName);
                    if (role != null)
                    {
                        TabPermissionInfo perm =
                            localizedTab.TabPermissions.Where(
                                tp => tp.RoleID == role.RoleID && tp.PermissionKey == "EDIT").SingleOrDefault();
                        if (perm == null)
                        {
                            //Create Permission
                            var tabTranslatePermission = new TabPermissionInfo(translatePermisison)
                                {
                                    RoleID = role.RoleID,
                                    AllowAccess = true,
                                    RoleName = roleName
                                };
                            localizedTab.TabPermissions.Add(tabTranslatePermission);
                            UpdateTab(localizedTab);
                        }
                    }
                }
            }
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:51,代码来源:TabController.cs

示例11: DeserializeTabPermissions

        private static void DeserializeTabPermissions(XmlNodeList nodeTabPermissions, TabInfo tab, bool isAdminTemplate)
        {
            var permissionController = new PermissionController();
            int permissionID = 0;
            foreach (XmlNode tabPermissionNode in nodeTabPermissions)
            {
                string permissionKey = XmlUtils.GetNodeValue(tabPermissionNode.CreateNavigator(), "permissionkey");
                string permissionCode = XmlUtils.GetNodeValue(tabPermissionNode.CreateNavigator(), "permissioncode");
                string roleName = XmlUtils.GetNodeValue(tabPermissionNode.CreateNavigator(), "rolename");
                bool allowAccess = XmlUtils.GetNodeValueBoolean(tabPermissionNode, "allowaccess");
                ArrayList arrPermissions = permissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);
                int i;
                for (i = 0; i <= arrPermissions.Count - 1; i++)
                {
                    var permission = (PermissionInfo)arrPermissions[i];
                    permissionID = permission.PermissionID;
                }
                int roleID = int.MinValue;
                switch (roleName)
                {
                    case Globals.glbRoleAllUsersName:
                        roleID = Convert.ToInt32(Globals.glbRoleAllUsers);
                        break;
                    case Globals.glbRoleUnauthUserName:
                        roleID = Convert.ToInt32(Globals.glbRoleUnauthUser);
                        break;
                    default:
                        var portalController = new PortalController();
                        PortalInfo portal = portalController.GetPortal(tab.PortalID);
                        RoleInfo role = TestableRoleController.Instance.GetRole(portal.PortalID,
                                                                                r => r.RoleName == roleName);
                        if (role != null)
                        {
                            roleID = role.RoleID;
                        }
                        else
                        {
                            if (isAdminTemplate && roleName.ToLower() == "administrators")
                            {
                                roleID = portal.AdministratorRoleId;
                            }
                        }
                        break;
                }
                if (roleID != int.MinValue)
                {
                    var tabPermission = new TabPermissionInfo
                        {
                            TabID = tab.TabID,
                            PermissionID = permissionID,
                            RoleID = roleID,
                            UserID = Null.NullInteger,
                            AllowAccess = allowAccess
                        };

                    bool canAdd = !tab.TabPermissions.Cast<TabPermissionInfo>()
                                      .Any(tp => tp.TabID == tabPermission.TabID
                                                 && tp.PermissionID == tabPermission.PermissionID
                                                 && tp.RoleID == tabPermission.RoleID
                                                 && tp.UserID == tabPermission.UserID);
                    if (canAdd)
                    {
                        tab.TabPermissions.Add(tabPermission);
                    }
                }
            }
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:67,代码来源:TabController.cs

示例12: AddNewModule

        protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
        {

            TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
            PermissionController objPermissionController = new PermissionController();
            ModuleController objModules = new ModuleController();
            ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
            Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
            int intIndex;

            try
            {
                DesktopModuleController objDesktopModules = new DesktopModuleController();
                ArrayList arrDM = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId);
                bool isSelectable = false;
                for (int intloop = 0; intloop < arrDM.Count; intloop++)
                {
                    if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId)
                    {
                        isSelectable = true;
                        break;
                    }
                }
                if (isSelectable == false)
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            int UserId = -1;
            if (Request.IsAuthenticated)
            {
                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                UserId = objUserInfo.UserID;
            }

            ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId);
            for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++)
            {
                ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]);

                

                ModuleInfo objModule = new ModuleInfo();
                objModule.Initialize(PortalSettings.PortalId);

                objModule.PortalID = PortalSettings.PortalId;
                objModule.TabID = PortalSettings.ActiveTab.TabID;
                objModule.ModuleOrder = position;
                if (String.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }

                objModule.ModuleTitle = title;
                objModule.PaneName = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                objModule.CacheTime = objModuleDefinition.DefaultCacheTime;

                // initialize module permissions
                ModulePermissionCollection objModulePermissions = new ModulePermissionCollection();
                objModule.ModulePermissions = objModulePermissions;
                objModule.InheritViewPermissions = false;

                // get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                // get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    // get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    // loop through the system module permissions
                    int j;
                    for (j = 0; j < arrSystemModulePermissions.Count; j++)
                    {
                        // create the module permission
                        PermissionInfo objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]);
                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID);

                        // add the permission to the collection
                        if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess)
                        {
                            objModulePermissions.Add(objModulePermission);
                        }

                        // ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo();
                            objModuleViewperm.ModuleID = objModulePermission.ModuleID;
                            objModuleViewperm.PermissionID = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID;
//.........这里部分代码省略.........
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:101,代码来源:ControlPanelBase.ascx.cs

示例13: AddPagePermission

        /// <summary>
        /// AddPagePermission adds a TabPermission to a TabPermission Collection
        /// </summary>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        ///	<param name="key">The Permission key</param>
        ///	<param name="roleId">The role given the permission</param>
        private static void AddPagePermission(ref TabPermissionCollection permissions, string key, int roleId)
        {
            PermissionController objPermissionController = new PermissionController();
            PermissionInfo objPermission = (PermissionInfo)objPermissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", key)[0];

            TabPermissionInfo objTabPermission = new TabPermissionInfo();
            objTabPermission.PermissionID = objPermission.PermissionID;
            objTabPermission.RoleID = roleId;
            objTabPermission.AllowAccess = true;
            permissions.Add(objTabPermission);
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:17,代码来源:Upgrade.cs

示例14: CreateCustomPermissions

        /// <summary>Creates the custom permissions for the module.  Expected to be called once from <see cref="FeaturesController.UpgradeModule"/></summary>
        /// <remarks>based on <see href="http://www.codeproject.com/KB/aspnet/dnn_custom_permissions.aspx"/> </remarks>
        /// <returns>A status message for <see cref="IUpgradeable.UpgradeModule"/></returns>
        public static string CreateCustomPermissions()
        {
            var permissionController = new PermissionController();
            var existingPermissions = permissionController.GetPermissionByCodeAndKey(EngageEventsCustomPermissionsCode, ManageEventsCustomPermissionKey);
            if (existingPermissions != null && existingPermissions.Cast<PermissionInfo>().Any())
            {
                return "Engage: Events custom permissions were already created (presumably by DNN 5 manifest), no upgrade action taken";
            }

            var eventsDesktopModules = new DesktopModuleController().GetDesktopModuleByModuleName(Utility.DesktopModuleName);
            var moduleDefinition = new ModuleDefinitionController().GetModuleDefinitionByName(
                eventsDesktopModules.DesktopModuleID,
                Utility.ModuleDefinitionFriendlyName);

            permissionController.AddPermission(new PermissionInfo
                {
                    PermissionCode = EngageEventsCustomPermissionsCode,
                    PermissionKey = ManageEventsCustomPermissionKey,
                    PermissionName = "Manage Events",
                    ModuleDefID = moduleDefinition.ModuleDefID
                });
            permissionController.AddPermission(new PermissionInfo
                {
                    PermissionCode = EngageEventsCustomPermissionsCode,
                    PermissionKey = ManageCategoriesCustomPermissionKey,
                    PermissionName = "Manage Categories",
                    ModuleDefID = moduleDefinition.ModuleDefID
                });
            permissionController.AddPermission(new PermissionInfo
                {
                    PermissionCode = EngageEventsCustomPermissionsCode,
                    PermissionKey = ManageDisplayCustomPermissionKey,
                    PermissionName = "Manage Display",
                    ModuleDefID = moduleDefinition.ModuleDefID
                });
            permissionController.AddPermission(new PermissionInfo
                {
                    PermissionCode = EngageEventsCustomPermissionsCode,
                    PermissionKey = ViewResponsesCustomPermissionKey,
                    PermissionName = "View Responses",
                    ModuleDefID = moduleDefinition.ModuleDefID
                });

            return "Created custom permissions for category management in Engage: Events";
        }
开发者ID:JoshuaBradley,项目名称:Engage-Events,代码行数:48,代码来源:PermissionsService.cs

示例15: DeserializeModulePermissions

        static void DeserializeModulePermissions(XmlNodeList nodeModulePermissions, int portalId, ModuleInfo module)
        {
            var objRoleController = new RoleController();
            var objPermissionController = new PermissionController();

            foreach (XmlNode node in nodeModulePermissions)
            {
                var permissionKey = XmlUtils.GetNodeValue(node, "permissionkey", "");
                var permissionCode = XmlUtils.GetNodeValue(node, "permissioncode", "");
                var roleName = XmlUtils.GetNodeValue(node, "rolename", "");
                var allowAccess = XmlUtils.GetNodeValueBoolean(node, "allowaccess");

                var roleId = int.MinValue;
                switch (roleName)
                {
                    case Globals.glbRoleAllUsersName:
                        roleId = Convert.ToInt32(Globals.glbRoleAllUsers);
                        break;
                    case Globals.glbRoleUnauthUserName:
                        roleId = Convert.ToInt32(Globals.glbRoleUnauthUser);
                        break;
                    default:
                        var objRole = objRoleController.GetRoleByName(portalId, roleName);
                        if (objRole != null)
                        {
                            roleId = objRole.RoleID;
                        }
                        break;
                }
                if (roleId != int.MinValue)
                {
                    var permissionId = Convert.ToInt32(- 1);
                    var arrPermissions = objPermissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);

                    int i;
                    for (i = 0; i <= arrPermissions.Count - 1; i++)
                    {
                        var permission = (PermissionInfo) (arrPermissions[i]);
                        permissionId = permission.PermissionID;
                    }

                    // if role was found add, otherwise ignore
                    if (permissionId != - 1)
                    {
                        var modulePermission = new ModulePermissionInfo
                                                   {
                                                       ModuleID = module.ModuleID,
                                                       PermissionID = permissionId,
                                                       RoleID = roleId,
                                                       AllowAccess = allowAccess
                                                   };
                        module.ModulePermissions.Add(modulePermission);
                    }
                }
            }
        }
开发者ID:DNNCommunity,项目名称:DNN.FormAndList,代码行数:56,代码来源:ModuleSerializationController.cs


注:本文中的DotNetNuke.Security.Permissions.PermissionController.GetPermissionByCodeAndKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。