Exemplo n.º 1
0
        // POST /api/forummod
        public ModerationResult Post(ModerationRequest modReq)
        {
            //log.Info("cmd = " + modReq.Cmd);
            //log.Info("pageId = " + modReq.PageId.ToInvariantString());
            //log.Info("moduleId = " + modReq.ModuleId.ToInvariantString());
            //log.Info("pageNumber = " + modReq.PageNumber.ToInvariantString());
            //log.Info("threadId = " + modReq.ThreadId.ToInvariantString());
            //log.Info("postId = " + modReq.PostId.ToInvariantString());


            ModerationResult result = new ModerationResult();

            result.Msg = "rejected";
            if (IsAllowed(modReq))
            {
                switch (modReq.Cmd)
                {
                case "sendnotification":



                    bool notifyModeratorOnly = false;

                    ForumNotification.NotifySubscribers(
                        forum,
                        thread,
                        module,
                        postUser,
                        siteSettings,
                        config,
                        SiteUtils.GetNavigationSiteRoot(),
                        modReq.PageId,
                        modReq.PageNumber,
                        SiteUtils.GetDefaultCulture(),
                        ForumConfiguration.GetSmtpSettings(),
                        notifyModeratorOnly
                        );

                    thread.NotificationSent = true;
                    thread.UpdatePost();

                    result.Msg = "success";

                    break;

                case "marksent":

                    thread.NotificationSent = true;
                    thread.UpdatePost();

                    //System.Threading.Thread.Sleep(7000);

                    result.Msg = "success";

                    break;
                }
            }

            return(result);
        }
        private void ConfigureEditor()
        {
            fckEditor.CustomConfigurationsPath = "";

            fckEditor.BasePath = scriptBaseUrl;
            fckEditor.SkinPath = scriptBaseUrl + "editor/skins/" + WebConfigSettings.FCKeditorSkin + "/";
            //fckEditor.BaseHref = fckEditor.ResolveUrl("~/");

            //fckEditor.PluginsPath = "";
            ConfigurePaths();



            if (editorCSSUrl.Length > 0)
            {
                fckEditor.Config["EditorAreaCSS"] = editorCSSUrl;
            }

            CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

            fckEditor.AutoDetectLanguage = false;

            fckEditor.DefaultLanguage = defaultCulture.TwoLetterISOLanguageName;



            if ((textDirection == Direction.RightToLeft) || (defaultCulture.TextInfo.IsRightToLeft))
            {
                fckEditor.Config["ContentLangDirection"] = "rtl";
            }

            fckEditor.Width  = editorWidth;
            fckEditor.Height = editorHeight;
            if (setFocusOnStart)
            {
                fckEditor.StartupFocus = true;
            }

            if ((ConfigurationManager.AppSettings["FCKeditor:Debug"] != null) &&
                (ConfigurationManager.AppSettings["FCKeditor:Debug"] == "true"))
            {
                fckEditor.Debug = true;
            }

            SetToolBar();
        }
Exemplo n.º 3
0
        private void SendNotification(HttpContext context)
        {
            //log.Info("theadId = " + threadId);
            //log.Info("postId = " + postId);
            //log.Info("pageId = " + pageId);
            //log.Info("mid = " + moduleId);

            bool      notifyModeratorOnly = false;
            ModResult result = new ModResult();

            if (LoadAndValidateForumObjects())
            {
                thread.NotificationSent = true;
                thread.UpdatePost();

                ForumNotification.NotifySubscribers(
                    forum,
                    thread,
                    module,
                    postUser,
                    siteSettings,
                    config,
                    SiteUtils.GetNavigationSiteRoot(),
                    pageId,
                    pageNumber,
                    SiteUtils.GetDefaultCulture(),
                    ForumConfiguration.GetSmtpSettings(),
                    notifyModeratorOnly
                    );

                result.Msg = "success";
            }
            else
            {
                log.Info("Send forum notification request rejected due to invalid params");

                result.Msg = "rejected";
            }

            context.Response.ContentType = "application/json";
            JavaScriptSerializer s = new JavaScriptSerializer();

            context.Response.Write(s.Serialize(result));
        }
Exemplo n.º 4
0
        public static void SendRejectionNotification(
            SmtpSettings smtpSettings,
            SiteSettings siteSettings,
            SiteUser rejectingUser,
            ContentWorkflow rejectedWorkflow,
            string rejectionReason
            )
        {
            EmailMessageTask messageTask = new EmailMessageTask(smtpSettings);

            messageTask.SiteGuid     = siteSettings.SiteGuid;
            messageTask.EmailFrom    = siteSettings.DefaultEmailFromAddress;
            messageTask.EmailReplyTo = rejectingUser.Email;
            messageTask.EmailTo      = rejectedWorkflow.RecentActionByUserEmail;

            CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

            messageTask.Subject = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestRejectionNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName);

            StringBuilder message = new StringBuilder();

            message.Append(ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestRejectionNotification.config"));
            message.Replace("{ModuleTitle}", rejectedWorkflow.ModuleTitle);
            message.Replace("{ApprovalRequestedDate}", rejectedWorkflow.RecentActionOn.ToShortDateString());
            message.Replace("{RejectionReason}", rejectionReason);
            message.Replace("{RejectedBy}", rejectingUser.Name);

            if (!Email.IsValidEmailAddressSyntax(rejectedWorkflow.RecentActionByUserEmail))
            {
                //invalid address log it
                log.Error("Failed to send workflow rejection message, invalid recipient email "
                          + rejectedWorkflow.RecentActionByUserEmail
                          + " message was " + message.ToString());

                return;
            }

            messageTask.TextBody = message.ToString();
            messageTask.QueueTask();

            WebTaskManager.StartOrResumeTasks();
        }
        private void SetupInstanceScript()
        {
            if (languageCode.Length == 0)
            {
                CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();
                languageCode = defaultCulture.TwoLetterISOLanguageName;
            }

            StringBuilder script = new StringBuilder();

            script.Append("\n<script type=\"text/javascript\">\n");

            script.Append("function googleTranslateElementInit() {");
            script.Append("new google.translate.TranslateElement({");
            script.Append("pageLanguage: '" + languageCode + "'},");
            script.Append("'" + ClientID + "');}");

            script.Append("\n</script>");

            this.Page.ClientScript.RegisterClientScriptBlock(
                this.GetType(),
                this.UniqueID,
                script.ToString());
        }
        private void BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (WebUtils.IsRequestForStaticFile(app.Request.Path))
            {
                return;
            }
            if (app.Request.Path.ContainsCaseInsensitive("csshandler.ashx"))
            {
                return;
            }
            if (app.Request.Path.ContainsCaseInsensitive("thumbnailservice.ashx"))
            {
                return;
            }
            if (app.Request.Path.ContainsCaseInsensitive("GCheckoutNotificationHandler.ashx"))
            {
                return;
            }


            // 2006-12-29 Joe Audette
            // CultureInfo for the executing thread is automatically set to the
            // preferred culture of the user's browser by this web.config setting:
            // <globalization
            //   culture="auto:en-US"
            //   uiCulture="auto:en"
            //   requestEncoding="utf-8"
            //   responseEncoding="utf-8"
            //   fileEncoding="iso-8859-15" />
            //
            // the "auto" tells the runtime to use the browser preference
            // and the :en-US tells the runtime to fall back to en-US as the default culture for
            // missing resource keys or if no resource file exists for the preferred culture
            // you can specify a different default culture by replacing en-US with your preferred
            // culture, but you should make sure that the resource file for the default culture
            // has no missing keys or runtime errors could occur

            //by default the culture of the executing thread is set to that of the browser preferred language setting
            // and this causes the use of the language specific resource if available else it falls back to the default en-US
            //as defined in Web.config globalization section
            //below we are using a config setting to change the default behavior to force the thread to use a specific culture
            //however if there are missing keys in the specified culture it can still fall back to en-US as it should
            if (WebConfigSettings.UseCultureOverride)
            {
                CultureInfo siteCulture;
                CultureInfo siteUICulture;
                try
                {
                    siteCulture   = SiteUtils.GetDefaultCulture();
                    siteUICulture = SiteUtils.GetDefaultUICulture();
                }
                catch (InvalidOperationException) { return; }
                catch (System.Data.Common.DbException) { return; }

                if (siteCulture.IsNeutralCulture)
                {
                    log.Info("cannot use culture " + siteCulture.Name + " because it is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture.");
                }
                else
                {
                    try
                    {
                        Thread.CurrentThread.CurrentCulture = siteCulture;
                        if (WebConfigSettings.SetUICultureWhenSettingCulture)
                        {
                            Thread.CurrentThread.CurrentUICulture = siteUICulture;
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        log.Info("swallowed error in culture helper", ex);
                    }
                    catch (NotSupportedException ex)
                    {
                        log.Info("swallowed error in culture helper", ex);
                    }
                }
            }


            // below we are overriding only to handle culture specific workarounds, for most cultures
            // we don't need to do anything here as the runtime handles it correctly
            // but there are some cultures which are either poorly or incorrectly implemented
            // in the .NET runtime

            if (WebConfigSettings.UseCustomHandlingForPersianCulture)
            {
                if (
                    (CultureInfo.CurrentCulture.Name == "fa-IR") ||
                    (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "fa")
                    )
                {
                    try
                    {
                        CultureInfo PersianCulture = CultureHelper.GetPersianCulture();
                        Thread.CurrentThread.CurrentCulture   = PersianCulture;
                        Thread.CurrentThread.CurrentUICulture = PersianCulture;
                    }
                    catch (System.Security.SecurityException ex)
                    {
                        //can happen in medium trust
                        log.Error(ex);
                    }
                    catch (ArgumentException ex)
                    {
                        log.Info("swallowed error in culture helper", ex);
                    }
                }
            }


            //this doesn't work but was a nice idea
            //http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/27/displaying-arabic-number.aspx
            //has the only real solution
            //if ((CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ar") && (!CultureInfo.CurrentCulture.IsNeutralCulture))
            //{
            //    CultureInfo arabic = new CultureInfo(CultureInfo.CurrentCulture.Name);
            //    arabic.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
            //    string[] arabicDigits = new string[] { "٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩" };
            //    arabic.NumberFormat.NativeDigits = arabicDigits;
            //    Thread.CurrentThread.CurrentCulture = arabic;
            //    Thread.CurrentThread.CurrentUICulture = arabic;
            //}
        }
Exemplo n.º 7
0
        private void RenderRss()
        {
            Argotic.Syndication.RssFeed feed = new Argotic.Syndication.RssFeed();
            RssChannel channel = new RssChannel();

            channel.Generator = "mojoPortal Blog Module";

            channel.Language = SiteUtils.GetDefaultCulture();
            feed.Channel     = channel;
            if (module.ModuleTitle.Length > 0)
            {
                channel.Title = module.ModuleTitle;
            }
            else
            {
                channel.Title = "Blog"; // it will cause an error if this is left blank so we must populate it if the module title is an emty string.
            }

            // this became broken when we combined query string params, since pageid is not one of the params this always returns the home page url
            // instead of the blog page url
            //string pu = WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl());

            string pu = WebUtils.ResolveServerUrl(SiteUtils.GetPageUrl(pageSettings));


            channel.Link     = new System.Uri(pu);
            channel.SelfLink = Request.Url;


            if (config.ChannelDescription.Length > 0)
            {
                channel.Description = config.ChannelDescription;
            }
            if (config.Copyright.Length > 0)
            {
                channel.Copyright = config.Copyright;
            }

            channel.ManagingEditor = config.ManagingEditorEmail;
            if (config.ManagingEditorName.Length > 0)
            {
                channel.ManagingEditor += " (" + config.ManagingEditorName + ")";
            }


            if (config.FeedTimeToLive > -1)
            {
                channel.TimeToLive = config.FeedTimeToLive;
            }


            //  Create and add iTunes information to feed channel
            ITunesSyndicationExtension channelExtension = new ITunesSyndicationExtension();

            channelExtension.Context.Subtitle = config.ChannelDescription;


            if (config.HasExplicitContent)
            {
                channelExtension.Context.ExplicitMaterial = ITunesExplicitMaterial.Yes;
            }
            else
            {
                channelExtension.Context.ExplicitMaterial = ITunesExplicitMaterial.No;
            }

            channelExtension.Context.Author = config.ManagingEditorEmail;
            if (config.ManagingEditorName.Length > 0)
            {
                channelExtension.Context.Author += " (" + config.ManagingEditorName + ")";
            }
            channelExtension.Context.Summary = config.ChannelDescription;
            channelExtension.Context.Owner   = new ITunesOwner(config.ManagingEditorEmail, config.ManagingEditorName);



            if (config.FeedLogoUrl.Length > 0)
            {
                try
                {
                    channelExtension.Context.Image = new Uri(config.FeedLogoUrl);
                }
                catch (ArgumentNullException) { }
                catch (UriFormatException) { }
            }


            if (config.FeedMainCategory.Length > 0)
            {
                ITunesCategory mainCat = new ITunesCategory(config.FeedMainCategory);

                if (config.FeedSubCategory.Length > 0)
                {
                    mainCat.Categories.Add(new ITunesCategory(config.FeedSubCategory));
                }


                channelExtension.Context.Categories.Add(mainCat);
            }


            feed.Channel.AddExtension(channelExtension);


            DataSet dsBlogPosts = GetData();

            DataTable posts = dsBlogPosts.Tables["Posts"];


            foreach (DataRow dr in posts.Rows)
            {
                bool inFeed = Convert.ToBoolean(dr["IncludeInFeed"]);
                if (!inFeed)
                {
                    continue;
                }

                RssItem item = new RssItem();

                int    itemId      = Convert.ToInt32(dr["ItemID"]);
                string blogItemUrl = FormatBlogUrl(dr["ItemUrl"].ToString(), itemId);
                item.Link            = new Uri(Request.Url, blogItemUrl);
                item.Guid            = new RssGuid(blogItemUrl);
                item.Title           = dr["Heading"].ToString();
                item.PublicationDate = Convert.ToDateTime(dr["StartDate"]);

                bool showAuthor = Convert.ToBoolean(dr["ShowAuthorName"]);
                if (showAuthor)
                {
                    // techically this is supposed to be an email address
                    // but wouldn't that lead to a lot of spam?

                    string authorEmail = dr["Email"].ToString();
                    string authorName  = dr["Name"].ToString();

                    if (BlogConfiguration.IncludeAuthorEmailInFeed)
                    {
                        item.Author = authorEmail + " (" + authorName + ")";
                    }
                    else
                    {
                        item.Author = authorName;
                    }
                }
                else if (config.ManagingEditorEmail.Length > 0)
                {
                    item.Author = config.ManagingEditorEmail;
                }

                item.Comments = new Uri(blogItemUrl);

                string signature = string.Empty;

                if (config.AddSignature)
                {
                    signature = "<br /><a href='" + blogItemUrl + "'>" + dr["Name"].ToString() + "</a>";
                }

                if ((config.AddCommentsLinkToFeed) && (config.AllowComments))
                {
                    signature += "&nbsp;&nbsp;" + "<a href='" + blogItemUrl + "'>...</a>";
                }

                if (config.AddTweetThisToFeed)
                {
                    signature += GenerateTweetThisLink(item.Title, blogItemUrl);
                }

                if (config.AddFacebookLikeToFeed)
                {
                    signature += GenerateFacebookLikeButton(blogItemUrl);
                }


                string blogPost = SiteUtils.ChangeRelativeUrlsToFullyQualifiedUrls(navigationSiteRoot, imageSiteRoot, dr["Description"].ToString().RemoveCDataTags());

                string staticMapLink = BuildStaticMapMarkup(dr);

                if (staticMapLink.Length > 0)
                {
                    // add a google static map
                    blogPost += staticMapLink;
                }


                if ((!config.UseExcerptInFeed) || (blogPost.Length <= config.ExcerptLength))
                {
                    item.Description = blogPost + signature;
                }
                else
                {
                    string excerpt = SiteUtils.ChangeRelativeUrlsToFullyQualifiedUrls(navigationSiteRoot, imageSiteRoot, dr["Abstract"].ToString().RemoveCDataTags());

                    if ((excerpt.Length > 0) && (excerpt != "<p>&#160;</p>"))
                    {
                        excerpt = excerpt
                                  + config.ExcerptSuffix
                                  + " <a href='"
                                  + blogItemUrl + "'>" + config.MoreLinkText + "</a><div class='excerptspacer'>&nbsp;</div>";
                    }
                    else
                    {
                        excerpt = UIHelper.CreateExcerpt(dr["Description"].ToString(), config.ExcerptLength, config.ExcerptSuffix)
                                  + " <a href='"
                                  + blogItemUrl + "'>" + config.MoreLinkText + "</a><div class='excerptspacer'>&nbsp;</div>";;
                    }

                    item.Description = excerpt;
                }



                // how to add media enclosures for podcasting
                //http://www.podcast411.com/howto_1.html

                //http://argotic.codeplex.com/wikipage?title=Generating%20an%20extended%20RSS%20feed

                //http://techwhimsy.com/stream-mp3s-with-google-mp3-player


                //Uri url = new Uri("http://media.libsyn.com/media/podcast411/411_060325.mp3");
                //string type = "audio/mpeg";
                //long length = 11779397;

                string blogGuid    = dr["BlogGuid"].ToString();
                string whereClause = string.Format("ItemGuid = '{0}'", blogGuid);


                if (!config.UseExcerptInFeed)
                {
                    DataView dv = new DataView(dsBlogPosts.Tables["Attachments"], whereClause, "", DataViewRowState.CurrentRows);

                    foreach (DataRowView rowView in dv)
                    {
                        DataRow row = rowView.Row;

                        Uri    mediaUrl      = new Uri(WebUtils.ResolveServerUrl(attachmentBaseUrl + row["ServerFileName"].ToString()));
                        long   contentLength = Convert.ToInt64(row["ContentLength"]);
                        string contentType   = row["ContentType"].ToString();

                        RssEnclosure enclosure = new RssEnclosure(contentLength, contentType, mediaUrl);
                        item.Enclosures.Add(enclosure);

                        //http://argotic.codeplex.com/wikipage?title=Generating%20an%20extended%20RSS%20feed

                        ITunesSyndicationExtension itemExtension = new ITunesSyndicationExtension();
                        itemExtension.Context.Author   = dr["Name"].ToString();
                        itemExtension.Context.Subtitle = dr["SubTitle"].ToString();
                        //itemExtension.Context.Summary = "The iTunes syndication extension properties that are used vary based on whether extending the channel or an item";
                        //itemExtension.Context.Duration = new TimeSpan(1, 2, 13);
                        //itemExtension.Context.Keywords.Add("Podcast");
                        //itemExtension.Context.Keywords.Add("iTunes");


                        whereClause = string.Format("ItemID = '{0}'", itemId);
                        DataView dvCat = new DataView(dsBlogPosts.Tables["Categories"], whereClause, "", DataViewRowState.CurrentRows);

                        foreach (DataRowView rView in dvCat)
                        {
                            DataRow r = rView.Row;

                            item.Categories.Add(new RssCategory(r["Category"].ToString()));

                            itemExtension.Context.Keywords.Add(r["Category"].ToString());
                        }

                        item.AddExtension(itemExtension);
                    }
                }



                channel.AddItem(item);
            }


            if ((config.FeedburnerFeedUrl.Length > 0) || (Request.Url.AbsolutePath.Contains("localhost")))
            {
                Response.Cache.SetExpires(DateTime.Now.AddMinutes(-30));
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.VaryByParams["r"] = true;
            }
            else
            {
                Response.Cache.SetExpires(DateTime.Now.AddMinutes(30));
                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);
            }
        }
Exemplo n.º 8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (group == null)
            {
                group = new Group(groupId);
            }

            if (!group.AllowAnonymousPosts)
            {
                captcha.Enabled     = false;
                pnlAntiSpam.Visible = false;
                pnlEdit.Controls.Remove(pnlAntiSpam);
            }

            Page.Validate();
            if (!Page.IsValid)
            {
                PopulateControls();
                return;
            }
            else
            {
                if ((useSpamBlockingForAnonymous) && (pnlAntiSpam.Visible))
                {
                    if (!captcha.IsValid)
                    {
                        PopulateControls();
                        return;
                    }
                }

                GroupTopic topic;
                bool       userIsAllowedToUpdateThisPost = false;
                if (topicId == -1)
                {
                    topic         = new GroupTopic();
                    topic.GroupId = groupId;
                }
                else
                {
                    if (postId > -1)
                    {
                        topic = new GroupTopic(topicId, postId);
                        if (WebUser.IsAdmin ||
                            WebUser.IsInRoles(CurrentPage.EditRoles) ||
                            (this.theUser.UserId == topic.PostUserId)
                            )
                        {
                            userIsAllowedToUpdateThisPost = true;
                        }
                    }
                    else
                    {
                        topic = new GroupTopic(topicId);
                    }
                    groupId = topic.GroupId;
                }

                topic.ContentChanged += new ContentChangedEventHandler(topic_ContentChanged);
                topic.PostSubject     = this.txtSubject.Text;
                topic.PostMessage     = edMessage.Text;

                if (Request.IsAuthenticated)
                {
                    SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                    if (siteUser != null)
                    {
                        topic.PostUserId = siteUser.UserId;
                    }
                    if (chkSubscribeToGroup.Checked)
                    {
                        group.Subscribe(siteUser.UserId);
                    }
                    else
                    {
                        topic.SubscribeUserToTopic = this.chkNotifyOnReply.Checked;
                    }
                }
                else
                {
                    topic.PostUserId = 0;                     //guest
                }

                string topicViewUrl = SiteRoot + "/Groups/Topic.aspx?topic="
                                      + topic.TopicId.ToInvariantString()
                                      + "&mid=" + moduleId.ToInvariantString()
                                      + "&pageid=" + pageId.ToInvariantString()
                                      + "&ItemID=" + groupId.ToInvariantString()
                                      + "&pagenumber=" + this.pageNumber.ToInvariantString();

                if ((topic.PostId == -1) || (userIsAllowedToUpdateThisPost))
                {
                    topic.Post();
                    CurrentPage.UpdateLastModifiedTime();

                    topicViewUrl = SiteRoot + "/Groups/Topic.aspx?topic="
                                   + topic.TopicId.ToInvariantString()
                                   + "&mid=" + moduleId.ToInvariantString()
                                   + "&pageid=" + pageId.ToInvariantString()
                                   + "&ItemID=" + groupId.ToInvariantString()
                                   + "&pagenumber=" + this.pageNumber.ToInvariantString()
                                   + "#post" + topic.PostId.ToInvariantString();

                    // Send notification to subscribers
                    // this doesn't make sense it only gets topic subscribers not group subscribers and yet I get the emails
                    DataSet dsTopicSubscribers = topic.GetTopicSubscribers();

                    //ConfigurationManager.AppSettings["DefaultEmailFrom"]
                    GroupNotificationInfo notificationInfo = new GroupNotificationInfo();

                    CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

                    notificationInfo.SubjectTemplate
                        = ResourceHelper.GetMessageTemplate(defaultCulture,
                                                            "GroupNotificationEmailSubject.config");

                    if (includePostBodyInNotification)
                    {
                        notificationInfo.BodyTemplate = Server.HtmlDecode(SecurityHelper.RemoveMarkup(topic.PostMessage)) + "\n\n\n";
                    }

                    notificationInfo.BodyTemplate
                        += ResourceHelper.GetMessageTemplate(defaultCulture,
                                                             "GroupNotificationEmail.config");

                    notificationInfo.FromEmail   = siteSettings.DefaultEmailFromAddress;
                    notificationInfo.SiteName    = siteSettings.SiteName;
                    notificationInfo.ModuleName  = new Module(moduleId).ModuleTitle;
                    notificationInfo.GroupName   = new Group(groupId).Title;
                    notificationInfo.Subject     = topic.PostSubject;
                    notificationInfo.Subscribers = dsTopicSubscribers;
                    notificationInfo.MessageLink = topicViewUrl;
                    notificationInfo.UnsubscribeGroupTopicLink = SiteRoot + "/Groups/UnsubscribeTopic.aspx?topicid=" + topic.TopicId;
                    notificationInfo.UnsubscribeGroupLink      = SiteRoot + "/Groups/UnsubscribeGroup.aspx?mid=" + moduleId + "&itemid=" + topic.GroupId;
                    notificationInfo.SmtpSettings = SiteUtils.GetSmtpSettings();

                    ThreadPool.QueueUserWorkItem(new WaitCallback(Notification.SendGroupNotificationEmail), notificationInfo);


                    String cacheDependencyKey = "Module-" + moduleId.ToInvariantString();
                    CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    SiteUtils.QueueIndexing();
                }

                //WebUtils.SetupRedirect(this, topicViewUrl);
                Response.Redirect(topicViewUrl);
            }
        }
Exemplo n.º 9
0
        private void SetupScripts()
        {
            this.Page.ClientScript.RegisterClientScriptBlock(
                this.GetType(),
                "tinymcemain",
                "<script type=\"text/javascript\" src=\""
                + ResolveUrl(this.BasePath + "tiny_mce.js") + "\"></script>");

            StringBuilder setupScript = new StringBuilder();

            setupScript.Append("\n<script type=\"text/javascript\">");

            //this older approach did not work inside tabs
            // so we switched to use the editor constructor
            //setupScript.Append("tinyMCE.init({");
            //setupScript.Append("mode :\"specific_textareas\" ");
            //setupScript.Append(", editor_selector : \"mceEditor\" ");

            setupScript.Append(" var ed" + this.ClientID + " = new tinymce.Editor('" + this.ClientID + "', { ");


            setupScript.Append("accessibility_focus : true ");

            //if (!AccessibilityFocus) // true is default
            //{
            //    setupScript.Append(", accessibility_focus : false ");
            //}
            if (!AccessibilityWarnings)
            {
                setupScript.Append(", accessibility_warnings : false ");
            }

            setupScript.Append(", browsers : \"" + this.Browsers + "\"");

            setupScript.Append(",forced_root_block:'" + forcedRootBlock + "'");

            if (!CustomShortcuts)
            {
                setupScript.Append(", custom_shortcuts : false ");
            }

            if (!convertUrls)
            {
                setupScript.Append(", convert_urls : false ");
            }

            // added 2009-12-15 previously TinyMCE was encoding German chars and this made it not find matches in search index
            setupScript.Append(", entity_encoding : 'raw' ");

            setupScript.Append(", dialog_type : \"" + this.DialogType + "\"");

            CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

            setupScript.Append(",language:'" + defaultCulture.TwoLetterISOLanguageName + "'");

            if (defaultCulture.TextInfo.IsRightToLeft)
            {
                textDirection = "rtl";
            }

            if (extendedValidElements.Length > 0)
            {
                setupScript.Append(",extended_valid_elements:\"" + extendedValidElements + "\"");
            }

            //extended_valid_elements

            setupScript.Append(",directionality:\"" + this.TextDirection + "\"");

            setupScript.Append(",editor_deselector:\"" + this.DeSelectorCSSClass + "\"");

            if (spellCheckerUrl.Length > 0)
            {
                setupScript.Append(", spellchecker_rpc_url:\"" + spellCheckerUrl + "\"");
            }
            else
            {
                if (EnableGeckoSpellCheck)
                {
                    setupScript.Append(",gecko_spellcheck : true ");
                }
            }

            if ((plugins.Contains("spellchecker")) && (SpellCheckerLanguages.Length > 0))
            {
                setupScript.Append(",spellchecker_languages:\"" + SpellCheckerLanguages + "\"");
            }

            //setupScript.Append(", language : \"" + this.Language + "\"");

            if (!EnableObjectResizing)
            {
                setupScript.Append(", object_resizing : false ");
            }

            if (Plugins.Length > 0)
            {
                setupScript.Append(", plugins : \"" + this.Plugins + "\"");
                if (Plugins.Contains("preview"))
                {
                    setupScript.Append(",plugin_preview_width:'850'");
                    setupScript.Append(",plugin_preview_height:'900'");
                }

                //TODO: populate from style templates for a element
                //http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink
                //This option should contain a semicolon separated list of class titles and class names separated by =
                //advlink_styles : “Code=code;Excel=excel;Flash=flash;Sound=sound;Office=office;PDF=pdf;Image=image;PowerPoint=powerpoint;Word=word;Video=video?
                //advlink_styles

                //setupScript.Append(",media_strict:false");
            }

            //setupScript.Append(",apply_source_formatting:true");

            //if (UseStrictLoadingMode)
            //{
            //    setupScript.Append(", strict_loading_mode : true ");
            //}

            setupScript.Append(", theme : \"" + this.Theme + "\"");

            if (!EnableUndoRedo)
            {
                setupScript.Append(", custom_undo_redo : false ");
            }

            if (EnableUndoRedo)
            {
                setupScript.Append(", custom_undo_redo_levels : " + this.UnDoLevels.ToString());
            }

            if (Theme == "advanced")
            {
                setupScript.Append(", layout_manager : \"" + this.AdvancedLayoutManager + "\"");
                setupScript.Append(", theme_advanced_blockformats : \"" + this.AdvancedBlockFormats + "\"");
                if (AdvancedStyles.Length > 0)
                {
                    setupScript.Append(", theme_advanced_styles : \"" + this.AdvancedStyles + "\"");
                }

                setupScript.Append(", theme_advanced_source_editor_width : \"" + this.AdvancedSourceEditorWidth + "\"");
                setupScript.Append(", theme_advanced_source_editor_height : \"" + this.AdvancedSourceEditorHeight + "\"");
                if (!AdvancedSourceEditorWrap)
                {
                    setupScript.Append(", theme_advanced_source_editor_wrap : false ");
                }

                if (AdvancedLayoutManager == "SimpleLayout")
                {
                    setupScript.Append(", theme_advanced_toolbar_location : \"" + this.AdvancedToolbarLocation + "\"");
                    setupScript.Append(", theme_advanced_toolbar_align : \"" + this.AdvancedToolbarAlign + "\"");
                    setupScript.Append(", theme_advanced_statusbar_location : \"" + this.AdvancedStatusBarLocation + "\"");

                    setupScript.Append(", theme_advanced_buttons1 : \"" + this.AdvancedRow1Buttons + "\"");
                    setupScript.Append(", theme_advanced_buttons2 : \"" + this.AdvancedRow2Buttons + "\"");
                    setupScript.Append(", theme_advanced_buttons3 : \"" + this.AdvancedRow3Buttons + "\"");

                    //setupScript.Append(", theme_advanced_buttons1_add : \"pastetext,pasteword,selectall\"");

                    setupScript.Append(",theme_advanced_resizing : true ");
                }

                //advanced theme has 2 skins default and o2k7
                // o2k7 also supports skin_variant with default, silver and black as options
                // so basically we have
                // default
                // o2k7default
                // o2k7silver
                // o2k7black
                switch (skin)
                {
                case "o2k7default":
                    setupScript.Append(",skin :'o2k7'");
                    break;

                case "o2k7silver":
                    setupScript.Append(",skin :'o2k7'");
                    setupScript.Append(",skin_variant :'silver'");
                    break;

                case "o2k7black":
                    setupScript.Append(",skin :'o2k7'");
                    setupScript.Append(",skin_variant :'black'");
                    break;


                case "default":
                default:
                    //do nothing
                    break;
                }

                if (templatesUrl.Length > 0)
                {
                    setupScript.Append(",template_external_list_url: \"" + this.templatesUrl + "\"");
                }

                if (!Cleanup)
                {
                    setupScript.Append(", cleanup : false ");
                }

                if (CleanupOnStart)
                {
                    setupScript.Append(", cleanup_on_startup : true ");
                }

                //setupScript.Append(",convert_newlines_to_brs : true ");

                if (!InlineStyles)
                {
                    setupScript.Append(", inline_styles : false ");
                }

                if (EditorAreaCSS.Length > 0)
                {
                    setupScript.Append(", content_css : \"" + this.EditorAreaCSS + "\"");
                }

                if (AutoFocus)
                {
                    setupScript.Append(", auto_focus : \"" + this.ClientID + "\" ");
                }

                if ((enableFileBrowser) && (fileManagerUrl.Length > 0))
                {
                    setupScript.Append(",file_browser_callback : 'myFileBrowser' ");
                }
            }

            setupScript.Append("}); ");

            if (plugins.Contains("fullpage"))
            {
                StringBuilder supScript = new StringBuilder();
                supScript.Append("\n<script type=\"text/javascript\">");
                supScript.Append("var editorContentFilter = {");
                supScript.Append("setContent: function(originalContent) {");
                supScript.Append(" var headMatch = originalContent.match(/<head>(.|\\n|\\r)*?<\\/head>/i);");
                supScript.Append("if (headMatch) {");
                supScript.Append("var headText = headMatch[0];");
                supScript.Append("var stylesMatch = headText.match(/<style(.|\\n|\\r)*?>(.|\\n|\\r)*?<\\/style>/ig);");
                supScript.Append("if (stylesMatch) {");
                supScript.Append("var styleText = \"\";");
                supScript.Append("for (var i = 0; i < stylesMatch.length; i++) {");
                supScript.Append("styleText += stylesMatch[i];");
                supScript.Append("}");
                supScript.Append("originalContent = originalContent.replace(/<body((.|\\n|\\r)*?)>/gi, \"<body$1><!--style begin-->\" + styleText + \"<!--style end-->\");");
                supScript.Append("}");
                supScript.Append("}");
                supScript.Append("return originalContent;");
                supScript.Append("},");
                supScript.Append("getContent: function(originalContent) {");
                supScript.Append(" return originalContent.replace(/<!--style begin-->(.|\\n|\\r)*?<!--style end-->/g, '');");
                supScript.Append("}");
                supScript.Append("};");

                supScript.Append("</script>");

                this.Page.ClientScript.RegisterClientScriptBlock(
                    typeof(Page),
                    "tmcfpfix",
                    supScript.ToString());

                setupScript.Append("ed" + this.ClientID + ".onBeforeSetContent.add(function(ed, o) {");
                setupScript.Append("o.content = editorContentFilter.setContent(o.content);");
                setupScript.Append(" });");

                setupScript.Append("ed" + this.ClientID + ".onGetContent.add(function(ed, o) {");
                setupScript.Append("o.content = editorContentFilter.getContent(o.content);");
                setupScript.Append(" });");
            }

            setupScript.Append("ed" + this.ClientID + ".render(); ");

            if (forcePasteAsPlainText)
            {
                setupScript.Append("ed" + this.ClientID + ".onPaste.add( function(ed, e, o){ ");
                setupScript.Append("ed.execCommand('mcePasteText', true); ");
                setupScript.Append("return tinymce.dom.Event.cancel(e); ");
                setupScript.Append("});");
            }


            setupScript.Append("</script>");

            this.Page.ClientScript.RegisterStartupScript(
                this.GetType(),
                this.UniqueID,
                setupScript.ToString());


            if ((enableFileBrowser) && (fileManagerUrl.Length > 0))
            {
                SetupFileBrowserScript();
            }

            //string submitScript = " tinyMCE.triggerSave(false,true); ";
            ////submitScript = " alert(tinyMCE.getContent('" + this.ClientID + "')); return false; ";

            //this.Page.ClientScript.RegisterOnSubmitStatement(
            //    this.GetType(), "tmsubmit", submitScript);
        }
Exemplo n.º 10
0
        private void DoSubscribe(LetterInfo letter, string email)
        {
            LetterSubscriber s = subscriptions.Fetch(siteSettings.SiteGuid, letter.LetterInfoGuid, email);

            bool needToSendVerification = false;

            if (s == null)
            {
                s                = new LetterSubscriber();
                s.SiteGuid       = siteSettings.SiteGuid;
                s.EmailAddress   = email;
                s.LetterInfoGuid = letter.LetterInfoGuid;
                if (showFormatOptions)
                {
                    s.UseHtml = rbHtmlFormat.Checked;
                }
                else
                {
                    s.UseHtml = htmlIsDefault;
                }

                if ((currentUser != null) && (string.Equals(currentUser.Email, email, StringComparison.InvariantCultureIgnoreCase)))
                {
                    s.UserGuid   = currentUser.UserGuid;
                    s.IsVerified = true;
                }
                else
                {
                    // user is not authenticated but may still exist
                    // attach userguid but don't flag as verified
                    // because we don't know that the user who submited the form is the account owner
                    SiteUser siteUser = SiteUser.GetByEmail(siteSettings, email);
                    if (siteUser != null)
                    {
                        s.UserGuid = siteUser.UserGuid;
                    }
                }
                s.IpAddress = SiteUtils.GetIP4Address();
                subscriptions.Save(s);

                LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);

                if (!s.IsVerified)
                {
                    needToSendVerification = true;
                }
            }
            else
            {
                // we found an existing subscription

                if (!s.IsVerified)
                {
                    // if the current authenticated user has the same email mark it as verified
                    if ((currentUser != null) && (string.Equals(currentUser.Email, email, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        s.UserGuid = currentUser.UserGuid;
                        if (showFormatOptions)
                        {
                            s.UseHtml = rbHtmlFormat.Checked;
                        }
                        subscriptions.Save(s);
                        subscriptions.Verify(s.SubscribeGuid, true, Guid.Empty);
                    }
                    else if (s.BeginUtc < DateTime.UtcNow.AddDays(-WebConfigSettings.NewsletterReVerifcationAfterDays))
                    {
                        // if the user never verifed before and its been at least x days go ahead and send another chance to verify
                        needToSendVerification = true;
                        // TODO: maybe we should log this in case some spam script is using the same email over and over
                        // or maybe we should add a verification sent count on subscription
                    }
                }
            }

            if (needToSendVerification)
            {
                string verificationTemplate = ResourceHelper.GetMessageTemplate(SiteUtils.GetDefaultCulture(), "NewsletterVerificationEmailMessage.config");
                string confirmLink          = siteRoot + "/eletter/Confirm.aspx?s=" + s.SubscribeGuid.ToString();
                string messageBody          = verificationTemplate.Replace("{NewsletterName}", letter.Title).Replace("{ConfirmationLink}", confirmLink).Replace("{SiteLink}", siteRoot);
                string subject = string.Format(CultureInfo.InvariantCulture, Resource.NewsletterVerifySubjectFormat, letter.Title);

                EmailMessageTask messageTask = new EmailMessageTask(SiteUtils.GetSmtpSettings());
                messageTask.SiteGuid = siteSettings.SiteGuid;
                if (letter.FromAddress.Length > 0)
                {
                    messageTask.EmailFrom = letter.FromAddress;
                }
                else
                {
                    messageTask.EmailFrom = siteSettings.DefaultEmailFromAddress;
                }
                messageTask.EmailTo  = email;
                messageTask.Subject  = subject;
                messageTask.TextBody = messageBody;


                messageTask.QueueTask();
                WebTaskManager.StartOrResumeTasks();
            }
        }
Exemplo n.º 11
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (forum == null)
            {
                forum = new Forum(forumId);
            }

            if (WebUser.IsInRoles(forum.RolesThatCanPost))
            {
                if (Request.IsAuthenticated)
                {
                    captcha.Enabled     = false;
                    pnlAntiSpam.Visible = false;
                }
            }
            else
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            Page.Validate("Forum");
            if (!Page.IsValid)
            {
                PopulateControls();
                return;
            }
            else
            {
                if ((config.UseSpamBlockingForAnonymous) && (pnlAntiSpam.Visible) && (captcha.Enabled))
                {
                    if (!captcha.IsValid)
                    {
                        PopulateControls();
                        return;
                    }
                }

                ForumThread thread;
                bool        userIsAllowedToUpdateThisPost = false;
                if (threadId == -1)
                {
                    //new thread
                    thread                  = new ForumThread();
                    thread.ForumId          = forumId;
                    thread.IncludeInSiteMap = forum.IncludeInGoogleMap;
                    thread.SetNoIndexMeta   = forum.AddNoIndexMeta;
                }
                else
                {
                    if (postId > -1)
                    {
                        thread = new ForumThread(threadId, postId);
                        if (isModerator || (this.theUser.UserId == thread.PostUserId))
                        {
                            userIsAllowedToUpdateThisPost = true;
                        }

                        if ((isModerator) && (divSortOrder.Visible))
                        {
                            int sort = thread.PostSortOrder;
                            int.TryParse(txtSortOrder.Text, out sort);
                            thread.PostSortOrder = sort;
                        }
                    }
                    else
                    {
                        thread = new ForumThread(threadId);
                    }

                    //existing thread but it does not belong to this forum
                    if (forumId != thread.ForumId)
                    {
                        SiteUtils.RedirectToAccessDeniedPage(this);
                        return;
                    }
                }

                thread.ContentChanged += new ContentChangedEventHandler(thread_ContentChanged);
                thread.PostSubject     = this.txtSubject.Text;
                thread.PostMessage     = edMessage.Text;

                bool isNewPost = (thread.PostId == -1);

                SiteUser siteUser = null;

                if (Request.IsAuthenticated)
                {
                    siteUser = SiteUtils.GetCurrentSiteUser();
                    if (siteUser != null)
                    {
                        thread.PostUserId = siteUser.UserId;
                    }
                    if (chkSubscribeToForum.Checked)
                    {
                        forum.Subscribe(siteUser.UserId);
                    }
                    else
                    {
                        thread.SubscribeUserToThread = this.chkNotifyOnReply.Checked;
                    }
                }
                else
                {
                    thread.PostUserId = -1;                     //guest
                }

                string threadViewUrl;
                if (ForumConfiguration.CombineUrlParams)
                {
                    threadViewUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + pageId.ToInvariantString()
                                    + "&t=" + thread.ThreadId.ToInvariantString()
                                    + "~" + this.pageNumber.ToInvariantString();
                }
                else
                {
                    threadViewUrl = SiteRoot + "/Forums/Thread.aspx?thread="
                                    + thread.ThreadId.ToInvariantString()
                                    + "&mid=" + moduleId.ToInvariantString()
                                    + "&pageid=" + pageId.ToInvariantString()
                                    + "&ItemID=" + forumId.ToInvariantString()
                                    + "&pagenumber=" + this.pageNumber.ToInvariantString();
                }

                if ((thread.PostId == -1) || (userIsAllowedToUpdateThisPost))
                {
                    thread.Post();
                    CurrentPage.UpdateLastModifiedTime();

                    if (ForumConfiguration.CombineUrlParams)
                    {
                        threadViewUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + pageId.ToInvariantString()
                                        + "&t=" + thread.ThreadId.ToInvariantString()
                                        + "~" + pageNumber.ToInvariantString()
                                        + "#post" + thread.PostId.ToInvariantString();
                    }
                    else
                    {
                        threadViewUrl = SiteRoot + "/Forums/Thread.aspx?thread="
                                        + thread.ThreadId.ToInvariantString()
                                        + "&mid=" + moduleId.ToInvariantString()
                                        + "&pageid=" + pageId.ToInvariantString()
                                        + "&ItemID=" + forum.ItemId.ToInvariantString()
                                        + "&pagenumber=" + pageNumber.ToInvariantString()
                                        + "#post" + thread.PostId.ToInvariantString();
                    }

                    if ((isNewPost) || (!config.SuppressNotificationOfPostEdits))
                    {
                        bool notifyModeratorOnly = false;

                        if (forum.RequireModForNotify)
                        {
                            notifyModeratorOnly = true;

                            if (forum.AllowTrustedDirectNotify && (siteUser != null) && siteUser.Trusted)
                            {
                                notifyModeratorOnly = false;
                            }
                        }

                        Module m = GetModule(moduleId, Forum.FeatureGuid);

                        ForumNotification.NotifySubscribers(
                            forum,
                            thread,
                            m,
                            siteUser,
                            siteSettings,
                            config,
                            SiteRoot,
                            pageId,
                            pageNumber,
                            SiteUtils.GetDefaultCulture(),
                            ForumConfiguration.GetSmtpSettings(),
                            notifyModeratorOnly
                            );

                        if (!notifyModeratorOnly)
                        {
                            thread.NotificationSent = true;
                            thread.UpdatePost();
                        }
                    }

                    //String cacheDependencyKey = "Module-" + moduleId.ToInvariantString();
                    //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    CacheHelper.ClearModuleCache(moduleId);
                    SiteUtils.QueueIndexing();
                }


                Response.Redirect(threadViewUrl);
            }
        }
Exemplo n.º 12
0
        public static void SendApprovalRequestNotification(
            SmtpSettings smtpSettings,
            SiteSettings siteSettings,
            SiteUser submittingUser,
            ContentWorkflow draftWorkflow,
            string approvalRoles,
            string contentUrl
            )
        {
            if (string.IsNullOrEmpty(approvalRoles))
            {
                approvalRoles = "Admins;Content Administrators;Content Publishers;";
            }

            List <string> emailAddresses = SiteUser.GetEmailAddresses(siteSettings.SiteId, approvalRoles);

            int queuedMessageCount = 0;

            CultureInfo defaultCulture  = SiteUtils.GetDefaultCulture();
            string      messageTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestNotification.config");
            string      messageSubject  = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName);

            foreach (string email in emailAddresses)
            {
                if (WebConfigSettings.EmailAddressesToExcludeFromAdminNotifications.IndexOf(email, StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    continue;
                }

                if (!Email.IsValidEmailAddressSyntax(email))
                {
                    continue;
                }

                EmailMessageTask messageTask = new EmailMessageTask(smtpSettings);
                messageTask.SiteGuid     = siteSettings.SiteGuid;
                messageTask.EmailFrom    = siteSettings.DefaultEmailFromAddress;
                messageTask.EmailReplyTo = submittingUser.Email;
                messageTask.EmailTo      = email;

                messageTask.Subject = messageSubject;

                StringBuilder message = new StringBuilder();
                message.Append(messageTemplate);
                message.Replace("{ModuleTitle}", draftWorkflow.ModuleTitle);
                message.Replace("{ApprovalRequestedDate}", draftWorkflow.RecentActionOn.ToShortDateString());
                message.Replace("{SubmittedBy}", submittingUser.Name);
                message.Replace("{ContentUrl}", contentUrl);

                if (!Email.IsValidEmailAddressSyntax(draftWorkflow.RecentActionByUserEmail))
                {
                    //invalid address log it
                    log.Error("Failed to send workflow rejection message, invalid recipient email "
                              + draftWorkflow.RecentActionByUserEmail
                              + " message was " + message.ToString());

                    return;
                }

                messageTask.TextBody = message.ToString();
                messageTask.QueueTask();
                queuedMessageCount += 1;
            }

            if (queuedMessageCount > 0)
            {
                WebTaskManager.StartOrResumeTasks();
            }
        }
Exemplo n.º 13
0
        private void SetupScripts()
        {
            this.Page.ClientScript.RegisterClientScriptBlock(
                this.GetType(),
                "ckeditormain",
                "\n<script type=\"text/javascript\" src=\""
                + ResolveUrl(this.BasePath + "ckeditor.js") + "\"></script>");

            StringBuilder script = new StringBuilder();

            script.Append("\n<script type=\"text/javascript\">");

            script.Append("var editor" + this.ClientID + " = CKEDITOR.replace('" + this.ClientID + "'");

            script.Append(", { ");

            script.Append("customConfig : '" + ResolveUrl(customConfigPath) + "' ");

            //script.Append("customConfig : '' ");



            script.Append(", baseHref : '" + siteRoot + "'");

            if (Height != Unit.Empty)
            {
                script.Append(", height : " + this.Height.ToString().Replace("px", string.Empty));
            }
            else
            {
                script.Append(", height : 350");
            }

            script.Append(",skin:'" + skin + "'");



            CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

            script.Append(",language:'" + defaultCulture.TwoLetterISOLanguageName + "'");

            if ((textDirection == Direction.RightToLeft) || (defaultCulture.TextInfo.IsRightToLeft))
            {
                script.Append(", contentsLangDirection : 'rtl'");
            }

            if (editorCSSUrl.Length > 0)
            {
                script.Append(", contentsCss : '" + editorCSSUrl + "'");
            }

            if ((enableFileBrowser) && (fileManagerUrl.Length > 0))
            {
                script.Append(",filebrowserWindowWidth : 860");
                script.Append(",filebrowserWindowHeight : 700");
                script.Append(",filebrowserBrowseUrl:'" + fileManagerUrl + "?ed=ck&type=file' ");
                script.Append(",filebrowserImageBrowseUrl:'" + fileManagerUrl + "?ed=ck&type=image' ");
                script.Append(",filebrowserFlashBrowseUrl:'" + fileManagerUrl + "?ed=ck&type=media' ");
            }

            // script.Append(",ignoreEmptyParagraph:true");

            if (forcePasteAsPlainText)
            {
                script.Append(",forcePasteAsPlainText:true");
            }



            //if (templatesJsonUrl.Length > 0)
            //{
            //    script.Append(",templates_files: ['" + templatesJsonUrl + "']");
            //}

            //if (templatesXmlUrl.Length > 0)
            //{
            //    script.Append(",templates_xml: '" + templatesXmlUrl + "'");
            //}

            //if (stylesJsonUrl.Length > 0)
            //{

            //    script.Append(",stylesCombo_stylesSet: ['C:" + stylesJsonUrl + "']");
            //}

            if (fullPageMode)
            {
                script.Append(",fullPage : true ");
            }

            SetupToolBar(script);
            script.Append("}");

            script.Append("); ");

            if (stylesJsonUrl.Length > 0)
            {
                script.Append("function SetupEditor" + this.ClientID + "( editorObj){");

                //if (fullPageMode)
                //{
                //    script.Append("editorObj.config.fullPage = true; ");

                //}

                //if (stylesJsonUrl.Length > 0)
                //{

                script.Append("editorObj.config.stylesCombo_stylesSet = 'C:" + stylesJsonUrl + "';");
                //}

                if (templatesJsonUrl.Length > 0)
                {
                    script.Append("editorObj.config.templates = 'C';");
                    script.Append("editorObj.config.templates_files = ['" + templatesJsonUrl + "'];");
                    script.Append("editorObj.config.templates_replaceContent = false;");
                }

                //if ((enableFileBrowser) && (fileManagerUrl.Length > 0))
                //{
                //    script.Append("editorObj.config.filebrowserWindowWidth = 860; ");
                //    script.Append("editorObj.config.filebrowserWindowHeight = 700; ");
                //    script.Append("editorObj.config.filebrowserBrowseUrl = '" + fileManagerUrl + "?ed=ck&type=file'; ");
                //    script.Append("editorObj.config.filebrowserImageBrowseUrl = '" + fileManagerUrl + "?ed=ck&type=image'; ");
                //    script.Append("editorObj.config.filebrowserFlashBrowseUrl = '" + fileManagerUrl + "?ed=ck&type=media' ");

                //}

                script.Append("}");

                script.Append("SetupEditor" + this.ClientID + "(editor" + this.ClientID + ");");
            }

            script.Append("</script>");

            this.Page.ClientScript.RegisterStartupScript(
                this.GetType(),
                this.UniqueID,
                script.ToString());
        }
Exemplo n.º 14
0
        private void SetupJQueryUI()
        {
            string jqueryUIBasePath = GetJQueryUIBasePath();

            if (includejQueryUICore)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqueryui-core", "\n<script src=\""
                                                            + jqueryUIBasePath + "jquery-ui.min.js" + "\" type=\"text/javascript\" ></script>");
            }

            if (includejQueryAccordion)
            {
                // this also includes jqueryui tabs
                string initAutoScript = " $('div.C-accordion').accordion(); $('div.C-accordion-nh').accordion({autoHeight: false});  $('div.C-tabs').tabs(); ";

                Page.ClientScript.RegisterStartupScript(typeof(Page),
                                                        "jui-init", "\n<script type=\"text/javascript\" >"
                                                        + initAutoScript + "</script>");
            }

            if (includeClueTip)
            {
                SetupClueTip();
            }

            if (includeImpromtu)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqprompt", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/jquery-impromptu.min.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includeQtFile)
            {
                CultureInfo defaultCulture = SiteUtils.GetDefaultCulture();

                bool loadedQtLangFile = false;
                if (defaultCulture.TwoLetterISOLanguageName != "en")
                {
                    if (File.Exists(HostingEnvironment.MapPath("~/ClientScript/jqCynthia/" + defaultCulture.TwoLetterISOLanguageName + ".qtfile.js")))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                                    "qtfilelocalize", "\n<script src=\""
                                                                    + Page.ResolveUrl("~/ClientScript/jqCynthia/" + defaultCulture.TwoLetterISOLanguageName + ".qtfile.js") + "\" type=\"text/javascript\"></script>");

                        loadedQtLangFile = true;
                    }
                }

                if (!loadedQtLangFile)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                                "qtfilelocalize", "\n<script src=\""
                                                                + Page.ResolveUrl("~/ClientScript/jqCynthia/en.qtfile.js") + "\" type=\"text/javascript\"></script>");
                }


                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "qtfile", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/cynthiaqtfile.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includejQueryHoverIntent)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqhoverintent", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/jquery.hoverIntent.min.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includejQueryMetaData)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqmetadata", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/jquery.metadata.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includejQueryFlipText)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqfliptext", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/jquery.mb.flipText.min.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includejQueryExtruder)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqextruder", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/cynthia-mbExtruder.js") + "\" type=\"text/javascript\"></script>");
            }

            if (includejQueryLayout)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                            "jqlayout", "\n<script src=\""
                                                            + Page.ResolveUrl("~/ClientScript/jqCynthia/jquery.layout.min.js") + "\" type=\"text/javascript\"></script>");
            }
        }