• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Permissions.PermissionController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PermissionController类属于DotNetNuke.Security.Permissions命名空间,在下文中一共展示了PermissionController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: AddModuleToPage

        /// <summary>
        /// Adds the module to page.
        /// </summary>
        /// <param name="portalId">The portal id.</param>
        /// <param name="tabId">The tab id.</param>
        /// <exception cref="System.ArgumentException">desktopModuleId</exception>
        private void AddModuleToPage(int portalId, int tabId)
        {
            TabPermissionCollection objTabPermissions = new TabController().GetTab(tabId, portalId, false).TabPermissions;
            var objPermissionController = new PermissionController();
            var objModules = new ModuleController();
            new EventLogController();

            int desktopModuleId =
                DesktopModuleController.GetDesktopModuleByFriendlyName("VanityURLs").DesktopModuleID;

            try
            {
                DesktopModuleInfo desktopModule;
                if (!DesktopModuleController.GetDesktopModules(portalId).TryGetValue(desktopModuleId, out desktopModule))
                {
                    throw new ArgumentException("desktopModuleId");
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }

            foreach (ModuleDefinitionInfo objModuleDefinition in
                ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.PortalID = portalId;
                objModule.TabID = tabId;
                objModule.ModuleOrder = 0;
                objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                objModule.PaneName = "ContentPane";
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                objModule.InheritViewPermissions = true;
                objModule.CultureCode = Null.NullString;
                objModule.AllTabs = false;
                objModules.AddModule(objModule);
            }
        }
开发者ID:jsheely,项目名称:DotNetNuke-VanityUrls,代码行数:45,代码来源:DNNController.cs


示例5: InitialModulePermission

		public void InitialModulePermission(ModuleInfo module, int tabId, int permissionType)
		{
			var tabPermissions = TabPermissionController.GetTabPermissions(tabId, module.PortalID);
            var permissionController = new PermissionController();

            module.InheritViewPermissions = permissionType == 0;

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

            // get the permissions from the page
			foreach (TabPermissionInfo tabPermission in tabPermissions)
			{
				if (tabPermission.PermissionKey == "VIEW" && permissionType == 0)
				{
					//Don't need to explicitly add View permisisons if "Same As Page"
					continue;
				}

				// get the system module permissions for the permissionkey
				ArrayList systemModulePermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", tabPermission.PermissionKey);
				// loop through the system module permissions
				int j;
				for (j = 0; j <= systemModulePermissions.Count - 1; j++)
				{
					// create the module permission
					var systemModulePermission = (PermissionInfo) systemModulePermissions[j];
					if (systemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && tabPermission.PermissionKey != "EDIT")
					{
						//Only Page Editors get View permissions if "Page Editors Only"
						continue;
					}

					ModulePermissionInfo modulePermission = AddModulePermission(module, systemModulePermission, tabPermission.RoleID, tabPermission.UserID, tabPermission.AllowAccess);

					// ensure that every EDIT permission which allows access also provides VIEW permission
					if (modulePermission.PermissionKey == "EDIT" && modulePermission.AllowAccess)
					{
						AddModulePermission(module, (PermissionInfo) systemModuleViewPermissions[0], modulePermission.RoleID, modulePermission.UserID, true);
					}
				}

				//Get the custom Module Permissions,  Assume that roles with Edit Tab Permissions
				//are automatically assigned to the Custom Module Permissions
				if (tabPermission.PermissionKey == "EDIT")
				{
					ArrayList customModulePermissions = permissionController.GetPermissionsByModuleDefID(module.ModuleDefID);

					// loop through the custom module permissions
					for (j = 0; j <= customModulePermissions.Count - 1; j++)
					{
						// create the module permission
						var customModulePermission = (PermissionInfo)customModulePermissions[j];

						AddModulePermission(module, customModulePermission, tabPermission.RoleID, tabPermission.UserID, tabPermission.AllowAccess);
					}
				}
			}
		}
开发者ID:rajeshvar,项目名称:Dnn.Platform,代码行数:59,代码来源:ModuleController.cs


示例6: 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


示例7: ParsePortalDesktopModules

 private static void ParsePortalDesktopModules(XPathNavigator nav, int portalID)
 {
     string friendlyName = Null.NullString;
     DesktopModuleInfo desktopModule = null;
     foreach (XPathNavigator desktopModuleNav in nav.Select("portalDesktopModule"))
     {
         friendlyName = XmlUtils.GetNodeValue(desktopModuleNav, "friendlyname");
         if (!string.IsNullOrEmpty(friendlyName))
         {
             desktopModule = DesktopModuleController.GetDesktopModuleByFriendlyName(friendlyName);
             if (desktopModule != null)
             {
                 //Parse the permissions
                 DesktopModulePermissionCollection permissions = new DesktopModulePermissionCollection();
                 foreach (XPathNavigator permissionNav in
                     desktopModuleNav.Select("portalDesktopModulePermissions/portalDesktopModulePermission"))
                 {
                     string code = XmlUtils.GetNodeValue(permissionNav, "permissioncode");
                     string key = XmlUtils.GetNodeValue(permissionNav, "permissionkey");
                     DesktopModulePermissionInfo desktopModulePermission = null;
                     ArrayList arrPermissions = new PermissionController().GetPermissionByCodeAndKey(code, key);
                     if (arrPermissions.Count > 0)
                     {
                         PermissionInfo permission = arrPermissions[0] as PermissionInfo;
                         if (permission != null)
                         {
                             desktopModulePermission = new DesktopModulePermissionInfo(permission);
                         }
                     }
                     desktopModulePermission.AllowAccess = bool.Parse(XmlUtils.GetNodeValue(permissionNav, "allowaccess"));
                     string rolename = XmlUtils.GetNodeValue(permissionNav, "rolename");
                     if (!string.IsNullOrEmpty(rolename))
                     {
                         RoleInfo role = TestableRoleController.Instance.GetRole(portalID, r => r.RoleName == rolename);
                         if (role != null)
                         {
                             desktopModulePermission.RoleID = role.RoleID;
                         }
                     }
                     permissions.Add(desktopModulePermission);
                 }
                 DesktopModuleController.AddDesktopModuleToPortal(portalID, desktopModule, permissions, false);
             }
         }
     }
 }
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:46,代码来源:PortalController.cs


示例8: 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


示例9: UpgradeModule

        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                    case "01.00.00":
                        ModuleDefinitionInfo moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Messaging");

                        if (moduleDefinition != null)
                        {
                            //Add Module to User Profile Page for all Portals
                            var objPortalController = new PortalController();
                            var objTabController = new TabController();
                            var objModuleController = new ModuleController();

                            ArrayList portals = objPortalController.GetPortals();
                            foreach (PortalInfo portal in portals)
                            {
                                int tabID = TabController.GetTabByTabPath(portal.PortalID, "//UserProfile", Null.NullString);
                                if ((tabID != Null.NullInteger))
                                {
                                    TabInfo tab = objTabController.GetTab(tabID, portal.PortalID, true);
                                    if ((tab != null))
                                    {
                                        int moduleId = Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "My Inbox", "", true);
                                        ModuleInfo objModule = objModuleController.GetModule(moduleId, tabID, false);

                                        var settings = new PortalSettings(portal);

                                        var modulePermission = (from ModulePermissionInfo p in objModule.ModulePermissions
                                                                where p.ModuleID == moduleId
                                                                   && p.RoleID == settings.RegisteredRoleId
                                                                   && p.UserID == Null.NullInteger
                                                                   && p.PermissionKey == "EDIT"
                                                                select p).SingleOrDefault();

                                        if (modulePermission == null)
                                        {
                                            ArrayList permissions = new PermissionController().GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "EDIT");
                                            PermissionInfo permission = null;
                                            if (permissions.Count == 1)
                                            {
                                                permission = permissions[0] as PermissionInfo;
                                            }
                                            if (permission != null)
                                            {
                                                modulePermission = new ModulePermissionInfo(permission)
                                                                            {
                                                                                ModuleID = moduleId,
                                                                                RoleID = settings.RegisteredRoleId,
                                                                                UserID = Null.NullInteger,
                                                                                AllowAccess = true
                                                                            };


                                                objModule.ModulePermissions.Add(modulePermission);

                                                ModulePermissionController.SaveModulePermissions(objModule);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                }
                return "Success";
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

                return "Failed";
            }
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:76,代码来源:MessagingBusinessController.cs


示例10: DeserializeTabPermissions

        public static void DeserializeTabPermissions(XmlNodeList nodeTabPermissions, TabInfo tab)
        {
            var permissionController = new PermissionController();
            foreach (XmlNode xmlTabPermission in nodeTabPermissions)
            {
                var permissionKey = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissionkey");
                var permissionCode = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissioncode");
                var roleName = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "rolename");
                var allowAccess = XmlUtils.GetNodeValueBoolean(xmlTabPermission, "allowaccess");
                var permissions = permissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);
                var permissionId = permissions.Cast<PermissionInfo>().Last().PermissionID;

                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 portal = PortalController.Instance.GetPortal(tab.PortalID);
                        var role = RoleController.Instance.GetRole(portal.PortalID, r => r.RoleName == roleName);
                        if (role != null)
                        {
                            roleId = role.RoleID;
                        }
                        break;
                }
                if (roleId != int.MinValue &&
                        !tab.TabPermissions.Cast<TabPermissionInfo>().Any(p =>
                                                                            p.RoleID == roleId
                                                                            && p.PermissionID == permissionId))
                {
                    var tabPermission = new TabPermissionInfo
                    {
                        TabID = tab.TabID,
                        PermissionID = permissionId,
                        RoleID = roleId,
                        AllowAccess = allowAccess
                    };

                    tab.TabPermissions.Add(tabPermission);
                }
            }

            TabController.Instance.UpdateTab(tab);
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:49,代码来源:RibbonBarManager.cs


示例11: 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


示例12: SetFolderPermissions

 /// <summary>
 /// Sets a Folders Permissions
 /// </summary>
 /// <param name="PortalId">The Id of the Portal</param>
 /// <param name="FolderId">The Id of the Folder</param>
 /// <param name="AdministratorRoleId">The Id of the Administrator Role</param>
 /// <param name="relativePath">The folder's Relative Path</param>
 /// <remarks>
 /// </remarks>
 public static void SetFolderPermissions( int PortalId, int FolderId, int AdministratorRoleId, string relativePath )
 {
     //Set Permissions
     PermissionController objPermissionController = new PermissionController();
     ArrayList Permissions = objPermissionController.GetPermissionsByFolder( PortalId, "" );
     foreach( PermissionInfo objPermssionsInfo in Permissions )
     {
         SetFolderPermission( PortalId, FolderId, objPermssionsInfo.PermissionID, AdministratorRoleId, relativePath );
     }
 }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:19,代码来源:FileSystemUtils.cs


示例13: DoAddExistingModule

        private int DoAddExistingModule(int moduleId, int tabId, string paneName, int position, string align, bool cloneModule)
        {
            var moduleCtrl = new ModuleController();
            ModuleInfo moduleInfo = moduleCtrl.GetModule(moduleId, tabId, false);

            int userID = -1;
          
            UserInfo user = UserController.GetCurrentUserInfo();
            if (user != null)
            {
                userID = user.UserID;
            }
            

            if ((moduleInfo != null))
            {
                // Is this from a site other than our own? (i.e., is the user requesting "module sharing"?)
                var remote = moduleInfo.PortalID != PortalSettings.Current.PortalId;
                if (remote)
                {
                    switch (moduleInfo.DesktopModule.Shareable)
                    {
                        case ModuleSharing.Unsupported:
                            // Should never happen since the module should not be listed in the first place.
                            throw new ApplicationException(string.Format("Module '{0}' does not support Shareable and should not be listed in Add Existing Module from a different source site",
                                                                         moduleInfo.DesktopModule.FriendlyName));
                        case ModuleSharing.Supported:
                            break;
                        case ModuleSharing.Unknown:
                            break;
                    }
                }

                // clone the module object ( to avoid creating an object reference to the data cache )
                ModuleInfo newModule = moduleInfo.Clone();

                newModule.UniqueId = Guid.NewGuid(); // Cloned Module requires a different uniqueID

                newModule.TabID = PortalSettings.Current.ActiveTab.TabID;
                newModule.ModuleOrder = position;
                newModule.PaneName = paneName;
                newModule.Alignment = align;

                if ((cloneModule))
                {
                    newModule.ModuleID = Null.NullInteger;
                    //reset the module id
                    newModule.ModuleID = moduleCtrl.AddModule(newModule);

                    if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass))
                    {
                        object objObject = DotNetNuke.Framework.Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass);
                        if (objObject is IPortable)
                        {
                            string content = Convert.ToString(((IPortable)objObject).ExportModule(moduleId));
                            if (!string.IsNullOrEmpty(content))
                            {
                                ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, userID);
                            }
                        }
                    }
                }
                else
                {
                    moduleCtrl.AddModule(newModule);
                }

                if (remote)
                {
                    //Ensure the Portal Admin has View rights
                    var permissionController = new PermissionController();
                    ArrayList arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
                    AddModulePermission(newModule,
                                    (PermissionInfo)arrSystemModuleViewPermissions[0],
                                    PortalSettings.Current.AdministratorRoleId,
                                    Null.NullInteger,
                                    true);

                    //Set PortalID correctly
                    newModule.OwnerPortalID = newModule.PortalID;
                    newModule.PortalID = PortalSettings.Current.PortalId;
                    ModulePermissionController.SaveModulePermissions(newModule);
                }

                //Add Event Log
                var objEventLog = new EventLogController();
                objEventLog.AddLog(newModule, PortalSettings.Current, userID, "", EventLogController.EventLogType.MODULE_CREATED);

                return newModule.ModuleID;
            }

            return -1;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:93,代码来源:ControlBarController.cs


示例14: AddNewModule

        private int AddNewModule(TabInfo tab, string title, int desktopModuleId, string paneName, int permissionType, string align)
        {
            TabPermissionCollection objTabPermissions = tab.TabPermissions;
            var objPermissionController = new PermissionController();
            var objModules = new ModuleController();
            int j;
            var mdc = new ModuleDefinitionController();

            foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.Initialize(tab.PortalID);

                objModule.PortalID = tab.PortalID;
                objModule.TabID = tab.TabID;
                if (string.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                objModule.CacheTime = 0;
                objModule.InheritViewPermissions = true;
                objModule.DisplayTitle = 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)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0)
                    {
                        //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
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        // create the module permission
                        PermissionInfo objSystemModulePermission = default(PermissionInfo);
                        objSystemModulePermission = (PermissionInfo) arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT")
                        {
                            //Only Page Editors get View permissions if "Page Editors Only"
                            continue;
                        }

                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule,
                                                                                       objSystemModulePermission,
                                                                                       objTabPermission.RoleID,
                                                                                       objTabPermission.UserID,
                                                                                       objTabPermission.AllowAccess);

                        // ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule,
                                                                                         (PermissionInfo) arrSystemModuleViewPermissions[0],
                                                                                         objModulePermission.RoleID,
                                                                                         objModulePermission.UserID,
                                                                                         true);
                    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Roles.RoleController类代码示例发布时间:2022-05-24
下一篇:
C# Security.PortalSecurity类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap