예제 #1
0
        /// <summary>
        /// This should only run after the Post exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks>
        internal ContentItem CreateContentItem(AlbumInfo objPost, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t);
            int contentTypeID;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeID = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeID = CreateContentType();
            }

            var objContent = new ContentItem
                                {
                                    Content = objPost.ShortContent,
                                    ContentTypeId = contentTypeID,
                                    Indexed = false,
                                    ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objPost.AlbumID,
                                    ModuleID = objPost.ModuleID,
                                    TabID = tabId
                                };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageQuestionTerms(objPost, objContent);

            return objContent;
        }
예제 #2
0
        /// <summary>
        /// This should only run after the Post exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks>
        internal ContentItem CreateContentItem(JournalItem objJournalItem, int tabId) {
            var typeController = new ContentTypeController();
            string contentTypeName = "DNNCorp_JournalProfile";
            if (objJournalItem.SocialGroupId > 0) {
                contentTypeName = "DNNCorp_JournalGroup";
            }
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == contentTypeName select t);
            int contentTypeID;

            if (colContentTypes.Count() > 0) {
                var contentType = colContentTypes.Single();
                contentTypeID = contentType == null ? CreateContentType(contentTypeName) : contentType.ContentTypeId;
            } else {
                contentTypeID = CreateContentType(contentTypeName);
            }
            
            var objContent = new ContentItem {
                Content = GetContentBody(objJournalItem),                
                ContentTypeId = contentTypeID,
                Indexed = false,
                ContentKey = "journalid=" + objJournalItem.JournalId,
                ModuleID = -1,
                TabID = tabId
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            //var cntTerm = new Terms();
            //cntTerm.ManageQuestionTerms(objPost, objContent);

            return objContent;
        }
예제 #3
0
        /// <summary>
        /// This should only run after the Article exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        public ContentItem CreateContentItem(Article objArticle, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == ContentTypeName select t);
            int contentTypeId;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeId = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeId = CreateContentType();
            }

            var objContent = new ContentItem
            {
                Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description),
                ContentTypeId = contentTypeId,
                Indexed = false,
                ContentKey = "aid=" + objArticle.ArticleId,
                ModuleID = objArticle.ModuleId,
                TabID = tabId
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageArticleTerms(objArticle, objContent);

            return objContent;
        }
예제 #4
0
        public void ContentTypeController_AddContentType_Throws_On_Null_ContentType()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentNullException>(() => contentTypeController.AddContentType(null));
        }
예제 #5
0
        public void ContentTypeController_AddContentType_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            ContentType contentType = ContentTestHelper.CreateValidContentType();

            //Act
            int contentTypeId = contentTypeController.AddContentType(contentType);

            //Assert
            mockDataService.Verify(ds => ds.AddContentType(contentType));
        }
예제 #6
0
        /// <summary>
        /// This is used to determine the ContentTypeID (part of the Core API) based on this module's content type. If the content type doesn't exist yet for the module, it is created.
        /// </summary>
        /// <returns>The primary key value (ContentTypeID) from the core API's Content Types table.</returns>
        internal static int GetContentTypeID()
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t);
            int contentTypeId;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeId = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeId = CreateContentType();
            }

            return contentTypeId;
        }
예제 #7
0
        private static ContentItem CreateFileContentItem()
        {
            var typeController = new ContentTypeController();
            var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            if (contentTypeFile == null)
            {
                contentTypeFile = new ContentType { ContentType = "File" };
                contentTypeFile.ContentTypeId = typeController.AddContentType(contentTypeFile);
            }

            var objContent = new ContentItem
            {
                ContentTypeId = contentTypeFile.ContentTypeId,
                Indexed = false,
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            return objContent;
        }
예제 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private string GenerateNotifications(DateTime lastRunDate, DateTime currentRunDate, Constants.SubscriptionType subType)
        {
            var strErrors = "";

            // based on subscription type, generate list of content additions to email
            switch (subType)
            {
                case Constants.SubscriptionType.DailyTerm:
                    // daily term (all questions created between dates)

                    // This email is going to be user specific, so we need to start w/ a list of subscribers (based on type daily term); each user can have multiple terms
                    // -- select all questions where

                    // we retrieve a collection of questions, each question will have a contentItem associated with it (we only retrieve stuff not voted out)

                    // we need to retrieve a collection of terms, based on content item collection from above
                    strErrors = "Daily Term: Sent " + 0 + " emails <br />";
                    break;
                case Constants.SubscriptionType.InstantTerm:
                    var typeController = new ContentTypeController();
                    var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t);

                    if (colContentTypes.Count() > 0)
                    {
                        var contentType = colContentTypes.Single();
                        var colContentItems = Controller.GetContentItemsByTypeAndCreated(contentType.ContentTypeId, lastRunDate, currentRunDate);

                        foreach (var item in colContentItems)
                        {
                            // we are using the question object because content item doesn't have a title association yet (for core integration)
                            var objQuestion = Controller.GetQuestionByContentItem(item.ContentItemId);

                            if (objQuestion != null)
                            {
                                // use the content item to build the email subject/body/content (sub question for content item now)
                                var colEmail = QaSettings.GetEmailCollection(Controller.GetQaPortalSettings(objQuestion.PortalId), objQuestion.PortalId);
                                var senderEmail = colEmail.Single(s => s.Key == Constants.EmailSettings.FromAddress.ToString()).Value;
                                //var urlBase = colEmail.Single(s => s.Key == Constants.EmailSettings.PrimaryUrl.ToString()).Value;
                                var questionTemplate =  colEmail.Single(s => s.Key == Constants.EmailSettings.SingleQuestionTemplate.ToString()).Value;
                                var ps = new PortalSettings(objQuestion.PortalId);

                                var titleLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/question/id/" + objQuestion.PostId + "/" + DotNetNuke.Common.Globals.glbDefaultPage;
                                var subscribeLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/subscriptions/" + DotNetNuke.Common.Globals.glbDefaultPage;

                                var terms = "";
                                var i = 0;
                                foreach (var t in objQuestion.Terms)
                                {
                                    terms += t.Name;
                                    i += 1;

                                    if (objQuestion.Terms.Count != i)
                                    {
                                        terms += ", ";
                                    }
                                }

                                questionTemplate = questionTemplate.Replace("[AUTHOR]", objQuestion.CreatedByDisplayName);
                                questionTemplate = questionTemplate.Replace("[TERMS]", terms);
                                questionTemplate = questionTemplate.Replace("[TITLELINK]", titleLink);
                                questionTemplate = questionTemplate.Replace("[TITLE]", objQuestion.Title);
                                questionTemplate = questionTemplate.Replace("[BODY]", Utils.ProcessDisplayPostBody(objQuestion.Body));
                                questionTemplate = questionTemplate.Replace("[SUBSCRIBELINK]", subscribeLink);

                                var colSubscribers = Controller.GetSubscribersByContentItem(item.ContentItemId, (int)Constants.SubscriptionType.InstantTerm, objQuestion.PortalId);
                                foreach (var subscriber in colSubscribers)
                                {
                                    // send off the email one by one (same email to multiple subscribers)
                                    Mail.SendMail(senderEmail, subscriber.Email, "", "", MailPriority.Normal,
                                                  HtmlUtils.StripWhiteSpace(objQuestion.Title, true), MailFormat.Html, Encoding.UTF8, questionTemplate,
                                                  "", Host.SMTPServer, Host.SMTPAuthentication, Host.SMTPUsername,
                                                  Host.SMTPPassword, Host.EnableSMTPSSL);
                                }

                                strErrors = "Instant Term: Sent " + colSubscribers.Count + " emails - " + objQuestion.Title + "<br />";
                            }
                        }
                    }
                    else
                    {
                        strErrors = "Instant Term: No email to send <br />";
                    }

                    break;
                default:
                    var colAnswers = Controller.GetAnswersByDate(lastRunDate, currentRunDate);

                    if (colAnswers.Count() > 0)
                    {
                        // for each content item in the collection, get a list of subscribers and send the emails off one by one.
                        foreach (var item in colAnswers)
                        {
                            var objQuestion = Controller.GetQuestionByContentItem(item.ContentItemId);
                            // use the post item to build the email subject/body/content (sub question for content item now)
                            var colEmail = QaSettings.GetEmailCollection(Controller.GetQaPortalSettings(item.PortalId), item.PortalId);
                            var senderEmail = colEmail.Single(s => s.Key == Constants.EmailSettings.FromAddress.ToString()).Value;
                            //var urlBase = colEmail.Single(s => s.Key == Constants.EmailSettings.PrimaryUrl.ToString()).Value;
                            var answerTemplate = colEmail.Single(s => s.Key == Constants.EmailSettings.AnswerTemplate.ToString()).Value;
                            var ps = new PortalSettings(item.PortalId);

                            var titleLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/question/id/" + objQuestion.PostId + "/" + DotNetNuke.Common.Globals.glbDefaultPage;
                            var subscribeLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/subscriptions/" + DotNetNuke.Common.Globals.glbDefaultPage;

                            answerTemplate = answerTemplate.Replace("[AUTHOR]", item.PostCreatedDisplayName);
                            answerTemplate = answerTemplate.Replace("[TITLELINK]", titleLink);
                            answerTemplate = answerTemplate.Replace("[TITLE]", objQuestion.Title);
                            answerTemplate = answerTemplate.Replace("[BODY]", Utils.ProcessDisplayPostBody(item.Body));
                            answerTemplate = answerTemplate.Replace("[SUBSCRIBELINK]", subscribeLink);

                            var colSubscribers = Controller.GetSubscribersByQuestion(item.ParentId, (int)Constants.SubscriptionType.InstantPost, item.PortalId);
                            foreach (var subscriber in colSubscribers)
                            {
                                // send off the email one by one (same email to multiple subscribers)
                                Mail.SendMail(senderEmail, subscriber.Email, "", "", MailPriority.Normal,
                                              HtmlUtils.StripWhiteSpace(objQuestion.Title, true), MailFormat.Html, Encoding.UTF8, answerTemplate,
                                              "", Host.SMTPServer, Host.SMTPAuthentication, Host.SMTPUsername,
                                              Host.SMTPPassword, Host.EnableSMTPSSL);
                            }

                            strErrors = "Instant Post: Sent " + colSubscribers.Count + " emails - " + objQuestion.Title + "<br />";
                        }
                    }
                    else
                    {
                        strErrors = "Instant Post: No new answers to email <br />";
                    }

                    // now we move onto comments
                    var colComments = Controller.GetCommentsByDate(lastRunDate, currentRunDate);

                    if (colComments.Count() > 0)
                    {
                        foreach (var item in colComments)
                        {
                            var objPost = Controller.GetPost(item.PostId, -1);
                            var ps = new PortalSettings(objPost.PortalId);
                            var objQuestion = objPost.ParentId == 0 ? objPost : Controller.GetQuestionByContentItem(objPost.ContentItemId);
                            var colEmail = QaSettings.GetEmailCollection(Controller.GetQaPortalSettings(objQuestion.PortalId), objPost.PortalId);
                            var commentTemplate = colEmail.Single(s => s.Key == Constants.EmailSettings.CommentTemplate.ToString()).Value;
                            var senderEmail = colEmail.Single(s => s.Key == Constants.EmailSettings.FromAddress.ToString()).Value;

                            var titleLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/question/id/" + objQuestion.PostId + "/" + DotNetNuke.Common.Globals.glbDefaultPage;
                            var subscribeLink = "http://" + ps.DefaultPortalAlias + "/tabid/" + objQuestion.TabID + "/view/subscriptions/" + DotNetNuke.Common.Globals.glbDefaultPage;

                            commentTemplate = commentTemplate.Replace("[AUTHOR]", DotNetNuke.Entities.Users.UserController.GetUserById(objQuestion.PortalId, item.UserId).DisplayName);
                            commentTemplate = commentTemplate.Replace("[TITLELINK]", titleLink);
                            commentTemplate = commentTemplate.Replace("[TITLE]", objQuestion.Title);
                            commentTemplate = commentTemplate.Replace("[COMMENT]", Utils.ProcessDisplayPostBody(item.Comment));
                            commentTemplate = commentTemplate.Replace("[SUBSCRIBELINK]", subscribeLink);

                            var colSubscribers = Controller.GetSubscribersByQuestion(objQuestion.PostId, (int)Constants.SubscriptionType.InstantPost, objQuestion.PortalId);
                            foreach (var subscriber in colSubscribers)
                            {
                                // send off the email one by one (same email to multiple subscribers)
                                Mail.SendMail(senderEmail, subscriber.Email, "", "", MailPriority.Normal,
                                              HtmlUtils.StripWhiteSpace(objQuestion.Title, true), MailFormat.Html, Encoding.UTF8, commentTemplate,
                                              "", Host.SMTPServer, Host.SMTPAuthentication, Host.SMTPUsername,
                                              Host.SMTPPassword, Host.EnableSMTPSSL);
                            }
                            // we also have to remember to check if we emailed notification of a comment around this question already (only within this method, to avoid to comments on question being emailed 2x).
                            // also avoid emailing someone of their own comment

                        }
                    }
                    else
                    {
                        strErrors = "Instant Post: No new comments to email <br />";
                    }

                    break;
            }

            return strErrors;
        }
예제 #9
0
        /// <summary>
        /// Creates a Content Type (for taxonomy) in the data store.
        /// </summary>
        /// <returns>The primary key value of the new ContentType.</returns>
        private static int CreateContentType(string ContentTypeName) {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType { ContentType = ContentTypeName };

            return typeController.AddContentType(objContentType);
        }
예제 #10
0
 /// <summary>
 /// </summary>
 /// <param name = "module"></param>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///   [vnguyen]   20110-05-10   Modified: Added update tabmodule versionguids
 /// </history>
 public void CreateContentItem(ModuleInfo module)
 {
     IContentTypeController typeController = new ContentTypeController();
     ContentType contentType = (from t in typeController.GetContentTypes()
                                where t.ContentType == "Module"
                                select t).SingleOrDefault();
     //This module does not have a valid ContentItem
     //create ContentItem
     IContentController contentController = Util.GetContentController();
     module.Content = module.ModuleTitle;
     module.Indexed = false;
     if (contentType != null)
     {
         module.ContentTypeId = contentType.ContentTypeId;
     }
     module.ContentItemId = contentController.AddContentItem(module);
 }
        /// <summary>
        /// Creates a unique content type for this module
        /// </summary>
        /// <returns></returns>
        private static int CreateContentType()
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType { ContentType = MODULE_TYPE_NAME };

            return typeController.AddContentType(objContentType);
        }
예제 #12
0
        /// <summary>
        /// Creates content item for the tab..
        /// </summary>
        /// <param name="tab">The updated tab.</param>
        public void CreateContentItem(TabInfo tab)
        {
            //First create ContentItem as we need the ContentItemID
            var typeController = new ContentTypeController();
            ContentType contentType =
                (from t in typeController.GetContentTypes() where t.ContentType == "Tab" select t).SingleOrDefault();

            IContentController contentController = Util.GetContentController();
            tab.Content = String.IsNullOrEmpty(tab.Title) ? tab.TabName : tab.Title;
            if (contentType != null)
            {
                tab.ContentTypeId = contentType.ContentTypeId;
            }
            tab.Indexed = false;
            contentController.AddContentItem(tab);
        }
예제 #13
0
        public void ContentTypeController_GetContentTypes_Returns_Empty_List_Of_ContentTypes_If_No_ContentTypes()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetContentTypes()).Returns(MockHelper.CreateEmptyContentTypeReader());
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            //Act
            var contentTypes = contentTypeController.GetContentTypes();

            //Assert
            Assert.IsNotNull(contentTypes);
            Assert.AreEqual(0, contentTypes.Count());
        }
예제 #14
0
        public void ContentTypeController_AddContentType_Returns_ValidId_On_Valid_ContentType()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.AddContentType(It.IsAny<ContentType>())).Returns(Constants.CONTENTTYPE_AddContentTypeId);
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            var contentType = ContentTestHelper.CreateValidContentType();

            //Act
            int contentTypeId = contentTypeController.AddContentType(contentType);

            //Assert
            Assert.AreEqual(Constants.CONTENTTYPE_AddContentTypeId, contentTypeId);
        }
예제 #15
0
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType contentType = (from t in typeController.GetContentTypes()
                                       where t.ContentType == "DesktopModule"
                                       select t).SingleOrDefault();

            if (contentType == null)
            {
                contentType = new ContentType { ContentType = "DesktopModule" };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();
            desktopModule.Content = desktopModule.FriendlyName;
            desktopModule.Indexed = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
예제 #16
0
        public void ContentTypeController_DeleteContentType_Throws_On_Negative_ContentTypeId()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            ContentType contentType = ContentTestHelper.CreateValidContentType();
            contentType.ContentTypeId = Null.NullInteger;

            //Act, Arrange
            Assert.Throws<ArgumentOutOfRangeException>(() => contentTypeController.DeleteContentType(contentType));
        }
예제 #17
0
        public void ContentTypeController_UpdateContentType_Calls_DataService_On_Valid_ContentType()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            var contentType = ContentTestHelper.CreateValidContentType();
            contentType.ContentTypeId = Constants.CONTENTTYPE_UpdateContentTypeId;
            contentType.ContentType = Constants.CONTENTTYPE_UpdateContentType;

            //Act
            contentTypeController.UpdateContentType(contentType);

            //Assert
            mockDataService.Verify(ds => ds.UpdateContentType(contentType));
        }
예제 #18
0
        public void ContentTypeController_UpdateContentType_Throws_On_Negative_ContentTypeId()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            var contentType = ContentTestHelper.CreateValidContentType();
            contentType.ContentType = Constants.CONTENTTYPE_InValidContentType;

            Assert.Throws<ArgumentOutOfRangeException>(() => contentTypeController.UpdateContentType(contentType));
        }
예제 #19
0
        public void ContentTypeController_GetContentTypes_Returns_List_Of_ContentTypes()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetContentTypes()).Returns(MockHelper.CreateValidContentTypesReader(Constants.CONTENTTYPE_ValidContentTypeCount));
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            //Act
            var contentTypes = contentTypeController.GetContentTypes();

            //Assert
            Assert.AreEqual(Constants.CONTENTTYPE_ValidContentTypeCount, contentTypes.Count());
        }
예제 #20
0
        private static void UpgradeToVersion710()
        {
            //create a placeholder entry - uses the most common 5 character password (seed list is 6 characters and above)
            const string listName = "BannedPasswords";
            var listController = new ListController();
            var entry = new ListEntryInfo();
            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID = Null.NullInteger;
                entry.ListName = listName;
                entry.Value = "12345";
                entry.Text = "Placeholder";
                entry.SystemList = false;
            }

            //add list to each portal and update primary alias
            foreach (PortalInfo portal in PortalController.Instance.GetPortals())
            {
                entry.PortalID = portal.PortalID;
                entry.SystemList = false;
                entry.ListName = listName + "-" + portal.PortalID;
                listController.AddListEntry(entry);

                var defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", portal.PortalID, String.Empty);
                if (!String.IsNullOrEmpty(defaultAlias))
                {
                    foreach (var alias in PortalAliasController.Instance.GetPortalAliasesByPortalId(portal.PortalID).Where(alias => alias.HTTPAlias == defaultAlias))
                    {
                        alias.IsPrimary = true;
                        PortalAliasController.Instance.UpdatePortalAlias(alias);
                    }
                }
            }

            // Add File Content Type
            var typeController = new ContentTypeController();
            var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            if (contentTypeFile == null)
            {
                typeController.AddContentType(new ContentType { ContentType = "File" });
            }

            var fileContentType = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();


            //only perform following for an existing installation upgrading
            if (Globals.Status == Globals.UpgradeStatus.Upgrade)
            {
                UpdateFoldersForParentId();
                ImportDocumentLibraryCategories();
                ImportDocumentLibraryCategoryAssoc(fileContentType);
            }

            //Add 404 Log
            var logTypeInfo = new LogTypeInfo
            {
                LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(),
                LogTypeFriendlyName = "HTTP Error Code 404 Page Not Found",
                LogTypeDescription = "",
                LogTypeCSSClass = "OperationFailure",
                LogTypeOwner = "DotNetNuke.Logging.EventLogType"
            };
            LogController.Instance.AddLogType(logTypeInfo);

            //Add LogType
            var logTypeConf = new LogTypeConfigInfo
            {
                LoggingIsActive = true,
                LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(),
                KeepMostRecent = "100",
                NotificationThreshold = 1,
                NotificationThresholdTime = 1,
                NotificationThresholdTimeType = LogTypeConfigInfo.NotificationThresholdTimeTypes.Seconds,
                MailFromAddress = Null.NullString,
                MailToAddress = Null.NullString,
                LogTypePortalID = "*"
            };
            LogController.Instance.AddLogTypeConfigInfo(logTypeConf);

            UninstallPackage("DotNetNuke.SearchInput");

            //enable password strength meter for new installs only
            HostController.Instance.Update("EnableStrengthMeter", Globals.Status == Globals.UpgradeStatus.Install ? "Y" : "N");

            //Add IP filter log type
            var logTypeFilterInfo = new LogTypeInfo
            {
                LogTypeKey = EventLogController.EventLogType.IP_LOGIN_BANNED.ToString(),
                LogTypeFriendlyName = "HTTP Error Code 403.6 forbidden ip address rejected",
                LogTypeDescription = "",
                LogTypeCSSClass = "OperationFailure",
                LogTypeOwner = "DotNetNuke.Logging.EventLogType"
            };
            LogController.Instance.AddLogType(logTypeFilterInfo);

            //Add LogType
            var logTypeFilterConf = new LogTypeConfigInfo
            {
                LoggingIsActive = true,
                LogTypeKey = EventLogController.EventLogType.IP_LOGIN_BANNED.ToString(),
                KeepMostRecent = "100",
                NotificationThreshold = 1,
                NotificationThresholdTime = 1,
                NotificationThresholdTimeType = LogTypeConfigInfo.NotificationThresholdTimeTypes.Seconds,
                MailFromAddress = Null.NullString,
                MailToAddress = Null.NullString,
                LogTypePortalID = "*"
            };
            LogController.Instance.AddLogTypeConfigInfo(logTypeFilterConf);

            int tabID = TabController.GetTabByTabPath(Null.NullInteger, "//Host//SearchAdmin", Null.NullString);
            if (tabID > Null.NullInteger)
            {
                TabController.Instance.DeleteTab(tabID, Null.NullInteger);
            }

            var modDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Search Admin");

            if (modDef != null)
                AddAdminPages("Search Admin", "Manage search settings associated with DotNetNuke's search capability.", "~/Icons/Sigma/Search_16x16_Standard.png", "~/Icons/Sigma/Search_32x32_Standard.png", true, modDef.ModuleDefID, "Search Admin", "");

            CopyGettingStartedStyles();
        }
예제 #21
0
        private static void UpgradeToVersion720()
        {
            var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName("51Degrees.mobi", Null.NullInteger);
            if (desktopModule != null)
            {
                DesktopModuleController.RemoveDesktopModuleFromPortals(desktopModule.DesktopModuleID);
            }

            desktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DotNetNuke.RadEditorProvider", Null.NullInteger);
            if (desktopModule != null)
            {
                DesktopModuleController.RemoveDesktopModuleFromPortals(desktopModule.DesktopModuleID);
            }

            //ensure old codeplex module is uninstalled - need to check for both variants of package name
            UninstallPackage("DotNetNuke.Module Creator");
            UninstallPackage("DNNCorp.ModuleCreator");

            DesktopModuleController.AddModuleCategory("Developer");
            var moduleDefId = AddModuleDefinition("Module Creator", "Development of modules.", "Module Creator");
            AddModuleControl(moduleDefId, "", "", "DesktopModules/Admin/ModuleCreator/CreateModule.ascx", "~/DesktopModules/Admin/ModuleCreator/icon.png", SecurityAccessLevel.Host, 0);
            if (ModuleDefinitionController.GetModuleDefinitionByID(moduleDefId) != null)
            {
                var desktopModuleId = ModuleDefinitionController.GetModuleDefinitionByID(moduleDefId).DesktopModuleID;
                desktopModule = DesktopModuleController.GetDesktopModule(desktopModuleId, Null.NullInteger);
                desktopModule.Category = "Developer";
                DesktopModuleController.SaveDesktopModule(desktopModule, false, false);

                var package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == desktopModule.PackageID);
                package.IconFile = "~/Icons/Sigma/ModuleCreator_32x32.png";
                PackageController.Instance.SaveExtensionPackage(package);
            }

            var typeController = new ContentTypeController();
            var fileContentType = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            //only perform following for an existing installation upgrading
            if (Globals.Status == Globals.UpgradeStatus.Upgrade)
            {
                ImportDocumentLibraryCategories();
                ImportDocumentLibraryCategoryAssoc(fileContentType);
            }
            
            //fixes issue introduced by eventlog's being defined in upgrade.cs
            PortalController.EnsureRequiredEventLogTypesExist();

            //Remove Professional Features pages from CE
            int advancedFeaturesTabId = TabController.GetTabByTabPath(Null.NullInteger, "//Host//ProfessionalFeatures", Null.NullString);
            if (DotNetNukeContext.Current.Application.Name == "DNNCORP.CE")
            {
                foreach (var tab in TabController.GetTabsByParent(advancedFeaturesTabId, Null.NullInteger))
                {
                    TabController.Instance.DeleteTab(tab.TabID, Null.NullInteger);
                }
                TabController.Instance.DeleteTab(advancedFeaturesTabId, Null.NullInteger);
            }

            //Remove Whats New
            int whatsNewTabId = TabController.GetTabByTabPath(Null.NullInteger, "//Host//WhatsNew", Null.NullString);
            TabController.Instance.DeleteTab(whatsNewTabId, Null.NullInteger);

            //Remove WhatsNew module
            DesktopModuleController.DeleteDesktopModule("WhatsNew");

            //read plaintext password via old API and encrypt
            var current = HostController.Instance.GetString("SMTPPassword");
            if (!string.IsNullOrEmpty(current))
            {
                HostController.Instance.UpdateEncryptedString("SMTPPassword", current, Config.GetDecryptionkey());
            }
        }
예제 #22
0
        public void ContentTypeController_GetContentTypes_Calls_DataService()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetContentTypes()).Returns(MockHelper.CreateValidContentTypesReader(Constants.CONTENTTYPE_ValidContentTypeCount));
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            //Act
            var contentTypes = contentTypeController.GetContentTypes();

            //Assert
            mockDataService.Verify(ds => ds.GetContentTypes());
        }