public static void AddAdminPages(string tabName, string description, string tabIconFile, string tabIconFileLarge, bool isVisible, int moduleDefId, string moduleTitle, string moduleIconFile, bool inheritPermissions)
        {
            var portalController = new PortalController();
            ArrayList portals = portalController.GetPortals();

            //Add Page to Admin Menu of all configured Portals
            for (int intPortal = 0; intPortal <= portals.Count - 1; intPortal++)
            {
                var portal = (PortalInfo)portals[intPortal];

                //Create New Admin Page (or get existing one)
                TabInfo newPage = Upgrade.AddAdminPage(portal, tabName, description, tabIconFile, tabIconFileLarge, isVisible);

                //Add Module To Page
                Upgrade.AddModuleToPage(newPage, moduleDefId, moduleTitle, moduleIconFile, inheritPermissions);
                var moduleController = new ModuleController();

                if (newPage != null) {
                    foreach (var module in moduleController.GetTabModules(newPage.TabID).Values)
                    {
                        moduleController.UpdateTabModuleSetting(module.TabModuleID, "hideadminborder", "true");
                    }
                }

            }
        }
        public UserCreateStatus CreateNewUser(string firstName, string lastName, string emailAddress, int portalId)
        {
            var ctlPortal = new PortalController();
            var portalSettings = ctlPortal.GetPortals().Cast<PortalInfo>().FirstOrDefault(p => p.PortalID == portalId);

            var user = new UserInfo()
            {
                FirstName = firstName,
                LastName = lastName,
                Email = emailAddress,
                Username = emailAddress,
                DisplayName = string.Concat(firstName, " ", lastName),
                PortalID = portalId
            };

            user.Profile.PreferredLocale = portalSettings.DefaultLanguage;
            user.Profile.FirstName = firstName;
            user.Profile.LastName = lastName;

            user.Membership.Approved = true;
            user.Membership.Password = PasswordGenerator.GeneratePassword();
            user.Membership.UpdatePassword = true;

            var status = UserController.CreateUser(ref user);

            User = user;

            return status;
        }
        private void BindSettingControls()
        {
			// Toggle fields if a redirect already exists for the Portal Home Page
			var defaultRedirect = HomePageRedirectExists();

            // Populating Portals dropdown
            var portalController = new PortalController();
        	var portals = portalController.GetPortals().Cast<PortalInfo>().Where(p => p.PortalID != ModuleContext.PortalId).ToList();
            if (portals.Count > 0)
            {
                cboPortal.DataSource = portals;
                cboPortal.DataTextField = "PortalName";
                cboPortal.DataValueField = "PortalID";
                cboPortal.DataBind();
            }
            else
            {
                optRedirectTarget.Items[0].Enabled = false;
                optRedirectTarget.Items[0].Selected = false;
                optRedirectTarget.Items[1].Selected = true;
            }

            cboSourcePage.Visible = defaultRedirect;
            lblHomePage.Visible = !defaultRedirect;
            lblRedirectName.Visible = defaultRedirect;
            txtRedirectName.Visible = defaultRedirect;
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataToPage()
        {
            cbCopyOfOtherModule.Checked = Settings["DNNGalleryPro_CopyOfOtherModule"] != null && !string.IsNullOrEmpty(Settings["DNNGalleryPro_CopyOfOtherModule"].ToString()) ? Convert.ToBoolean(Settings["DNNGalleryPro_CopyOfOtherModule"]) : false;


            //绑定当前站点列表
            DotNetNuke.Entities.Portals.PortalController portalController = new DotNetNuke.Entities.Portals.PortalController();
            WebHelper.BindList <PortalInfo>(ddlPortals, Common.Split <PortalInfo>(portalController.GetPortals(), 1, int.MaxValue), "PortalName", "PortalID");
            WebHelper.SelectedListByValue(ddlPortals, Settings["DNNGalleryPro_CopyOfPortal"] != null && !string.IsNullOrEmpty(Settings["DNNGalleryPro_CopyOfPortal"].ToString()) ? Convert.ToInt32(Settings["DNNGalleryPro_CopyOfPortal"]) : PortalId);


            BindModuleList();
            WebHelper.SelectedListByValue(ddlTabModule, String.Format("{0}-{1}", Settings_TabID, Settings_ModuleID));

            WebHelper.BindList(ddlSortby, typeof(EnumSortby));
            WebHelper.SelectedListByValue(ddlSortby, Settings["DNNGalleryPro_Sortby"] != null && !string.IsNullOrEmpty(Settings["DNNGalleryPro_Sortby"].ToString()) ? Convert.ToInt32(Settings["DNNGalleryPro_Sortby"]) : 0);

            divSortbyHelp.Visible = !Setting_SliderSettingDB.Exists(r => r.Name == "Title");


            cbFilterStartTime.Checked = Settings["DNNGalleryPro_FilterStartTime"] != null?Convert.ToBoolean(Settings["DNNGalleryPro_FilterStartTime"]) : true;

            cbFilterEndTime.Checked = Settings["DNNGalleryPro_FilterEndTime"] != null?Convert.ToBoolean(Settings["DNNGalleryPro_FilterEndTime"]) : true;


            cbCompressionEnable.Checked = Settings["DNNGalleryPro_CompressionEnable"] != null?Convert.ToBoolean(Settings["DNNGalleryPro_CompressionEnable"]) : false;

            txtCompressionQuality.Text = Settings["DNNGalleryPro_CompressionQuality"] != null?Convert.ToString(Settings["DNNGalleryPro_CompressionQuality"]) : "90";
        }
        /// <summary>
        /// 执行多个任务
        /// </summary>
        public void ExecutionTasks()
        {
            //遍历每个站点
            DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController();
            ModuleController objModules     = new ModuleController();
            Int32            AllRecordCount = 0;
            //遍历所有站点
            ArrayList    Portals   = pc.GetPortals();
            List <Int32> ModuleIDs = new List <int>();

            foreach (PortalInfo p in Portals)
            {
                if (p != null && p.PortalID >= 0)
                {
                    //遍历所有模块
                    ArrayList Modules = objModules.GetModulesByDefinition(p.PortalID, "DNNGo.PowerForms");
                    foreach (ModuleInfo m in Modules)
                    {
                        if (m != null && m.ModuleID > 0 && !ModuleIDs.Exists(r => r == m.ModuleID))
                        {
                            Hashtable ModuleSettings = m.ModuleSettings;
                            Boolean   Cleanup_Enable = ModuleSettings["PowerForms_Cleanup_Enable"] != null?Convert.ToBoolean(ModuleSettings["PowerForms_Cleanup_Enable"]) : false;

                            if (Cleanup_Enable)//开启了清除
                            {
                                AllRecordCount += ExecutionTask(ModuleSettings, m);
                            }
                            ModuleIDs.Add(m.ModuleID);
                        }
                    }
                }
            }
            this.ScheduleHistoryItem.AddLogNote(String.Format("It cleared a total of {0} histroy records for all modules. time:{1}<br />", AllRecordCount, DateTime.Now.ToString()));
        }
        private void BindDetailData()
        {
            var pc = new PortalController();
            cboLogTypePortalID.DataTextField = "PortalName";
            cboLogTypePortalID.DataValueField = "PortalID";
            cboLogTypePortalID.DataSource = pc.GetPortals();
            cboLogTypePortalID.DataBind();

// ReSharper disable LocalizableElement
            var i = new DnnComboBoxItem{Text = Localization.GetString("All"), Value = "*"};
// ReSharper restore LocalizableElement
            cboLogTypePortalID.Items.Insert(0, i);


            pnlEditLogTypeConfigInfo.Visible = true;
            pnlLogTypeConfigInfo.Visible = false;
            var logController = new LogController();

        	var arrLogTypeInfo = logController.GetLogTypeInfoDictionary().Values.OrderBy(t => t.LogTypeFriendlyName);

            cboLogTypeKey.DataTextField = "LogTypeFriendlyName";
            cboLogTypeKey.DataValueField = "LogTypeKey";
            cboLogTypeKey.DataSource = arrLogTypeInfo;
            cboLogTypeKey.DataBind();

            int[] items = {1, 2, 3, 4, 5, 10, 25, 100, 250, 500};
            cboKeepMostRecent.Items.Clear();
            cboKeepMostRecent.Items.Add(new DnnComboBoxItem(Localization.GetString("All"), "*"));
            foreach (int item in items)
            {
                cboKeepMostRecent.Items.Add(item == 1
                                                ? new DnnComboBoxItem(item + Localization.GetString("LogEntry", LocalResourceFile), item.ToString(CultureInfo.InvariantCulture))
                                                : new DnnComboBoxItem(item + Localization.GetString("LogEntries", LocalResourceFile), item.ToString(CultureInfo.InvariantCulture)));
            }
            int[] items2 = {1, 2, 3, 4, 5, 10, 25, 100, 250, 500, 1000};
            cboThreshold.Items.Clear();
            foreach (int item in items2)
            {
                cboThreshold.Items.Add(item == 1
                                           ? new DnnComboBoxItem(item + Localization.GetString("Occurence", LocalResourceFile), item.ToString(CultureInfo.InvariantCulture))
                                           : new DnnComboBoxItem(item + Localization.GetString("Occurences", LocalResourceFile), item.ToString(CultureInfo.InvariantCulture)));
            }

            cboThresholdNotificationTime.Items.Clear();
            foreach (int item in new []{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 60, 90, 120})
            {
                cboThresholdNotificationTime.Items.Add(new DnnComboBoxItem(item.ToString(CultureInfo.InvariantCulture), item.ToString(CultureInfo.InvariantCulture)));
            }

            cboThresholdNotificationTimeType.Items.Clear();
            foreach (int item in new[] { 1, 2, 3, 4 })
            {
                cboThresholdNotificationTimeType.Items.Add(new DnnComboBoxItem(Localization.GetString(string.Format("TimeType_{0}", item), LocalResourceFile), item.ToString(CultureInfo.InvariantCulture)));
            }
// ReSharper disable LocalizableElement
            var j = new DnnComboBoxItem{Text = Localization.GetString("All"), Value = "*"};
// ReSharper restore LocalizableElement
            cboLogTypeKey.Items.Insert(0, j);
        }
 private static void ClearCache()
 {
     var portalController = new PortalController();
     foreach (PortalAliasInfo portal in portalController.GetPortals())
     {
         ClearCache(portal.PortalID);
     }
 }
        public IEnumerable <PortalInfo> GetPortalsByGroup(int portalGroupId)
        {
            var controller = new PortalController();
            var portals    = controller.GetPortals();

            return(portals.Cast <PortalInfo>()
                   .Where(portal => portal.PortalGroupID == portalGroupId)
                   .ToList());
        }
Esempio n. 9
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataToPage()
        {
            //绑定当前站点列表
            DotNetNuke.Entities.Portals.PortalController portalController = new DotNetNuke.Entities.Portals.PortalController();
            WebHelper.BindList <PortalInfo>(ddlPortals, Common.Split <PortalInfo>(portalController.GetPortals(), 1, int.MaxValue), "PortalName", "PortalID");
            WebHelper.SelectedListByValue(ddlPortals, Settings["ClientZone_PortalID"] != null && !string.IsNullOrEmpty(Settings["ClientZone_PortalID"].ToString()) ? Convert.ToInt32(Settings["ClientZone_PortalID"]) : PortalId);


            BindModuleList();
            WebHelper.SelectedListByValue(ddlTabModule, String.Format("{0}-{1}", Settings_TabID, Settings_ModuleID));
        }
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                    case "06.02.00":
                        var portalController = new PortalController();
                        var moduleController = new ModuleController();
                        var tabController = new TabController();

                        var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center");
                        if (moduleDefinition != null)
                        {
                            var portals = portalController.GetPortals();
                            foreach (PortalInfo portal in portals)
                            {
                                if (portal.UserTabId > Null.NullInteger)
                                {
                                    //Find TabInfo
                                    var tab = tabController.GetTab(portal.UserTabId, portal.PortalID, true);
                                    if (tab != null)
                                    {
                                        foreach (var module in moduleController.GetTabModules(portal.UserTabId).Values)
                                        {
                                            if (module.DesktopModule.FriendlyName == "Messaging")
                                            {
                                                //Delete the Module from the Modules list
                                                moduleController.DeleteTabModule(module.TabID, module.ModuleID, false);

                                                //Add new module to the page
                                                Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", "", true);

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

                return "Failed";
            }
        }
Esempio n. 11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// CacheMappedDirectory caches the Portal Mapped Directory(s)
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]    1/27/2005   Moved back to App_Start from Caching Module
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void CacheMappedDirectory()
        {
            //This code is only retained for binary compatability.
#pragma warning disable 612,618
            var objFolderController = new FolderController();
            var objPortalController = new PortalController();
            ArrayList arrPortals = objPortalController.GetPortals();
            int i;
            for (i = 0; i <= arrPortals.Count - 1; i++)
            {
                var objPortalInfo = (PortalInfo)arrPortals[i];
                objFolderController.SetMappedDirectory(objPortalInfo, HttpContext.Current);
            }
#pragma warning restore 612,618
        }
Esempio n. 12
0
        /// <Summary>
        /// GetContent gets all the content and passes it to the Indexer
        /// </Summary>
        /// <Param name="Indexer">
        /// The Index Provider that will index the content of the portal
        /// </Param>
        protected SearchItemInfoCollection GetContent( IndexingProvider Indexer )
        {
            SearchItemInfoCollection SearchItems = new SearchItemInfoCollection();
            PortalController objPortals = new PortalController();
            PortalInfo objPortal;

            ArrayList arrPortals = objPortals.GetPortals();
            int intPortal;
            for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
            {
                objPortal = (PortalInfo)arrPortals[intPortal];

                SearchItems.AddRange(Indexer.GetSearchIndexItems(objPortal.PortalID));
            }
            return SearchItems;
        }
        private void Synchronize()
        {
            PortalController objPortals = new PortalController();
            ArrayList arrPortals = objPortals.GetPortals();
            PortalInfo objPortal;

            //Sync Host
            FileSystemUtils.Synchronize(Null.NullInteger, Null.NullInteger, Globals.HostMapPath);

            //Sync Portals
            int intIndex;
            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                FileSystemUtils.Synchronize(objPortal.PortalID, objPortal.AdministratorRoleId, objPortal.HomeDirectoryMapPath);
            }
        }
Esempio n. 14
0
 private void DoPurgeSiteLog()
 {
     var objSiteLog = new SiteLogController();
     var objPortals = new PortalController();
     ArrayList arrPortals = objPortals.GetPortals();
     PortalInfo objPortal;
     DateTime PurgeDate;
     int intIndex;
     for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
     {
         objPortal = (PortalInfo) arrPortals[intIndex];
         if (objPortal.SiteLogHistory > 0)
         {
             PurgeDate = DateTime.Now.AddDays(-(objPortal.SiteLogHistory));
             objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
         }
     }
 }
        private void Synchronize()
        {
            var folderManager = FolderManager.Instance;
            
            folderManager.Synchronize(Null.NullInteger);
            
            PortalInfo objPortal;

            var objPortals = new PortalController();
            var arrPortals = objPortals.GetPortals();

            //Sync Portals
			for (int intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo) arrPortals[intIndex];
                folderManager.Synchronize(objPortal.PortalID);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// GET Portals
        /// </summary>
        /// <returns></returns>
        public static List <PortalInfo> GetAllPortals()
        {
            var pList = new List <PortalInfo>();
            var objPC = new DotNetNuke.Entities.Portals.PortalController();

            var list = objPC.GetPortals();

            if (list == null || list.Count == 0)
            {
                //Problem with DNN6 GetPortals when ran from scheduler.
                PortalInfo objPInfo;
                var        flagdeleted = 0;

                for (var lp = 0; lp <= 500; lp++)
                {
                    objPInfo = objPC.GetPortal(lp);
                    if ((objPInfo != null))
                    {
                        pList.Add(objPInfo);
                    }
                    else
                    {
                        // some portals may be deleted, skip 3 to see if we've got to the end of the list.
                        // VERY weak!!! shame!! but issue with a DNN6 version only.
                        if (flagdeleted == 3)
                        {
                            break;
                        }
                        flagdeleted += 1;
                    }
                }
            }
            else
            {
                foreach (PortalInfo p in list)
                {
                    pList.Add(p);
                }
            }


            return(pList);
        }
Esempio n. 17
0
		private void UpdateDisplaySearchSettings()
		{
            var moduleController = new ModuleController();
            var portalController = new PortalController();

            foreach (PortalInfo portal in portalController.GetPortals())
            {
				foreach (ModuleInfo module in moduleController.GetModulesByDefinition(portal.PortalID, "Member Directory"))
	            {
					foreach (ModuleInfo tabModule in moduleController.GetAllTabsModulesByModuleID(module.ModuleID))
		            {
			            if (tabModule.TabModuleSettings.ContainsKey("DisplaySearch"))
			            {
				            var oldValue = bool.Parse(tabModule.TabModuleSettings["DisplaySearch"].ToString());
							moduleController.UpdateTabModuleSetting(tabModule.TabModuleID, "DisplaySearch", oldValue ? "Both" : "None");
			            }
		            }
	            }
            }
		}
Esempio n. 18
0
        private void PurgeSiteLog_Renamed()
        {
            SiteLogController objSiteLog = new SiteLogController();

            PortalController objPortals = new PortalController();
            ArrayList arrPortals = objPortals.GetPortals();
            PortalInfo objPortal;
            DateTime PurgeDate;

            int intIndex;
            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                if (objPortal.SiteLogHistory > 0)
                {
                    PurgeDate = DateAndTime.DateAdd(DateInterval.Day, -(objPortal.SiteLogHistory), DateTime.Now);
                    objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
                }
            }
        }
Esempio n. 19
0
        public override void DoWork()
        {
            try
            {
                ArrayList portals;
                var portalController = new PortalController();
                portals = portalController.GetPortals();
                foreach (KeyValuePair<string, ModuleCachingProvider> kvp in ModuleCachingProvider.GetProviderList())
                {
                    try
                    {
                        foreach (PortalInfo portal in portals)
                        {
                            kvp.Value.PurgeExpiredItems(portal.PortalID);
                            ScheduleHistoryItem.AddLogNote(string.Format("Purged Module cache for {0}.  ", kvp.Key));
                        }
                    }
                    catch (NotSupportedException exc)
                    {
						//some Module caching providers don't use this feature
                        Logger.Debug(exc);

                    }
                }
                ScheduleHistoryItem.Succeeded = true; //REQUIRED
            }
            catch (Exception exc) //REQUIRED
            {
                ScheduleHistoryItem.Succeeded = false; //REQUIRED

                ScheduleHistoryItem.AddLogNote(string.Format("Purging Module cache task failed: {0}.", exc.ToString()));

                //notification that we have errored
                Errored(ref exc); //REQUIRED
				
				//log the exception
                Exceptions.Exceptions.LogException(exc); //OPTIONAL
            }
        }
Esempio n. 20
0
File: V5.cs Progetto: 2sic/2sxc
        /// <summary>
        /// While upgrading to 05.04.02, make sure the template folders get renamed to "2sxc"
        /// </summary>
        internal void Version050500()
        {
            logger.LogStep("05.05.00", "Starting", false);

            var portalController = new PortalController();
            var portals = portalController.GetPortals();
            var pathsToCopy = portals.Cast<PortalInfo>().Select(p => p.HomeDirectoryMapPath).ToList();
            pathsToCopy.Add(HttpContext.Current.Server.MapPath("~/Portals/_default/"));
            logger.LogStep("05.05.00", "Starting paths for " + pathsToCopy.Count + " paths", false);
            foreach (var path in pathsToCopy)
            {
                logger.LogStep("05.05.00", "Path: " + path, false);
                var portalFolder = new DirectoryInfo(path);
                if (portalFolder.Exists)
                {
                    var oldSexyFolder = new DirectoryInfo(Path.Combine(path, "2sexy"));
                    var newSexyFolder = new DirectoryInfo(Path.Combine(path, "2sxc"));
                    var newSexyContentFolder = new DirectoryInfo(Path.Combine(newSexyFolder.FullName, Constants.ContentAppName));
                    if (oldSexyFolder.Exists && !newSexyFolder.Exists)
                    {
                        logger.LogStep("05.05.00", "Path: " + path + " will copy from 2Sexy to 2sxc", false);

                        // Move 2sexy directory to 2sxc/Content
                        Helpers.DirectoryCopy(oldSexyFolder.FullName, newSexyContentFolder.FullName, true);

                        // Leave info message in the content folder
                        File.WriteAllText(Path.Combine(oldSexyFolder.FullName, "__WARNING - old copy of files - READ ME.txt"), "This is a short information\r\n\r\n2sxc renamed the main folder from \"[Portal]/2Sexy\" to \"[Portal]/2sxc\" in version 5.5.\r\n\r\nTo make sure that links to images/css/js still work, the old folder was copied and this was left. Please clean up and delete the entire \"[Portal]/2Sexy/\" folder once you're done. \r\n\r\nMany thanks!\r\n2sxc\r\n\r\nPS: Remember that you might have ClientDependency activated, so maybe you still have bundled & minified  JS/CSS-Files in your cache pointing to the old location. When done cleaning up, we recommend increasing the version just to be sure you're not seeing an old files that don't exist any more. ");

                        // Move web.config (should be directly in 2sxc)
                        if (File.Exists(Path.Combine(newSexyContentFolder.FullName, "web.config")))
                            File.Move(Path.Combine(newSexyContentFolder.FullName, "web.config"), Path.Combine(newSexyFolder.FullName, "web.config"));

                    }
                }
            }
            logger.LogStep("05.05.00", "Paths done", false);
        }
        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";
            }
        }
Esempio n. 22
0
 /// <summary>
 /// CacheMappedDirectory caches the Portal Mapped Directory(s)
 /// </summary>
 /// <history>
 ///     [cnurse]    1/27/2005   Moved back to App_Start from Caching Module
 /// </history>
 private void CacheMappedDirectory()
 {
     //Cache the mapped physical home directory for each portal
     //so the mapped directories are available outside
     //of httpcontext.   This is especially necessary
     //when the /Portals or portal home directory has been
     //mapped in IIS to another directory or server.
     FolderController objFolderController = new FolderController();
     PortalController objPortalController = new PortalController();
     ArrayList arrPortals = objPortalController.GetPortals();
     int i;
     for( i = 0; i <= arrPortals.Count - 1; i++ )
     {
         PortalInfo objPortalInfo = (PortalInfo)arrPortals[i];
         objFolderController.SetMappedDirectory( objPortalInfo, HttpContext.Current );
     }
 }
Esempio n. 23
0
        private static void Handle404OrException(FriendlyUrlSettings settings, HttpContext context, Exception ex, UrlAction result, bool transfer, bool showDebug)
        {
            //handle Auto-Add Alias
            if (result.Action == ActionType.Output404 && CanAutoAddPortalAlias())
            {
                //Need to determine if this is a real 404 or a possible new alias.
                var portalId = Host.Host.HostPortalID;
                if (portalId > Null.NullInteger)
                {
                    //Get all the existing aliases
                    var aliases = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(portalId).ToList();

                    bool autoaddAlias;
                    bool isPrimary = false;
                    if (!aliases.Any())
                    {
                        autoaddAlias = true;
                        isPrimary = true;
                    }
                    else
                    {
                        autoaddAlias = true;
                        foreach (var alias in aliases)
                        {
                            if (result.DomainName.ToLowerInvariant().IndexOf(alias.HTTPAlias, StringComparison.Ordinal) == 0
                                    && result.DomainName.Length >= alias.HTTPAlias.Length)
                            {
                                autoaddAlias = false;
                                break;
                            }
                        }
                    }

                    if (autoaddAlias)
                    {
                        var portalAliasInfo = new PortalAliasInfo
                                                  {
                                                      PortalID = portalId, 
                                                      HTTPAlias = result.RewritePath,
                                                      IsPrimary = isPrimary
                                                  };
                        TestablePortalAliasController.Instance.AddPortalAlias(portalAliasInfo);

                        context.Response.Redirect(context.Request.Url.ToString(), true);
                    }
                }
            }


            if (context != null)
            {
                HttpRequest request = context.Request;
                HttpResponse response = context.Response;
                HttpServerUtility server = context.Server;

                const string errorPageHtmlHeader = @"<html><head><title>{0}</title></head><body>";
                const string errorPageHtmlFooter = @"</body></html>";
                var errorPageHtml = new StringWriter();
                CustomErrorsSection ceSection = null;
                //876 : security catch for custom error reading
                try
                {
                    ceSection = (CustomErrorsSection) WebConfigurationManager.GetSection("system.web/customErrors");
                }
// ReSharper disable EmptyGeneralCatchClause
                catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
                {
                    //on some medium trust environments, this will throw an exception for trying to read the custom Errors
                    //do nothing
                }

                /* 454 new 404/500 error handling routine */
                bool useDNNTab = false;
                int errTabId = -1;
                string errUrl = null;
                string status = "";
                bool isPostback = false;
                if (settings != null)
                {
                    if (request.RequestType == "POST")
                    {
                        isPostback = true;
                    }
                    if (result != null && ex != null)
                    {
                        result.DebugMessages.Add("Exception: " + ex.Message);
                        result.DebugMessages.Add("Stack Trace: " + ex.StackTrace);
                        if (ex.InnerException != null)
                        {
                            result.DebugMessages.Add("Inner Ex : " + ex.InnerException.Message);
                            result.DebugMessages.Add("Stack Trace: " + ex.InnerException.StackTrace);
                        }
                        else
                        {
                            result.DebugMessages.Add("Inner Ex : null");
                        }
                    }
                    string errRH;
                    string errRV;
                    int statusCode;
                    if (result != null && result.Action != ActionType.Output404)
                    {
                        //output everything but 404 (usually 500)
                        if (settings.TabId500 > -1) //tabid specified for 500 error page, use that
                        {
                            useDNNTab = true;
                            errTabId = settings.TabId500;
                        }
                        errUrl = settings.Url500;
                        errRH = "X-UrlRewriter-500";
                        errRV = "500 Rewritten to {0} : {1}";
                        statusCode = 500;
                        status = "500 Internal Server Error";
                    }
                    else //output 404 error 
                    {
                        if (settings.TabId404 > -1) //if the tabid is specified for a 404 page, then use that
                        {
                            useDNNTab = true;
                            errTabId = settings.TabId404;
                        }
                        if (!String.IsNullOrEmpty(settings.Regex404))
                            //with 404 errors, there's an option to catch certain urls and use an external url for extra processing.
                        {
                            try
                            {
                                //944 : check the original Url in case the requested Url has been rewritten before discovering it's a 404 error
                                string requestedUrl = request.Url.ToString();
                                if (result != null && string.IsNullOrEmpty(result.OriginalPath) == false)
                                {
                                    requestedUrl = result.OriginalPath;
                                }
                                if (Regex.IsMatch(requestedUrl, settings.Regex404, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                                {
                                    useDNNTab = false;
                                        //if we have a match in the 404 regex value, then don't use the tabid
                                }
                            }
                            catch (Exception regexEx)
                            {
                                //.some type of exception : output in response header, and go back to using the tabid 
                                response.AppendHeader("X-UrlRewriter-404Exception", regexEx.Message);
                            }
                        }
                        errUrl = settings.Url404;
                        errRH = "X-UrlRewriter-404";
                        errRV = "404 Rewritten to {0} : {1} : Reason {2}";
                        status = "404 Not Found";
                        statusCode = 404;
                    }

                    // check for 404 logging
                    if ((result == null || result.Action == ActionType.Output404))
                    {
                        //Log 404 errors to Event Log
                        UrlRewriterUtils.Log404(request, settings, result);
                    }
                    //912 : use unhandled 404 switch
                    string reason404 = null;
                    bool unhandled404 = true;
                    if (useDNNTab && errTabId > -1)
                    {
                        unhandled404 = false; //we're handling it here
                        var tc = new TabController();
                        TabInfo errTab = tc.GetTab(errTabId, result.PortalId, true);
                        if (errTab != null)
                        {
                            bool redirect = false;
                            //ok, valid tabid.  what we're going to do is to load up this tab via a rewrite of the url, and then change the output status
                            string reason = "Not Found";
                            if (result != null)
                            {
                                reason = result.Reason.ToString();
                            }
                            response.AppendHeader(errRH, string.Format(errRV, "DNN Tab",
                                                                errTab.TabName + "(Tabid:" + errTabId.ToString() + ")",
                                                                reason));
                            //show debug messages even if in debug mode
                            if (context != null && response != null && result != null && showDebug)
                            {
                                ShowDebugData(context, result.OriginalPath, result, null);
                            }
                            if (!isPostback)
                            {
                                response.ClearContent();
                                response.StatusCode = statusCode;
                                response.Status = status;
                            }
                            else
                            {
                                redirect = true;
                                    //redirect postbacks as you can't postback successfully to a server.transfer
                            }
                            errUrl = Globals.glbDefaultPage + TabIndexController.CreateRewritePath(errTab.TabID, "");
                            //have to update the portal settings with the new tabid
                            PortalSettings ps = null;
                            if (context != null && context.Items != null)
                            {
                                if (context.Items.Contains("PortalSettings"))
                                {
                                    ps = (PortalSettings) context.Items["PortalSettings"];
                                    context.Items.Remove("PortalSettings"); //nix it from the context
                                }
                            }
                            if (ps != null && ps.PortalAlias != null)
                            {
                                ps = new PortalSettings(errTabId, ps.PortalAlias);
                            }
                            else
                            {
                                if (result.HttpAlias != null && result.PortalId > -1)
                                {
                                    var pac = new PortalAliasController();
                                    PortalAliasInfo pa = pac.GetPortalAlias(result.HttpAlias, result.PortalId);
                                    ps = new PortalSettings(errTabId, pa);
                                }
                                else
                                {
                                    //912 : handle 404 when no valid portal can be identified
                                    //results when iis is configured to handle portal alias, but 
                                    //DNN isn't.  This always returns 404 because a multi-portal site
                                    //can't just show the 404 page of the host site.
                                    var pc = new PortalController();
                                    ArrayList portals = pc.GetPortals();
                                    if (portals != null && portals.Count == 1)
                                    {
                                        //single portal install, load up portal settings for this portal
                                        var singlePortal = (PortalInfo) portals[0];
                                        //list of aliases from database
                                        var aliases = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(singlePortal.PortalID).ToList();
                                        //list of aliases from Advanced Url settings
                                        List<string> chosen = aliases.GetAliasesForPortalId(singlePortal.PortalID);
                                        PortalAliasInfo useFor404 = null;
                                        //go through all aliases and either get the first valid one, or the first 
                                        //as chosen in the advanced url management settings
                                        foreach (var pa in aliases)
                                        {
                                            if (useFor404 == null)
                                            {
                                                useFor404 = pa; //first one by default
                                            }

                                            //matching?
                                            if (chosen != null && chosen.Count > 0)
                                            {
                                                if (chosen.Contains(pa.HTTPAlias))
                                                {
                                                    useFor404 = pa;
                                                }
                                            }
                                            else
                                            {
                                                break; //no further checking
                                            }
                                        }
                                        //now configure that as the portal settings
                                        if (useFor404 != null)
                                        {
                                            //create portal settings context for identified portal alias in single portal install
                                            ps = new PortalSettings(errTabId, useFor404);
                                        }
                                    }
                                    else
                                    {
                                        reason404 = "Requested domain name is not configured as valid website";
                                        unhandled404 = true;
                                    }
                                }
                            }
                            if (ps != null)
                            {
                                //re-add the context items portal settings back in
                                context.Items.Add("PortalSettings", ps);
                            }
                            if (redirect)
                            {
                                errUrl = Globals.NavigateURL();
                                response.Redirect(errUrl, true); //redirect and end response.  
                                //It will mean the user will have to postback again, but it will work the second time
                            }
                            else
                            {
                                if (transfer)
                                {
                                    //execute a server transfer to the default.aspx?tabid=xx url
                                    //767 : object not set error on extensionless 404 errors
                                    if (context.User == null)
                                    {
                                        context.User = Thread.CurrentPrincipal;
                                    }
                                    response.TrySkipIisCustomErrors = true;
                                    //881 : spoof the basePage object so that the client dependency framework
                                    //is satisfied it's working with a page-based handler
                                    IHttpHandler spoofPage = new CDefault();
                                    context.Handler = spoofPage;
                                    server.Transfer("~/" + errUrl, true);
                                }
                                else
                                {
                                    context.RewritePath("~/Default.aspx", false);
                                    response.TrySkipIisCustomErrors = true;
                                    response.Status = "404 Not Found";
                                    response.StatusCode = 404;
                                }
                            }
                        }
                    }
                    //912 : change to new if statement to handle cases where the TabId404 couldn't be handled correctly
                    if (unhandled404)
                    {
                        //proces the error on the external Url by rewriting to the external url
                        if (!String.IsNullOrEmpty(errUrl))
                        {
                            response.ClearContent();
                            response.TrySkipIisCustomErrors = true;
                            string reason = "Not Found";
                            if (result != null)
                            {
                                reason = result.Reason.ToString();
                            }
                            response.AppendHeader(errRH, string.Format(errRV, "Url", errUrl, reason));
                            if (reason404 != null)
                            {
                                response.AppendHeader("X-Url-Master-404-Data", reason404);
                            }
                            response.StatusCode = statusCode;
                            response.Status = status;
                            server.Transfer("~/" + errUrl, true);
                        }
                        else
                        {
#if (DEBUG)
                            //955: xss vulnerability when outputting raw url back to the page
                            //only do so in debug mode, and sanitize the Url.
                            //sanitize output Url to prevent xss attacks on the default 404 page
                            string requestedUrl = request.Url.ToString();
                            requestedUrl = HttpUtility.HtmlEncode(requestedUrl);
                            errorPageHtml.Write(status + "<br>The requested Url (" + requestedUrl +
                                                ") does not return any valid content.");
#else
                            errorPageHtml.Write(status + "<br>The requested Url does not return any valid content.");
#endif
                            if (reason404 != null)
                            {
                                errorPageHtml.Write(status + "<br>" + reason404);
                            }
                            errorPageHtml.Write("<div style='font-weight:bolder'>Administrators</div>");
                            errorPageHtml.Write("<div>Change this message by configuring a specific 404 Error Page or Url for this website.</div>");

                            //output a reason for the 404
                            string reason = "";
                            if (result != null)
                            {
                                reason = result.Reason.ToString();
                            }
                            if (!string.IsNullOrEmpty(errRH) && !string.IsNullOrEmpty(reason))
                            {
                                response.AppendHeader(errRH, reason);
                            }
                            response.StatusCode = statusCode;
                            response.Status = status;
                        }
                    }
                }
                else
                {
                    //fallback output if not valid settings
                    if (result != null && result.Action == ActionType.Output404)
                    {
                        //don't restate the requested Url to prevent cross site scripting
                        errorPageHtml.Write("404 Not Found<br>The requested Url does not return any valid content.");
                        response.StatusCode = 404;
                        response.Status = "404 Not Found";
                    }
                    else
                    {
                        //error, especially if invalid result object

                        errorPageHtml.Write("500 Server Error<br><div style='font-weight:bolder'>An error occured during processing : if possible, check the event log of the server</div>");
                        response.StatusCode = 500;
                        response.Status = "500 Internal Server Error";
                        if (result != null)
                        {
                            result.Action = ActionType.Output500;
                        }
                    }
                }

                if (ex != null)
                {
                    if (context != null)
                    {
                        if (context.Items.Contains("UrlRewrite:Exception") == false)
                        {
                            context.Items.Add("UrlRewrite:Exception", ex.Message);
                            context.Items.Add("UrlRewrite:StackTrace", ex.StackTrace);
                        }
                    }

                    if (ceSection != null && ceSection.Mode == CustomErrorsMode.Off)
                    {
                        errorPageHtml.Write(errorPageHtmlHeader);
                        errorPageHtml.Write("<div style='font-weight:bolder'>Exception:</div><div>" + ex.Message + "</div>");
                        errorPageHtml.Write("<div style='font-weight:bolder'>Stack Trace:</div><div>" + ex.StackTrace + "</div>");
                        errorPageHtml.Write("<div style='font-weight:bolder'>Administrators</div>");
                        errorPageHtml.Write("<div>You can see this exception because the customErrors attribute in the web.config is set to 'off'.  Change this value to 'on' or 'RemoteOnly' to show Error Handling</div>");
                        try
                        {
                            if (errUrl != null && errUrl.StartsWith("~"))
                            {
                                errUrl = VirtualPathUtility.ToAbsolute(errUrl);
                            }
                        }
                        finally
                        {
                            if (errUrl != null)
                            {
                                errorPageHtml.Write("<div>The error handling would have shown this page : <a href='" + errUrl + "'>" + errUrl + "</a></div>");
                            }
                            else
                            {
                                errorPageHtml.Write("<div>The error handling could not determine the correct page to show.</div>");
                            }
                        }
                    }
                }

                string errorPageHtmlBody = errorPageHtml.ToString();
                if (errorPageHtmlBody.Length > 0)
                {
                    response.Write(errorPageHtmlHeader);
                    response.Write(errorPageHtmlBody);
                    response.Write(errorPageHtmlFooter);
                }
                if (ex != null)
                {
                    UrlRewriterUtils.LogExceptionInRequest(ex, status, result);
                }
            }
        }
Esempio n. 24
0
 /// <summary>
 /// Page_Load runs when the control is loaded
 /// </summary>
 /// <history>
 /// 	[VMasanas]	23/09/2004	Created
 /// </history>
 protected void Page_Load( Object sender, EventArgs e )
 {
     try
     {
         if( ! Page.IsPostBack )
         {
             PortalController objportals = new PortalController();
             cboPortals.DataTextField = "PortalName";
             cboPortals.DataValueField = "PortalId";
             cboPortals.DataSource = objportals.GetPortals();
             cboPortals.DataBind();
         }
     }
     catch( Exception exc )
     {
         Exceptions.ProcessModuleLoadException( this, exc );
     }
 }
Esempio n. 25
0
		/// -----------------------------------------------------------------------------
        /// <summary>
        /// AddSearchResults adds a top level Hidden Search Results Page
        /// </summary>
        ///	<param name="moduleDefId">The Module Deinition Id for the Search Results Module</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
		private static void AddSearchResults(int moduleDefId)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddSearchResults:" + moduleDefId);
            var portalController = new PortalController();
            PortalInfo portal;
            var portals = portalController.GetPortals();
            int intPortal;

            //Add Page to Admin Menu of all configured Portals
            for (intPortal = 0; intPortal <= portals.Count - 1; intPortal++)
            {
                var tabPermissions = new TabPermissionCollection();

                portal = (PortalInfo) portals[intPortal];

                AddPagePermission(tabPermissions, "View", Convert.ToInt32(Globals.glbRoleAllUsers));
                AddPagePermission(tabPermissions, "View", Convert.ToInt32(portal.AdministratorRoleId));
                AddPagePermission(tabPermissions, "Edit", Convert.ToInt32(portal.AdministratorRoleId));

                //Create New Page (or get existing one)
                var tab = AddPage(portal.PortalID, Null.NullInteger, "Search Results", "", "", "", false, tabPermissions, false);

                //Add Module To Page
                AddModuleToPage(tab, moduleDefId, "Search Results", "");
            }
        }
        /// <summary>
        /// returns a target URL for the specific redirection
        /// </summary>
        /// <param name="redirection"></param>
        /// <param name="portalId"></param>
        /// <param name="currentTabId"></param>
        /// <returns></returns>
        public string GetRedirectUrlFromRule(IRedirection redirection, int portalId, int currentTabId)
        {
            string redirectUrl = string.Empty;

            if (redirection.TargetType == TargetType.Url) //independent url base
            {
                redirectUrl = redirection.TargetValue.ToString();
            }
            else if (redirection.TargetType == TargetType.Tab) //page within same site
            {
                int targetTabId = int.Parse(redirection.TargetValue.ToString());
                if (targetTabId != currentTabId) //ensure it's not redirecting to itself
                {
                    var tabController = new TabController();
                    var tab = tabController.GetTab(targetTabId, portalId, false);
                    if (tab != null && !tab.IsDeleted)
                    {
                        redirectUrl = Globals.NavigateURL(targetTabId);
                    }
                }
            }
            else if (redirection.TargetType == TargetType.Portal) //home page of another portal
            {
                int targetPortalId = int.Parse(redirection.TargetValue.ToString());
                if (targetPortalId != portalId) //ensure it's not redirecting to itself
                {
                    //check whethter the target portal still exists
                    var portalController = new PortalController();
                    if (portalController.GetPortals().Cast<PortalInfo>().Any(p => p.PortalID == targetPortalId))
                    {
                        var portalSettings = new PortalSettings(targetPortalId);
                        if (portalSettings.HomeTabId != Null.NullInteger && portalSettings.HomeTabId != currentTabId) //ensure it's not redirecting to itself
                        {
                            redirectUrl = GetPortalHomePageUrl(portalSettings);
                        }
                    }
                }
            }

            return redirectUrl;
        }
Esempio n. 27
0
        ///-----------------------------------------------------------------------------
        ///<summary>
        ///  AddAdminPages adds an Admin Page and an associated Module to all configured Portals
        ///</summary>
        ///<param name = "tabName">The Name to give this new Tab</param>
        ///<param name="description"></param>
        ///<param name = "tabIconFile">The Icon for this new Tab</param>
        ///<param name="tabIconFileLarge"></param>
        ///<param name = "isVisible">A flag indicating whether the tab is visible</param>
        ///<param name = "moduleDefId">The Module Deinition Id for the module to be aded to this tab</param>
        ///<param name = "moduleTitle">The Module's title</param>
        ///<param name = "moduleIconFile">The Module's icon</param>
        ///<param name = "inheritPermissions">Modules Inherit the Pages View Permisions</param>
        ///<history>
        ///  [cnurse]	11/11/2004	created
        ///</history>
        ///-----------------------------------------------------------------------------
        public static void AddAdminPages(string tabName, string description, string tabIconFile, string tabIconFileLarge, bool isVisible, int moduleDefId, string moduleTitle, string moduleIconFile, bool inheritPermissions)
        {
            var portalController = new PortalController();
            ArrayList portals = portalController.GetPortals();

            //Add Page to Admin Menu of all configured Portals
            for (int intPortal = 0; intPortal <= portals.Count - 1; intPortal++)
            {
                var portal = (PortalInfo) portals[intPortal];

                //Create New Admin Page (or get existing one)
                TabInfo newPage = AddAdminPage(portal, tabName, description, tabIconFile, tabIconFileLarge, isVisible);

                //Add Module To Page
                AddModuleToPage(newPage, moduleDefId, moduleTitle, moduleIconFile, inheritPermissions);
            }
        }
        private static void UpdateSupportedFeatures(object objController, int desktopModuleId)
        {
            try
            {
                DesktopModuleInfo desktopModule = DesktopModuleController.GetDesktopModule(desktopModuleId, Null.NullInteger);
                if ((desktopModule != null))
                {
                    //Initialise the SupportedFeatures
                    desktopModule.SupportedFeatures = 0;

                    //Test the interfaces
                    desktopModule.IsPortable = (objController is IPortable);
#pragma warning disable 0618
                    desktopModule.IsSearchable = (objController is ModuleSearchBase) || (objController is ISearchable);
#pragma warning restore 0618
                    desktopModule.IsUpgradeable = (objController is IUpgradeable);
                    DesktopModuleController.SaveDesktopModule(desktopModule, false, false, false);

                    var portalController = new PortalController();
                    foreach (PortalInfo portal in portalController.GetPortals())
                    {
                        DataCache.RemoveCache(String.Format(DataCache.DesktopModuleCacheKey, portal.PortalID));
                        DataCache.RemoveCache(String.Format(DataCache.PortalDesktopModuleCacheKey, portal.PortalID));
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
        }
Esempio n. 29
0
        private void LoadPortalsList()
        {
            var portalCtrl = new PortalController();
            ArrayList portals = portalCtrl.GetPortals();

            SitesLst.ClearSelection();
            SitesLst.Items.Clear();

            SitesLst.DataSource = portals;
            SitesLst.DataTextField = "PortalName";
            SitesLst.DataValueField = "PortalID";
            SitesLst.DataBind();

            //SitesLst.Items.Insert(0, new ListItem(string.Empty));
            SitesLst.InsertItem(0, string.Empty, string.Empty);
        }
Esempio n. 30
0
        public static void ClearHostCache(bool Cascade)
        {
            RemoveCache("GetHostSettings");
            RemoveCache("GetPortalByAlias");
            RemoveCache("CSS");
            RemoveCache("Folders:-1");
            if (Cascade)
            {
                PortalController objPortals = new PortalController();
                PortalInfo objPortal = null;
                ArrayList arrPortals = objPortals.GetPortals();

                int intIndex = 0;
                for (intIndex = 0; intIndex < arrPortals.Count; intIndex++)
                {
                    objPortal = (PortalInfo)(arrPortals[intIndex]);
                    ClearPortalCache(objPortal.PortalID, Cascade);
                }
            }
        }
Esempio n. 31
0
 private static void MovePhotoProperty()
 {
     DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "MovePhotoProperty");
     var portalController = new PortalController();
     foreach (PortalInfo portal in portalController.GetPortals())
     {
         var properties = ProfileController.GetPropertyDefinitionsByPortal(portal.PortalID).Cast<ProfilePropertyDefinition>();
         var propPhoto = properties.FirstOrDefault(p => p.PropertyName == "Photo");
         if (propPhoto != null)
         {
             var maxOrder = properties.Max(p => p.ViewOrder);
             if (propPhoto.ViewOrder != maxOrder)
             {
                 properties.Where(p => p.ViewOrder > propPhoto.ViewOrder).ToList().ForEach(p =>
                 {
                     p.ViewOrder -= 2;
                     ProfileController.UpdatePropertyDefinition(p);
                 });
                 propPhoto.ViewOrder = maxOrder;
                 ProfileController.UpdatePropertyDefinition(propPhoto);
             }
         }
     }
 }
Esempio n. 32
0
        private static void ReplaceMessagingModule()
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "ReplaceMessagingModule");
            var portalController = new PortalController();
            var moduleController = new ModuleController();
            var tabController = new TabController();

            var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center");
            if (moduleDefinition == null) return;

            var portals = portalController.GetPortals();
            foreach (PortalInfo portal in portals)
            {
                if (portal.UserTabId > Null.NullInteger)
                {
                    //Find TabInfo
                    TabInfo tab = tabController.GetTab(portal.UserTabId, portal.PortalID, true);
                    if (tab != null)
                    {
                        //Add new module to the page
                        AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", "", true);
                    }

                    foreach (KeyValuePair<int, ModuleInfo> kvp in moduleController.GetTabModules(portal.UserTabId))
                    {
                        var module = kvp.Value;
                        if (module.DesktopModule.FriendlyName == "Messaging")
                        {
                            //Delete the Module from the Modules list
                            moduleController.DeleteTabModule(module.TabID, module.ModuleID, false);
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// TransferUsersToMembershipProvider transfers legacy users to the
        ///	new ASP.NET MemberRole Architecture
        /// </summary>
        /// <history>
        /// 	[cnurse]	11/6/2004	documented
        ///     [cnurse]    12/15/2005  Moved to MembershipProvider
        /// </history>
        public override void TransferUsersToMembershipProvider()
        {
            int j;
            ArrayList arrUsers = new ArrayList();
            UserController objUserController = new UserController();

            //Get the Super Users and Transfer them to the Provider
            arrUsers = GetLegacyUsers( dataProvider.GetSuperUsers() );
            TransferUsers( - 1, arrUsers, true );

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

            for( j = 0; j <= arrPortals.Count - 1; j++ )
            {
                PortalInfo objPortal;
                objPortal = (PortalInfo)arrPortals[j];

                RoleController objRoles = new RoleController();
                ArrayList arrRoles = objRoles.GetPortalRoles( objPortal.PortalID );
                int q;
                for( q = 0; q <= arrRoles.Count - 1; q++ )
                {
                    try
                    {
                        System.Web.Security.Roles.CreateRole( ( (RoleInfo)arrRoles[q] ).RoleName );
                    }
                    catch( Exception exc )
                    {
                        Exceptions.LogException( exc );
                    }
                }

                //Get the Portal Users and Transfer them to the Provider
                arrUsers = GetLegacyUsers( dataProvider.GetUsers( objPortal.PortalID ) );
                TransferUsers( objPortal.PortalID, arrUsers, false );
            }
        }
Esempio n. 34
0
        public static void RemoveAdminPages(string tabPath)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "RemoveAdminPages:" + tabPath);
            var portalController = new PortalController();
            var tabController = new TabController();

            ArrayList portals = portalController.GetPortals();
            foreach (PortalInfo portal in portals)
            {
                int tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath, Null.NullString);
                if ((tabID != Null.NullInteger))
                {
                    tabController.DeleteTab(tabID, portal.PortalID);
                }
            }
        }
Esempio n. 35
0
        public static void AddModuleToPages(string tabPath, int moduleDefId, string moduleTitle, string moduleIconFile, bool inheritPermissions)
        {
            var objPortalController = new PortalController();
            var objTabController = new TabController();

            ArrayList portals = objPortalController.GetPortals();
            foreach (PortalInfo portal in portals)
            {
                int tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath, Null.NullString);
                if ((tabID != Null.NullInteger))
                {
                    TabInfo tab = objTabController.GetTab(tabID, portal.PortalID, true);
                    if ((tab != null))
                    {
                        AddModuleToPage(tab, moduleDefId, moduleTitle, moduleIconFile, inheritPermissions);
                    }
                }
            }
        }