public static int GetCountOfState(
            SiteSettings siteSettings,
            PersonalizationScope scope,
            PersonalizationStateQuery query)
        {
            int result = 0;

            if (siteSettings != null)
            {
                Guid userGuid = Guid.Empty;
                if ((query.UsernameToMatch != null) && (query.UsernameToMatch.Length > 0))
                {
                    SiteUser siteUser = new SiteUser(siteSettings, query.UsernameToMatch);
                    if (siteUser.UserId > 0)
                    {
                        userGuid = siteUser.UserGuid;
                    }

                }

                bool allUsersScope = (scope == PersonalizationScope.Shared);
                result = SitePersonalization.GetCountOfState(
                    siteSettings.SiteId,
                    query.PathToMatch,
                    allUsersScope,
                    userGuid,
                    query.UserInactiveSinceDate);

            }

            return result;
        }
        private void BindList()
        {
            if (siteSettings == null) { siteSettings = CacheHelper.GetCurrentSiteSettings(); }
            //why is this null here, its declared
            if (chkAllowedRoles == null)
            {
                chkAllowedRoles = new CheckBoxList();
                if (this.Controls.Count == 0) { this.Controls.Add(chkAllowedRoles); }
            }

            chkAllowedRoles.Items.Clear();

            ListItem allItem = new ListItem();
            allItem.Text = Resource.RolesAllUsersRole;
            allItem.Value = "All Users";
            chkAllowedRoles.Items.Add(allItem);

            using (IDataReader reader = Role.GetSiteRoles(siteSettings.SiteId))
            {
                while (reader.Read())
                {
                    ListItem listItem = new ListItem();
                    listItem.Text = reader["DisplayName"].ToString();
                    listItem.Value = reader["RoleName"].ToString();

                    if ((selectedRoles.LastIndexOf(listItem.Value + ";") > -1))
                    {
                        listItem.Selected = true;
                    }

                    chkAllowedRoles.Items.Add(listItem);

                }
            }
        }
        private void LoadSettings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (WebUser.IsAdminOrContentAdmin || WebUser.IsInRoles(siteSettings.RolesThatCanDeleteFilesInEditor) || SiteUtils.UserIsSiteEditor())
            {
                canAccess = true;
            }
        }
        public override IFileSystem GetFileSystem(IFileSystemPermission permission)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            //IFileSystemPermission p = GetFileSystemPermission();
            if (permission == null) { return null; }
            if (string.IsNullOrEmpty(permission.VirtualRoot)) { return null; }

            return DiskFileSystem.GetFileSystem(permission);
        }
        public void ProcessRequest(HttpContext context)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null)
            {

                return;
            }
            RenderJsonList(context);
        }
        public override void DeleteSiteContent(int siteId)
        {
            SiteSettings siteSettings = new SiteSettings(siteId);
            CommerceReport.DeleteBySite(siteSettings.SiteGuid);
            FileAttachment.DeleteBySite(siteSettings.SiteGuid);
            EmailSendLog.DeleteBySite(siteSettings.SiteGuid);
            EmailTemplate.DeleteBySite(siteSettings.SiteGuid);
            ContentHistory.DeleteBySite(siteSettings.SiteGuid);
            ContentWorkflow.DeleteBySite(siteSettings.SiteGuid);

            ContentMetaRespository metaRepository = new ContentMetaRespository();
            metaRepository.DeleteBySite(siteSettings.SiteGuid);
        }
        public void ProcessRequest(HttpContext context)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null)
            {
                //TODO: should we return some xml with an error message?
                return;
            }

            imagebaseUrl = WebUtils.GetSiteRoot() + "/Data/Sites/" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture) +"/htmltemplateimages/";

            RenderXml(context);
        }
        private void LoadSettings(HttpContext context)
        {
            rpxToken = context.Request.Params.Get("token");

            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null) { return; }

            //if (siteSettings.SiteRoot.Length > 0)
            //{
            //    siteRoot = siteSettings.SiteRoot;
            //}
            //else
            //{
                siteRoot = SiteUtils.GetNavigationSiteRoot();
            //}
        }
        public static void LoadPersonalizationBlobs(
            SiteSettings siteSettings,
            WebPartManager webPartManager,
            string path,
            string userName,
            ref byte[] sharedDataBlob,
            ref byte[] userDataBlob)
        {
            if (siteSettings != null)
            {
                if ((userName != null) && (userName.Length > 0))
                {
                    SiteUser siteUser = new SiteUser(siteSettings, userName);
                    Guid userID = Guid.Empty;
                    if (siteUser.UserId > 0)
                    {
                        userID = siteUser.UserGuid;
                    }

                    if (userID != Guid.Empty)
                    {
                        userDataBlob = SitePersonalization.GetPersonalizationBlob(
                            siteSettings.SiteId,
                            path,
                            userID);

                        siteUser.UpdateLastActivityTime();

                        sharedDataBlob = SitePersonalization.GetPersonalizationBlobAllUsers(
                            siteSettings.SiteId,
                            path);

                    }
                }
                else
                {
                    //TODO: tracking/personalization for unauthenticated users?

                    sharedDataBlob = SitePersonalization.GetPersonalizationBlobAllUsers(
                            siteSettings.SiteId,
                            path);

                }

            }
        }
        private void LoadSettings(HttpContext context)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null) { return; }

            pageId = WebUtils.ParseInt32FromQueryString("pageid", true, pageId);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, moduleId);

            if (moduleId == -1) { return; }
            if (pageId == -1) { return; }

            galleryPage = new PageSettings(siteSettings.SiteId, pageId);
            if (galleryPage.PageId == -1) { return; }

            galleryModule = new Module(moduleId, pageId);
            if (galleryModule.ModuleId == -1) { return; }

            if ((!WebUser.IsInRoles(galleryPage.AuthorizedRoles)) && (!WebUser.IsInRoles(galleryModule.ViewRoles))) { return; }

            siteRoot = WebUtils.GetSiteRoot();

            //thumbnailBaseUrl = siteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
            //    + "/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";

            //fullSizeBaseUrl = siteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
            //    + "/GalleryImages/" + moduleId.ToInvariantString() + "/WebImages/";

            string baseUrl;
            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                baseUrl = siteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }
            else
            {
                baseUrl = siteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }

            thumbnailBaseUrl = baseUrl + "Thumbnails/";

            fullSizeBaseUrl = baseUrl + "WebImages/";

            gallery = new Gallery(moduleId);

            canRender = true;
        }
Exemple #11
0
        private bool LoadAndValidateForumObjects()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if(siteSettings == null)
            {
                //log.Info("SiteSettings was null");
                return false;
            }
            currentPage = CacheHelper.GetPage(pageId);
            if (
                (currentPage.PageId != pageId)
                || (currentPage.SiteId != siteSettings.SiteId)
                )
            {
                log.Info("request rejected - pageid did not match");
                return false;
            }

            thread = new ForumThread(threadId, postId);

            if (thread.ModuleId != moduleId)
            {
                log.Info("thread module id did not match");
                return false;
            }
            forum = new Forum(thread.ForumId);

            module = GetModule(thread.ModuleId);
            if (module == null)
            {
                log.Info("module not found in page modules");
                return false;
            }
            config = new ForumConfiguration(ModuleSettings.GetModuleSettings(module.ModuleId));
            if(thread.PostUserId > -1)
            {
                postUser = new SiteUser(siteSettings, thread.PostUserId);
            }

            return UserCanModerate();
        }
        // TODO: add link for site mail when authenticated
        // set to use top 30 here, link to OnlineMembers.aspx
        // for page able list of online members
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null) { this.Visible = false; return; }

            siteRoot = SiteUtils.GetNavigationSiteRoot();

            switch (siteSettings.AvatarSystem)
            {
                case "gravatar":
                    allowGravatars = true;
                    disableAvatars = false;
                    break;

                case "internal":
                    allowGravatars = false;
                    disableAvatars = false;
                    break;

                case "none":
                default:
                    allowGravatars = false;
                    disableAvatars = true;
                    break;

            }

            toolTipPrefix = Resource.OnlineMemberListProfileLinkPrefix;

            isAdmin = WebUser.IsAdmin;

            //if (Context.Request.IsAuthenticated)
            //{
            //    isAuthenticated = true;
            //}

            siteMailEnabled = WebConfigSettings.UseSiteMailFeature;

            PopulateControls();
        }
        public void InstallContent(Module module, string configInfo)
        {
            HtmlContent htmlContent = new HtmlContent();
            htmlContent.ModuleId = module.ModuleId;
            if (configInfo.StartsWith("~/"))
            {
                if (File.Exists(HostingEnvironment.MapPath(configInfo)))
                {
                    htmlContent.Body = File.ReadAllText(HostingEnvironment.MapPath(configInfo), Encoding.UTF8);
                }
            }
            else
            {
                htmlContent.Body = ResourceHelper.GetMessageTemplate(CultureInfo.CurrentUICulture, configInfo);
            }

            htmlContent.ModuleGuid = module.ModuleGuid;

            SiteSettings siteSettings = new SiteSettings(module.SiteId);
            SiteUser adminUser = null;
            if (siteSettings.UseEmailForLogin)
            {
                adminUser = new SiteUser(siteSettings, "*****@*****.**");
                if (adminUser.UserId == -1) { adminUser = null; }
            }
            else
            {
                adminUser = new SiteUser(siteSettings, "admin");
                if (adminUser.UserId == -1) { adminUser = null; }
            }

            if (adminUser != null)
            {
                htmlContent.UserGuid = adminUser.UserGuid;
                htmlContent.LastModUserGuid = adminUser.UserGuid;
            }

            HtmlRepository repository = new HtmlRepository();
            repository.Save(htmlContent);
        }
Exemple #14
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (HttpContext.Current == null) { return; }

            siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null) { return; }
            if (siteSettings.Slogan.Length == 0) { return; }

            if (topMarkup.Length > 0)
            {
                writer.Write(topMarkup);
            }

            writer.Write(HttpUtility.HtmlAttributeEncode(siteSettings.Slogan));
            //base.Render(writer);

            if (bottomMarkup.Length > 0)
            {
                writer.Write(bottomMarkup);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null)
            {

                return;
            }

            templateGuid = WebUtils.ParseGuidFromQueryString("g", templateGuid);
            if (templateGuid != Guid.Empty) { templateGuidString = templateGuid.ToString(); }

            if (templateGuid != Guid.Empty)
            {
                RenderTemplate(context);

            }
            else
            {
                RenderJsonList(context);

            }
        }
Exemple #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            isSiteEditor = SiteUtils.UserIsSiteEditor();

            if ((!isSiteEditor)&&(!WebUser.IsAdminOrContentAdmin))
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (Request.Params.Get("helpkey") != null)
            {
                helpKey = Request.Params.Get("helpkey");
            }

            PopulateLabels();

            if (!IsPostBack)
            {
                PopulateControls();
            }
        }
Exemple #17
0
        public static void EnsureRolesAndAdminUser(SiteSettings site)
        {
            SiteUser adminUser = EnsureAdminUser(site);

            if (!Role.Exists(site.SiteId, "Admins"))
            {
                Role adminRole = new Role();
                adminRole.RoleName = "Admins";
                adminRole.SiteId = site.SiteId;
                adminRole.SiteGuid = site.SiteGuid;
                adminRole.Save();
                adminRole.RoleName = "Administrators";
                adminRole.Save();

                Role.AddUser(adminRole.RoleId, adminUser.UserId, adminRole.RoleGuid, adminUser.UserGuid);

            }

            if (!Role.Exists(site.SiteId, "Role Admins"))
            {
                Role roleAdminRole = new Role();
                roleAdminRole.RoleName = "Role Admins";
                roleAdminRole.SiteId = site.SiteId;
                roleAdminRole.SiteGuid = site.SiteGuid;
                roleAdminRole.Save();
                roleAdminRole.RoleName = "Role Administrators";
                roleAdminRole.Save();
            }

            if (!Role.Exists(site.SiteId, "Content Administrators"))
            {
                Role contentAdminRole = new Role();
                contentAdminRole.RoleName = "Content Administrators";
                contentAdminRole.SiteId = site.SiteId;
                contentAdminRole.SiteGuid = site.SiteGuid;
                contentAdminRole.Save();
            }

            if (!Role.Exists(site.SiteId, "Authenticated Users"))
            {
                Role authenticatedUserRole = new Role();
                authenticatedUserRole.RoleName = "Authenticated Users";
                authenticatedUserRole.SiteId = site.SiteId;
                authenticatedUserRole.SiteGuid = site.SiteGuid;
                authenticatedUserRole.Save();
            }

            if (!Role.Exists(site.SiteId, "Content Publishers"))
            {
                Role contentPublisherRole = new Role();
                contentPublisherRole.RoleName = "Content Publishers";
                contentPublisherRole.SiteId = site.SiteId;
                contentPublisherRole.SiteGuid = site.SiteGuid;
                contentPublisherRole.Save();
            }

            if (!Role.Exists(site.SiteId, "Content Authors"))
            {
                Role contentAuthorRole = new Role();
                contentAuthorRole.RoleName = "Content Authors";
                contentAuthorRole.SiteId = site.SiteId;
                contentAuthorRole.SiteGuid = site.SiteGuid;
                contentAuthorRole.Save();
            }

            if (!Role.Exists(site.SiteId, "Newsletter Administrators"))
            {
                Role newsletterAdminRole = new Role();
                newsletterAdminRole.RoleName = "Newsletter Administrators";
                newsletterAdminRole.SiteId = site.SiteId;
                newsletterAdminRole.SiteGuid = site.SiteGuid;
                newsletterAdminRole.Save();
            }
        }
Exemple #18
0
        public static void EnsureFolderGalleryFolder(SiteSettings siteSettings)
        {
            if (HttpContext.Current == null) return;

            string path = "~/Data/Sites/" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture)
                + "/FolderGalleries/";

            if (!Directory.Exists(HttpContext.Current.Server.MapPath(path)))
            {
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path));
            }
        }
Exemple #19
0
        public static void CreateRequiredRolesAndAdminUser(SiteSettings site)
        {
            Role adminRole = new Role();
            adminRole.RoleName = "Admins";
            adminRole.SiteId = site.SiteId;
            adminRole.SiteGuid = site.SiteGuid;
            adminRole.Save();
            adminRole.RoleName = "Administrators";
            adminRole.Save();

            Role roleAdminRole = new Role();
            roleAdminRole.RoleName = "Role Admins";
            roleAdminRole.SiteId = site.SiteId;
            roleAdminRole.SiteGuid = site.SiteGuid;
            roleAdminRole.Save();
            roleAdminRole.RoleName = "Role Administrators";
            roleAdminRole.Save();

            Role contentAdminRole = new Role();
            contentAdminRole.RoleName = "Content Administrators";
            contentAdminRole.SiteId = site.SiteId;
            contentAdminRole.SiteGuid = site.SiteGuid;
            contentAdminRole.Save();

            Role authenticatedUserRole = new Role();
            authenticatedUserRole.RoleName = "Authenticated Users";
            authenticatedUserRole.SiteId = site.SiteId;
            authenticatedUserRole.SiteGuid = site.SiteGuid;
            authenticatedUserRole.Save();

            Role contentPublisherRole = new Role();
            contentPublisherRole.RoleName = "Content Publishers";
            contentPublisherRole.SiteId = site.SiteId;
            contentPublisherRole.SiteGuid = site.SiteGuid;
            contentPublisherRole.Save();

            Role contentAuthorRole = new Role();
            contentAuthorRole.RoleName = "Content Authors";
            contentAuthorRole.SiteId = site.SiteId;
            contentAuthorRole.SiteGuid = site.SiteGuid;
            contentAuthorRole.Save();

            Role newsletterAdminRole = new Role();
            newsletterAdminRole.RoleName = "Newsletter Administrators";
            newsletterAdminRole.SiteId = site.SiteId;
            newsletterAdminRole.SiteGuid = site.SiteGuid;
            newsletterAdminRole.Save();

            // if using related sites mode there is a problem if we already have user [email protected]
            // and we create another one in the child site with the same email and login so we need to make it different
            // we could just skip creating this user since in related sites mode all users come from the first site
            // but then if the config were changed to not related sites mode there would be no admin user
            // so in related sites mode we create one only as a backup in case settings are changed later
            int countOfSites = SiteSettings.SiteCount();
            string siteDifferentiator = string.Empty;
            if (
                (countOfSites >= 1)
                && (WebConfigSettings.UseRelatedSiteMode)
                )
            {
                if (site.SiteId > 1)
                {
                    siteDifferentiator = site.SiteId.ToInvariantString();
                }
            }

            mojoMembershipProvider membership = Membership.Provider as mojoMembershipProvider;
            bool overridRelatedSiteMode = true;
            SiteUser adminUser = new SiteUser(site, overridRelatedSiteMode);
            adminUser.Email = "admin" + siteDifferentiator + "@admin.com";
            adminUser.Name = "Admin";
            adminUser.LoginName = "admin" + siteDifferentiator;
            adminUser.Password = "******";

            if (membership != null)
            {
                adminUser.Password = membership.EncodePassword(site, adminUser, "admin");
            }

            adminUser.PasswordQuestion = "What is your user name?";
            adminUser.PasswordAnswer = "admin";
            adminUser.Save();

            Role.AddUser(adminRole.RoleId, adminUser.UserId, adminRole.RoleGuid, adminUser.UserGuid);
        }
Exemple #20
0
        public static void CreatePage(SiteSettings siteSettings, ContentPage contentPage, PageSettings parentPage)
        {
            PageSettings pageSettings = new PageSettings();
            pageSettings.PageGuid = Guid.NewGuid();

            if (parentPage != null)
            {
                pageSettings.ParentGuid = parentPage.PageGuid;
                pageSettings.ParentId = parentPage.PageId;
            }

            pageSettings.SiteId = siteSettings.SiteId;
            pageSettings.SiteGuid = siteSettings.SiteGuid;
            pageSettings.AuthorizedRoles = contentPage.VisibleToRoles;
            pageSettings.EditRoles = contentPage.EditRoles;
            pageSettings.DraftEditOnlyRoles = contentPage.DraftEditRoles;
            pageSettings.CreateChildPageRoles = contentPage.CreateChildPageRoles;
            pageSettings.MenuImage = contentPage.MenuImage;
            pageSettings.PageMetaKeyWords = contentPage.PageMetaKeyWords;
            pageSettings.PageMetaDescription = contentPage.PageMetaDescription;

            CultureInfo uiCulture = Thread.CurrentThread.CurrentUICulture;
            if (WebConfigSettings.UseCultureOverride)
            {
                uiCulture = SiteUtils.GetDefaultUICulture(siteSettings.SiteId);
            }

            if (contentPage.ResourceFile.Length > 0)
            {
                pageSettings.PageName = ResourceHelper.GetResourceString(contentPage.ResourceFile, contentPage.Name, uiCulture, false);
                if (contentPage.Title.Length > 0)
                {
                    pageSettings.PageTitle = ResourceHelper.GetResourceString(contentPage.ResourceFile, contentPage.Title, uiCulture, false);
                }
            }
            else
            {
                pageSettings.PageName = contentPage.Name;
                pageSettings.PageTitle = contentPage.Title;
            }

            pageSettings.PageOrder = contentPage.PageOrder;
            pageSettings.Url = contentPage.Url;
            pageSettings.RequireSsl = contentPage.RequireSsl;
            pageSettings.ShowBreadcrumbs = contentPage.ShowBreadcrumbs;

            pageSettings.BodyCssClass = contentPage.BodyCssClass;
            pageSettings.MenuCssClass = contentPage.MenuCssClass;
            pageSettings.IncludeInMenu = contentPage.IncludeInMenu;
            pageSettings.IsClickable = contentPage.IsClickable;
            pageSettings.IncludeInSiteMap = contentPage.IncludeInSiteMap;
            pageSettings.IncludeInChildSiteMap = contentPage.IncludeInChildPagesSiteMap;
            pageSettings.AllowBrowserCache = contentPage.AllowBrowserCaching;
            pageSettings.ShowChildPageBreadcrumbs = contentPage.ShowChildPageBreadcrumbs;
            pageSettings.ShowHomeCrumb = contentPage.ShowHomeCrumb;
            pageSettings.ShowChildPageMenu = contentPage.ShowChildPagesSiteMap;
            pageSettings.HideAfterLogin = contentPage.HideFromAuthenticated;
            pageSettings.EnableComments = contentPage.EnableComments;

            pageSettings.Save();

            if (!FriendlyUrl.Exists(siteSettings.SiteId, pageSettings.Url))
            {
                if (!WebPageInfo.IsPhysicalWebPage(pageSettings.Url))
                {
                    FriendlyUrl friendlyUrl = new FriendlyUrl();
                    friendlyUrl.SiteId = siteSettings.SiteId;
                    friendlyUrl.SiteGuid = siteSettings.SiteGuid;
                    friendlyUrl.PageGuid = pageSettings.PageGuid;
                    friendlyUrl.Url = pageSettings.Url.Replace("~/", string.Empty);
                    friendlyUrl.RealUrl = "~/Default.aspx?pageid=" + pageSettings.PageId.ToInvariantString();
                    friendlyUrl.Save();
                }
            }

            foreach (ContentPageItem pageItem in contentPage.PageItems)
            {

                // tni-20130624: moduleGuidxxxx handling
                Guid moduleGuid2Use = Guid.Empty;
                bool updateModule = false;

                Module findModule = null;

                if (pageItem.ModuleGuidToPublish != Guid.Empty)
                {
                    Module existingModule = new Module(pageItem.ModuleGuidToPublish);
                    if (existingModule.ModuleGuid == pageItem.ModuleGuidToPublish && existingModule.SiteId == siteSettings.SiteId)
                    {
                        Module.Publish(pageSettings.PageGuid, existingModule.ModuleGuid, existingModule.ModuleId, pageSettings.PageId,
                            pageItem.Location, pageItem.SortOrder, DateTime.UtcNow, DateTime.MinValue);

                        // tni: I assume there's nothing else to do now so let's go to the next content...
                        continue;
                    }
                }
                else if (pageItem.ModuleGuid != Guid.Empty)
                {
                    findModule = new Module(pageItem.ModuleGuid);
                    if (findModule.ModuleGuid == Guid.Empty)
                    {
                        // Module does not exist, we can create new one with the specified Guid
                        moduleGuid2Use = pageItem.ModuleGuid;
                    }

                    if (findModule.ModuleGuid == pageItem.ModuleGuid && findModule.SiteId == siteSettings.SiteId)
                    {
                        // The module already exist, we'll update existing one
                        updateModule = true;
                        moduleGuid2Use = findModule.ModuleGuid;
                    }
                }
                //

                ModuleDefinition moduleDef = new ModuleDefinition(pageItem.FeatureGuid);

                // this only adds if its not already there
                try
                {
                    SiteSettings.AddFeature(siteSettings.SiteGuid, pageItem.FeatureGuid);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

                if (moduleDef.ModuleDefId > -1)
                {

                    Module module = null;
                    if (updateModule && (findModule != null))
                    {
                        module = findModule;
                    }
                    else
                    {
                        module = new Module();
                        module.ModuleGuid = moduleGuid2Use;
                    }

                    module.SiteId = siteSettings.SiteId;
                    module.SiteGuid = siteSettings.SiteGuid;
                    module.PageId = pageSettings.PageId;
                    module.ModuleDefId = moduleDef.ModuleDefId;
                    module.FeatureGuid = moduleDef.FeatureGuid;
                    module.PaneName = pageItem.Location;
                    if (contentPage.ResourceFile.Length > 0)
                    {
                        module.ModuleTitle
                            = ResourceHelper.GetResourceString(contentPage.ResourceFile, pageItem.ContentTitle, uiCulture, false);
                    }
                    else
                    {
                        module.ModuleTitle = pageItem.ContentTitle;
                    }
                    module.ModuleOrder = pageItem.SortOrder;
                    module.CacheTime = pageItem.CacheTimeInSeconds;
                    module.Icon = moduleDef.Icon;
                    module.ShowTitle = pageItem.ShowTitle;
                    module.AuthorizedEditRoles = pageItem.EditRoles;
                    module.DraftEditRoles = pageItem.DraftEditRoles;
                    module.ViewRoles = pageItem.ViewRoles;
                    module.IsGlobal = pageItem.IsGlobal;
                    module.HeadElement = pageItem.HeadElement;
                    module.HideFromAuthenticated = pageItem.HideFromAuthenticated;
                    module.HideFromUnauthenticated = pageItem.HideFromAnonymous;

                    module.Save();

                    if ((pageItem.Installer != null) && (pageItem.ConfigInfo.Length > 0))
                    {
                        //this is the newer implementation for populating feature content
                        pageItem.Installer.InstallContent(module, pageItem.ConfigInfo);
                    }
                    else
                    {
                        // legacy implementation for backward compatibility
                        if (
                            (pageItem.FeatureGuid == HtmlContent.FeatureGuid)
                            && (pageItem.ContentTemplate.EndsWith(".config"))
                            )
                        {
                            HtmlContent htmlContent = new HtmlContent();
                            htmlContent.ModuleId = module.ModuleId;
                            htmlContent.Body = ResourceHelper.GetMessageTemplate(uiCulture, pageItem.ContentTemplate);
                            htmlContent.ModuleGuid = module.ModuleGuid;
                            HtmlRepository repository = new HtmlRepository();
                            repository.Save(htmlContent);

                        }
                    }

                    // tni-20130624: handling module settings
                    foreach (KeyValuePair<string, string> item in pageItem.ModuleSettings)
                    {
                        ModuleSettings.UpdateModuleSetting(module.ModuleGuid, module.ModuleId, item.Key, item.Value);
                    }

                }
            }

            foreach (ContentPage childPage in contentPage.ChildPages)
            {
                CreatePage(siteSettings, childPage, pageSettings);
            }
        }
Exemple #21
0
 public static void CreateNewSiteData(SiteSettings siteSettings)
 {
     CreateRequiredRolesAndAdminUser(siteSettings);
     CreateDefaultSiteFolders(siteSettings.SiteId);
     CreateOrRestoreSiteSkins(siteSettings.SiteId);
     if (PageSettings.GetCountOfPages(siteSettings.SiteId) == 0)
     {
         SetupDefaultContentPages(siteSettings);
     }
 }
Exemple #22
0
        public static SiteSettings CreateNewSite()
        {
            String templateFolderPath = GetMessageTemplateFolder();
            String templateFolder = templateFolderPath;

            SiteSettings newSite = new SiteSettings();

            newSite.SiteName = GetMessageTemplate(templateFolder, "InitialSiteNameContent.config");
            newSite.Skin = WebConfigSettings.DefaultInitialSkin;

            newSite.Logo = GetMessageTemplate(templateFolder, "InitialSiteLogoContent.config");

            newSite.AllowHideMenuOnPages = false;
            newSite.AllowNewRegistration = true;
            newSite.AllowPageSkins = false;
            newSite.AllowUserFullNameChange = false;
            newSite.AllowUserSkins = false;
            newSite.AutoCreateLdapUserOnFirstLogin = true;
            //newSite.DefaultFriendlyUrlPattern = SiteSettings.FriendlyUrlPattern.PageNameWithDotASPX;
            newSite.EditorSkin = SiteSettings.ContentEditorSkin.normal;
            //newSite.EncryptPasswords = false;
            newSite.Icon = String.Empty;
            newSite.IsServerAdminSite = true;
            newSite.ReallyDeleteUsers = true;
            newSite.SiteLdapSettings.Port = 389;
            newSite.SiteLdapSettings.RootDN = String.Empty;
            newSite.SiteLdapSettings.Server = String.Empty;
            newSite.UseEmailForLogin = true;
            newSite.UseLdapAuth = false;
            newSite.UseSecureRegistration = false;
            newSite.UseSslOnAllPages = WebConfigSettings.SslIsRequiredByWebServer;
            //newSite.CreateInitialDataOnCreate = false;

            newSite.AllowPasswordReset = true;
            newSite.AllowPasswordRetrieval = true;
            //0 = clear, 1= hashed, 2= encrypted
            newSite.PasswordFormat = WebConfigSettings.InitialSitePasswordFormat;

            newSite.RequiresQuestionAndAnswer = true;
            newSite.MaxInvalidPasswordAttempts = 10;
            newSite.PasswordAttemptWindowMinutes = 5;
            newSite.RequiresUniqueEmail = true;
            newSite.MinRequiredNonAlphanumericCharacters = 0;
            newSite.MinRequiredPasswordLength = 7;
            newSite.PasswordStrengthRegularExpression = String.Empty;
            newSite.DefaultEmailFromAddress = GetMessageTemplate(templateFolder, "InitialEmailFromContent.config");

            newSite.EnableMyPageFeature = false;

            newSite.Save();

            return newSite;
        }
Exemple #23
0
        public static void SetupDefaultContentPages(SiteSettings siteSettings)
        {
            ContentPageConfiguration appPageConfig
                = ContentPageConfiguration.GetConfig();

            foreach (ContentPage contentPage in appPageConfig.ContentPages)
            {
                CreatePage(siteSettings, contentPage, null);

            }

            CacheHelper.ResetSiteMapCache();
        }
 private void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     siteRoot = SiteUtils.GetNavigationSiteRoot();
     returnUrlCookieName = "ret"
         + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture);
 }
        private void LoadSetings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            repository = new CommentRepository();

            edComment.WebEditor.ToolBar = ToolBar.AnonymousUser;
            edComment.WebEditor.Height = Unit.Pixel(170);

            captcha.ProviderName = siteSettings.CaptchaProvider;
            captcha.Captcha.ControlID = "captcha" + contentGuid.ToString().Replace("-", "");
            //captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
            //captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;

            regexUrl.ErrorMessage = Resource.WebSiteUrlRegexWarning;
            regexEmail.ErrorMessage = Resource.NewsletterEmailRegexxMessage;

            reqEmail.ErrorMessage = Resource.EmailRequired;
            reqName.ErrorMessage = Resource.RegisterNameRequiredMessage;

            if ((!requireCaptcha) || (Request.IsAuthenticated))
            {
                pnlAntiSpam.Visible = false;
                captcha.Visible = false;
                captcha.Enabled = false;
            }

            divCommentUrl.Visible = showUserUrl;

            if (Request.IsAuthenticated)
            {
                divUserName.Visible = displaySettings.ShowNameInputWhenAuthenticated;
                divUserEmail.Visible = displaySettings.ShowEmailInputWhenAuthenticated;
                if (showUserUrl)
                {
                    divCommentUrl.Visible = displaySettings.ShowUrlInputWhenAuthenticated;
                }
            }

            divTitle.Visible = useCommentTitle;
            pnlRemeberMe.Visible = showRememberMe && !Request.IsAuthenticated;
        }
Exemple #26
0
        private void DoRender(HtmlTextWriter writer)
        {
            #if !MONO

            if (HttpContext.Current == null) { return; }
            if (!WebConfigSettings.MyPageIsInstalled) { return; }
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null) { return; }
            if (!siteSettings.EnableMyPageFeature) { return; }

            if (WebUser.IsInRoles(siteSettings.RolesThatCanViewMyPage))
            {
                if (renderAsListItem)
                {
                    //writer.Write("<li class='" + listItemCSS + "'>");
                    writer.WriteBeginTag("li");
                    writer.WriteAttribute("class", listItemCSS);
                    writer.Write(HtmlTextWriter.TagRightChar);

                }

                if (leftSeparatorImageUrl.Length > 0)
                {
                    writer.Write("<img class='accent' src='" + Page.ResolveUrl(leftSeparatorImageUrl) + "' border='0' /> ");
                }
                else
                {
                    if (UseLeftSeparator)
                    {
                        writer.Write("<span class='accent'>|</span>");
                    }
                }

                string urlToUse;
                if (WebConfigSettings.UseSslForMyPage)
                {
                    urlToUse = SiteUtils.GetSecureNavigationSiteRoot() + "/MyPage.aspx";
                }
                else
                {
                    urlToUse = SiteUtils.GetRelativeNavigationSiteRoot() + "/MyPage.aspx";
                    //if ((SiteUtils.IsSecureRequest()) && (!siteSettings.UseSslOnAllPages))
                    //{
                    //    urlToUse = urlToUse.Replace("https", "http");
                    //}
                }

                if (CssClass.Length == 0) CssClass = "sitelink";

                writer.WriteBeginTag("a");
                writer.WriteAttribute("class", CssClass);
                //writer.WriteAttribute("title", Resource.MyPageLink);
                writer.WriteAttribute("href", Page.ResolveUrl(urlToUse));
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.WriteEncodedText(Resource.MyPageLink);
                writer.WriteEndTag("a");

                if (renderAsListItem) writer.WriteEndTag("li");

            }

            #endif
        }
        private void LoadSettings()
        {
            lblErrorMessage.Text = String.Empty;
            isAdmin = WebUser.IsAdmin;
            isContentAdmin = WebUser.IsContentAdmin || SiteUtils.UserIsSiteEditor();
            useFolderForSiteDetection = WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites;
            divShowPasswordStrength.Visible = WebConfigSettings.EnableAjaxControlPasswordStrength;

            #if!MONO
            divTimeZone.Visible = true;

            #endif
            if (Request.QueryString["t"] != null)
            {
                requestedTab = Request.QueryString["t"];
            }

            divMyPage.Visible = WebConfigSettings.MyPageIsInstalled;
            divMyPageSkin.Visible = WebConfigSettings.MyPageIsInstalled;
            //myPagePermissionHeading.Visible = WebConfigSettings.MyPageIsInstalled;
            //myPagePermissionsDiv.Visible = WebConfigSettings.MyPageIsInstalled;

            if (SiteUtils.SslIsAvailable())
            {
                this.sslIsAvailable = true;
                this.divSSL.Visible = true;
            }
            else
            {
                this.divSSL.Visible = false;
            }

            lblSiteRoot.Text = SiteRoot;
            if (WebConfigSettings.GloballyDisableMemberUseOfWindowsLiveMessenger)
            {
                divLiveMessenger.Visible = false;
            }

            divApprovalsWorkflow.Visible = WebConfigSettings.EnableContentWorkflow;

            enableSiteSettingsSmtpSettings = WebConfigSettings.EnableSiteSettingsSmtpSettings;
            maskSMTPPassword = WebConfigSettings.MaskSmtpPasswordInSiteSettings;

            divOpenIDSelector.Visible = WebConfigSettings.ShowLegacyOpenIDSelector;
            divOpenID.Visible = WebConfigSettings.EnableOpenIdAuthentication;

            IsServerAdmin = siteSettings.IsServerAdminSite;

            divSiteIsClosed.Visible = (WebConfigSettings.AllowClosingSites) && (isAdmin || WebUser.IsContentAdmin);

            //divAdditionalMeta.Visible = WebConfigSettings.ShowAdditionalMeta;
            //divPageEncoding.Visible = WebConfigSettings.ShowPageEncoding;
            //txtDefaultPageEncoding.Text = mojoSetup.DefaultPageEncoding;

            currentSiteID = siteSettings.SiteId;
            currentSiteGuid = siteSettings.SiteGuid;

            selectedSiteID = siteSettings.SiteId;

            if ((IsServerAdmin)
                && (Page.Request.Params.Get("SiteID") != null)
                )
            {
                selectedSiteID  = WebUtils.ParseInt32FromQueryString("SiteID", selectedSiteID);

            }

            if ((selectedSiteID != siteSettings.SiteId)
                && (selectedSiteID > -1))
            {
                selectedSite = new SiteSettings((selectedSiteID));

            }
            else
            {
                selectedSite = siteSettings;
            }

            if (WebConfigSettings.SiteLogoUseMediaFolder)
            {
                logoPath = ImageSiteRoot
                + "/Data/Sites/" + selectedSite.SiteId.ToString() + "/media/logos/";
            }
            else
            {
                logoPath = ImageSiteRoot
                + "/Data/Sites/" + selectedSite.SiteId.ToString() + "/logos/";
            }

            imgLogo.Src = ImageSiteRoot
                + "/Data/SitesImages/1x1.gif";

            allowPasswordFormatChange
                = ((IsServerAdmin && WebConfigSettings.AllowPasswordFormatChange) || ((IsServerAdmin) && (selectedSiteID == -1)));

            if ((!IsServerAdmin) && (!WebConfigSettings.AllowPasswordFormatChangeInChildSites))
            {
                allowPasswordFormatChange = false;
            }

                //h3DefaultRootPageViewRoles.Visible = true;
                //divDefaultRootPageViewRoles.Visible = true;
                //h3DefaultRootPageEditRoles.Visible = true;
                //divDefaultRootPageEditRoles.Visible = true;
                //h3DefaultRootPageCreateChildPageRoles.Visible = true;
                //divDefaultRootPageCreateChildPageRoles.Visible = true;

                if (!WebConfigSettings.AllowMultipleSites)
                {
                    this.IsServerAdmin = false;
                }
                //else
                //{
                //    if ((!IsServerAdmin) && (WebConfigSettings.UseRelatedSiteMode))
                //    {
                //        // in related sites mode these are propagated from the master site
                //        // and should not be editable here
                //        chkRolesThatCanCreateUsers.Enabled = false;
                //        chkRolesThatCanLookupUsers.Enabled = false;
                //        chkRolesThatCanManageUsers.Enabled = false;
                //        chkRolesThatCanViewMemberList.Enabled = false;

                //    }

                //}

            try
            {
                // this keeps the action from changing during ajax postback in folder based sites
                SiteUtils.SetFormAction(Page, Request.RawUrl);
            }
            catch (MissingMethodException)
            {
                //this method was introduced in .NET 3.5 SP1
            }

            // I use this to prevent users from changing the mobile skin on the demo site
            ddMobileSkin.Enabled = siteSettings.IsServerAdminSite || WebConfigSettings.AllowSettingMobileSkinInChildSites || WebConfigSettings.MobilePhoneSkin.Length > 0;

            AddClassToBody("administration");
            AddClassToBody("sitesettings");
        }
Exemple #28
0
        private static SiteUser EnsureAdminUser(SiteSettings site)
        {
            // if using related sites mode there is a problem if we already have user [email protected]
            // and we create another one in the child site with the same email and login so we need to make it different
            // we could just skip creating this user since in related sites mode all users come from the first site
            // but then if the config were changed to not related sites mode there would be no admin user
            // so in related sites mode we create one only as a backup in case settings are changed later
            int countOfSites = SiteSettings.SiteCount();
            string siteDifferentiator = string.Empty;
            if (
                (countOfSites >= 1)
                && (WebConfigSettings.UseRelatedSiteMode)
                )
            {
                siteDifferentiator = site.SiteId.ToString(CultureInfo.InvariantCulture);
            }

            mojoMembershipProvider membership = Membership.Provider as mojoMembershipProvider;
            bool overridRelatedSiteMode = true;
            SiteUser adminUser = new SiteUser(site, overridRelatedSiteMode);
            adminUser.Email = "admin" + siteDifferentiator + "@admin.com";
            adminUser.Name = "Admin";
            adminUser.LoginName = "admin" + siteDifferentiator;
            bool userExists = false;
            if (site.UseEmailForLogin)
            {
                userExists = SiteUser.EmailExistsInDB(site.SiteId, adminUser.Email);
            }
            else
            {
                userExists = SiteUser.LoginExistsInDB(site.SiteId, adminUser.LoginName);
            }

            if (!userExists)
            {
                adminUser.Password = "******";

                if (membership != null)
                {
                    adminUser.Password = membership.EncodePassword(site, adminUser, "admin");
                }

                adminUser.PasswordQuestion = "What is your user name?";
                adminUser.PasswordAnswer = "admin";
                adminUser.Save();

                //Role.AddUser(adminRole.RoleId, adminUser.UserId, adminRole.RoleGuid, adminUser.UserGuid);
            }
            else
            {
                if (site.UseEmailForLogin)
                {
                    adminUser = new SiteUser(site, adminUser.Email);
                }
                else
                {
                    adminUser = new SiteUser(site, adminUser.LoginName);
                }
            }

            return adminUser;
        }
        public override void HandleNewOrderNotificationExtended(
            string requestXml,
            NewOrderNotificationExtended newOrder, 
            MerchantData merchantData)
        {
            //NotificationSerialNumber = newOrder.serialnumber;

            GoogleCheckoutLog gLog = new GoogleCheckoutLog();
            gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider";
            gLog.RawResponse = requestXml;
            gLog.NotificationType = "NewOrderNotification";
            gLog.SerialNumber = newOrder.serialnumber;
            gLog.OrderNumber = newOrder.googleordernumber;
            gLog.OrderTotal = newOrder.ordertotal.Value;
            gLog.BuyerId = newOrder.buyerid.ToString(CultureInfo.InvariantCulture);
            gLog.FullfillState = newOrder.fulfillmentorderstate.ToString();
            gLog.FinanceState = newOrder.financialorderstate.ToString();
            gLog.ShippingTotal = newOrder.ShippingCost;
            gLog.TaxTotal = newOrder.orderadjustment.totaltax.Value;
            //gLog.DiscountTotal = ext.orderadjustment.adjustmenttotal.Value;
            gLog.EmailListOptIn = newOrder.buyermarketingpreferences.emailallowed;
            gLog.GTimestamp = newOrder.timestamp;
            gLog.CartXml = SerializationHelper.RestoreXmlDeclaration(merchantData.SerializedObject);
            gLog.Save();

            Cart gCart = DeserializeCart(merchantData);

            Guid cartGuid = Guid.Empty;
            if (gCart != null)
                cartGuid = gCart.CartGuid;

            if (cartGuid == Guid.Empty) return;

            Cart cart = new Cart(cartGuid);
            if (cart.CartGuid != cartGuid) return;

            Store store = new Store(gCart.StoreGuid);
            if (store.Guid != cart.StoreGuid) return;

            gCart.DeSerializeCartOffers();

            gLog.SiteGuid = store.SiteGuid;
            gLog.UserGuid = gCart.UserGuid;
            gLog.CartGuid = gCart.CartGuid;
            gLog.StoreGuid = gCart.StoreGuid;
            gLog.Save();

            gCart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address();

            gCart.OrderInfo.Completed = DateTime.UtcNow;
            if (newOrder.buyerbillingaddress.structuredname != null)
            {
                gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.structuredname.firstname;
                gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.structuredname.lastname;
            }
            else
            {
                gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.contactname;
                gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.contactname;
            }
            gCart.OrderInfo.CustomerEmail = newOrder.buyerbillingaddress.email;
            gCart.OrderInfo.CustomerCompany = newOrder.buyerbillingaddress.companyname;
            gCart.OrderInfo.CustomerAddressLine1 = newOrder.buyerbillingaddress.address1;
            gCart.OrderInfo.CustomerAddressLine2 = newOrder.buyerbillingaddress.address2;
            gCart.OrderInfo.CustomerCity = newOrder.buyerbillingaddress.city;
            gCart.OrderInfo.CustomerState = newOrder.buyerbillingaddress.region;
            gCart.OrderInfo.CustomerCountry = newOrder.buyerbillingaddress.countrycode;
            gCart.OrderInfo.CustomerPostalCode = newOrder.buyerbillingaddress.postalcode;
            gCart.OrderInfo.CustomerTelephoneDay = newOrder.buyerbillingaddress.phone;

            gCart.CopyCustomerToBilling();

            if (newOrder.buyershippingaddress.structuredname != null)
            {
                gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.structuredname.firstname;
                gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.structuredname.lastname;
            }
            else
            {
                gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.contactname;
                gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.contactname;
            }
            gCart.OrderInfo.DeliveryCompany = newOrder.buyershippingaddress.companyname;
            gCart.OrderInfo.DeliveryAddress1 = newOrder.buyershippingaddress.address1;
            gCart.OrderInfo.DeliveryAddress2 = newOrder.buyershippingaddress.address2;
            gCart.OrderInfo.DeliveryCity = newOrder.buyershippingaddress.city;
            gCart.OrderInfo.DeliveryState = newOrder.buyershippingaddress.region;
            gCart.OrderInfo.DeliveryCountry = newOrder.buyershippingaddress.countrycode;
            gCart.OrderInfo.DeliveryPostalCode = newOrder.buyershippingaddress.postalcode;

            gCart.TaxTotal = newOrder.orderadjustment.totaltax.Value;
            if (newOrder.ShippingCost > 0)
            {
                gCart.ShippingTotal = newOrder.ShippingCost;
            }
            gCart.OrderTotal = newOrder.ordertotal.Value;

            Guid orderStatusGuid = OrderStatus.OrderStatusReceivedGuid;

            if (
                (newOrder.financialorderstate == FinancialOrderState.CHARGEABLE)
                || (newOrder.financialorderstate == FinancialOrderState.CHARGED)
                || (newOrder.financialorderstate == FinancialOrderState.CHARGING)
                )
            {
                orderStatusGuid = OrderStatus.OrderStatusFulfillableGuid;

            }

            StoreHelper.EnsureUserForOrder(gCart);

            gCart.Save();

            //Currency currency = new Currency(store.DefaultCurrencyId);
            SiteSettings siteSettings = new SiteSettings(store.SiteGuid);

            Order order = Order.CreateOrder(
                store,
                gCart,
                gLog.RawResponse,
                gLog.OrderNumber,
                string.Empty,
                siteSettings.GetCurrency().Code,
                "GoogleCheckout",
                orderStatusGuid);

            //StoreHelper.ClearCartCookie(cart.StoreGuid);
            if (orderStatusGuid == OrderStatus.OrderStatusFulfillableGuid)
            {
                StoreHelper.ConfirmOrder(store, order);
                PayPalLog.DeleteByCart(order.OrderGuid);

            }

            if (orderStatusGuid == OrderStatus.OrderStatusReceivedGuid)
            {
                StoreHelper.ConfirmOrderReceived(store, order);
            }
        }
Exemple #30
0
 private void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     useSeparatePagesForRoles = (Role.CountOfRoles(siteSettings.SiteId) >= WebConfigSettings.TooManyRolesForModuleSettings);
 }