private void LoadSettings()
        {
            pageId                = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId              = WebUtils.ParseInt32FromQueryString("mid", -1);
            cacheDependencyKey    = "Module-" + moduleId.ToString();
            iconPath              = ImageSiteRoot + "/Data/SiteImages/FeatureIcons/";
            skinBaseUrl           = SiteUtils.GetSkinBaseUrl(this);
            isSiteEditor          = SiteUtils.UserIsSiteEditor();
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();


            if ((WebUser.IsAdminOrContentAdmin) || (isSiteEditor))
            {
                canEdit = true;
                isAdmin = true;
                lnkEditContent.Visible     = true;
                lnkEditContent.Text        = Resource.ContentManagerViewEditContentLabel;
                lnkEditContent.NavigateUrl = SiteRoot
                                             + "/Admin/ContentManagerPreview.aspx?mid=" + this.moduleId.ToString(CultureInfo.InvariantCulture);

                lnkPublishing.Visible     = true;
                lnkPublishing.Text        = Resource.ContentManagerPublishingContentLink;
                lnkPublishing.NavigateUrl = SiteRoot
                                            + "/Admin/ContentManager.aspx?mid=" + this.moduleId.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                bool hideOtherTabs = WebConfigSettings.HideModuleSettingsGeneralAndSecurityTabsFromNonAdmins;
                if (hideOtherTabs)
                {
                    liGeneralSettings.Visible  = false;
                    liSecurity.Visible         = false;
                    tabGeneralSettings.Visible = false;
                    tabSecurity.Visible        = false;
                }
            }



            divCacheTimeout.Visible   = !WebConfigSettings.DisableContentCache;
            pnlDraftEditRoles.Visible = (WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow);

            if (pageId > -1)
            {
                this.divParentPage.Visible = true;
                module = new Module(this.moduleId, pageId);
            }
            else
            {
                module = new Module(this.moduleId);
            }

            if (!canEdit)
            {
                if (
                    (WebUser.IsInRoles(module.AuthorizedEditRoles)) ||
                    (WebUser.IsInRoles(module.DraftEditRoles)) ||
                    (WebUser.IsInRoles(CurrentPage.EditRoles)) ||
                    (WebUser.IsInRoles(CurrentPage.DraftEditOnlyRoles))
                    )
                {
                    canEdit = true;
                }
            }

            if (!canEdit)
            {
                if (module.EditUserId > 0)
                {
                    SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                    if (module.EditUserId == siteUser.UserId)
                    {
                        canEdit = true;
                    }
                }
            }

            if (module.SiteGuid != siteSettings.SiteGuid)
            {
                canEdit = false;
            }

            if (canEdit && (!isAdmin) && (WebUser.IsInRoles(siteSettings.RolesNotAllowedToEditModuleSettings)))
            {
                canEdit = false;
            }
        }
예제 #2
0
        void btnUpload_Click(object sender, EventArgs e)
        {
            Module   module   = new Module(moduleId);
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            try
            {
                if (multiFile.Files.Length > 0)
                {
                    foreach (UploadedFile file in multiFile.Files)
                    {
                        if (file != null && file.FileName != null && file.FileName.Trim().Length > 0)
                        {
                            string ext = Path.GetExtension(file.FileName);
                            if (SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                            {
                                GalleryImage galleryImage = new GalleryImage(this.moduleId, this.imageFolderPath);
                                galleryImage.ModuleGuid = module.ModuleGuid;

                                if (webImageHeightSetting > -1)
                                {
                                    galleryImage.WebImageHeight = webImageHeightSetting;
                                }

                                if (webImageWidthSetting > -1)
                                {
                                    galleryImage.WebImageWidth = webImageWidthSetting;
                                }

                                if (thumbNailHeightSetting > -1)
                                {
                                    galleryImage.ThumbNailHeight = thumbNailHeightSetting;
                                }

                                if (thumbNailWidthSetting > -1)
                                {
                                    galleryImage.ThumbNailWidth = thumbNailWidthSetting;
                                }


                                galleryImage.UploadUser = Context.User.Identity.Name;

                                if (siteUser != null)
                                {
                                    galleryImage.UserGuid = siteUser.UserGuid;
                                }

                                //string destPath = this.fullSizeImageFolderPath + galleryImage.ImageFile;
                                //if (File.Exists(destPath))
                                //{
                                //    File.Delete(destPath);
                                //}
                                //file.MoveTo(destPath, MoveToOptions.Overwrite);

                                // 2010-02-12 change from previous implementation with ugly guid file names
                                string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

                                if (galleryImage.ImageFile == newFileName)
                                {
                                    // an existing gallery image delete the old one
                                    if (File.Exists(fullSizeImageFolderPath + newFileName))
                                    {
                                        File.Delete(fullSizeImageFolderPath + newFileName);
                                    }
                                }
                                else
                                {
                                    // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                                    int i = 1;
                                    while (File.Exists(fullSizeImageFolderPath + newFileName))
                                    {
                                        newFileName = i.ToInvariantString() + newFileName;
                                        i          += 1;
                                    }
                                }

                                string destPath = fullSizeImageFolderPath + newFileName;
                                file.MoveTo(destPath, MoveToOptions.Overwrite);

                                galleryImage.ImageFile     = newFileName;
                                galleryImage.WebImageFile  = newFileName;
                                galleryImage.ThumbnailFile = newFileName;

                                GalleryHelper.ProcessImage(galleryImage, file.FileName);
                            }
                        }
                    }
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
            catch (UnauthorizedAccessException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (ArgumentException ex)
            {
                lblError.Text = ex.Message;
            }
        }
예제 #3
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
 }
예제 #4
0
        private void PopulateLabels()
        {
            Title = SiteUtils.FormatPageTitle(siteSettings, Resource.PageLayoutPageTitle);

            btnCreateNewContent.Text    = Resource.ContentManagerCreateNewContentButton;
            btnCreateNewContent.ToolTip = Resource.ContentManagerCreateNewContentButton;

            SiteUtils.SetButtonAccessKey
                (btnCreateNewContent, AccessKeys.ContentManagerCreateNewContentButtonAccessKey);

            lnkEditSettings.Text    = Resource.PageLayoutEditSettingsLink;
            lnkEditSettings.ToolTip = Resource.PageLayoutEditSettingsLink;
            lnkViewPage.Text        = Resource.PageViewPageLink;
            lnkViewPage.ToolTip     = Resource.PageViewPageLink;

            LeftUpBtn.AlternateText = Resource.PageLayoutLeftUpAlternateText;
            LeftUpBtn.ToolTip       = Resource.PageLayoutLeftUpAlternateText;

            LeftRightBtn.AlternateText = Resource.PageLayoutLeftRightAlternateText;
            LeftRightBtn.ToolTip       = Resource.PageLayoutLeftRightAlternateText;

            LeftDownBtn.AlternateText = Resource.PageLayoutLeftDownAlternateText;
            LeftDownBtn.ToolTip       = Resource.PageLayoutLeftDownAlternateText;

            LeftEditBtn.AlternateText = Resource.PageLayoutLeftEditAlternateText;
            LeftEditBtn.ToolTip       = Resource.PageLayoutLeftEditAlternateText;
            LeftEditBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditSettingsImage;

            LeftDeleteBtn.AlternateText = Resource.PageLayoutLeftDeleteAlternateText;
            LeftDeleteBtn.ToolTip       = Resource.PageLayoutLeftDeleteAlternateText;
            LeftDeleteBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;
            UIHelper.AddConfirmationDialog(LeftDeleteBtn, Resource.PageLayoutRemoveContentWarning);

            ContentUpBtn.AlternateText = Resource.PageLayoutContentUpAlternateText;
            ContentUpBtn.ToolTip       = Resource.PageLayoutContentUpAlternateText;

            ContentLeftBtn.AlternateText = Resource.PageLayoutContentLeftAlternateText;
            ContentLeftBtn.ToolTip       = Resource.PageLayoutContentLeftAlternateText;

            ContentRightBtn.AlternateText = Resource.PageLayoutContentRightAlternateText;
            ContentRightBtn.ToolTip       = Resource.PageLayoutContentRightAlternateText;

            ContentDownBtn.AlternateText = Resource.PageLayoutContentDownAlternateText;
            ContentDownBtn.ToolTip       = Resource.PageLayoutContentDownAlternateText;

            ContentEditBtn.AlternateText = Resource.PageLayoutContentEditAlternateText;
            ContentEditBtn.ToolTip       = Resource.PageLayoutContentEditAlternateText;
            ContentEditBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditSettingsImage;

            ContentDeleteBtn.AlternateText = Resource.PageLayoutContentDeleteAlternateText;
            ContentDeleteBtn.ToolTip       = Resource.PageLayoutContentDeleteAlternateText;
            ContentDeleteBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;
            UIHelper.AddConfirmationDialog(ContentDeleteBtn, Resource.PageLayoutRemoveContentWarning);

            RightUpBtn.AlternateText = Resource.PageLayoutRightUpAlternateText;
            RightUpBtn.ToolTip       = Resource.PageLayoutRightUpAlternateText;

            RightLeftBtn.AlternateText = Resource.PageLayoutRightLeftAlternateText;
            RightLeftBtn.ToolTip       = Resource.PageLayoutRightLeftAlternateText;

            RightDownBtn.AlternateText = Resource.PageLayoutRightDownAlternateText;
            RightDownBtn.ToolTip       = Resource.PageLayoutRightDownAlternateText;

            RightEditBtn.AlternateText = Resource.PageLayoutRightEditAlternateText;
            RightEditBtn.ToolTip       = Resource.PageLayoutRightEditAlternateText;
            RightEditBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditSettingsImage;

            RightDeleteBtn.AlternateText = Resource.PageLayoutRightDeleteAlternateText;
            RightDeleteBtn.ToolTip       = Resource.PageLayoutRightDeleteAlternateText;
            RightDeleteBtn.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;
            UIHelper.AddConfirmationDialog(RightDeleteBtn, Resource.PageLayoutRemoveContentWarning);

            litEditNotes.Text = string.Format(CultureInfo.InvariantCulture,
                                              Resource.LayoutEditNotesFormat, "<a href='" + SiteUtils.GetCurrentPageUrl() + "' title='" + Resource.LayoutViewThePageLink + "'>"
                                              + Resource.LayoutViewThePageLink + "</a>");

            litAltLayoutNotice.Text = Resource.PageLayoutAltPanelInfo;

            if (!Page.IsPostBack)
            {
                if (WebConfigSettings.PrePopulateDefaultContentTitle)
                {
                    moduleTitle.Text = Resource.PageLayoutDefaultNewModuleName;
                }
            }

            if (!Page.IsPostBack)
            {
                ddPaneNames.DataSource = PaneList();
                ddPaneNames.DataBind();
            }

            lnkPageTree.Visible     = WebUser.IsAdminOrContentAdmin;
            lnkPageTree.Text        = Resource.AdminMenuPageTreeLink;
            lnkPageTree.ToolTip     = Resource.AdminMenuPageTreeLink;
            lnkPageTree.NavigateUrl = SiteRoot + WebConfigSettings.PageTreeRelativeUrl;

            ContentDownToNextButton.AlternateText = Resource.PageLayoutMoveCenterToAlt2Button;
            ContentDownToNextButton.ToolTip       = Resource.PageLayoutMoveCenterToAlt2Button;
            ContentUpToNextButton.AlternateText   = Resource.PageLayoutMoveCenterToAlt1Button;
            ContentUpToNextButton.ToolTip         = Resource.PageLayoutMoveCenterToAlt1Button;

            btnMoveAlt1ToCenter.AlternateText = Resource.PageLayoutMoveAltToCenterButton;
            btnMoveAlt1ToCenter.ToolTip       = Resource.PageLayoutMoveAltToCenterButton;

            btnAlt2MoveUp.AlternateText = Resource.PageLayoutAlt2MoveUpButton;
            btnAlt2MoveUp.ToolTip       = Resource.PageLayoutAlt2MoveUpButton;

            btnAlt1MoveUp.AlternateText = Resource.PageLayoutAlt1MoveUpButton;
            btnAlt1MoveUp.ToolTip       = Resource.PageLayoutAlt1MoveUpButton;

            btnAlt1MoveDown.AlternateText = Resource.PageLayoutAlt1MoveDownButton;
            btnAlt1MoveDown.ToolTip       = Resource.PageLayoutAlt1MoveDownButton;

            //btnMoveAlt1ToAlt2.AlternateText = Resource.PageLayoutMoveAlt1ToAlt2Button;
            //btnMoveAlt1ToAlt2.ToolTip = Resource.PageLayoutMoveAlt1ToAlt2Button;

            btnEditAlt1.AlternateText = Resource.PageLayoutAlt1EditButton;
            btnEditAlt1.ToolTip       = Resource.PageLayoutAlt1EditButton;
            btnEditAlt1.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditSettingsImage;

            btnDeleteAlt1.AlternateText = Resource.PageLayoutAlt1DeleteButton;
            btnDeleteAlt1.ToolTip       = Resource.PageLayoutAlt1DeleteButton;
            btnDeleteAlt1.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;

            //btnMoveAlt2ToAlt1.AlternateText = Resource.PageLayoutMoveAlt2ToAlt1Button;
            //btnMoveAlt2ToAlt1.ToolTip = Resource.PageLayoutMoveAlt2ToAlt1Button;

            btnMoveAlt2ToCenter.AlternateText = Resource.PageLayoutMoveAltToCenterButton;
            btnMoveAlt2ToCenter.ToolTip       = Resource.PageLayoutMoveAltToCenterButton;

            btnAlt2MoveUp.AlternateText = Resource.PageLayoutAlt2MoveUpButton;
            btnAlt2MoveUp.ToolTip       = Resource.PageLayoutAlt2MoveUpButton;

            btnAlt2MoveDown.AlternateText = Resource.PageLayoutAlt2MoveDownButton;
            btnAlt2MoveDown.ToolTip       = Resource.PageLayoutAlt2MoveDownButton;

            btnEditAlt2.AlternateText = Resource.PageLayoutAlt2EditButton;
            btnEditAlt2.ToolTip       = Resource.PageLayoutAlt2EditButton;
            btnEditAlt2.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditSettingsImage;

            btnDeleteAlt2.AlternateText = Resource.PageLayoutAlt2DeleteButton;
            btnDeleteAlt2.ToolTip       = Resource.PageLayoutAlt2DeleteButton;
            btnDeleteAlt2.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;



            this.divAltLayoutNotice.Visible = true;
            this.divAltPanel1.Visible       = pageHasAltContent1;
            this.divAltPanel2.Visible       = pageHasAltContent2;
            ContentUpToNextButton.Visible   = pageHasAltContent1;
            ContentDownToNextButton.Visible = pageHasAltContent2;

            if (pageHasAltContent1 || pageHasAltContent2)
            {
                divAltLayoutNotice.Visible = true;
            }
            else
            {
                divAltLayoutNotice.Visible = false;
            }



            //lnkContentLookup.Visible = ((globalContentCount > 0) && !WebConfigSettings.DisableGlobalContent);
            //lnkContentLookup.Text = Resource.AddExistingContent;
            //lnkContentLookup.ToolTip = Resource.AddExistingContent;
            //lnkContentLookup.DialogCloseText = Resource.CloseDialogButton;
            //lnkContentLookup.NavigateUrl = SiteRoot + "/Dialog/GlobalContentDialog.aspx?pageid=" + pageID.ToInvariantString();
            btnAddExisting.ImageUrl = "~/Data/SiteImages/1x1.gif";
            btnAddExisting.Attributes.Add("tabIndex", "-1");

            lnkGlobalContent.Text        = Resource.AddExistingContent;
            lnkGlobalContent.ToolTip     = Resource.AddExistingContent;
            lnkGlobalContent.Visible     = ((globalContentCount > 0) && !WebConfigSettings.DisableGlobalContent);
            lnkGlobalContent.NavigateUrl = SiteRoot + "/Dialog/GlobalContentDialog.aspx?pageid=" + pageID.ToInvariantString();

            reqModuleTitle.ErrorMessage = Resource.TitleRequiredWarning;
            reqModuleTitle.Enabled      = WebConfigSettings.RequireContentTitle;

            cvModuleTitle.ValueToCompare = Resource.PageLayoutDefaultNewModuleName;
            cvModuleTitle.ErrorMessage   = Resource.DefaultContentTitleWarning;
            cvModuleTitle.Enabled        = WebConfigSettings.RequireChangeDefaultContentTitle;
        }
예제 #5
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            ArrayList pageIDs   = new ArrayList();
            ArrayList sitePages = new ArrayList();

            PopulatePageArray(sitePages);
            List <ModuleDecoratedSiteMapNode> pageList
                = ModuleDecoratedSiteMapNode.GetDecoratedNodes(sitePages, moduleID);

            foreach (ModuleDecoratedSiteMapNode decoratedPage in pageList)
            {
                if (decoratedPage.IsPublished)
                {
                    pageIDs.Add(decoratedPage.PageId);
                }
            }

            foreach (int p in pageIDs)
            {
                Module.DeleteModuleInstance(this.moduleID, p);
                mojoPortal.SearchIndex.IndexHelper.RebuildPageIndexAsync(new PageSettings(siteSettings.SiteId, p));
            }

            Module           m       = new Module(moduleID);
            ModuleDefinition feature = new ModuleDefinition(m.ModuleDefId);

            if (feature.DeleteProvider.Length > 0)
            {
                try
                {
                    ContentDeleteHandlerProvider contentDeleter = ContentDeleteHandlerProviderManager.Providers[feature.DeleteProvider];
                    if (contentDeleter != null)
                    {
                        contentDeleter.DeleteContent(m.ModuleId, m.ModuleGuid);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Failed to invoke content delete handler " + feature.DeleteProvider, ex);
                }
            }

            if (WebConfigSettings.LogIpAddressForContentDeletions)
            {
                string   userName    = string.Empty;
                SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                if (currentUser != null)
                {
                    userName = currentUser.Name;
                }

                log.Info("user " + userName + " deleted module " + m.ModuleTitle + " from ip address " + SiteUtils.GetIP4Address());
            }

            Module.DeleteModule(this.moduleID);

            if (hdnReturnUrl.Value.Length > 0)
            {
                if (hdnReturnUrl.Value.Contains("ModuleSettings.aspx"))
                {
                    // redirecting back to module settings for a deleted module cuases an error
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                    return;
                }

                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetNavigationSiteRoot());
        }
예제 #6
0
        private void LoadSettings()
        {
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            mojoSetup.EnsureFolderGalleryFolder(siteSettings);

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

            // previous value
            //~/Data/Sites/{0}/FolderGalleries/
            // changed to
            //~/Data/Sites/{0}/media/FolderGalleries/
            // 2013-04-04
            // did this to make more useful since that allows browsing the images from the wysiwyg editor

            //basePath = "~/Data/Sites/"
            //    + siteSettings.SiteId.ToInvariantString()
            //    + "/FolderGalleries/";
            basePath = string.Format(CultureInfo.InvariantCulture,
                                     FolderGalleryConfiguration.BasePathFormat,
                                     siteSettings.SiteId);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new FolderGalleryConfiguration(moduleSettings);

            // this check is for backward compat with galleries previously created below ~/Data/Sites/{0}/FolderGalleries/
            if (config.GalleryRootFolder.Length > 0)
            {
                if (!config.GalleryRootFolder.StartsWith(basePath))
                {
                    // legacy path
                    basePath = "~/Data/Sites/"
                               + siteSettings.SiteId.ToInvariantString()
                               + "/FolderGalleries/";
                }
            }

            try
            {
                // ensure directory
                if (!Directory.Exists(Server.MapPath(basePath)))
                {
                    Directory.CreateDirectory(Server.MapPath(basePath));
                }
            }
            catch (IOException ex)
            {
                log.Error(ex);
            }

            //allowEditUsersToChangeFolderPath = WebUtils.ParseBoolFromHashtable(
            //    moduleSettings, "AllowEditUsersToChangeFolderPath", allowEditUsersToChangeFolderPath);

            //allowEditUsersToUpload = WebUtils.ParseBoolFromHashtable(
            //    moduleSettings, "AllowEditUsersToUpload", allowEditUsersToUpload);

            if (!WebUser.IsAdminOrContentAdmin)
            {
                pnlUpload.Visible = config.AllowEditUsersToUpload;
                pnlEdit.Visible   = config.AllowEditUsersToChangeFolderPath;
            }

            uploader.MaxFilesAllowed      = FolderGalleryConfiguration.MaxFilesToUploadAtOnce;
            uploader.AcceptFileTypes      = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(WebConfigSettings.ImageFileExtensions);
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl           = SiteRoot + "/FolderGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                                            + "&mid=" + moduleId.ToInvariantString();
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { window.location.href = '" + SiteUtils.GetCurrentPageUrl() + "'; } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);


            AddClassToBody("foldergalleryedit");
        }
예제 #7
0
        private void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            if ((siteSettings != null) && (CurrentPage != null))
            {
                if ((SiteUtils.SslIsAvailable()) &&
                    ((siteSettings.UseSslOnAllPages) || (CurrentPage.RequireSsl))
                    )
                {
                    SiteUtils.ForceSsl();
                }
                else
                {
                    SiteUtils.ClearSsl();
                }
            }

            LoadParams();

            if ((forum == null) || (!forumParams.ParamsAreValid))
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }

            // if we get here then the module exists on the page and matches the forum module id
            // so check view permission
            if (!UserCanViewPage(ModuleId, Forum.FeatureGuid))
            {
                if (!Request.IsAuthenticated)
                {
                    SiteUtils.RedirectToLoginPage(this);
                    return;
                }
                else
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }
            }
            //this page has no content other than links
            SiteUtils.AddNoIndexFollowMeta(Page);

            LoadSettings();

            if ((!forum.Visible) && (!userCanEdit))
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            PopulateLabels();
            PopulateControls();

            AnalyticsSection = ConfigHelper.GetStringProperty("AnalyticsForumSection", "forums");


            LoadSideContent(config.ShowLeftContent, config.ShowRightContent);
            LoadAltContent(ForumConfiguration.ShowTopContent, ForumConfiguration.ShowBottomContent);
        }
예제 #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("in btnUpdate_Click");
            }

            if (!Page.IsValid)
            {
                return;
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Page.IsValid");
            }

            GalleryImage galleryImage;

            if (moduleId > -1)
            {
                if (itemId > -1)
                {
                    galleryImage = new GalleryImage(moduleId, itemId, imageFolderPath);
                }
                else
                {
                    galleryImage = new GalleryImage(moduleId, imageFolderPath);
                }

                Module module = new Module(moduleId);
                galleryImage.ModuleGuid = module.ModuleGuid;

                galleryImage.ContentChanged += new ContentChangedEventHandler(galleryImage_ContentChanged);

                int displayOrder;
                if (!Int32.TryParse(txtDisplayOrder.Text, out displayOrder))
                {
                    displayOrder = -1;
                }

                if (displayOrder > -1)
                {
                    galleryImage.DisplayOrder = displayOrder;
                }

                if (webImageHeightSetting > -1)
                {
                    galleryImage.WebImageHeight = webImageHeightSetting;
                }

                if (webImageWidthSetting > -1)
                {
                    galleryImage.WebImageWidth = webImageWidthSetting;
                }

                if (thumbNailHeightSetting > -1)
                {
                    galleryImage.ThumbNailHeight = thumbNailHeightSetting;
                }

                if (thumbNailWidthSetting > -1)
                {
                    galleryImage.ThumbNailWidth = thumbNailWidthSetting;
                }

                galleryImage.Description = edDescription.Text;
                galleryImage.Caption     = txtCaption.Text;
                galleryImage.UploadUser  = Context.User.Identity.Name;
                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                if (siteUser != null)
                {
                    galleryImage.UserGuid = siteUser.UserGuid;
                }

                if (flImage.HasFile && flImage.FileName != null && flImage.FileName.Trim().Length > 0)
                {
                    string ext = Path.GetExtension(flImage.FileName);
                    if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        lblMessage.Text = GalleryResources.InvalidFile;

                        return;
                    }
                    // 2010-02-12 change from previous implementation with ugly guid file names
                    string newFileName = Path.GetFileName(flImage.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

                    if (galleryImage.ImageFile == newFileName)
                    {
                        // an existing gallery image delete the old one
                        if (File.Exists(fullSizeImageFolderPath + newFileName))
                        {
                            File.Delete(fullSizeImageFolderPath + newFileName);
                        }
                    }
                    else
                    {
                        // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                        int i = 1;
                        while (File.Exists(fullSizeImageFolderPath + newFileName))
                        {
                            newFileName = i.ToInvariantString() + newFileName;
                            i          += 1;
                        }
                    }

                    string destPath = fullSizeImageFolderPath + newFileName;
                    flImage.MoveTo(destPath, MoveToOptions.Overwrite);

                    galleryImage.ImageFile     = newFileName;
                    galleryImage.WebImageFile  = newFileName;
                    galleryImage.ThumbnailFile = newFileName;

                    //galleryImage.ProcessImage(flImage.FileName);
                    GalleryHelper.ProcessImage(galleryImage, flImage.FileName);

                    CurrentPage.UpdateLastModifiedTime();
                    CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    SiteUtils.QueueIndexing();
                    if (ViewState["UrlReferrer"] != null)
                    {
                        WebUtils.SetupRedirect(this, (string)ViewState["UrlReferrer"]);
                        return;
                    }
                }
                else
                {               //updating a previously uploaded image
                    if (itemId > -1)
                    {
                        if (galleryImage.Save())
                        {
                            CurrentPage.UpdateLastModifiedTime();
                            CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                            SiteUtils.QueueIndexing();
                            if (hdnReturnUrl.Value.Length > 0)
                            {
                                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                                return;
                            }

                            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                        }
                    }
                }
            }
        }
예제 #9
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            GalleryImage galleryImage;

            if (moduleId > -1)
            {
                if (itemId > -1)
                {
                    galleryImage = new GalleryImage(moduleId, itemId);
                }
                else
                {
                    galleryImage = new GalleryImage(moduleId);
                }

                if (galleryImage.ModuleId != moduleId)
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                Module module = GetModule(moduleId, Gallery.FeatureGuid);
                galleryImage.ModuleGuid = module.ModuleGuid;

                galleryImage.ContentChanged += new ContentChangedEventHandler(galleryImage_ContentChanged);

                int displayOrder;
                if (!Int32.TryParse(txtDisplayOrder.Text, out displayOrder))
                {
                    displayOrder = -1;
                }

                if (displayOrder > -1)
                {
                    galleryImage.DisplayOrder = displayOrder;
                }

                galleryImage.WebImageHeight  = config.WebSizeHeight;
                galleryImage.WebImageWidth   = config.WebSizeWidth;
                galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                galleryImage.ThumbNailWidth  = config.ThumbnailWidth;
                galleryImage.Description     = edDescription.Text;
                galleryImage.Caption         = txtCaption.Text;
                galleryImage.UploadUser      = Context.User.Identity.Name;
                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                if (siteUser != null)
                {
                    galleryImage.UserGuid = siteUser.UserGuid;
                }

                // as long as javascript is available this code should never execute
                // because the standard file input ir replaced by javascript and the file upload happens
                // at the service url /ImageGallery/upload.ashx
                // this is fallback implementation

                if (uploader.HasFile)
                {
                    string ext = Path.GetExtension(uploader.FileName);
                    if (!SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                    {
                        lblMessage.Text = GalleryResources.InvalidFile;

                        return;
                    }

                    string newFileName  = Path.GetFileName(uploader.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                    string newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);
                    if (galleryImage.ImageFile == newFileName)
                    {
                        // an existing gallery image delete the old one
                        fileSystem.DeleteFile(newImagePath);
                    }
                    else
                    {
                        // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                        int i = 1;
                        while (fileSystem.FileExists(VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName)))
                        {
                            newFileName = i.ToInvariantString() + newFileName;
                            i          += 1;
                        }
                    }
                    newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);

                    if (galleryImage.ItemId > -1)
                    {
                        //updating with a new image so delete the previous version
                        GalleryHelper.DeleteImages(galleryImage, fileSystem, imageFolderPath);
                    }


                    //using (Stream s = flImage.FileContent)
                    //{
                    //    fileSystem.SaveFile(newImagePath, s, flImage.ContentType, true);
                    //}
                    using (Stream s = uploader.FileContent)
                    {
                        fileSystem.SaveFile(newImagePath, s, IOHelper.GetMimeType(Path.GetExtension(ext).ToLower()), true);
                    }



                    galleryImage.ImageFile     = newFileName;
                    galleryImage.WebImageFile  = newFileName;
                    galleryImage.ThumbnailFile = newFileName;
                    galleryImage.Save();
                    GalleryHelper.ProcessImage(galleryImage, fileSystem, imageFolderPath, uploader.FileName, config.ResizeBackgroundColor);

                    CurrentPage.UpdateLastModifiedTime();
                    CacheHelper.ClearModuleCache(moduleId);

                    SiteUtils.QueueIndexing();
                    if (hdnReturnUrl.Value.Length > 0)
                    {
                        WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                        return;
                    }
                }
                else // not hasfile
                {       //updating a previously uploaded image
                    if (itemId > -1)
                    {
                        if (galleryImage.Save())
                        {
                            CurrentPage.UpdateLastModifiedTime();
                            CacheHelper.ClearModuleCache(moduleId);
                            SiteUtils.QueueIndexing();
                            if (newItem)
                            {
                                string thisUrl = SiteRoot + "/ImageGallery/EditImage.aspx?pageid="
                                                 + pageId.ToInvariantString()
                                                 + "&mid=" + moduleId.ToInvariantString()
                                                 + "&ItemID=" + galleryImage.ItemId.ToInvariantString();

                                WebUtils.SetupRedirect(this, thisUrl);
                                return;
                            }
                            else
                            {
                                if (hdnReturnUrl.Value.Length > 0)
                                {
                                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                                    return;
                                }

                                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        private void PopulateControls()
        {
            GroupTopic topic = null;

            if (topicId == -1)
            {
                this.btnDelete.Visible   = false;
                this.rptMessages.Visible = false;
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName + " - " + GroupResources.NewTopicLabel);
            }
            else
            {
                if (postId > -1)
                {
                    topic = new GroupTopic(topicId, postId);
                    if (WebUser.IsAdmin ||
                        (isSiteEditor) ||
                        (WebUser.IsInRoles(CurrentPage.EditRoles)) ||
                        ((this.theUser != null) && (this.theUser.UserId == topic.PostUserId))
                        )
                    {
                        this.txtSubject.Text = topic.PostSubject;
                        edMessage.Text       = topic.PostMessage;
                    }
                }
                else
                {
                    topic = new GroupTopic(topicId);
                    this.txtSubject.Text
                        = ResourceHelper.GetMessageTemplate(ResourceHelper.GetDefaultCulture(), "GroupPostReplyPrefix.config")
                          + topic.Subject;
                }

                if ((group != null) && (topic != null))
                {
                    Title = SiteUtils.FormatPageTitle(siteSettings, group.Title + " - " + topic.Subject);
                }

                if (groupId == -1)
                {
                    groupId = topic.GroupId;
                }

                using (IDataReader reader = topic.GetPostsReverseSorted())
                {
                    this.rptMessages.DataSource = reader;
                    this.rptMessages.DataBind();
                }
            }

            if (group != null)
            {
                litGroupPostLabel.Text   = group.Title;
                litGroupDescription.Text = group.Description;
            }

            if (postId == -1)
            {
                string hookupInputScript = "<script type=\"text/javascript\">"
                                           + "document.getElementById('" + this.txtSubject.ClientID + "').focus();</script>";

                if (!Page.ClientScript.IsStartupScriptRegistered("finitscript"))
                {
                    this.Page.ClientScript.RegisterStartupScript(
                        typeof(Page),
                        "finitscript", hookupInputScript);
                }
            }

            chkNotifyOnReply.Checked = isSubscribedToTopic;

            lnkPageCrumb.Text        = CurrentPage.PageName;
            lnkPageCrumb.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            lnkGroup.HRef            = SiteRoot + "/Groups/GroupView.aspx?ItemID="
                                       + group.ItemId.ToInvariantString()
                                       + "&amp;pageid=" + pageId.ToInvariantString()
                                       + "&amp;mid=" + group.ModuleId.ToInvariantString();

            lnkGroup.InnerHtml = group.Title;
            if (topic != null)
            {
                lblTopicDescription.Text = Server.HtmlEncode(topic.Subject);
            }
        }
예제 #11
0
        private void LoadSettings()
        {
            virtualRoot = WebUtils.GetApplicationRoot();

            pageId                = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId              = WebUtils.ParseInt32FromQueryString("mid", -1);
            groupId               = WebUtils.ParseInt32FromQueryString("groupid", -1);
            topicId               = WebUtils.ParseInt32FromQueryString("topic", -1);
            postId                = WebUtils.ParseInt32FromQueryString("postid", -1);
            pageNumber            = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            timeOffset            = SiteUtils.GetUserTimeOffset();

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

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

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

            if (Request.IsAuthenticated)
            {
                theUser = SiteUtils.GetCurrentSiteUser();
                if (groupId > -1)
                {
                    isSubscribedToGroup = Group.IsSubscribed(groupId, theUser.UserId);
                }
                if (topicId > -1)
                {
                    isSubscribedToTopic = GroupTopic.IsSubscribed(topicId, theUser.UserId);
                }
            }

            if (WebUser.IsAdminOrContentAdmin)
            {
                edMessage.WebEditor.ToolBar = ToolBar.FullWithTemplates;
            }
            else if ((Request.IsAuthenticated) && (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles)))
            {
                edMessage.WebEditor.ToolBar = ToolBar.GroupWithImages;
            }
            else
            {
                edMessage.WebEditor.ToolBar = ToolBar.Group;
            }

            edMessage.WebEditor.SetFocusOnStart = true;
            edMessage.WebEditor.Height          = Unit.Parse("350px");

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            useSpamBlockingForAnonymous = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GroupEnableAntiSpamSetting", useSpamBlockingForAnonymous);

            includePostBodyInNotification = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "IncludePostBodyInNotificationEmail", includePostBodyInNotification);



            if (useSpamBlockingForAnonymous)
            {
                captcha.ProviderName        = siteSettings.CaptchaProvider;
                captcha.Captcha.ControlID   = "captcha" + moduleId.ToString(CultureInfo.InvariantCulture);
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey  = siteSettings.RecaptchaPublicKey;
            }
        }
예제 #12
0
        private void LoadPage()
        {
            EnsurePageAndSite();
            if (CurrentPage == null)
            {
                return;
            }
            LoadSettings();
            EnforceSecuritySettings();
            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }
            SetupAdminLinks();
            if (CurrentPage.PageId == -1)
            {
                return;
            }

            if ((CurrentPage.ShowChildPageMenu) ||
                (CurrentPage.ShowBreadcrumbs) ||
                (CurrentPage.ShowChildPageBreadcrumbs)
                )
            {
                // this is needed to override some hide logic in
                // layout.Master.cs
                this.MPContent.Visible        = true;
                this.MPContent.Parent.Visible = true;
            }


            if (CurrentPage.PageTitle.Length > 0)
            {
                Title = Server.HtmlEncode(CurrentPage.PageTitle);
            }
            else
            {
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
            }

            if (CurrentPage.PageMetaKeyWords.Length > 0)
            {
                MetaKeywordCsv = CurrentPage.PageMetaKeyWords;
            }


            if (CurrentPage.PageMetaDescription.Length > 0)
            {
                MetaDescription = CurrentPage.PageMetaDescription;
            }


            if (CurrentPage.CompiledMeta.Length > 0)
            {
                AdditionalMetaMarkup = CurrentPage.CompiledMeta;
            }

            if ((Page.Header != null) && (CurrentPage.UseUrl) && (CurrentPage.Url.Length > 0))
            {
                string urlToUse = SiteRoot + CurrentPage.Url.Replace("~/", "/");
                if (CurrentPage.CanonicalOverride.Length > 0)
                {
                    urlToUse = CurrentPage.CanonicalOverride;
                }
                using (Literal link = new Literal {
                    ID = "pageurl", Text = String.Format("\n<link rel='canonical' href='{0}' />", urlToUse)
                })
                {
                    Page.Header.Controls.Add(link);
                }
            }

            if (CurrentPage.Modules.Count == 0)
            {
                return;
            }

            foreach (Module module in CurrentPage.Modules)
            {
                if (!ModuleIsVisible(module))
                {
                    continue;
                }
                if (!WebUser.IsInRoles(module.ViewRoles))
                {
                    continue;
                }

                Control parent = this.MPContent;

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "leftpane"))
                {
                    parent = this.MPLeftPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "rightpane"))
                {
                    parent = this.MPRightPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent1"))
                {
                    if (AltPane1 != null)
                    {
                        parent = this.AltPane1;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent1 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent2"))
                {
                    if (AltPane2 != null)
                    {
                        parent = this.AltPane2;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent2 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                // 2008-10-04 since more an more of our features use postback via ajax
                // its not feasible to use output caching as this breaks postback,
                // so I changed the default the use of WebConfigSettings.DisableContentCache to true
                // this also reduces the memory consumption footprint

                if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                {
                    //2008-10-16 in ulu's blog post:http://dotfresh.blogspot.com/2008/10/in-search-of-developer-friendly-cms.html
                    // he complains about having to inherit from a base class (SiteModuleControl) to make a plugin.
                    // he wishes he could just use a UserControl
                    // While SiteModuleControl "is a" UserControl that provides additional functionality
                    // Its easy enough to support using
                    // a plain UserControl so I'm making the needed change here now.
                    // The drawback of a plain UserControl is that is not reusable in the same way as SiteModuleControl.
                    // If you use a plain UserControl, its going to be exactly the same on any page you use it on.
                    // It has no instance specific properties.
                    // SiteModuleControl gives you instance specific ids and internal tracking of which instance this is so
                    // that you can have different instances.
                    // For example the Blog is instance specific, if you put a blog on one page and then put a blog on another page
                    // those are 2 different blogs with different content.
                    // However, if you don't need a re-usable feature with instance specific properties
                    // you are now free to use a plain old UserControl and I think freedom is a good thing
                    // so this was valuable feedback from ulu.
                    // Those who do need instance specific features should read my developer Guidelines for building one:
                    //http://www.vivasky.com/addingfeatures.aspx

                    Control c = Page.LoadControl("~/" + module.ControlSource);
                    if (c == null)
                    {
                        continue;
                    }

                    if (c is SiteModuleControl)
                    {
                        SiteModuleControl siteModule = (SiteModuleControl)c;
                        siteModule.SiteId = siteSettings.SiteId;
                        siteModule.ModuleConfiguration = module;

                        if (siteModule is IWorkflow)
                        {
                            countOfIWorkflow += 1;
                        }
                    }



                    parent.Controls.Add(c);
                }
                else
                {
                    using (CachedSiteModuleControl siteModule = new CachedSiteModuleControl {
                        SiteId = siteSettings.SiteId, ModuleConfiguration = module
                    })
                    {
                        parent.Controls.Add(siteModule);
                    }
                }

                parent.Visible        = true;
                parent.Parent.Visible = true;
            } //end foreach

            if ((!WebConfigSettings.DisableExternalCommentSystems) && (siteSettings != null) && (CurrentPage != null) && (CurrentPage.EnableComments))
            {
                switch (siteSettings.CommentProvider)
                {
                case "disqus":

                    if (siteSettings.DisqusSiteShortName.Length > 0)
                    {
                        using (DisqusWidget disqus = new DisqusWidget())
                        {
                            disqus.SiteShortName = siteSettings.DisqusSiteShortName;
                            disqus.WidgetPageUrl = SiteUtils.GetCurrentPageUrl();
                            disqus.RenderWidget  = true;
                            MPContent.Controls.Add(disqus);
                        }
                    }

                    break;

                case "intensedebate":

                    if (siteSettings.IntenseDebateAccountId.Length > 0)
                    {
                        using (IntenseDebateDiscussion d = new IntenseDebateDiscussion())
                        {
                            d.AccountId = siteSettings.IntenseDebateAccountId;
                            d.PostUrl   = SiteUtils.GetCurrentPageUrl();
                            MPContent.Controls.Add(d);
                        }
                    }

                    break;
                }
            }

            if (WebConfigSettings.HidePageViewModeIfNoWorkflowItems && (countOfIWorkflow == 0))
            {
                HideViewSelector();
            }

            // (to show the last mnodified time of a page we may have this control in layout.master, but I set it invisible by default
            // because we only want to show it on content pages not edit pages
            // since Default.aspx.cs is the handler for content pages, we look for it here and make it visible.
            Control pageLastMod = Master.FindControl("pageLastMod");

            if (pageLastMod != null)
            {
                pageLastMod.Visible = true;
            }
        }
예제 #13
0
        private void LoadSettings()
        {
            virtualRoot = WebUtils.GetApplicationRoot();

            pageId                = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId              = WebUtils.ParseInt32FromQueryString("mid", -1);
            forumId               = WebUtils.ParseInt32FromQueryString("forumid", -1);
            threadId              = WebUtils.ParseInt32FromQueryString("thread", -1);
            postId                = WebUtils.ParseInt32FromQueryString("postid", -1);
            pageNumber            = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            timeOffset            = SiteUtils.GetUserTimeOffset();
            timeZone              = SiteUtils.GetUserTimeZone();

            isModerator    = UserCanEditModule(moduleId, Forum.FeatureGuid);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new ForumConfiguration(moduleSettings);

            postList.Config                 = config;
            postList.PageId                 = pageId;
            postList.ModuleId               = moduleId;
            postList.ItemId                 = forumId;
            postList.ThreadId               = threadId;
            postList.PageNumber             = pageNumber;
            postList.IsAdmin                = WebUser.IsAdmin;
            postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postList.SiteRoot               = SiteRoot;
            postList.ImageSiteRoot          = ImageSiteRoot;
            postList.SiteSettings           = siteSettings;
            postList.IsEditable             = false;
            postList.IsSubscribedToForum    = true;

            postListAlt.Config                 = config;
            postListAlt.PageId                 = pageId;
            postListAlt.ModuleId               = moduleId;
            postListAlt.ItemId                 = forumId;
            postListAlt.ThreadId               = threadId;
            postListAlt.PageNumber             = pageNumber;
            postListAlt.IsAdmin                = postList.IsAdmin;
            postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postListAlt.SiteRoot               = SiteRoot;
            postListAlt.ImageSiteRoot          = ImageSiteRoot;
            postListAlt.SiteSettings           = siteSettings;
            postListAlt.IsEditable             = false;
            postListAlt.IsSubscribedToForum    = true;

            if (Request.IsAuthenticated)
            {
                theUser = SiteUtils.GetCurrentSiteUser();
                if (theUser != null)
                {
                    if (forumId > -1)
                    {
                        isSubscribedToForum = Forum.IsSubscribed(forumId, theUser.UserId);
                    }
                    if (threadId > -1)
                    {
                        isSubscribedToThread = ForumThread.IsSubscribed(threadId, theUser.UserId);
                    }
                }
            }

            if (isModerator)
            {
                edMessage.WebEditor.ToolBar = ToolBar.FullWithTemplates;
            }
            else if ((Request.IsAuthenticated) && (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles)))
            {
                edMessage.WebEditor.ToolBar = ToolBar.ForumWithImages;
            }
            else
            {
                edMessage.WebEditor.ToolBar = ToolBar.Forum;
            }

            edMessage.WebEditor.SetFocusOnStart = true;
            edMessage.WebEditor.Height          = Unit.Parse("350px");

            if (config.UseSpamBlockingForAnonymous)
            {
                captcha.ProviderName        = siteSettings.CaptchaProvider;
                captcha.Captcha.ControlID   = "captcha" + moduleId.ToString(CultureInfo.InvariantCulture);
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey  = siteSettings.RecaptchaPublicKey;
            }

            forum = new Forum(forumId);

            if (displaySettings.UseAltPostList)
            {
                postList.Visible    = false;
                postListAlt.Visible = true;
            }

            AddClassToBody("editforumpost");
        }
예제 #14
0
        private void PopulateControls()
        {
            ForumThread thread = null;

            if (threadId == -1)
            {
                this.btnDelete.Visible = false;
                postList.Visible       = false;
                postListAlt.Visible    = false;
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName + " - " + ForumResources.NewThreadLabel);
            }
            else
            {
                if (postId > -1)
                {
                    thread = new ForumThread(threadId, postId);
                    if (isModerator ||
                        ((this.theUser != null) && (this.theUser.UserId == thread.PostUserId))
                        )
                    {
                        this.txtSubject.Text = thread.PostSubject;
                        edMessage.Text       = thread.PostMessage;
                    }
                    else
                    {
                        //user has no permission to edit this post
                        WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                        return;
                    }

                    if (isModerator)
                    {
                        divSortOrder.Visible = true;
                        txtSortOrder.Text    = thread.PostSortOrder.ToInvariantString();
                    }
                    else if ((config.AllowEditingPostsLessThanMinutesOld != -1) && (thread.CurrentPostDate < DateTime.UtcNow.AddMinutes(-config.AllowEditingPostsLessThanMinutesOld)))
                    {
                        // not allowing edit of older posts
                        WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                        return;
                    }
                }
                else
                {
                    thread = new ForumThread(threadId);
                    this.txtSubject.Text
                        = ResourceHelper.GetMessageTemplate(SiteUtils.GetDefaultUICulture(), "ForumPostReplyPrefix.config")
                          + SecurityHelper.RemoveMarkup(thread.Subject);
                }

                if ((thread.IsLocked || thread.IsClosed(config.CloseThreadsOlderThanDays)) && (!isModerator))
                {
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                    return;
                }


                if ((forum != null) && (thread != null))
                {
                    Title = SiteUtils.FormatPageTitle(siteSettings, forum.Title + " - " + SecurityHelper.RemoveMarkup(thread.Subject));
                }

                if (forumId == -1)
                {
                    forumId = thread.ForumId;
                }

                postList.Forum    = forum;
                postListAlt.Forum = forum;

                postList.Thread    = thread;
                postListAlt.Thread = thread;
            }

            if (forum != null)
            {
                heading.Text             = forum.Title;
                litForumDescription.Text = forum.Description;
                divDescription.Visible   = (forum.Description.Length > 0) && (!displaySettings.HideForumDescriptionOnPostEdit);
            }


            if (threadId == -1) //only focus the subject on new threads
            {
                string hookupInputScript = "<script type=\"text/javascript\">"
                                           + "document.getElementById('" + this.txtSubject.ClientID + "').focus();</script>";

                if (!Page.ClientScript.IsStartupScriptRegistered("finitscript"))
                {
                    this.Page.ClientScript.RegisterStartupScript(
                        typeof(Page),
                        "finitscript", hookupInputScript);
                }

                edMessage.WebEditor.SetFocusOnStart = false;
            }
            else
            {
                edMessage.WebEditor.SetFocusOnStart = true;
            }



            chkNotifyOnReply.Checked = isSubscribedToThread;

            lnkPageCrumb.Text        = CurrentPage.PageName;
            lnkPageCrumb.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            if (ForumConfiguration.CombineUrlParams)
            {
                lnkForum.HRef = SiteRoot + "/Forums/ForumView.aspx?pageid=" + pageId.ToInvariantString()
                                + "&amp;f=" + forum.ItemId.ToInvariantString() + "~1";
            }
            else
            {
                lnkForum.HRef = SiteRoot + "/Forums/ForumView.aspx?ItemID="
                                + forum.ItemId.ToInvariantString()
                                + "&amp;pageid=" + pageId.ToInvariantString()
                                + "&amp;mid=" + forum.ModuleId.ToInvariantString();
            }

            lnkForum.InnerHtml = forum.Title;
            if (thread != null)
            {
                lblThreadDescription.Text = SecurityHelper.RemoveMarkup(thread.Subject);
            }
        }
예제 #15
0
        private void LoadSettings()
        {
            thread = threadParams.Thread;


            if (thread.ThreadId == -1)
            {
                //thread does not exist, probably just got deleted
                //redirect back to thread list
                string redirectUrl;
                if (ForumConfiguration.CombineUrlParams)
                {
                    redirectUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString()
                                  + "&f=" + ItemId.ToInvariantString() + "~1";
                }
                else
                {
                    redirectUrl = SiteRoot + "/Forums/ForumView.aspx?ItemID="
                                  + ItemId.ToInvariantString()
                                  + "&pageid=" + PageId.ToInvariantString()
                                  + "&mid=" + moduleId.ToInvariantString();
                }


                WebUtils.SetupRedirect(this, redirectUrl);

                return;
            }

            if (thread.ModuleId != moduleId)
            {
                //SiteUtils.RedirectToAccessDeniedPage(this);
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }

            forum = threadParams.Forum;

            //if (forum.ModuleId != moduleId)
            //{
            //    //SiteUtils.RedirectToAccessDeniedPage(this);
            //    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            //    return;
            //}

            postList.Forum  = forum;
            postList.Thread = thread;

            postListAlt.Forum  = forum;
            postListAlt.Thread = thread;

            if (ForumConfiguration.TrackFakeTopicUrlInAnalytics)
            {
                SetupAnalytics();
            }

            if ((IsEditable) || (WebUser.IsInRoles(forum.RolesThatCanModerate)))
            {
                SetupNotifyScript();
            }
        }
        void btnMakePayment_Click(object sender, EventArgs e)
        {
            PayPalExpressGateway gateway
                = new PayPalExpressGateway(
                      commerceConfig.PayPalAPIUsername,
                      commerceConfig.PayPalAPIPassword,
                      commerceConfig.PayPalAPISignature,
                      commerceConfig.PayPalStandardEmailAddress);

            gateway.UseTestMode   = commerceConfig.PaymentGatewayUseTestMode;
            gateway.PayPalToken   = checkoutDetailsLog.Token;
            gateway.PayPalPayerId = checkoutDetailsLog.PayerId;

            gateway.MerchantCartId = cart.CartGuid.ToString();
            gateway.ChargeTotal    = cart.OrderTotal;
            gateway.ReturnUrl      = SiteRoot + "/Services/PayPalReturnHandler.ashx";
            gateway.CancelUrl      = SiteUtils.GetCurrentPageUrl();
            gateway.CurrencyCode   = siteSettings.GetCurrency().Code;

            // **** here's where the payment is requested ******
            bool executed = gateway.CallDoExpressCheckoutPayment();

            PayPalLog payPalLog = new PayPalLog();

            payPalLog.RequestType      = "DoExpressCheckoutPayment";
            payPalLog.ProviderName     = WebStorePayPalReturnHandler.ProviderName;
            payPalLog.SerializedObject = checkoutDetailsLog.SerializedObject;
            payPalLog.ReturnUrl        = checkoutDetailsLog.ReturnUrl;
            payPalLog.RawResponse      = gateway.RawResponse;

            payPalLog.TransactionId = gateway.TransactionId;
            payPalLog.PaymentType   = gateway.PayPalPaymentType;
            payPalLog.PaymentStatus = gateway.PayPalPaymentStatus;
            payPalLog.PendingReason = gateway.PayPalPendingReason;
            payPalLog.ReasonCode    = gateway.ReasonCode;
            payPalLog.PayPalAmt     = gateway.ChargeTotal;
            payPalLog.FeeAmt        = gateway.PayPalFeeAmount;
            payPalLog.SettleAmt     = gateway.PayPalSettlementAmount;
            payPalLog.TaxAmt        = gateway.PayPalTaxTotal;

            payPalLog.Token        = gateway.PayPalToken;
            payPalLog.PayerId      = gateway.PayPalPayerId;
            payPalLog.RequestType  = "DoExpressCheckoutPayment";
            payPalLog.SiteGuid     = store.SiteGuid;
            payPalLog.StoreGuid    = store.Guid;
            payPalLog.CartGuid     = cart.CartGuid;
            payPalLog.UserGuid     = cart.UserGuid;
            payPalLog.CartTotal    = cart.OrderTotal;
            payPalLog.CurrencyCode = gateway.CurrencyCode;

            if (gateway.PayPalExchangeRate.Length > 0)
            {
                payPalLog.ExchangeRate = decimal.Parse(gateway.PayPalExchangeRate);
            }


            payPalLog.Save();

            if (!executed)
            {
                lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage;

                if (gateway.LastExecutionException != null)
                {
                    log.Error("ExpressCheckout gateway error", gateway.LastExecutionException);

                    if (commerceConfig.PaymentGatewayUseTestMode)
                    {
                        lblMessage.Text = gateway.LastExecutionException.ToString();
                    }
                }
                else
                {
                    if (commerceConfig.PaymentGatewayUseTestMode)
                    {
                        lblMessage.Text = gateway.RawResponse;
                    }
                }

                return;
            }

            string redirectUrl = string.Empty;

            if (gateway.TransactionId.Length == 0)
            {
                // TODO: redirect where?
                redirectUrl = SiteRoot + "/WebStore/PayPalGatewayError.aspx?plog=" + payPalLog.RowGuid.ToString();
                Response.Redirect(redirectUrl);
            }


            Guid orderStatusGuid;

            if (payPalLog.PaymentStatus == "Completed")
            {
                orderStatusGuid = OrderStatus.OrderStatusFulfillableGuid;
            }
            else
            {
                orderStatusGuid = OrderStatus.OrderStatusReceivedGuid;
            }


            Order order = Order.CreateOrder(
                store,
                cart,
                payPalLog.RawResponse,
                payPalLog.TransactionId,
                string.Empty,
                siteSettings.GetCurrency().Code,
                "PayPal",
                orderStatusGuid);

            StoreHelper.ClearCartCookie(cart.StoreGuid);


            // send confirmation email
            // paypal sends an order confirmation so no need

            // redirect to order details
            redirectUrl = SiteRoot +
                          "/WebStore/OrderDetail.aspx?pageid="
                          + PageId.ToString(CultureInfo.InvariantCulture)
                          + "&mid=" + store.ModuleId.ToString(CultureInfo.InvariantCulture)
                          + "&orderid=" + order.OrderGuid.ToString();

            Response.Redirect(redirectUrl);
        }
예제 #17
0
        private void Page_Load(object sender, EventArgs e)
        {
            if ((siteSettings != null) && (CurrentPage != null))
            {
                if ((SiteUtils.SslIsAvailable()) &&
                    ((siteSettings.UseSslOnAllPages) || (CurrentPage.RequireSsl))
                    )
                {
                    SiteUtils.ForceSsl();
                }
                else
                {
                    SiteUtils.ClearSsl();
                }
            }

            LoadParams();

            if (!threadParams.ParamsAreValid)
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }

            if (!UserCanViewPage(moduleId, Forum.FeatureGuid))
            {
                if (!Request.IsAuthenticated)
                {
                    SiteUtils.RedirectToLoginPage(this);
                }
                else
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                }
                return;
            }

            LoadSettings();
            PopulateLabels();

            if (Page.IsPostBack)
            {
                return;
            }

            AddConnoicalUrl();
            PopulateControls();

            if (UserCanEditModule(moduleId, Forum.FeatureGuid))
            {
                heading.LiteralExtraMarkup = "&nbsp;<a href='"
                                             + SiteRoot
                                             + "/Forums/EditThread.aspx?pageid=" + PageId.ToInvariantString()
                                             + "&amp;mid=" + moduleId.ToInvariantString()
                                             + "&amp;thread=" + threadId.ToInvariantString()
                                             + "' class='ModuleEditLink'>" + ForumResources.ForumThreadEditLabel + "</a>";
            }

            AnalyticsSection = ConfigHelper.GetStringProperty("AnalyticsForumSection", "forums");

            LoadSideContent(config.ShowLeftContent, config.ShowRightContent);
            LoadAltContent(ForumConfiguration.ShowTopContent, ForumConfiguration.ShowBottomContent);
        }
        private void LoadSettings()
        {
            PageId   = WebUtils.ParseInt32FromQueryString("pageid", -1);
            ModuleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            payPalGetExpressCheckoutLogGuid = WebUtils.ParseGuidFromQueryString("plog", payPalGetExpressCheckoutLogGuid);

            if (payPalGetExpressCheckoutLogGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            checkoutDetailsLog = new PayPalLog(payPalGetExpressCheckoutLogGuid);

            if (checkoutDetailsLog.RowGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), checkoutDetailsLog.SerializedObject);

            if (cart == null)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }
            cart.DeSerializeCartOffers();

            cart.RefreshTotals();


            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }


            siteUser = SiteUtils.GetCurrentSiteUser();
            //if (siteUser == null)
            //{
            //    Response.Redirect(SiteUtils.GetCurrentPageUrl());
            //}

            if ((siteUser != null) && (cart.UserGuid == Guid.Empty))
            {
                // user wasn't logged in when express checkout was called
                cart.UserGuid = siteUser.UserGuid;
                cart.Save();
                //if (checkoutDetailsLog.UserGuid == Guid.Empty)
                //{
                //    // we need to make sure we have the user in the log and serialized cart
                //    checkoutDetailsLog.UserGuid = siteUser.UserGuid;
                //    cart.SerializeCartOffers();
                //    checkoutDetailsLog.SerializedObject = SerializationHelper.SerializeToSoap(cart);
                //    checkoutDetailsLog.Save();

                //}
            }

            if ((siteUser != null) && (cart.UserGuid != siteUser.UserGuid))
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }



            if (ModuleId == -1)
            {
                ModuleId = StoreHelper.FindStoreModuleId(CurrentPage);
            }


            store = StoreHelper.GetStore();


            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (siteUser != null)
            {
                pnlRequireLogin.Visible = false;
            }
            else
            {
                btnMakePayment.Visible = false;
            }

            AddClassToBody("webstore webstoreexpresscheckout");
        }
예제 #19
0
 private void PopulateLabels()
 {
     lnkPageCrumb.Text        = CurrentPage.PageName;
     lnkPageCrumb.NavigateUrl = SiteUtils.GetCurrentPageUrl();
 }
예제 #20
0
        private void UpdateBtn_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Link linkItem = new Link(itemId);
                if ((linkItem.ItemId > -1) && (linkItem.ModuleId != moduleId))
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                linkItem.ContentChanged += new ContentChangedEventHandler(linkItem_ContentChanged);

                Module module = new Module(moduleId);
                linkItem.ModuleGuid = module.ModuleGuid;
                linkItem.ModuleId   = this.moduleId;
                linkItem.Title      = this.txtTitle.Text;
                if (chkUseNewWindow.Checked)
                {
                    linkItem.Target = "_blank";
                }
                else
                {
                    linkItem.Target = String.Empty;
                }

                linkItem.Description = edDescription.Text;

                if ((!ddProtocol.Visible) || (txtUrl.Text.StartsWith("/")))
                {
                    linkItem.Url = txtUrl.Text;
                }
                else
                {
                    linkItem.Url = ddProtocol.SelectedValue + txtUrl.Text.Replace("https://", String.Empty).Replace("http://", String.Empty).Replace("~/", String.Empty);
                }


                linkItem.ViewOrder = int.Parse(this.txtViewOrder.Text);
                SiteUser linkUser = SiteUtils.GetCurrentSiteUser();
                if (linkUser != null)
                {
                    linkItem.CreatedByUser = linkUser.UserId;
                    linkItem.UserGuid      = linkUser.UserGuid;
                }

                if (linkItem.Save())
                {
                    CurrentPage.UpdateLastModifiedTime();
                    //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    CacheHelper.ClearModuleCache(linkItem.ModuleId);
                    SiteUtils.QueueIndexing();
                    if (hdnReturnUrl.Value.Length > 0)
                    {
                        WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                        return;
                    }

                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                }
            }
        }
예제 #21
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Page.Validate("feeds");
            if (!Page.IsValid)
            {
                return;
            }

            RssFeed feed = new RssFeed(ModuleId, ItemId);

            if (feed.ModuleId != ModuleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            feed.ModuleId = ModuleId;
            feed.Author   = txtAuthor.Text;
            feed.Url      = txtWebSite.Text;
            feed.RssUrl   = txtRssUrl.Text;
            feed.ImageUrl = txtImageUrl.Text;
            int sortRank = 500;

            int.TryParse(txtSortRank.Text, out sortRank);
            feed.SortRank = sortRank;

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser == null)
            {
                return;
            }

            Module module = new Module(ModuleId);

            feed.ModuleGuid       = module.ModuleGuid;
            feed.UserId           = siteUser.UserId;
            feed.UserGuid         = siteUser.UserGuid;
            feed.LastModUserGuid  = siteUser.UserGuid;
            feed.PublishByDefault = chkPublishByDefault.Checked;

            if (feed.Save())
            {
                CurrentPage.UpdateLastModifiedTime();

                FeedCache.RefreshFeed(
                    feed,
                    ModuleId,
                    module.ModuleGuid,
                    config.MaxDaysOld,
                    config.MaxEntriesPerFeed,
                    config.EnableSelectivePublishing);


                String rssFriendlyUrl = "aggregator" + ModuleId.ToInvariantString() + "rss.aspx";
                if (!FriendlyUrl.Exists(siteSettings.SiteId, rssFriendlyUrl))
                {
                    FriendlyUrl friendlyUrl = new FriendlyUrl();
                    friendlyUrl.SiteId   = siteSettings.SiteId;
                    friendlyUrl.SiteGuid = siteSettings.SiteGuid;
                    friendlyUrl.Url      = rssFriendlyUrl;
                    friendlyUrl.RealUrl  = "~/FeedManager/FeedAggregate.aspx?pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString();
                    friendlyUrl.Save();
                }

                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
        }
예제 #22
0
        void btnUpload_Click(object sender, EventArgs e)
        {
            // as long as javascript is available this code should never execute
            // because the standard file input ir replaced by javascript and the file upload happens
            // at the service url /ImageGallery/upload.ashx
            // this is fallback implementation

            Module module = GetModule(moduleId, Gallery.FeatureGuid);

            if (module == null)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            try
            {
                if (uploader.HasFile)
                {
                    string ext = Path.GetExtension(uploader.FileName);
                    if (SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        GalleryImage galleryImage = new GalleryImage(this.moduleId);
                        galleryImage.ModuleGuid      = module.ModuleGuid;
                        galleryImage.WebImageHeight  = config.WebSizeHeight;
                        galleryImage.WebImageWidth   = config.WebSizeWidth;
                        galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                        galleryImage.ThumbNailWidth  = config.ThumbnailWidth;
                        galleryImage.UploadUser      = Context.User.Identity.Name;

                        if (siteUser != null)
                        {
                            galleryImage.UserGuid = siteUser.UserGuid;
                        }

                        //string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                        string newFileName  = Path.GetFileName(uploader.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                        string newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);

                        if (galleryImage.ImageFile == newFileName)
                        {
                            // an existing gallery image delete the old one
                            fileSystem.DeleteFile(newImagePath);
                        }
                        else
                        {
                            // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                            int i = 1;
                            while (fileSystem.FileExists(VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName)))
                            {
                                newFileName = i.ToInvariantString() + newFileName;
                                i          += 1;
                            }
                        }

                        newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);


                        using (Stream s = uploader.FileContent)
                        {
                            //fileSystem.SaveFile(newImagePath, s, uploader.FileContentType, true);
                            fileSystem.SaveFile(newImagePath, s, IOHelper.GetMimeType(Path.GetExtension(ext).ToLower()), true);
                        }


                        galleryImage.ImageFile     = newFileName;
                        galleryImage.WebImageFile  = newFileName;
                        galleryImage.ThumbnailFile = newFileName;
                        galleryImage.Save();
                        GalleryHelper.ProcessImage(galleryImage, fileSystem, imageFolderPath, uploader.FileName, config.ResizeBackgroundColor);
                    }
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
            catch (UnauthorizedAccessException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (ArgumentException ex)
            {
                lblError.Text = ex.Message;
            }
        }
예제 #23
0
        private void LoadSettings()
        {
            pageID             = WebUtils.ParseInt32FromQueryString("pageid", -1);
            isSiteEditor       = SiteUtils.UserIsSiteEditor();
            pageHasAltContent1 = this.ContainsPlaceHolder("altContent1");
            pageHasAltContent2 = this.ContainsPlaceHolder("altContent2");



            if (pageID > -1)
            {
                pnlContent.Visible = true;

                lnkEditSettings.NavigateUrl = SiteRoot + "/Admin/PageSettings.aspx?pageid=" + pageID.ToString();

                if (CurrentPage != null)
                {
                    lnkViewPage.NavigateUrl = SiteUtils.GetCurrentPageUrl();
                    if (CurrentPage.BodyCssClass.Length > 0)
                    {
                        AddClassToBody(CurrentPage.BodyCssClass);
                    }
                }
                else
                {
                    lnkViewPage.Visible = false;
                }
            }

            AddClassToBody("administration");
            AddClassToBody("pagelayout");

            divAdminLinks.Attributes.Add("class", displaySettings.AdminLinksContainerDivCssClass);
            lnkEditSettings.CssClass = displaySettings.AdminLinkCssClass;
            lnkViewPage.CssClass     = displaySettings.AdminLinkCssClass;
            lnkPageTree.CssClass     = displaySettings.AdminLinkCssClass;
            litLinkSpacer1.Text      = displaySettings.AdminLinkSeparator;
            litLinkSpacer2.Text      = displaySettings.AdminLinkSeparator;

            globalContentCount = Module.GetGlobalCount(siteSettings.SiteId, -1, pageID);

            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
            }

            if (ScriptController != null)
            {
                ScriptController.RegisterAsyncPostBackControl(btnCreateNewContent);

                ScriptController.RegisterAsyncPostBackControl(LeftUpBtn);
                ScriptController.RegisterAsyncPostBackControl(LeftDownBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentUpBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentDownBtn);
                ScriptController.RegisterAsyncPostBackControl(RightUpBtn);
                ScriptController.RegisterAsyncPostBackControl(RightDownBtn);
                ScriptController.RegisterAsyncPostBackControl(btnAlt1MoveUp);
                ScriptController.RegisterAsyncPostBackControl(btnAlt1MoveDown);
                ScriptController.RegisterAsyncPostBackControl(btnAlt2MoveUp);
                ScriptController.RegisterAsyncPostBackControl(btnAlt2MoveDown);
                ScriptController.RegisterAsyncPostBackControl(LeftEditBtn);


                ScriptController.RegisterAsyncPostBackControl(LeftDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(RightDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(btnDeleteAlt1);
                ScriptController.RegisterAsyncPostBackControl(btnDeleteAlt2);
                ScriptController.RegisterAsyncPostBackControl(LeftRightBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentLeftBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentRightBtn);
                ScriptController.RegisterAsyncPostBackControl(RightLeftBtn);
                ScriptController.RegisterAsyncPostBackControl(btnMoveAlt1ToCenter);
                ScriptController.RegisterAsyncPostBackControl(btnMoveAlt2ToCenter);
                //ScriptController.RegisterAsyncPostBackControl(btnMoveAlt2ToAlt1);
            }
        }
예제 #24
0
        private void RenderRss()
        {
            DataView dv = FeedCache.GetRssFeedEntries(
                module.ModuleId,
                module.ModuleGuid,
                entryCacheTimeout,
                maxDaysOld,
                maxEntriesPerFeed,
                EnableSelectivePublishing).DefaultView;

            dv.Sort = "PubDate DESC";

            if (dv.Table.Rows.Count == 0)
            {
                return;
            }


            Argotic.Syndication.RssFeed feed = new Argotic.Syndication.RssFeed();

            RssChannel channel = new RssChannel();

            channel.Generator = "mojoPortal Feed Manager module";
            feed.Channel      = channel;


            if (module != null)
            {
                channel.Title       = module.ModuleTitle;
                channel.Description = module.ModuleTitle;
                //channel.LastBuildDate = channel.Items.LatestPubDate();
                try
                {
                    channel.Link = new System.Uri(WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl()));
                }
                catch (UriFormatException)
                {
                    channel.Link = new System.Uri(SiteUtils.GetNavigationSiteRoot());
                }
            }
            else
            {
                // this prevents an error: Can't close RssWriter without first writing a channel.
                channel.Title         = "Not Found";
                channel.Description   = "Not Found";
                channel.LastBuildDate = DateTime.UtcNow;
                //channel.Link = new System.Uri(SiteUtils.GetCurrentPageUrl());
            }

            foreach (DataRowView row in dv)
            {
                bool confirmed = Convert.ToBoolean(row["Confirmed"]);
                if (!EnableSelectivePublishing)
                {
                    confirmed = true;
                }

                if (confirmed)
                {
                    RssItem item = new RssItem();


                    item.Title           = row["Title"].ToString();
                    item.Description     = row["Description"].ToString();
                    item.PublicationDate = Convert.ToDateTime(row["PubDate"]);
                    item.Link            = new System.Uri(row["Link"].ToString());
                    Trace.Write(item.Link.ToString());
                    item.Author = row["Author"].ToString();

                    channel.AddItem(item);
                }
            }

            Response.Cache.SetExpires(DateTime.Now.AddMinutes(5));
            Response.Cache.SetCacheability(HttpCacheability.Public);
            Response.ContentType = "application/xml";

            Encoding encoding = new UTF8Encoding();

            Response.ContentEncoding = encoding;

            using (XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, encoding))
            {
                xmlTextWriter.Formatting = Formatting.Indented;

                //////////////////
                // style for RSS Feed viewed in browsers
                if (ConfigurationManager.AppSettings["RSSCSS"] != null)
                {
                    string rssCss = ConfigurationManager.AppSettings["RSSCSS"].ToString();
                    xmlTextWriter.WriteWhitespace(" ");
                    xmlTextWriter.WriteRaw("<?xml-stylesheet type=\"text/css\" href=\"" + cssBaseUrl + rssCss + "\" ?>");
                }

                if (ConfigurationManager.AppSettings["RSSXsl"] != null)
                {
                    string rssXsl = ConfigurationManager.AppSettings["RSSXsl"].ToString();
                    xmlTextWriter.WriteWhitespace(" ");
                    xmlTextWriter.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"" + cssBaseUrl + rssXsl + "\" ?>");
                }
                ///////////////////////////


                feed.Save(xmlTextWriter);
            }
        }
예제 #25
0
        private void LoadPage()
        {
            EnsurePageAndSite();
            if (CurrentPage == null)
            {
                return;
            }
            LoadSettings();
            EnforceSecuritySettings();
            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }

            if (CurrentPage.PageId == -1)
            {
                SetupAdminLinks();
                return;
            }

            if ((CurrentPage.ShowChildPageMenu) ||
                (CurrentPage.ShowBreadcrumbs) ||
                (CurrentPage.ShowChildPageBreadcrumbs)
                )
            {
                // this is needed to override some hide logic in
                // layout.Master.cs
                this.MPContent.Visible        = true;
                this.MPContent.Parent.Visible = true;
            }

            if (CurrentPage.BodyCssClass.Length > 0)
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }

            // solves background problems with some skin in WLW
            if ((StyleCombiner != null) && (StyleCombiner.AddBodyClassForLiveWriter))
            {
                if (BrowserHelper.IsWindowsLiveWriter())
                {
                    AddClassToBody("wysiwygeditor");
                }
            }

            if (CurrentPage.PageTitle.Length > 0)
            {
                if (WebConfigSettings.FormatOverridePageTitle)
                {
                    Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageTitle);
                }
                else
                {
                    Title = CurrentPage.PageTitle;
                }
            }
            else
            {
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
            }

            if (CurrentPage.PageMetaKeyWords.Length > 0)
            {
                MetaKeywordCsv = CurrentPage.PageMetaKeyWords;
            }


            if (CurrentPage.PageMetaDescription.Length > 0)
            {
                MetaDescription = CurrentPage.PageMetaDescription;
            }


            if (CurrentPage.CompiledMeta.Length > 0)
            {
                AdditionalMetaMarkup = CurrentPage.CompiledMeta;
            }

            if (WebConfigSettings.AutomaticallyAddCanonicalUrlToCmsPages)
            {
                if ((Page.Header != null) && (CurrentPage.UseUrl) && (CurrentPage.Url.Length > 0))
                {
                    string urlToUse;
                    if (CurrentPage.CanonicalOverride.Length > 0)
                    {
                        urlToUse = CurrentPage.CanonicalOverride;
                    }
                    else
                    {
                        if (CurrentPage.Url.StartsWith("http"))
                        {
                            urlToUse = CurrentPage.Url;
                        }
                        else
                        {
                            if (CurrentPage.UrlHasBeenAdjustedForFolderSites)
                            {
                                urlToUse = WebUtils.GetSiteRoot() + CurrentPage.Url.Replace("~/", "/");
                            }
                            else
                            {
                                urlToUse = SiteRoot + CurrentPage.Url.Replace("~/", "/");
                            }

                            if (SiteUtils.IsSecureRequest() && (!CurrentPage.RequireSsl) && (!siteSettings.UseSslOnAllPages))
                            {
                                if (WebConfigSettings.ForceHttpForCanonicalUrlsThatDontRequireSsl)
                                {
                                    urlToUse = urlToUse.Replace("https:", "http:");
                                }
                            }
                        }
                    }

                    Literal link = new Literal();
                    link.ID   = "pageurl";
                    link.Text = "\n<link rel='canonical' href='"
                                + urlToUse
                                + "' />";

                    Page.Header.Controls.Add(link);
                }
            }

            // if (CurrentPage.Modules.Count == 0) { return; }

            bool isAdmin        = WebUser.IsAdmin;
            bool isContentAdmin = false;
            bool isSiteEditor   = false;

            if (!isAdmin)
            {
                isContentAdmin = WebUser.IsContentAdmin;
                isSiteEditor   = SiteUtils.UserIsSiteEditor();
            }

            if (CurrentPage.Modules.Count == 0)
            {
                if (!CurrentPage.ShowChildPageMenu) // we'll consider Child Page Menu as a feature for our purpose here
                {
                    if (
                        (WebConfigSettings.UsePageContentWizard)
                        &&
                        (isAdmin || isContentAdmin || isSiteEditor || WebUser.IsInRoles(CurrentPage.EditRoles))
                        )
                    {
                        // this is to make it a little more intuitive
                        // sometimes users create pages but fail to see the link in pagesettings to
                        // add features so if they visit the empty page give them an easy opportunity
                        // to add a feature
                        Control wiz = Page.LoadControl("~/Admin/Controls/PageContentWizard.ascx");
                        MPContent.Controls.Add(wiz);
                    }
                }

                return;
            }

            foreach (Module module in CurrentPage.Modules)
            {
                if (!ModuleIsVisible(module))
                {
                    continue;
                }

                if (
                    (!WebUser.IsInRoles(module.ViewRoles)) &&
                    (!isContentAdmin) &&
                    (!isSiteEditor)
                    )
                {
                    continue;
                }

                if ((module.ViewRoles == "Admins;") && (!isAdmin))
                {
                    continue;
                }


                if (module.ControlSource == "Modules/LoginModule.ascx")
                {
                    LoginModuleDisplaySettings loginSettings = new LoginModuleDisplaySettings();
                    this.MPContent.Controls.Add(loginSettings); ///theme is not applied until its loaded
                    if ((Request.IsAuthenticated) && (loginSettings.HideWhenAuthenticated))
                    {
                        continue;
                    }
                }

                Control parent = this.MPContent;

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "leftpane"))
                {
                    parent = this.MPLeftPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "rightpane"))
                {
                    parent = this.MPRightPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent1"))
                {
                    if (AltPane1 != null)
                    {
                        parent = this.AltPane1;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent1 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent2"))
                {
                    if (AltPane2 != null)
                    {
                        parent = this.AltPane2;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent2 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                // this checks if we are using the mobile skin and whether the content is for all web only or mobile only
                if (!ShouldShowModule(module))
                {
                    continue;
                }

                // 2008-10-04 since more an more of our features use postback via ajax
                // its not feasible to use output caching as this breaks postback,
                // so I changed the default the use of WebConfigSettings.DisableContentCache to true
                // this also reduces the memory consumption footprint

                if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                {
                    //2008-10-16 in ulu's blog post:http://dotfresh.blogspot.com/2008/10/in-search-of-developer-friendly-cms.html
                    // he complains about having to inherit from a base class (SiteModuleControl) to make a plugin.
                    // he wishes he could just use a UserControl
                    // While SiteModuleControl "is a" UserControl that provides additional functionality
                    // Its easy enough to support using
                    // a plain UserControl so I'm making the needed change here now.
                    // The drawback of a plain UserControl is that is not reusable in the same way as SiteModuleControl.
                    // If you use a plain UserControl, its going to be exactly the same on any page you use it on.
                    // It has no instance specific properties.
                    // SiteModuleControl gives you instance specific ids and internal tracking of which instance this is so
                    // that you can have different instances.
                    // For example the Blog is instance specific, if you put a blog on one page and then put a blog on another page
                    // those are 2 different blogs with different content.
                    // However, if you don't need a re-usable feature with instance specific properties
                    // you are now free to use a plain old UserControl and I think freedom is a good thing
                    // so this was valuable feedback from ulu.
                    // Those who do need instance specific features should read my developer Guidelines for building one:
                    //http://www.mojoportal.com/addingfeatures.aspx

                    try
                    {
                        Control c = Page.LoadControl("~/" + module.ControlSource);
                        if (c == null)
                        {
                            continue;
                        }

                        if (c is SiteModuleControl)
                        {
                            SiteModuleControl siteModule = (SiteModuleControl)c;
                            siteModule.SiteId = siteSettings.SiteId;
                            siteModule.ModuleConfiguration = module;

                            if (siteModule is IWorkflow)
                            {
                                if (WebUser.IsInRoles(module.AuthorizedEditRoles))
                                {
                                    forceShowWorkflow = true;
                                }
                                if (WebUser.IsInRoles(module.DraftEditRoles))
                                {
                                    forceShowWorkflow = true;
                                }

                                countOfIWorkflow += 1;
                            }
                        }

                        parent.Controls.Add(c);
                    }
                    catch (HttpException ex)
                    {
                        log.Error("failed to load control " + module.ControlSource, ex);
                    }
                }
                else
                {
                    CachedSiteModuleControl siteModule = new CachedSiteModuleControl();

                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ModuleConfiguration = module;
                    parent.Controls.Add(siteModule);
                }

                parent.Visible        = true;
                parent.Parent.Visible = true;
            } //end foreach

            SetupAdminLinks();

            if ((!WebConfigSettings.DisableExternalCommentSystems) && (siteSettings != null) && (CurrentPage != null) && (CurrentPage.EnableComments))
            {
                switch (siteSettings.CommentProvider)
                {
                case "disqus":

                    if (siteSettings.DisqusSiteShortName.Length > 0)
                    {
                        DisqusWidget disqus = new DisqusWidget();
                        disqus.SiteShortName = siteSettings.DisqusSiteShortName;
                        disqus.WidgetPageUrl = WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl());
                        if (disqus.WidgetPageUrl.StartsWith("https"))
                        {
                            disqus.WidgetPageUrl = disqus.WidgetPageUrl.Replace("https", "http");
                        }
                        disqus.RenderWidget = true;
                        MPContent.Controls.Add(disqus);
                    }

                    break;

                case "intensedebate":

                    if (siteSettings.IntenseDebateAccountId.Length > 0)
                    {
                        IntenseDebateDiscussion d = new IntenseDebateDiscussion();
                        d.AccountId = siteSettings.IntenseDebateAccountId;
                        d.PostUrl   = SiteUtils.GetCurrentPageUrl();
                        MPContent.Controls.Add(d);
                    }



                    break;

                case "facebook":
                    FacebookCommentWidget fbComments = new FacebookCommentWidget();
                    fbComments.AutoDetectUrl = true;
                    MPContent.Controls.Add(fbComments);

                    break;
                }
            }

            if (WebConfigSettings.HidePageViewModeIfNoWorkflowItems && (countOfIWorkflow == 0))
            {
                HideViewSelector();
            }

            // (to show the last mnodified time of a page we may have this control in layout.master, but I set it invisible by default
            // because we only want to show it on content pages not edit pages
            // since Default.aspx.cs is the handler for content pages, we look for it here and make it visible.
            Control pageLastMod = Master.FindControl("pageLastMod");

            if (pageLastMod != null)
            {
                pageLastMod.Visible = true;
            }
        }
예제 #26
0
        protected virtual void PopulateControls()
        {
            if (parametersAreInvalid)
            {
                AllowComments   = false;
                pnlBlog.Visible = false;
                return;
            }

            // if not published only the editor can see it
            if (
                ((!ThePost.IsPublished) || (ThePost.StartDate > DateTime.UtcNow)) &&
                (!BasePage.UserCanEditModule(ModuleId))
                )
            {
                AllowComments   = false;
                pnlBlog.Visible = false;
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }
            //set post edit url
            PostEditUrl = String.Format("{0}/Blog/EditPost.aspx?pageid={1}&ItemID={2}&mid={3}", BasePage.SiteRoot, PageId, ItemId.ToString(CultureInfo.InvariantCulture), ModuleId.ToString(CultureInfo.InvariantCulture));

            BasePage.Title                     = SiteUtils.FormatPageTitle(BasePage.SiteInfo, ThePost.Title);
            BasePage.MetaDescription           = ThePost.MetaDescription;
            BasePage.MetaKeywordCsv            = ThePost.MetaKeywords;
            BasePage.AdditionalMetaMarkup      = ThePost.CompiledMeta;
            addThis1.TitleOfUrlToShare         = ThePost.Title;
            addThis1.AccountId                 = addThisAccountId;
            addThis1.CustomBrand               = addThisCustomBrand;
            addThis1.UseMouseOverWidget        = useAddThisMouseOverWidget;
            addThis1.ButtonImageUrl            = addThisButtonImageUrl;
            addThis1.CustomLogoBackgroundColor = addThisCustomLogoBackColor;
            addThis1.CustomLogoColor           = addThisCustomLogoForeColor;
            addThis1.CustomLogoUrl             = addThisCustomLogoUrl;
            addThis1.CustomOptions             = addThisCustomOptions;

            txtCommentTitle.Text = "re: " + ThePost.Title;

            odiogoPlayer.OdiogoFeedId = OdiogoFeedIDSetting;
            odiogoPlayer.ItemId       = ThePost.ItemId.ToString(CultureInfo.InvariantCulture);
            odiogoPlayer.ItemTitle    = ThePost.Title;
            if (BlogAuthor.Length == 0)
            {
                BlogAuthor = ThePost.UserName;
            }

            if (ThePost.PreviousPostUrl.Length > 0)
            {
                PreviousPostUrl = String.Format("{0}{1}", BasePage.SiteRoot, ThePost.PreviousPostUrl.Replace("~", string.Empty));
            }

            if (ThePost.NextPostUrl.Length > 0)
            {
                NextPostUrl = String.Format("{0}{1}", BasePage.SiteRoot, ThePost.NextPostUrl.Replace("~", string.Empty));
            }

            if (ThePost.Location.Length > 0)
            {
                gmap.Visible                 = true;
                gmap.GMapApiKey              = GmapApiKey;
                gmap.Location                = ThePost.Location;
                gmap.EnableMapType           = GoogleMapEnableMapTypeSetting;
                gmap.EnableZoom              = GoogleMapEnableZoomSetting;
                gmap.ShowInfoWindow          = GoogleMapShowInfoWindowSetting;
                gmap.EnableLocalSearch       = GoogleMapEnableLocalSearchSetting;
                gmap.MapHeight               = GoogleMapHeightSetting;
                gmap.MapWidth                = GoogleMapWidthSetting;
                gmap.EnableDrivingDirections = GoogleMapEnableDirectionsSetting;
                gmap.GmapType                = mapType;
                gmap.ZoomLevel               = GoogleMapInitialZoomSetting;
                gmap.DirectionsButtonText    = BlogResources.MapGetDirectionsButton;
                gmap.DirectionsButtonToolTip = BlogResources.MapGetDirectionsButton;
            }

            using (IDataReader dataReader = Blog.GetBlogComments(ModuleId, ItemId))
            {
                dlComments.DataSource = dataReader;
                dlComments.DataBind();
            }



            PopulateNavigation();

            if (Page.Header == null)
            {
                return;
            }

            Literal link = new Literal();

            link.ID   = "blogurl";
            link.Text = "\n<link rel='canonical' href='"
                        + SiteRoot
                        + ThePost.ItemUrl.Replace("~/", "/")
                        + "' />";

            Page.Header.Controls.Add(link);
        }
예제 #27
0
 void CancelButton_Click(object sender, EventArgs e)
 {
     WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
 }
예제 #28
0
        private void PopulateLabels()
        {
            lnkPageCrumb.Text        = CurrentPage.PageName;
            lnkPageCrumb.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            lnkSurveys.Text        = SurveyResources.ChooseActiveSurveyLink;
            lnkSurveys.NavigateUrl = SiteRoot + "/Survey/Surveys.aspx?pageid="
                                     + pageId.ToInvariantString() + "&mid="
                                     + ModuleId.ToInvariantString();


            lnkPages.Text        = SurveyResources.SurveyPagesBreadCrumbText;
            lnkPages.NavigateUrl = SiteRoot
                                   + "/Survey/SurveyPages.aspx?SurveyGuid="
                                   + surveyGuid.ToString() + "&pageid=" + pageId.ToInvariantString()
                                   + "&mid=" + ModuleId.ToInvariantString();

            lnkQuestions.NavigateUrl = SiteRoot
                                       + "/Survey/SurveyQuestions.aspx?SurveyGuid=" + surveyGuid.ToString()
                                       + "&SurveyPageGuid=" + surveyPageGuid.ToString()
                                       + "&PageId=" + pageId.ToInvariantString()
                                       + "&mid=" + moduleId.ToInvariantString();

            if (questionGuid != Guid.Empty)
            {
                litHeading.Text = SurveyResources.QuestionEditHeader;
            }
            else
            {
                litHeading.Text = SurveyResources.QuestionAddHeader;
            }

            //lnkQuestionEdit.Text = SurveyResources.SurveyQuestionEditBreadCrumbText;
            //lnkQuestionEdit.NavigateUrl = Request.RawUrl;

            btnSave.Text    = SurveyResources.QuestionEditOptionsSaveButton;
            btnSave.ToolTip = SurveyResources.QuestionEditOptionsSaveButtonToolTip;

            btnAddOption.Text    = SurveyResources.QuestionEditOptionsAddButton;
            btnAddOption.ToolTip = SurveyResources.QuestionEditOptionsAddToolTip;

            btnUp.AlternateText = SurveyResources.QuestionEditOptionsUpAlternateText;
            btnUp.ToolTip       = SurveyResources.QuestionEditOptionsUpAlternateText;
            btnUp.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/up.gif";

            btnDown.AlternateText = SurveyResources.QuestionEditOptionsDownAlternateText;
            btnDown.ToolTip       = SurveyResources.QuestionEditOptionsDownAlternateText;
            btnDown.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/dn.gif";

            btnEdit.AlternateText = SurveyResources.QuestionEditOptionsEditAlternateText;
            btnEdit.ToolTip       = SurveyResources.QuestionEditOptionsEditAlternateText;
            btnEdit.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + EditContentImage;

            btnDeleteOption.AlternateText = SurveyResources.QuestionEditOptionsDeleteAlternateText;
            btnDeleteOption.ToolTip       = SurveyResources.QuestionEditOptionsDeleteAlternateText;
            btnDeleteOption.ImageUrl      = ImageSiteRoot + "/Data/SiteImages/" + DeleteLinkImage;

            btnCancel.Text    = SurveyResources.QuestionEditCancelButton;
            btnCancel.ToolTip = SurveyResources.QuestionEditCancelButtonToolTip;


            edMessage.WebEditor.ToolBar = ToolBar.Full;
        }
예제 #29
0
        private void SaveHtml(bool draft)
        {
            if (html == null)
            {
                return;
            }

            this.itemId = html.ItemId;

            html.ContentChanged += new ContentChangedEventHandler(html_ContentChanged);

            bool   saveHtml = true;
            string htmlBody = edContent.Text;

            if (draft)
            {
                //ContentWorkflow wip = ContentWorkflow.GetWorkInProgress(this.module.ModuleGuid);
                //dont update the actual data, but edit/create the draft version:
                if (workInProgress != null)
                {
                    if (workInProgress.Status != ContentWorkflowStatus.Draft)
                    {
                        if ((workInProgress.Status == ContentWorkflowStatus.AwaitingApproval) && (userCanEdit))
                        {
                            // do nothing, let the editor update the draft without changing the status
                        }
                        else
                        {
                            //otherwise set the status back to draft
                            workInProgress.Status = ContentWorkflowStatus.Draft;
                        }
                    }

                    workInProgress.ContentText = edContent.Text;
                    workInProgress.Save();
                }
                else
                {
                    //draft version doesn't exist - create it:
                    ContentWorkflow.CreateDraftVersion(
                        siteSettings.SiteGuid,
                        edContent.Text,
                        string.Empty,
                        -1,
                        Guid.Empty,
                        this.module.ModuleGuid,
                        currentUser.UserGuid);
                }

                //if this is a new item, then we want to save it even though we will be saving it with no html,
                //this ensures that there is a record there from the start:
                if (html.ItemId < 1)
                {
                    saveHtml = true;
                    //save with no content as there will be no live content
                    htmlBody = String.Empty;
                }
                else
                {
                    saveHtml = false;
                }
            }

            if (saveHtml)
            {
                //update existing HTML content:

                html.Body            = htmlBody;
                html.LastModUserGuid = currentUser.UserGuid;
                if (module != null)
                {
                    html.ModuleGuid = module.ModuleGuid;
                }
                html.LastModUtc = DateTime.UtcNow;


                if (enableContentVersioning && !draft)
                {
                    html.CreateHistory(siteSettings.SiteGuid);
                }

                repository.Save(html);
            }
            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);

            SiteUtils.QueueIndexing();


            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
        private void btnSave_Click(Object sender, EventArgs e)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("ModuleSettingsPage about to call Page.Validate()");
            }

            Page.Validate();
            if (Page.IsValid)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("ModuleSettingsPage about to call Page IsValid = true");
                }

                bool ok            = true;
                bool needToReIndex = false;
                int  currentPageId = module.PageId;
                int  newPageId     = module.PageId;


                if (module.ModuleId > -1)
                {
                    if (isAdmin)
                    {
                        string viewRoles = string.Empty;

                        foreach (ListItem item in cblViewRoles.Items)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage inside loop of Role ListItems");
                            }
                            if (item.Selected == true)
                            {
                                viewRoles = viewRoles + item.Value + ";";
                            }
                        }
                        string previousViewRoles = this.module.ViewRoles;
                        this.module.ViewRoles = viewRoles;
                        if (previousViewRoles != viewRoles)
                        {
                            needToReIndex = true;
                        }

                        string editRoles = string.Empty;
                        if (log.IsDebugEnabled)
                        {
                            log.Debug("ModuleSettingsPage about to loop through Role ListItems");
                        }

                        foreach (ListItem item in authEditRoles.Items)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage inside loop of Role ListItems");
                            }
                            if (item.Selected == true)
                            {
                                editRoles = editRoles + item.Value + ";";
                            }
                        }

                        this.module.AuthorizedEditRoles = editRoles;

                        string draftEdits = string.Empty;

                        foreach (ListItem item in draftEditRoles.Items)
                        {
                            if (item.Selected == true)
                            {
                                draftEdits = draftEdits + item.Value + ";";
                            }
                        }

                        this.module.DraftEditRoles = draftEdits;
                    }

                    if (tabGeneralSettings.Visible)
                    {
                        this.module.ModuleTitle = moduleTitle.Text;
                        this.module.CacheTime   = int.Parse(cacheTime.Text);

                        this.module.ShowTitle                      = chkShowTitle.Checked;
                        this.module.AvailableForMyPage             = this.chkAvailableForMyPage.Checked;
                        this.module.AllowMultipleInstancesOnMyPage = this.chkAllowMultipleInstancesOnMyPage.Checked;
                        this.module.Icon = this.ddIcons.SelectedValue;
                        this.module.HideFromAuthenticated   = chkHideFromAuth.Checked;
                        this.module.HideFromUnauthenticated = chkHideFromUnauth.Checked;

                        if (this.divParentPage.Visible)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage about to check Page dropdown");
                            }
                            newPageId = int.Parse(this.ddPages.SelectedValue);
                            if (newPageId != currentPageId)
                            {
                                needToReIndex = true;
                                Module.UpdatePage(currentPageId, newPageId, this.module.ModuleId);
                            }
                            this.module.PageId = newPageId;
                        }

                        if (this.isAdmin)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage about to check user dropdown");
                            }
                            if (this.scUser.Value.Length > 0)
                            {
                                try
                                {
                                    this.module.EditUserId = int.Parse(this.scUser.Value);
                                }
                                catch (ArgumentException) { }
                                catch (FormatException) { }
                                catch (OverflowException) { }
                            }
                            else
                            {
                                this.module.EditUserId = 0;
                            }
                        }
                    }

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("ModuleSettingsPage about to Save Module");
                    }
                    this.module.Save();

                    if (needToReIndex)
                    {
                        // if content is moved from 1 page to another, need to reindex both pages
                        // to keep view permissions in sync

                        IndexHelper.RebuildPageIndexAsync(CurrentPage);

                        PageSettings newPage = new PageSettings(siteSettings.SiteId, newPageId);
                        newPage.PageIndex = 0;
                        IndexHelper.RebuildPageIndexAsync(newPage);
                    }

                    ArrayList defaultSettings = ModuleSettings.GetDefaultSettings(this.module.ModuleDefId);
                    foreach (CustomModuleSetting s in defaultSettings)
                    {
                        if (s.SettingControlType == string.Empty)
                        {
                            continue;
                        }
                        ok = true;

                        Object oSettingLabel = GetGlobalResourceObject("Resource", s.SettingName + "RegexWarning");
                        String settingLabel  = String.Empty;
                        if (oSettingLabel == null)
                        {
                            settingLabel = "Regex Warning";
                        }
                        else
                        {
                            settingLabel = oSettingLabel.ToString();
                        }

                        string settingValue = string.Empty;

                        if (s.SettingName == "WebPartModuleWebPartSetting")
                        {
                            ModuleSettings.UpdateModuleSetting(this.module.ModuleGuid, moduleId, s.SettingName, ddWebParts.SelectedValue);
                        }
                        else
                        {
                            if (s.SettingControlType == "ISettingControl")
                            {
                                string  controlID = "uc" + moduleId.ToString(CultureInfo.InvariantCulture) + s.SettingName;
                                Control c         = PlaceHolderAdvancedSettings.FindControl(controlID);
                                if (c != null)
                                {
                                    if (c is ISettingControl)
                                    {
                                        ISettingControl isc = c as ISettingControl;
                                        settingValue = isc.GetValue();
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                }
                                else
                                {
                                    log.Error("could not find control for " + s.SettingName);
                                    ok = false;
                                }
                            }
                            else
                            {
                                settingValue = Request.Params.Get(s.SettingName + this.moduleId.ToString(CultureInfo.InvariantCulture));

                                if (s.SettingControlType == "CheckBox")
                                {
                                    if (settingValue == "on")
                                    {
                                        settingValue = "true";
                                    }
                                    else
                                    {
                                        settingValue = "false";
                                    }
                                }
                                else
                                {
                                    if (s.SettingValidationRegex.Length > 0)
                                    {
                                        if (!Regex.IsMatch(settingValue, s.SettingValidationRegex))
                                        {
                                            ok = false;
                                            this.lblValidationSummary.Text += "<br />"
                                                                              + settingLabel;
                                        }
                                    }
                                }
                            }

                            if (ok)
                            {
                                ModuleSettings.UpdateModuleSetting(this.module.ModuleGuid, moduleId, s.SettingName, settingValue);
                            }
                        }
                    }
                }

                if (ok)
                {
                    CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                    return;
                }
            }
        }