コード例 #1
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Constructs a new ModulePermissionInfo
 /// </summary>
 /// <param name="permission">A PermissionInfo object</param>
 /// <history>
 /// 	[cnurse]	01/14/2008   Documented
 /// </history>
 /// -----------------------------------------------------------------------------
 public ModulePermissionInfo(PermissionInfo permission) : this()
 {
     ModuleDefID = permission.ModuleDefID;
     PermissionCode = permission.PermissionCode;
     PermissionID = permission.PermissionID;
     PermissionKey = permission.PermissionKey;
     PermissionName = permission.PermissionName;
 }
コード例 #2
0
        public int AddPermission(PermissionInfo objPermission)
        {
            var objEventLog = new EventLogController();

            objEventLog.AddLog(objPermission, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PERMISSION_CREATED);
            return
                (Convert.ToInt32(provider.AddPermission(objPermission.PermissionCode,
                                                        objPermission.ModuleDefID,
                                                        objPermission.PermissionKey,
                                                        objPermission.PermissionName,
                                                        UserController.GetCurrentUserInfo().UserID)));
        }
コード例 #3
0
        public void UpdatePermission(PermissionInfo objPermission)
        {
            var objEventLog = new EventLogController();

            objEventLog.AddLog(objPermission, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PERMISSION_UPDATED);
            provider.UpdatePermission(objPermission.PermissionID,
                                      objPermission.PermissionCode,
                                      objPermission.ModuleDefID,
                                      objPermission.PermissionKey,
                                      objPermission.PermissionName,
                                      UserController.GetCurrentUserInfo().UserID);
        }
コード例 #4
0
        public int AddPermission(PermissionInfo permission)
        {
            EventLogController.Instance.AddLog(permission, PortalController.Instance.GetCurrentPortalSettings(), UserController.Instance.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PERMISSION_CREATED);
            var permissionId = Convert.ToInt32(provider.AddPermission(permission.PermissionCode,
                                                                      permission.ModuleDefID,
                                                                      permission.PermissionKey,
                                                                      permission.PermissionName,
                                                                      UserController.Instance.GetCurrentUserInfo().UserID));

            ClearCache();
            return(permissionId);
        }
コード例 #5
0
 public void UpdatePermission(PermissionInfo permission)
 {
     EventLogController.Instance.AddLog(permission, PortalController.Instance.GetCurrentPortalSettings(), UserController.Instance.GetCurrentUserInfo().UserID, string.Empty, EventLogController.EventLogType.PERMISSION_UPDATED);
     provider.UpdatePermission(
         permission.PermissionID,
         permission.PermissionCode,
         permission.ModuleDefID,
         permission.PermissionKey,
         permission.PermissionName,
         UserController.Instance.GetCurrentUserInfo().UserID);
     this.ClearCache();
 }
コード例 #6
0
ファイル: Upgrade.cs プロジェクト: VegasoftTI/Dnn.Platform
        private static void AddManageUsersModulePermissions()
        {
           var permCtl = new PermissionController();
           var desktopInfo = DesktopModuleController.GetDesktopModuleByModuleName("Security", Null.NullInteger);
            //add new user dialog
            var md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("User Account", desktopInfo.DesktopModuleID);
               try
                   {
                   var pi = new PermissionInfo
                   {
                       ModuleDefID = md.ModuleDefID,
                       PermissionCode = "SECURITY_MODULE",
                       PermissionKey = "MANAGEUSER",
                       PermissionName = "Manage User"
                   };

                       permCtl.AddPermission(pi);

                     }
                catch
                {
                    //suppress
                }
               md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("User Accounts", desktopInfo.DesktopModuleID);
               try
               {
                   var pi = new PermissionInfo
                   {
                       ModuleDefID = md.ModuleDefID,
                       PermissionCode = "SECURITY_MODULE",
                       PermissionKey = "MANAGEUSERS",
                       PermissionName = "Manage Users"
                   };

                   permCtl.AddPermission(pi);

               }
               catch
               {
                   //suppress
               }
               md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Security Roles", desktopInfo.DesktopModuleID);
               try
               {
                   var pi = new PermissionInfo
                   {
                       ModuleDefID = md.ModuleDefID,
                       PermissionCode = "SECURITY_MODULE",
                       PermissionKey = "MANAGEROLES",
                       PermissionName = "Manage Roles"
                   };

                   permCtl.AddPermission(pi);

               }
               catch
               {
                   //suppress
               }
            
        }
コード例 #7
0
ファイル: FileSystemUtils.cs プロジェクト: biganth/Curt
 public static void AddAllUserReadPermission(FolderInfo folder, PermissionInfo permission)
 {
     FolderManager.Instance.AddAllUserReadPermission(folder, permission);
 }
コード例 #8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a Module Permission
        /// </summary>
        /// <param name="objModule">Module Info</param>
        /// <param name="permission">The permission to add</param>
        /// <param name="roleId">The Id of the role to add the permission for.</param>
        /// <param name="userId">Operator</param>
        /// <param name="allowAccess">Whether allow to access the module</param>
        /// <history>
        /// 	[cnurse]	01/11/2008  documented
        /// </history>
        /// -----------------------------------------------------------------------------
        private ModulePermissionInfo AddModulePermission(ModuleInfo objModule, PermissionInfo permission, int roleId, int userId, bool allowAccess)
        {
            var objModulePermission = new ModulePermissionInfo();
            objModulePermission.ModuleID = objModule.ModuleID;
            objModulePermission.PermissionID = permission.PermissionID;
            objModulePermission.RoleID = roleId;
            objModulePermission.UserID = userId;
            objModulePermission.PermissionKey = permission.PermissionKey;
            objModulePermission.AllowAccess = allowAccess;

            //add the permission to the collection
            if (!objModule.ModulePermissions.Contains(objModulePermission))
            {
                objModule.ModulePermissions.Add(objModulePermission);
            }
            return objModulePermission;
        }
コード例 #9
0
		private ModulePermissionInfo AddModulePermission(ModuleInfo module, PermissionInfo permission, int roleId, int userId, bool allowAccess)
        {
            var modulePermission = new ModulePermissionInfo
            {
				ModuleID = module.ModuleID,
                PermissionID = permission.PermissionID,
                RoleID = roleId,
                UserID = userId,
                PermissionKey = permission.PermissionKey,
                AllowAccess = allowAccess
            };

            // add the permission to the collection
			if (!module.ModulePermissions.Contains(modulePermission))
            {
				module.ModulePermissions.Add(modulePermission);
            }

			return modulePermission;
        }
コード例 #10
0
        private static void AddModulePermission(ref ModuleInfo module, int portalId, string roleName, PermissionInfo permission, string permissionKey)
        {
            var perm = module.ModulePermissions.Where(tp => tp.RoleName == roleName && tp.PermissionKey == permissionKey).SingleOrDefault();
            if (permission != null && perm == null)
            {
                var modulePermission = new ModulePermissionInfo(permission);
// ReSharper disable ImplicitlyCapturedClosure
                var role = TestableRoleController.Instance.GetRole(portalId, r => (r.RoleName == roleName));
// ReSharper restore ImplicitlyCapturedClosure
                if (role != null)
                {
                    modulePermission.RoleID = role.RoleID;
                    modulePermission.AllowAccess = true;

                    module.ModulePermissions.Add(modulePermission);
                }
            }
        }
コード例 #11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadManifest method reads the manifest file for the Module compoent.
        /// </summary>
        /// <history>
        /// 	[cnurse]	01/15/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            //Load the Desktop Module from the manifest
            _desktopModule = CBO.DeserializeObject<DesktopModuleInfo>(new StringReader(manifestNav.InnerXml));

            _desktopModule.FriendlyName = Package.FriendlyName;
            _desktopModule.Description = Package.Description;
            _desktopModule.Version = Globals.FormatVersion(Package.Version);
            _desktopModule.CompatibleVersions = Null.NullString;
            _desktopModule.Dependencies = Null.NullString;
            _desktopModule.Permissions = Null.NullString;
            if (string.IsNullOrEmpty(_desktopModule.BusinessControllerClass))
            {
                _desktopModule.SupportedFeatures = 0;
            }
            XPathNavigator eventMessageNav = manifestNav.SelectSingleNode("eventMessage");
            if (eventMessageNav != null)
            {
                _eventMessage = new EventMessage
                                    {
                                        Priority = MessagePriority.High,
                                        ExpirationDate = DateTime.Now.AddYears(-1),
                                        SentDate = DateTime.Now,
                                        Body = "",
                                        ProcessorType = Util.ReadElement(eventMessageNav, "processorType", Log, Util.EVENTMESSAGE_TypeMissing),
                                        ProcessorCommand = Util.ReadElement(eventMessageNav, "processorCommand", Log, Util.EVENTMESSAGE_CommandMissing)
                                    };
                foreach (XPathNavigator attributeNav in eventMessageNav.Select("attributes/*"))
                {
                    var attribName = attributeNav.Name;
                    var attribValue = attributeNav.Value;
                    if (attribName == "upgradeVersionsList")
                    {
                        if (!String.IsNullOrEmpty(attribValue))
                        {
                            string[] upgradeVersions = attribValue.Split(',');
                            attribValue = ""; 
                            foreach (string version in upgradeVersions)
                            {
                                Version upgradeVersion = null;
                                try
                                {
                                    upgradeVersion = new Version(version);
                                }
                                catch (FormatException)
                                {
                                    Log.AddWarning(string.Format(Util.MODULE_InvalidVersion, version));
                                }

                                if (upgradeVersion != null && (Globals.Status == Globals.UpgradeStatus.Install)) //To allow when fresh installing or installresources
                                {
                                    attribValue += version + ",";                                    
                                }
                                else if (upgradeVersion != null && upgradeVersion > Package.InstalledVersion)
                                {
                                    attribValue += version + ",";
                                }
                            }
                            attribValue = attribValue.TrimEnd(',');
                        }
                    }
                   _eventMessage.Attributes.Add(attribName, attribValue);
                }
            }
			
            //Load permissions (to add)
            foreach (XPathNavigator moduleDefinitionNav in manifestNav.Select("desktopModule/moduleDefinitions/moduleDefinition"))
            {
                string friendlyName = Util.ReadElement(moduleDefinitionNav, "friendlyName");
                foreach (XPathNavigator permissionNav in moduleDefinitionNav.Select("permissions/permission"))
                {
                    var permission = new PermissionInfo();
                    permission.PermissionCode = Util.ReadAttribute(permissionNav, "code");
                    permission.PermissionKey = Util.ReadAttribute(permissionNav, "key");
                    permission.PermissionName = Util.ReadAttribute(permissionNav, "name");
                    ModuleDefinitionInfo moduleDefinition = _desktopModule.ModuleDefinitions[friendlyName];
                    if (moduleDefinition != null)
                    {
                        moduleDefinition.Permissions.Add(permission.PermissionKey, permission);
                    }
                }
            }
            if (Log.Valid)
            {
                Log.AddInfo(Util.MODULE_ReadSuccess);
            }
        }
コード例 #12
0
 public void UpdatePermission(PermissionInfo objPermission)
 {
     DataProvider.Instance().UpdatePermission(objPermission.PermissionID, objPermission.PermissionCode, objPermission.ModuleDefID, objPermission.PermissionKey, objPermission.PermissionName);
 }
コード例 #13
0
 public int AddPermission( PermissionInfo objPermission )
 {
     return DataProvider.Instance().AddPermission( objPermission.PermissionCode, objPermission.ModuleDefID, objPermission.PermissionKey, objPermission.PermissionName );
 }
コード例 #14
0
        private ModulePermissionInfo AddModulePermission(int moduleId, PermissionInfo permission, int roleId)
        {
            RoleController objRoles = new RoleController();
            string roleName = Null.NullString;
            ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
            objModulePermission.ModuleID = moduleId;
            objModulePermission.PermissionID = permission.PermissionID;
            objModulePermission.RoleID = roleId;
            objModulePermission.PermissionKey = permission.PermissionKey;
            objModulePermission.AllowAccess = false;

            if (roleId == int.Parse(Globals.glbRoleUnauthUser))
            {
                roleName = Globals.glbRoleUnauthUserName;
            }
            else if (roleId == int.Parse(Globals.glbRoleAllUsers))
            {
                roleName = Globals.glbRoleAllUsersName;
            }
            else
            {
                RoleInfo objRole = objRoles.GetRole(objModulePermission.RoleID, PortalSettings.PortalId);
                if (objRole != null)
                {
                    roleName = objRole.RoleName;
                }
            }
            if (!(string.IsNullOrEmpty(roleName)))
            {
                if (PortalSettings.ActiveTab.AdministratorRoles.IndexOf(roleName) != -1)
                {
                    objModulePermission.AllowAccess = true;
                }
            }
            return objModulePermission;
        }
コード例 #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// SaveFolderPermissions updates a Folder's permissions
        /// </summary>
        /// <param name="folder">The Folder to update</param>
        /// <history>
        ///     [cnurse]	04/15/2009   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public virtual void SaveFolderPermissions(IFolderInfo folder)
        {
            if ((folder.FolderPermissions != null))
            {
                FolderPermissionCollection folderPermissions = GetFolderPermissionsCollectionByFolder(folder.PortalID, folder.FolderPath);

                //Ensure that if role/user has been given a permission that is not Read/Browse then they also need Read/Browse
                var            permController = new PermissionController();
                ArrayList      permArray      = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "READ");
                PermissionInfo readPerm       = null;
                if (permArray.Count == 1)
                {
                    readPerm = permArray[0] as PermissionInfo;
                }

                PermissionInfo browsePerm = null;
                permArray = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "BROWSE");
                if (permArray.Count == 1)
                {
                    browsePerm = permArray[0] as PermissionInfo;
                }

                var additionalPermissions = new FolderPermissionCollection();
                foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions)
                {
                    if (folderPermission.PermissionKey != "BROWSE" && folderPermission.PermissionKey != "READ")
                    {
                        //Try to add Read permission
                        var newFolderPerm = new FolderPermissionInfo(readPerm)
                        {
                            FolderID    = folderPermission.FolderID,
                            RoleID      = folderPermission.RoleID,
                            UserID      = folderPermission.UserID,
                            AllowAccess = folderPermission.AllowAccess
                        };

                        additionalPermissions.Add(newFolderPerm);

                        //Try to add Browse permission
                        newFolderPerm = new FolderPermissionInfo(browsePerm)
                        {
                            FolderID    = folderPermission.FolderID,
                            RoleID      = folderPermission.RoleID,
                            UserID      = folderPermission.UserID,
                            AllowAccess = folderPermission.AllowAccess
                        };

                        additionalPermissions.Add(newFolderPerm);
                    }
                }

                foreach (FolderPermissionInfo folderPermission in additionalPermissions)
                {
                    folder.FolderPermissions.Add(folderPermission, true);
                }

                if (!folderPermissions.CompareTo(folder.FolderPermissions))
                {
                    dataProvider.DeleteFolderPermissionsByFolderPath(folder.PortalID, folder.FolderPath);

                    foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions)
                    {
                        dataProvider.AddFolderPermission(folder.FolderID,
                                                         folderPermission.PermissionID,
                                                         folderPermission.RoleID,
                                                         folderPermission.AllowAccess,
                                                         folderPermission.UserID,
                                                         UserController.GetCurrentUserInfo().UserID);
                    }
                }
            }
        }
コード例 #16
0
        public T RemapPermission <T>(T permission, int portalId)
            where T : PermissionInfoBase
        {
            PermissionInfo permissionInfo = this.GetPermissionByCodeAndKey(permission.PermissionCode, permission.PermissionKey).ToArray().Cast <PermissionInfo>().FirstOrDefault();
            T result = null;

            if (permissionInfo != null)
            {
                int RoleID = int.MinValue;
                int UserID = int.MinValue;

                if (string.IsNullOrEmpty(permission.RoleName))
                {
                    UserInfo _user = UserController.GetUserByName(portalId, permission.Username);
                    if (_user != null)
                    {
                        UserID = _user.UserID;
                    }
                }
                else
                {
                    switch (permission.RoleName)
                    {
                    case Globals.glbRoleAllUsersName:
                        RoleID = Convert.ToInt32(Globals.glbRoleAllUsers);
                        break;

                    case Globals.glbRoleUnauthUserName:
                        RoleID = Convert.ToInt32(Globals.glbRoleUnauthUser);
                        break;

                    default:
                        RoleInfo _role = RoleController.Instance.GetRole(portalId, r => r.RoleName == permission.RoleName);
                        if (_role != null)
                        {
                            RoleID = _role.RoleID;
                        }

                        break;
                    }
                }

                // if role was found add, otherwise ignore
                if (RoleID != int.MinValue || UserID != int.MinValue)
                {
                    permission.PermissionID = permissionInfo.PermissionID;
                    if (RoleID != int.MinValue)
                    {
                        permission.RoleID = RoleID;
                    }

                    if (UserID != int.MinValue)
                    {
                        permission.UserID = UserID;
                    }

                    result = permission;
                }
            }

            return(result);
        }
コード例 #17
0
ファイル: Upgrade.cs プロジェクト: huayang912/cs-dotnetnuke
        /// <summary>
        /// UpgradeApplication - This overload is used for version specific application upgrade operations.
        /// </summary>
        /// <remarks>
        ///	This should be used for file system modifications or upgrade operations which
        ///	should only happen once. Database references are not recommended because future
        ///	versions of the application may result in code incompatibilties.
        /// </remarks>
        ///	<param name="Version">The Version being Upgraded</param>
        private static string UpgradeApplication(string Version)
        {
            string strExceptions = "";

            try
            {
                switch (Version)
                {
                    case "02.00.00":

                        IDataReader dr;

                        // change portal upload directory from GUID to ID - this only executes for version 2.0.0
                        string strServerPath = HttpContext.Current.Request.MapPath(Globals.ApplicationPath);
                        string strPortalsDirMapPath = Globals.ApplicationMapPath + "/Portals/";

                        dr = DataProvider.Instance().GetPortals();
                        while (dr.Read())
                        {
                            // if GUID folder exists
                            if (Directory.Exists(strPortalsDirMapPath + dr["GUID"]))
                            {
                                // if ID folder exists ( this may happen because the 2.x release contains a default ID=0 folder )
                                if (Directory.Exists(strPortalsDirMapPath + dr["PortalID"]))
                                {
                                    // rename the ID folder
                                    try
                                    {
                                        Directory.Move(strPortalsDirMapPath + dr["PortalID"], strServerPath + "\\Portals\\" + dr["PortalID"] + "_old");
                                    }
                                    catch (Exception ex)
                                    {
                                        // error moving the directory - security issue?
                                        strExceptions += "Could Not Move Folder " + strPortalsDirMapPath + dr["GUID"] + " To " + strPortalsDirMapPath + dr["PortalID"] + ". Error: " + ex.Message + "\r\n";
                                    }
                                }

                                // move GUID folder to ID folder
                                try
                                {
                                    Directory.Move(strPortalsDirMapPath + dr["GUID"], strPortalsDirMapPath + dr["PortalID"]);
                                }
                                catch (Exception ex)
                                {
                                    // error moving the directory - security issue?
                                    strExceptions += "Could Not Move Folder " + strPortalsDirMapPath + dr["GUID"] + " To " + strPortalsDirMapPath + dr["PortalID"] + ". Error: " + ex.Message + "\r\n";
                                }
                            }
                        }
                        dr.Close();

                        // copy the default style sheet to the default portal ( if it does not already exist )
                        if (File.Exists(strPortalsDirMapPath + "0\\portal.css") == false)
                        {
                            if (File.Exists(Globals.HostMapPath + "portal.css"))
                            {
                                File.Copy(Globals.HostMapPath + "portal.css", strPortalsDirMapPath + "0\\portal.css");
                            }
                        }
                        break;

                    case "02.02.00":

                        string strProviderPath = PortalSettings.GetProviderPath();
                        if (strProviderPath.StartsWith("ERROR:"))
                        {
                            strExceptions += strProviderPath;
                            break;
                        }

                        //Optionally Install the memberRoleProvider
                        bool installMemberRole = true;
                        if (Config.GetSetting("InstallMemberRole") != null)
                        {
                            installMemberRole = bool.Parse(Config.GetSetting("InstallMemberRole"));
                        }
                        if (installMemberRole)
                        {
                            HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing MemberRole Provider:<br>");
                            strExceptions += InstallMemberRoleProvider(strProviderPath);
                        }

                        PortalController objPortalController = new PortalController();
                        ArrayList arrPortals;
                        arrPortals = objPortalController.GetPortals();

                        int intViewModulePermissionID;
                        int intEditModulePermissionID;

                        int intViewTabPermissionID;
                        int intEditTabPermissionID;

                        int intReadFolderPermissionID;
                        int intWriteFolderPermissionID;

                        PermissionController objPermissionController = new PermissionController();
                        PermissionInfo objPermission = new PermissionInfo();
                        objPermission.PermissionCode = "SYSTEM_MODULE_DEFINITION";
                        objPermission.PermissionKey = "VIEW";
                        objPermission.PermissionName = "View";
                        objPermission.ModuleDefID = Null.NullInteger;
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "EDIT";
                        objPermission.PermissionName = "Edit";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionCode = "SYSTEM_TAB";
                        objPermission.PermissionKey = "VIEW";
                        objPermission.PermissionName = "View Tab";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "EDIT";
                        objPermission.PermissionName = "Edit Tab";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionCode = "SYSTEM_FOLDER";
                        objPermission.PermissionKey = "READ";
                        objPermission.PermissionName = "View Folder";
                        intReadFolderPermissionID = objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "WRITE";
                        objPermission.PermissionName = "Write to Folder";
                        intWriteFolderPermissionID = objPermissionController.AddPermission(objPermission);

                        FolderController objFolderController = new FolderController();

                        FolderPermissionController objFolderPermissionController = new FolderPermissionController();
                        int PortalCount;
                        for (PortalCount = 0; PortalCount <= arrPortals.Count - 1; PortalCount++)
                        {
                            PortalInfo objPortal = (PortalInfo)arrPortals[PortalCount];
                            int FolderID = objFolderController.AddFolder(objPortal.PortalID, "", (int)FolderController.StorageLocationTypes.InsecureFileSystem, true, false);

                            FolderPermissionInfo objFolderPermission = new FolderPermissionInfo();
                            objFolderPermission.FolderID = FolderID;
                            objFolderPermission.PermissionID = intReadFolderPermissionID;
                            objFolderPermission.AllowAccess = true;
                            objFolderPermission.RoleID = objPortal.AdministratorRoleId;
                            objFolderPermissionController.AddFolderPermission(objFolderPermission);

                            objFolderPermission.PermissionID = intWriteFolderPermissionID;
                            objFolderPermissionController.AddFolderPermission(objFolderPermission);

                            //TODO: loop through folders recursively here
                            //in case they created any nested folders
                            //and assign priveledges accordingly
                        }

                        //Transfer Users to the Membership Provider
                        MembershipProvider provider = MembershipProvider.Instance();
                        provider.TransferUsersToMembershipProvider();

                        ModuleController objModuleController = new ModuleController();
                        ArrayList arrModules = objModuleController.GetAllModules();

                        ModulePermissionController objModulePermissionController = new ModulePermissionController();
                        int ModCount;
                        for (ModCount = 0; ModCount <= arrModules.Count - 1; ModCount++)
                        {
                            ModuleInfo objModule = (ModuleInfo)arrModules[ModCount];
                            ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
                            objModulePermission.ModuleID = objModule.ModuleID;
                            int k;
                            string[] roles;
                            if (objModule.AuthorizedViewRoles.IndexOf(";") > 0)
                            {
                                roles = objModule.AuthorizedViewRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {

                                    if (Int32.TryParse(roles[k], out intViewModulePermissionID))
                                    {
                                        objModulePermission.PermissionID = intViewModulePermissionID;
                                        objModulePermission.AllowAccess = true;
                                        objModulePermission.RoleID = Convert.ToInt32(roles[k]);
                                        objModulePermissionController.AddModulePermission(objModulePermission);
                                    }
                                }
                            }
                            if (objModule.AuthorizedEditRoles.IndexOf(";") > 0)
                            {
                                roles = objModule.AuthorizedEditRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intEditModulePermissionID))
                                    {
                                        objModulePermission.PermissionID = intEditModulePermissionID;
                                        objModulePermission.AllowAccess = true;
                                        objModulePermission.RoleID = Convert.ToInt32(roles[k]);
                                        objModulePermissionController.AddModulePermission(objModulePermission);
                                    }
                                }
                            }
                        }

                        ArrayList arrTabs;
                        TabController objTabController = new TabController();
                        arrTabs = objTabController.GetAllTabs();

                        TabPermissionController objTabPermissionController = new TabPermissionController();
                        for (ModCount = 0; ModCount <= arrTabs.Count - 1; ModCount++)
                        {
                            TabInfo objTab = (TabInfo)arrTabs[ModCount];
                            TabPermissionInfo objTabPermission = new TabPermissionInfo();
                            objTabPermission.TabID = objTab.TabID;
                            int k;
                            string[] roles;
                            if (objTab.AuthorizedRoles.IndexOf(";") > 0)
                            {
                                roles = objTab.AuthorizedRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intViewTabPermissionID))
                                    {
                                        objTabPermission.PermissionID = intViewTabPermissionID;
                                        objTabPermission.AllowAccess = true;
                                        objTabPermission.RoleID = Convert.ToInt32(roles[k]);
                                        objTabPermissionController.AddTabPermission(objTabPermission);
                                    }
                                }
                            }
                            if (objTab.AdministratorRoles.IndexOf(";") > 0)
                            {
                                roles = objTab.AdministratorRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intEditTabPermissionID))
                                    {
                                        objTabPermission.PermissionID = intEditTabPermissionID;
                                        objTabPermission.AllowAccess = true;
                                        objTabPermission.RoleID = Convert.ToInt32(roles[k]);
                                        objTabPermissionController.AddTabPermission(objTabPermission);
                                    }
                                }
                            }
                        }
                        break;
                    case "03.00.01":

                        objTabController = new TabController();
                        arrTabs = objTabController.GetAllTabs();

                        int TabCount;
                        for (TabCount = 0; TabCount <= arrTabs.Count - 1; TabCount++)
                        {
                            TabInfo objTab = (TabInfo)arrTabs[TabCount];
                            if (objTab != null)
                            {
                                objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
                                DataProvider.Instance().UpdateTab(objTab.TabID, objTab.TabName, objTab.IsVisible, objTab.DisableLink, objTab.ParentId, objTab.IconFile, objTab.Title, objTab.Description, objTab.KeyWords, objTab.IsDeleted, objTab.Url, objTab.SkinSrc, objTab.ContainerSrc, objTab.TabPath, objTab.StartDate, objTab.EndDate);
                            }
                        }
                        break;
                    case "03.00.06":

                        //Need to clear the cache to pick up new HostSettings from the SQLDataProvider script
                        DataCache.RemoveCache("GetHostSettings");
                        break;
                    case "03.00.11":

                        //Need to convert any Profile Data to use XmlSerialization as Binary Formatting
                        //is not supported under Medium Trust

                        //Get all the Profiles
                        PersonalizationController objPersonalizationController = new PersonalizationController();

                        dr = DataProvider.Instance().GetAllProfiles();

                        while (dr.Read())
                        {
                            //Load Profile Data (using Binary Formatter method)
                            PersonalizationInfo objPersonalization = new PersonalizationInfo();
                            try
                            {
                                objPersonalization.UserId = Convert.ToInt32(Null.SetNull(dr["UserID"], objPersonalization.UserId));
                            }
                            catch
                            {
                            }
                            try
                            {
                                objPersonalization.PortalId = Convert.ToInt32(Null.SetNull(dr["PortalId"], objPersonalization.PortalId));
                            }
                            catch
                            {
                            }
                            objPersonalization.Profile = Globals.DeserializeHashTableBase64(dr["ProfileData"].ToString());
                            objPersonalization.IsModified = true;

                            //Save Profile Data (using XML Serializer)
                            objPersonalizationController.SaveProfile(objPersonalization);
                        }
                        dr.Close();
                        break;
                    case "03.00.12":

                        //If we are upgrading from a 3.0.x version then we need to upgrade the MembershipProvider
                        if (upgradeMemberShipProvider)
                        {
                            strProviderPath = PortalSettings.GetProviderPath();
                            StreamReader objStreamReader;
                            string strScript;

                            //Upgrade provider
                            HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Executing UpgradeMembershipProvider.sql<br>");
                            objStreamReader = File.OpenText(strProviderPath + "UpgradeMembershipProvider.sql");
                            strScript = objStreamReader.ReadToEnd();
                            objStreamReader.Close();
                            strExceptions += PortalSettings.ExecuteScript(strScript);
                        }
                        break;
                    case "03.01.00":

                        LogController objLogController = new LogController();
                        XmlDocument xmlDoc = new XmlDocument();
                        string xmlConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\LogConfig.xml.resources";
                        try
                        {
                            xmlDoc.Load(xmlConfigFile);
                        }
                        catch (FileNotFoundException)
                        {
                            xmlConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\LogConfigTemplate.xml.resources";
                            xmlDoc.Load(xmlConfigFile);
                        }
                        XmlNodeList LogType = xmlDoc.SelectNodes("/LogConfig/LogTypes/LogType");
                        foreach (XmlNode LogTypeInfo in LogType)
                        {
                            LogTypeInfo objLogTypeInfo = new LogTypeInfo();
                            objLogTypeInfo.LogTypeKey = LogTypeInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeInfo.LogTypeFriendlyName = LogTypeInfo.Attributes["LogTypeFriendlyName"].Value;
                            objLogTypeInfo.LogTypeDescription = LogTypeInfo.Attributes["LogTypeDescription"].Value;
                            objLogTypeInfo.LogTypeCSSClass = LogTypeInfo.Attributes["LogTypeCSSClass"].Value;
                            objLogTypeInfo.LogTypeOwner = LogTypeInfo.Attributes["LogTypeOwner"].Value;
                            objLogController.AddLogType(objLogTypeInfo);
                        }

                        XmlNodeList LogTypeConfig = xmlDoc.SelectNodes("/LogConfig/LogTypeConfig");
                        foreach (XmlNode LogTypeConfigInfo in LogTypeConfig)
                        {
                            LogTypeConfigInfo objLogTypeConfig = new LogTypeConfigInfo();
                            objLogTypeConfig.EmailNotificationIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["EmailNotificationStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.KeepMostRecent = LogTypeConfigInfo.Attributes["KeepMostRecent"].Value;
                            objLogTypeConfig.LoggingIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["LoggingStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.LogTypeKey = LogTypeConfigInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeConfig.LogTypePortalID = LogTypeConfigInfo.Attributes["LogTypePortalID"].Value;
                            objLogTypeConfig.MailFromAddress = LogTypeConfigInfo.Attributes["MailFromAddress"].Value;
                            objLogTypeConfig.MailToAddress = LogTypeConfigInfo.Attributes["MailToAddress"].Value;
                            objLogTypeConfig.NotificationThreshold = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThreshold"].Value);
                            objLogTypeConfig.NotificationThresholdTime = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThresholdTime"].Value);
                            objLogTypeConfig.NotificationThresholdTimeType = (LogTypeConfigInfo.NotificationThresholdTimeTypes)Enum.Parse(typeof(LogTypeConfigInfo.NotificationThresholdTimeTypes), LogTypeConfigInfo.Attributes["NotificationThresholdTimeType"].Value);
                            objLogController.AddLogTypeConfigInfo(objLogTypeConfig);
                        }

                        ScheduleItem objScheduleItem = new ScheduleItem();
                        objScheduleItem.TypeFullName = "DotNetNuke.Services.Cache.PurgeCache, DOTNETNUKE";
                        objScheduleItem.AttachToEvent = "";
                        objScheduleItem.CatchUpEnabled = false;
                        if (Globals.WebFarmEnabled)
                        {
                            objScheduleItem.Enabled = true;
                        }
                        else
                        {
                            objScheduleItem.Enabled = false;
                        }
                        objScheduleItem.ObjectDependencies = "";
                        objScheduleItem.RetainHistoryNum = 10;
                        objScheduleItem.Servers = "";
                        objScheduleItem.TimeLapse = 2;
                        objScheduleItem.TimeLapseMeasurement = "hz";
                        objScheduleItem.RetryTimeLapse = 30;
                        objScheduleItem.RetryTimeLapseMeasurement = "m";
                        SchedulingProvider.Instance().AddSchedule(objScheduleItem);
                        break;
                    case "03.02.03":

                        //add new SecurityException
                        LogController objSecLogController = new LogController();
                        XmlDocument xmlSecDoc = new XmlDocument();
                        string xmlSecConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\SecurityExceptionTemplate.xml.resources";
                        try
                        {
                            xmlSecDoc.Load(xmlSecConfigFile);
                        }
                        catch (FileNotFoundException)
                        {
                            //  xmlConfigFile = Common.Globals.HostMapPath + "Logs\LogConfig\LogConfigTemplate.xml.resources"
                            // xmlDoc.Load(xmlConfigFile)
                        }
                        LogType = xmlSecDoc.SelectNodes("/LogConfig/LogTypes/LogType");

                        foreach (XmlNode LogTypeInfo in LogType)
                        {
                            LogTypeInfo objLogTypeInfo = new LogTypeInfo();
                            objLogTypeInfo.LogTypeKey = LogTypeInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeInfo.LogTypeFriendlyName = LogTypeInfo.Attributes["LogTypeFriendlyName"].Value;
                            objLogTypeInfo.LogTypeDescription = LogTypeInfo.Attributes["LogTypeDescription"].Value;
                            objLogTypeInfo.LogTypeCSSClass = LogTypeInfo.Attributes["LogTypeCSSClass"].Value;
                            objLogTypeInfo.LogTypeOwner = LogTypeInfo.Attributes["LogTypeOwner"].Value;
                            objSecLogController.AddLogType(objLogTypeInfo);
                        }

                        LogTypeConfig = xmlSecDoc.SelectNodes("/LogConfig/LogTypeConfig");

                        foreach (XmlNode LogTypeConfigInfo in LogTypeConfig)
                        {
                            LogTypeConfigInfo objLogTypeConfig = new LogTypeConfigInfo();
                            objLogTypeConfig.EmailNotificationIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["EmailNotificationStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.KeepMostRecent = LogTypeConfigInfo.Attributes["KeepMostRecent"].Value;
                            objLogTypeConfig.LoggingIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["LoggingStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.LogTypeKey = LogTypeConfigInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeConfig.LogTypePortalID = LogTypeConfigInfo.Attributes["LogTypePortalID"].Value;
                            objLogTypeConfig.MailFromAddress = LogTypeConfigInfo.Attributes["MailFromAddress"].Value;
                            objLogTypeConfig.MailToAddress = LogTypeConfigInfo.Attributes["MailToAddress"].Value;
                            objLogTypeConfig.NotificationThreshold = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThreshold"].Value);
                            objLogTypeConfig.NotificationThresholdTime = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThresholdTime"].Value);
                            objLogTypeConfig.NotificationThresholdTimeType = (LogTypeConfigInfo.NotificationThresholdTimeTypes)Enum.Parse(typeof(LogTypeConfigInfo.NotificationThresholdTimeTypes), LogTypeConfigInfo.Attributes["NotificationThresholdTimeType"].Value);
                            objSecLogController.AddLogTypeConfigInfo(objLogTypeConfig);
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                strExceptions += "Error: " + ex.Message + "\r\n";
                try
                {
                    Exceptions.Exceptions.LogException(ex);
                }
                catch
                {
                    // ignore
                }
            }

            return strExceptions;
        }
コード例 #18
0
 public PermissionTriStateTemplate(PermissionInfo permission)
 {
     _permission = permission;
 }
コード例 #19
0
 public void UpdatePermission( PermissionInfo objPermission )
 {
     DataProvider.Instance().UpdatePermission( objPermission.PermissionID, objPermission.PermissionCode, objPermission.ModuleDefID, objPermission.PermissionKey, objPermission.PermissionName );
 }
コード例 #20
0
 public int AddPermission(PermissionInfo objPermission)
 {
     return(DataProvider.Instance().AddPermission(objPermission.PermissionCode, objPermission.ModuleDefID, objPermission.PermissionKey, objPermission.PermissionName));
 }