Exemplo n.º 1
0
        /// <summary>
        /// Gets the search items.
        /// </summary>
        /// <param name="modInfo">The module information.</param>
        /// <returns>Topics that meet the search criteria.</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            using (UnitOfWork uOw = new UnitOfWork())
            {
                TopicBO topicBo = new TopicBO(uOw);

                SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection();
                var            topics = topicBo.GetAllByModuleID(modInfo.ModuleID);
                UserController uc     = new UserController();

                foreach (var topic in topics)
                {
                    SearchItemInfo searchItem = new SearchItemInfo();

                    string strContent     = null;
                    string strDescription = null;
                    string strTitle       = null;
                    if (!string.IsNullOrWhiteSpace(topic.Title))
                    {
                        strTitle = topic.Title;
                    }
                    else
                    {
                        strTitle = topic.Name;
                    }

                    if (topic.Cache != null)
                    {
                        strContent  = topic.Cache;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100,
                                                           Localization.GetString("Dots", this.mSharedResourceFile));
                    }
                    else
                    {
                        strContent  = topic.Content;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100,
                                                           Localization.GetString("Dots", this.mSharedResourceFile));
                    }

                    int userID = 0;

                    userID = Null.NullInteger;
                    if (topic.UpdatedByUserID != -9999)
                    {
                        userID = topic.UpdatedByUserID;
                    }

                    searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name));

                    //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription,
                    //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _
                    //// "topic=" & WikiMarkup.EncodeTitle(topic.Name))

                    searchItemCollection.Add(searchItem);
                }

                return(searchItemCollection);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends the notifications.
        /// </summary>
        /// <param name="uow">The Unit Of Work.</param>
        /// <param name="topic">The topic.</param>
        /// <param name="name">The name.</param>
        /// <param name="email">The email.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="ipaddress">The IP Address.</param>
        public static void SendNotifications(
            UnitOfWork uow,
            Topic topic,
            string name,
            string email,
            string comment,
            string ipaddress)
        {
            if (topic != null)
            {
                List <string> lstEmailsAddresses = new TopicBO(uow).GetNotificationEmails(topic);

                if (lstEmailsAddresses.Count > 0)
                {
                    DotNetNuke.Entities.Portals.PortalSettings objPortalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                    string strResourceFile = Globals.ApplicationPath + "/DesktopModules/Wiki/Views/" + Localization.LocalResourceDirectory + "/" + Localization.LocalSharedResourceFile;
                    string strSubject      = Localization.GetString("NotificationSubject", strResourceFile);
                    string strBody         = Localization.GetString("NotificationBody", strResourceFile);

                    string redirectUrl = DotNetNuke.Common.Globals.NavigateURL(objPortalSettings.ActiveTab.TabID, objPortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(topic.Name));
                    strBody = strBody.Replace("[URL]", redirectUrl);

                    strBody = strBody.Replace("[NAME]", name);
                    strBody = strBody.Replace("[EMAIL]", email);
                    strBody = strBody.Replace("[COMMENT]", comment);
                    strBody = strBody.Replace("[IP]", string.Empty);

                    System.Text.StringBuilder usersToEmailSB = new System.Text.StringBuilder();
                    foreach (string userToEmail in lstEmailsAddresses)
                    {
                        usersToEmailSB.Append(userToEmail);
                        usersToEmailSB.Append(";");
                    }

                    // remove the last ;
                    usersToEmailSB.Remove(usersToEmailSB.Length - 1, 1);

                    // Services.Mail.Mail.SendMail(objPortalSettings.Email, objPortalSettings.Email,
                    //// sbUsersToEmail.ToString, strSubject, strBody, "", "", "", "", "", "")

                    Mail.SendMail(
                        objPortalSettings.Email,
                        usersToEmailSB.ToString(),
                        string.Empty,
                        string.Empty,
                        MailPriority.Normal,
                        strSubject,
                        MailFormat.Html,
                        Encoding.UTF8,
                        strBody,
                        string.Empty,
                        Host.SMTPServer,
                        Host.SMTPAuthentication,
                        Host.SMTPUsername,
                        Host.SMTPPassword,
                        Host.EnableSMTPSSL);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the table.
        /// </summary>
        /// <param name="topicCollection">The topic collection.</param>
        /// <returns>html for the topics</returns>
        protected string CreateTable(List <Topic> topicCollection)
        {
            System.Text.StringBuilder tableHTML = new System.Text.StringBuilder("<table><tr><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableTopic", this.RouterResourceFile));
            tableHTML.Append("</th><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableModBy", this.RouterResourceFile));
            tableHTML.Append("</th><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableModDate", this.RouterResourceFile));
            tableHTML.Append("</th></tr>");
            //// Dim TopicTable As String
            Topic localTopic = new Topic();
            int   i          = 0;

            if (topicCollection != null && topicCollection.Any())
            {
                for (i = 0; i <= topicCollection.Count - 1; i++)
                {
                    localTopic                = (Topic)topicCollection[i];
                    localTopic.TabID          = this.TabId;
                    localTopic.PortalSettings = this.PortalSettings;

                    string nameToUse = string.Empty;
                    if (!string.IsNullOrWhiteSpace(localTopic.Title))
                    {
                        nameToUse = localTopic.Title.Replace(WikiModuleBase.WikiHomeName, "Home");
                    }
                    else
                    {
                        nameToUse = localTopic.Name.Replace(WikiHomeName, "Home");
                    }

                    tableHTML.Append("<tr>");
                    tableHTML.Append("<td><a class=\"CommandButton\" href=\"");
                    tableHTML.Append(DotNetNuke.Common.Globals.NavigateURL(this.TabId, this.PortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(localTopic.Name)));
                    tableHTML.Append("\">");
                    tableHTML.Append(nameToUse);
                    tableHTML.Append("</a></td>");
                    tableHTML.Append("<td class=\"Normal\">");
                    tableHTML.Append(localTopic.UpdatedByUsername);
                    tableHTML.Append("</td>");
                    tableHTML.Append("<td class=\"Normal\">");
                    tableHTML.Append(localTopic.UpdateDate.ToString(CultureInfo.CurrentCulture));
                    tableHTML.Append("</td>");
                    tableHTML.Append("</tr>");
                }
            }
            else
            {
                tableHTML.Append("<tr><td colspan=3 class=\"Normal\">");
                tableHTML.Append(Localization.GetString("BaseCreateTableNoResults", this.RouterResourceFile));
                tableHTML.Append("</td></tr>");
            }

            tableHTML.Append("</table>");
            return(tableHTML.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the history table.
        /// </summary>
        /// <returns>html for the history table</returns>
        protected string CreateHistoryTable()
        {
            System.Text.StringBuilder tableText = new System.Text.StringBuilder(1000);
            tableText.Append("<table><tr><th>");
            tableText.Append(Localization.GetString("BaseCreateTableTopic", this.RouterResourceFile));
            tableText.Append("</th><th>");
            tableText.Append(Localization.GetString("BaseCreateTableTitle", this.RouterResourceFile));
            tableText.Append("</th><th>");
            tableText.Append(Localization.GetString("BaseCreateTableModBy", this.RouterResourceFile));
            tableText.Append("</th><th>");
            tableText.Append(Localization.GetString("BaseCreateTableModDate", this.RouterResourceFile));
            tableText.Append("</th></tr>");

            var topicHistories = this.GetHistory();
            //// Dim TopicTable As StringBuilder = New StringBuilder(500)
            TopicHistory history = null;
            int          i       = 0;

            if (topicHistories != null && topicHistories.Any())
            {
                var topicHistoryCollection = topicHistories.ToArray();
                i = topicHistoryCollection.Count();
                while (i > 0)
                {
                    history                = (TopicHistory)topicHistoryCollection[i - 1];
                    history.TabID          = this.TabId;
                    history.PortalSettings = this.PortalSettings;
                    tableText.Append("<tr><td><a class=\"CommandButton\" rel=\"noindex,nofollow\" href=\"");
                    tableText.Append(DotNetNuke.Common.Globals.NavigateURL(this.TabId, this.PortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(this.mPageTopicValue), "loc=TopicHistory", "ShowHistory=" + history.TopicHistoryId.ToString()));
                    tableText.Append("\">");
                    tableText.Append(history.Name.Replace(WikiHomeName, "Home"));

                    tableText.Append("</a></td>");
                    tableText.Append("<td class=\"Normal\">");
                    if (!string.IsNullOrWhiteSpace(history.Title))
                    {
                        tableText.Append(history.Title.Replace(WikiHomeName, "Home"));
                    }
                    else
                    {
                        tableText.Append(history.Name.Replace(WikiHomeName, "Home"));
                    }

                    tableText.Append("</td>");
                    tableText.Append("<td class=\"Normal\">");
                    tableText.Append(history.UpdatedByUsername);
                    tableText.Append("</td>");
                    tableText.Append("<td Class=\"Normal\">");
                    tableText.Append(history.UpdateDate.ToString(CultureInfo.CurrentCulture));
                    tableText.Append("</td>");
                    tableText.Append("</tr>");
                    i = i - 1;
                }
            }
            else
            {
                tableText.Append("<tr><td colspan=\"3\" class=\"Normal\">");
                tableText.Append(Localization.GetString("BaseCreateHistoryTableEmpty", this.RouterResourceFile));
                tableText.Append("</td></tr>");
            }

            tableText.Append("</table>");
            return(tableText.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
        /// data.</param>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Include Css files
                this.AddStylePageHeader(CSSWikiModuleCssId, CSSWikiModuleCssPath);

                // congfigure the URL to the home page (the wiki without any parameters)
                this.mHomeUrlValue = DotNetNuke.Common.Globals.NavigateURL();

                // Get the pageTopic
                if (this.Request.QueryString["topic"] == null)
                {
                    if (this.Request.QueryString["add"] == null & this.Request.QueryString["loc"] == null)
                    {
                        this.mPageTopicValue = WikiHomeName;
                    }
                    else
                    {
                        this.mPageTopicValue = string.Empty;
                    }
                }
                else
                {
                    this.mPageTopicValue = WikiMarkup.DecodeTitle(this.Request.QueryString["topic"].ToString());
                }

                // Sets the wikiSettings
                this.SetWikiSettings();

                // Get the edit rights
                if (this.mWikiSettingsObject.ContentEditorRoles.Equals("UseDNNSettings"))
                {
                    this.mCanEditValue = this.IsEditable;
                }
                else
                {
                    // User is logged in
                    if (Request.IsAuthenticated)
                    {
                        if (this.UserInfo.IsSuperUser)
                        {
                            this.mCanEditValue = true;
                            this.mIsAdminValue = true;
                        }
                        else if (this.mWikiSettingsObject.ContentEditorRoles.IndexOf(";" + DotNetNuke.Common.Globals.glbRoleAllUsersName + ";") > -1)
                        {
                            this.mCanEditValue = true;
                        }
                        else
                        {
                            string[] editorRoles = this.mWikiSettingsObject.ContentEditorRoles.Split(
                                new char[] { '|' },
                                StringSplitOptions.RemoveEmptyEntries)[0].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string role in editorRoles)
                            {
                                if (UserInfo.IsInRole(role))
                                {
                                    this.mCanEditValue = true;
                                    break; // TODO: might not be correct. Was : Exit For
                                }
                            }
                        }
                    }
                    else
                    {
                        // User is NOT logged in
                        if ((this.mWikiSettingsObject.ContentEditorRoles.IndexOf(";" + DotNetNuke.Common.Globals.glbRoleAllUsersName + ";") > -1) | (this.mWikiSettingsObject.ContentEditorRoles.IndexOf(";" + DotNetNuke.Common.Globals.glbRoleUnauthUserName + ";") > -1))
                        {
                            this.mCanEditValue = true;
                        }
                    }
                }

                this.LoadTopic();
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }