Example #1
0
        public IHttpHandler GetDnnHttpHandler(RequestContext requestContext, int portal, int tab, string[] passThrough)
        {
            PortalController pcontroller = new PortalController();
            PortalInfo pinfo = pcontroller.GetPortal(portal);
            PortalAliasController pacontroller = new PortalAliasController();
            PortalAliasCollection pacollection = pacontroller.GetPortalAliasByPortalID(portal);
            //pacollection.
            //PortalSettings psettings = new PortalSettings(pinfo);
            PortalSettings psettings = new PortalSettings(tab, portal);               // 64 is the stats tab. TODO: get by page name and not hardcoded id
            foreach (string key in pacollection.Keys)
            {
                psettings.PortalAlias = pacollection[key];
            }
            TabController tcontroller = new TabController();
            // psettings.ActiveTab = tcontroller.GetTab(57, 0, true);                  // 57 is the profile tab.
            requestContext.HttpContext.Items["PortalSettings"] = psettings;

            requestContext.HttpContext.Items["UrlRewrite:OriginalUrl"] = requestContext.HttpContext.Request.RawUrl;
            //UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetUserByName(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetCachedUser(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            requestContext.HttpContext.Items["UserInfo"] = uinfo;
            foreach (string s in passThrough)
            {
                requestContext.HttpContext.Items[s] = requestContext.RouteData.Values[s];
            }
            IHttpHandler page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(DotNetNuke.Framework.PageBase)) as IHttpHandler;
            return page;
        }
        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;
        }
        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");
                    }
                }

            }
        }
        /// <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 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;
        }
Example #7
0
        private static bool DeleteUserRoleInternal(int portalId, int userId, int roleId)
        {
            var roleController = new RoleController();
            var user = UserController.GetUserById(portalId, userId);
            var userRole = roleController.GetUserRole(portalId, userId, roleId);
            var portalController = new PortalController();
            bool delete = true;
            var portal = portalController.GetPortal(portalId);
            if (portal != null && userRole != null)
            {
                if (CanRemoveUserFromRole(portal, userId, roleId))
                {
                    provider.RemoveUserFromRole(portalId, user, userRole);
                    var objEventLog = new EventLogController();
                    objEventLog.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.ROLE_UPDATED);

                    //Remove the UserInfo from the Cache, as it has been modified
                    DataCache.ClearUserCache(portalId, user.Username);
                    TestableRoleController.Instance.ClearRoleCache(portalId);
                }
                else
                {
                    delete = false;
                }
            }
            return delete;
        }
        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);
     }
 }
Example #10
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";
            }
        }
Example #12
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
        }
 public void MustHaveSandboxedPaymentSettings()
 {
     var portalController = new PortalController();
     var site = portalController.GetPortal(0);
     if (site.ProcessorPassword == string.Empty)
     {
         PortalController.UpdatePortalSetting(0, "paypalsandbox", "true");
         //uses PayPal sandbox account.
         site.ProcessorUserId = "PayPal";
         site.ProcessorPassword = "******";
         site.ProcessorUserId = "*****@*****.**";
         portalController.UpdatePortalInfo(site);
     }
     WebConfigManager.TouchConfig(PhysicalPath);
 }
Example #14
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);
            }
        }
Example #16
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);
            }
        }
        private Dictionary<string, string> GetSkins(string skinRoot)
        {
            // load host skins
            var skins = SkinController.GetSkins(null, skinRoot, SkinScope.Host).ToDictionary(skin => skin.Key, skin => skin.Value);

            if (IncludePortalSkins)
            {
                // load portal skins
                var portalController = new PortalController();
                var portal = portalController.GetPortal(PortalId);

                foreach (var skin in SkinController.GetSkins(portal, skinRoot, SkinScope.Site))
                {
                    skins.Add(skin.Key, skin.Value);
                }
            }
            return skins;
        }
Example #19
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);
        }
Example #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "application/json";
        object json = new { Status = "Login Failed" };

        if (!string.IsNullOrWhiteSpace(Request.Form["u"]))
        {
            aqufitEntities entities = new aqufitEntities();
            string         uname    = Request.Form["u"];
            string         password = Request.Form["p"];
            if (uname.Contains("@"))
            {   // this is an email login
                User user = entities.UserSettings.OfType <User>().FirstOrDefault(u => u.UserEmail == uname);
                if (user == null)
                {
                    json = new { Status = "Email ERROR" };
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;
                }
                uname = user.UserName;
            }
            uname = uname.ToLower();
            DotNetNuke.Security.Membership.UserLoginStatus status = DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_FAILURE;
            DotNetNuke.Entities.Portals.PortalController   pc     = new DotNetNuke.Entities.Portals.PortalController();
            DotNetNuke.Entities.Portals.PortalInfo         pi     = pc.GetPortal(0);
            UserInfo uinfo = UserController.UserLogin(0, uname, password, null, pi.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status, true);
            if (status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS || status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER)
            {
                UserSettings usersettings = entities.UserSettings.OfType <User>().FirstOrDefault(u => u.UserKey == uinfo.UserID && u.PortalKey == 0);
                if (!usersettings.Guid.HasValue)
                {   // we only add a UUID if there was none before.. this is so the "remember me" on the desktop site will still work.
                    usersettings.Guid = Guid.NewGuid();
                    entities.SaveChanges();
                }
                json = new { Status = "SUCCESS", Token = usersettings.Guid.ToString(), UserId = usersettings.Id, Username = usersettings.UserName };
            }
        }
        Response.Write(serializer.Serialize(json));
        Response.Flush();
        Response.End();
    }
Example #21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.ContentType = "application/json";
     object json = new { Status = "Login Failed" };
     if (!string.IsNullOrWhiteSpace(Request.Form["u"]))
     {
         aqufitEntities entities = new aqufitEntities();
         string uname = Request.Form["u"];
         string password = Request.Form["p"];
         if (uname.Contains("@"))
         {   // this is an email login
             User user = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserEmail == uname);
             if (user == null)
             {
                 json = new { Status = "Email ERROR" };
                 Response.Write(json);
                 Response.Flush();
                 Response.End();
                 return;
             }
             uname = user.UserName;
         }
         uname = uname.ToLower();
         DotNetNuke.Security.Membership.UserLoginStatus status = DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_FAILURE;
         DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController();
         DotNetNuke.Entities.Portals.PortalInfo pi = pc.GetPortal(0);
         UserInfo uinfo = UserController.UserLogin(0, uname, password, null, pi.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status, true);
         if (status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS || status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER)
         {
             UserSettings usersettings = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserKey == uinfo.UserID && u.PortalKey == 0);
             if (!usersettings.Guid.HasValue)
             {   // we only add a UUID if there was none before.. this is so the "remember me" on the desktop site will still work.
                 usersettings.Guid = Guid.NewGuid();
                 entities.SaveChanges();
             }
             json = new { Status = "SUCCESS", Token = usersettings.Guid.ToString(), UserId = usersettings.Id, Username = usersettings.UserName };
         }
     }
     Response.Write(serializer.Serialize( json ));
     Response.Flush();
     Response.End();
 }
		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");
			            }
		            }
	            }
            }
		}
        /// <summary>
        /// LoadStyleSheet loads the stylesheet
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/8/2004	Created
        /// </history>
        private void LoadStyleSheet()
        {
            string strUploadDirectory = "";

            PortalController objPortalController = new PortalController();
            PortalInfo objPortal = objPortalController.GetPortal( intPortalId );
            if( objPortal != null )
            {
                strUploadDirectory = objPortal.HomeDirectoryMapPath;
            }

            // read CSS file
            if( File.Exists( strUploadDirectory + "portal.css" ) )
            {
                StreamReader objStreamReader;
                objStreamReader = File.OpenText( strUploadDirectory + "portal.css" );
                txtStyleSheet.Text = objStreamReader.ReadToEnd();
                objStreamReader.Close();
            }
        }
Example #24
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);
                }
            }
        }
Example #25
0
        //Get portal list to overcome problem with DNN6 GetPortals when ran from scheduler.
        public static List <PortalInfo> GetAllPortals()
        {
            var        pList = new List <PortalInfo>();
            var        objPC = new DotNetNuke.Entities.Portals.PortalController();
            PortalInfo objPInfo;

            for (var lp = 0; lp <= 500; lp++)
            {
                objPInfo = objPC.GetPortal(lp);
                if ((objPInfo != null))
                {
                    pList.Add(objPInfo);
                }
                else
                {
                    break;
                }
            }

            return(pList);
        }
Example #26
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
            }
        }
        /// <summary>
        /// Delete/Remove a User from a Role
        /// </summary>
        /// <param name="PortalId">The Id of the Portal</param>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <returns></returns>
        public bool DeleteUserRole(int PortalId, int UserId, int RoleId)
        {
            UserInfo objUser = UserController.GetUser(PortalId, UserId, false);
            UserRoleInfo objUserRole = GetUserRole(PortalId, UserId, RoleId);

            PortalController objPortals = new PortalController();
            bool blnDelete = true;

            PortalInfo objPortal = objPortals.GetPortal(PortalId);
            if (objPortal != null)
            {
                if ((objPortal.AdministratorId != UserId || objPortal.AdministratorRoleId != RoleId) && objPortal.RegisteredRoleId != RoleId)
                {
                    provider.RemoveUserFromRole(PortalId, objUser, objUserRole);
                }
                else
                {
                    blnDelete = false;
                }
            }

            return blnDelete;
        }
Example #28
0
File: V5.cs Project: 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);
        }
Example #29
0
        private string ExportModule(int moduleID, string fileName, IFolderInfo folder)
        {
            var strMessage = "";
            if (Module != null)
            {
                if (!String.IsNullOrEmpty(Module.DesktopModule.BusinessControllerClass) && Module.DesktopModule.IsPortable)
                {
                    try
                    {
                        var objObject = Reflection.CreateObject(Module.DesktopModule.BusinessControllerClass, Module.DesktopModule.BusinessControllerClass);
                        
						//Double-check
						if (objObject is IPortable)
                        {
                            var content = Convert.ToString(((IPortable)objObject).ExportModule(moduleID));
                            if (!String.IsNullOrEmpty(content))
                            {
								//remove invalid chars in content
	                            content = Regex.Replace(content, _invalidCharsRegex, string.Empty);
								//add attributes to XML document
                                content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<content type=\"" + CleanName(Module.DesktopModule.ModuleName) + "\" version=\"" +
                                          Module.DesktopModule.Version + "\">" + content + "</content>";

                                //First check the Portal limits will not be exceeded (this is approximate)
                                var objPortalController = new PortalController();
                                var strFile = PortalSettings.HomeDirectoryMapPath + folder.FolderPath + fileName;
                                if (objPortalController.HasSpaceAvailable(PortalId, content.Length))
                                {
                                    //add file to Files table
									using (var fileContent = new MemoryStream(Encoding.UTF8.GetBytes(content)))
									{
										FileManager.Instance.AddFile(folder, fileName, fileContent, true, true, "application/octet-stream");
									}
                                }
                                else
                                {
                                    strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFile);
                                }
                            }
                            else
                            {
                                strMessage = Localization.GetString("NoContent", LocalResourceFile);
                            }
                        }
                        else
                        {
                            strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
                        }
                    }
                    catch
                    {
                        strMessage = Localization.GetString("Error", LocalResourceFile);
                    }
                }
                else
                {
                    strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
                }
            }
            return strMessage;
        }
        private void BindSkinsAndContainers()
        {
            var portalController = new PortalController();
            var portal = portalController.GetPortal(PortalSettings.PortalId);

            var skins = SkinController.GetSkins(portal, SkinController.RootSkin, SkinScope.All)
                                         .ToDictionary(skin => skin.Key, skin => skin.Value);
            var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.All)
                                                    .ToDictionary(skin => skin.Key, skin => skin.Value);

            drpSkin.Items.Clear();
            drpSkin.DataSource = skins;
            drpSkin.DataBind();
            //drpSkin.Items.Insert(0, new ListItem(Localization.GetString("DefaultSkin", LocalResourceFile), ""));
            drpSkin.InsertItem(0, Localization.GetString("DefaultSkin", LocalResourceFile), "");

            drpContainer.Items.Clear();
            drpContainer.DataSource = containers;
            drpContainer.DataBind();
            //drpContainer.Items.Insert(0, new ListItem(Localization.GetString("DefaultContainer", LocalResourceFile), ""));
            drpContainer.InsertItem(0, Localization.GetString("DefaultContainer", LocalResourceFile), "");
        }
        protected void CtlPagesContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            SelectedNode = e.Node.Value;

            var tabController = new TabController();
            var portalId = rblMode.SelectedValue == "H" ? Null.NullInteger : PortalId;
            var objTab = tabController.GetTab(int.Parse(e.Node.Value), portalId, false);

            switch (e.MenuItem.Value.ToLower())
            {
                case "makehome":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        var portalController = new PortalController();
                        PortalInfo portalInfo = portalController.GetPortal(PortalId);
                        portalInfo.HomeTabId = objTab.TabID;
                        PortalSettings.HomeTabId = objTab.TabID;
                        portalController.UpdatePortalInfo(portalInfo);
                        DataCache.ClearPortalCache(PortalId, false);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabMadeHome", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "view":
                    Response.Redirect(objTab.FullUrl);
                    break;
                case "edit":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        var editUrl = Globals.NavigateURL(objTab.TabID, "Tab", "action=edit", "returntabid=" + TabId);
                        // Prevent PageSettings of the current page in a popup if SSL is enabled and enforced, which causes redirection/javascript broswer security issues.
                        if (PortalSettings.EnablePopUps && !(objTab.TabID == TabId && (PortalSettings.SSLEnabled && PortalSettings.SSLEnforced)))
                        {
                            editUrl = UrlUtils.PopUpUrl(editUrl, this, PortalSettings, true, false);
                            var script = string.Format("<script type=\"text/javascript\">{0}</script>", editUrl);
                            ClientAPI.RegisterStartUpScript(Page, "EditInPopup", script);
                        }
                        else
                        {
                            Response.Redirect(editUrl, true);
                        }
                    }
                    break;
                case "delete":
                    if (TabPermissionController.CanDeletePage(objTab))
                    {
                        tabController.SoftDeleteTab(objTab.TabID, PortalSettings);
                        BindTree();
                        //keep the parent tab selected
                        if (objTab.ParentId != Null.NullInteger)
                        {
                            SelectedNode = objTab.ParentId.ToString(CultureInfo.InvariantCulture);
                            ctlPages.FindNodeByValue(SelectedNode).Selected = true;
                            ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes();
                            BindTab(objTab.ParentId);
                        }
                        else
                        {
                            pnlDetails.Visible = false;
                        }
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDeleted", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "add":
                    if ((objTab!= null && TabPermissionController.CanAddPage(objTab)) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
                    {
                        pnlBulk.Visible = true;
                        btnBulkCreate.CommandArgument = e.Node.Value;
                        ctlPages.FindNodeByValue(e.Node.Value).Selected = true;
                        txtBulk.Focus();
                        pnlDetails.Visible = false;
                        //Response.Redirect(NavigateURL(objTab.TabID, "Tab", "action=add", "returntabid=" & TabId.ToString), True)
                    }
                    break;
                case "hide":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabHidden", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "show":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabShown", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "disable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDisabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "enable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabEnabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
            }
        }
Example #32
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);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                UserInfo objUserInfo = null;
                int intUserID = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }
                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }
                string strProcessorUserId = "";
                var objPortalController = new PortalController();
                PortalInfo objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }
                Dictionary<string, string> settings = PortalController.GetPortalSettingsDictionary(PortalSettings.PortalId);
                string strPayPalURL;
                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    // Sandbox mode
                    if (settings.ContainsKey("paypalsandbox") && !String.IsNullOrEmpty(settings["paypalsandbox"]) && settings["paypalsandbox"] == "true")
                    {
                        strPayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
                    }
                    else
                    {
                        strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";
                    }

                    if (Request.QueryString["cancel"] != null)
                    {
                        //build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";
                        var objRoles = new RoleController();
                        RoleInfo objRole = objRoles.GetRole(intRoleId, PortalSettings.PortalId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }

                            //explicitely format numbers using en-US so numbers are correctly built
                            var enFormat = new CultureInfo("en-US");
                            string strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string strTrial = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);
                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")
                            {
                                //build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                //build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " every " + intBillingPeriod + " " + GetBillingFrequencyCode(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }
                        var ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region);
                                strPayPalURL += "&address1=" +
                                                Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") +
                                                                       objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch (Exception ex)
                        {
                            //issue getting user address
                            DnnLog.Error(ex);
                        }

                        //Return URL
                        if (settings.ContainsKey("paypalsubscriptionreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptionreturn"]))
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Cancellation URL
                        if (settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"]))
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptioncancelreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Instant Payment Notification URL
                        if (settings.ContainsKey("paypalsubscriptionnotifyurl") && !string.IsNullOrEmpty(settings["paypalsubscriptionnotifyurl"]))
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionnotifyurl"]);
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }
                        strPayPalURL += "&sra=1"; //reattempt on failure
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    if ((settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"])))
                    {
                        strPayPalURL = settings["paypalsubscriptioncancelreturn"];
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
        protected virtual void UpdateSkinSettings(TabInfo activeTab, PortalSettings portalSettings)
        {
            if (Globals.IsAdminSkin())
            {
                //DNN-6170 ensure skin value is culture specific
                activeTab.SkinSrc = String.IsNullOrEmpty(PortalController.GetPortalSetting("DefaultAdminSkin", portalSettings.PortalId,
                                                                                           Host.Host.DefaultAdminSkin, portalSettings.CultureCode)) ? portalSettings.DefaultAdminSkin : PortalController.GetPortalSetting("DefaultAdminSkin", portalSettings.PortalId,
                                                                                                                                                                                                                          Host.Host.DefaultAdminSkin, portalSettings.CultureCode);
            }
            else if (String.IsNullOrEmpty(activeTab.SkinSrc))
            {
                //DNN-6170 ensure skin value is culture specific
                activeTab.SkinSrc = String.IsNullOrEmpty(PortalController.GetPortalSetting("DefaultPortalSkin", portalSettings.PortalId,
                                                                                           Host.Host.DefaultPortalSkin, portalSettings.CultureCode)) ? portalSettings.DefaultPortalSkin : PortalController.GetPortalSetting("DefaultPortalSkin", portalSettings.PortalId,
                                                                                                                                                                                                                            Host.Host.DefaultPortalSkin, portalSettings.CultureCode);
            }
            activeTab.SkinSrc  = SkinController.FormatSkinSrc(activeTab.SkinSrc, portalSettings);
            activeTab.SkinPath = SkinController.FormatSkinPath(activeTab.SkinSrc);

            if (Globals.IsAdminSkin())
            {
                activeTab.ContainerSrc = String.IsNullOrEmpty(PortalController.GetPortalSetting("DefaultAdminContainer", portalSettings.PortalId,
                                                                                                Host.Host.DefaultAdminContainer, portalSettings.CultureCode)) ? portalSettings.DefaultAdminContainer : PortalController.GetPortalSetting("DefaultAdminContainer", portalSettings.PortalId,
                                                                                                                                                                                                                                         Host.Host.DefaultAdminContainer, portalSettings.CultureCode);
            }
            else if (String.IsNullOrEmpty(activeTab.ContainerSrc))
            {
                activeTab.ContainerSrc = String.IsNullOrEmpty(PortalController.GetPortalSetting("DefaultPortalContainer", portalSettings.PortalId,
                                                                                                Host.Host.DefaultPortalContainer, portalSettings.CultureCode)) ? portalSettings.DefaultPortalContainer : PortalController.GetPortalSetting("DefaultPortalContainer", portalSettings.PortalId,
                                                                                                                                                                                                                                           Host.Host.DefaultPortalContainer, portalSettings.CultureCode);
            }

            activeTab.ContainerSrc  = SkinController.FormatSkinSrc(activeTab.ContainerSrc, portalSettings);
            activeTab.ContainerPath = SkinController.FormatSkinPath(activeTab.ContainerSrc);
        }
Example #35
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cboFolders.SelectedIndexChanged += cboFolders_SelectedIndexChanged;
            optType.SelectedIndexChanged += optType_SelectedIndexChanged;
            cmdAdd.Click += cmdAdd_Click;
            cmdCancel.Click += cmdCancel_Click;
            cmdDelete.Click += cmdDelete_Click;
            cmdSave.Click += cmdSave_Click;
            cmdSelect.Click += cmdSelect_Click;
            cmdUpload.Click += cmdUpload_Click;

            try
            {
                var objPortals = new PortalController();
                if ((Request.QueryString["pid"] != null) && (Globals.IsHostTab(PortalSettings.ActiveTab.TabID) || UserController.GetCurrentUserInfo().IsSuperUser))
                {
                    _objPortal = objPortals.GetPortal(Int32.Parse(Request.QueryString["pid"]));
                }
                else
                {
                    _objPortal = objPortals.GetPortal(PortalSettings.PortalId);
                }
                if (ViewState["IsUrlControlLoaded"] == null)
                {
                    //If Not Page.IsPostBack Then
                    //let's make at least an initialization
                    //The type radio button must be initialized
                    //The url must be initialized no matter its value
                    _doRenderTypes = true;
                    _doChangeURL = true;
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
                    //The following line was mover to the pre-render event to ensure render for the first time
                    //ViewState("IsUrlControlLoaded") = "Loaded"
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #36
0
 public static void UpdateSiteSetting(int portalId, string settingName, string settingValue)
 {
     PortalController.UpdatePortalSetting(portalId, settingName, settingValue);
 }
Example #37
0
        /// <summary>
        /// Gets the portal alias info.
        /// </summary>
        /// <param name="httpAlias">The portal alias.</param>
        /// <returns>Portal alias info</returns>
        public static PortalAliasInfo GetPortalAliasInfo(string httpAlias)
        {
            string strPortalAlias;

            //try the specified alias first
            PortalAliasInfo portalAlias = GetPortalAliasLookup(httpAlias.ToLower());

            //domain.com and www.domain.com should be synonymous
            if (portalAlias == null)
            {
                if (httpAlias.ToLower().StartsWith("www."))
                {
                    //try alias without the "www." prefix
                    strPortalAlias = httpAlias.Replace("www.", "");
                }
                else //try the alias with the "www." prefix
                {
                    strPortalAlias = string.Concat("www.", httpAlias);
                }
                //perform the lookup
                portalAlias = GetPortalAliasLookup(strPortalAlias.ToLower());
            }
            //allow domain wildcards
            if (portalAlias == null)
            {
                //remove the domain prefix ( ie. anything.domain.com = domain.com )
                if (httpAlias.IndexOf(".", StringComparison.Ordinal) != -1)
                {
                    strPortalAlias = httpAlias.Substring(httpAlias.IndexOf(".", StringComparison.Ordinal) + 1);
                }
                else //be sure we have a clean string (without leftovers from preceding 'if' block)
                {
                    strPortalAlias = httpAlias;
                }
                //try an explicit lookup using the wildcard entry ( ie. *.domain.com )
                portalAlias = GetPortalAliasLookup("*." + strPortalAlias.ToLower()) ??
                              GetPortalAliasLookup(strPortalAlias.ToLower());

                if (portalAlias == null)
                {
                    //try a lookup using "www." + raw domain
                    portalAlias = GetPortalAliasLookup("www." + strPortalAlias.ToLower());
                }
            }
            if (portalAlias == null)
            {
                //check if this is a fresh install ( no alias values in collection )
                var portalAliases = TestablePortalAliasController.Instance.GetPortalAliases();
                if (portalAliases.Keys.Count == 0 || (portalAliases.Count == 1 && portalAliases.ContainsKey("_default")))
                {
                    //relate the PortalAlias to the default portal on a fresh database installation
                    DataProvider.Instance().UpdatePortalAlias(httpAlias.ToLower().Trim('/'), UserController.GetCurrentUserInfo().UserID);
                    var objEventLog = new EventLogController();
                    objEventLog.AddLog("PortalAlias",
                                       httpAlias,
                                       PortalController.GetCurrentPortalSettings(),
                                       UserController.GetCurrentUserInfo().UserID,
                                       EventLogController.EventLogType.PORTALALIAS_UPDATED);

                    //clear the cachekey "GetPortalByAlias" otherwise portalalias "_default" stays in cache after first install
                    DataCache.RemoveCache("GetPortalByAlias");
                    //try again
                    portalAlias = GetPortalAliasLookup(httpAlias.ToLower());
                }
            }
            return(portalAlias);
        }
Example #38
0
        protected void grdPortals_DeleteCommand( object source, DataGridCommandEventArgs e )
        {
            try
            {
                PortalController objPortalController = new PortalController();
                PortalInfo portal = objPortalController.GetPortal( Int32.Parse( e.CommandArgument.ToString() ) );

                if( portal != null )
                {
                    string strMessage = PortalController.DeletePortal( portal, Globals.GetAbsoluteServerPath( Request ) );
                    if( string.IsNullOrEmpty( strMessage ) )
                    {
                        EventLogController objEventLog = new EventLogController();
                        objEventLog.AddLog( "PortalName", portal.PortalName, PortalSettings, UserId, EventLogController.EventLogType.PORTAL_DELETED );
                        UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "PortalDeleted", LocalResourceFile ), ModuleMessageType.GreenSuccess );
                    }
                    else
                    {
                        UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
                    }
                }

                BindData();
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        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";
            }
        }