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());
        }
        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());
        }
        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());
        }
        private int getContentType()
        {
            ContentTypeController ctCtrl = new ContentTypeController();
            var ct = ctCtrl.GetContentTypes().FirstOrDefault(c => c.ContentType == DATAACCESSITEM_CONTENTTYPE);

            if (ct != null)
            {
                return(ct.ContentTypeId);
            }
            else
            {
                // Add our custom content type
                return(ctCtrl.AddContentType(new ContentType {
                    ContentType = DATAACCESSITEM_CONTENTTYPE, KeyID = 0
                }));
            }
        }
Exemple #5
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(string ContentTypeName)
        {
            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(ContentTypeName) : contentType.ContentTypeId;
            }
            else
            {
                contentTypeId = CreateContentType(ContentTypeName);
            }

            return(contentTypeId);
        }
 protected int GetContentTypeID()
 {
     if (_ContentTypeID == Null.NullInteger)
     {
         var ctc          = new ContentTypeController();
         var contentTypes = ctc.GetContentTypes().Where(t => t.ContentType == Consts.ContentTypeName);
         if (contentTypes.Count() > 0)
         {
             var contentType = contentTypes.Single();
             _ContentTypeID = (contentType == null) ? CreateContentType() : contentType.ContentTypeId;
         }
         else
         {
             _ContentTypeID = CreateContentType();
         }
     }
     return(_ContentTypeID);
 }
Exemple #7
0
        public IQueryable <ContentItem> GetContentItems(int tabId, int moduleId)
        {
            var typeController  = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == ContentTypeName select t);
            int contentTypeId;

            if (colContentTypes.Any())
            {
                var contentType = colContentTypes.Single();
                contentTypeId = contentType == null?CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeId = CreateContentType();
            }
            var cc     = new ContentController();
            var slides = cc.GetContentItems(contentTypeId, tabId, moduleId);

            return(slides);
        }
Exemple #8
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(string contentTypeConstant)
        {
            var typeController = new ContentTypeController();
            IEnumerable <ContentType> colContentTypes =
                from t in typeController.GetContentTypes() where t.ContentType == contentTypeConstant select t;
            var contentTypeId = 0;

            if (colContentTypes.Any())
            {
                var contentType = colContentTypes.Single();
                contentTypeId = Convert.ToInt32(ReferenceEquals(contentType, null)
                                                    ? CreateContentType(contentTypeConstant)
                                                    : contentType.ContentTypeId);
            }
            else
            {
                contentTypeId = CreateContentType(contentTypeConstant);
            }

            return(contentTypeId);
        }
Exemple #9
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, int moduleId)
        {
            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      = moduleId,
                TabID         = tabId,
            };

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

            // Add Terms
            // var cntTerm = new Terms();
            // cntTerm.ManageQuestionTerms(objPost, objContent);
            return(objContent);
        }
Exemple #10
0
        /// <summary>
        /// This populates the drop downs and radio buttons with localized text.
        /// </summary>
        private void PopulateSettingOptions()
        {
            //General
            var typeController  = new ContentTypeController();
            var colContentTypes = typeController.GetContentTypes();

            ddlContentType.DataSource = colContentTypes.ToList();
            ddlContentType.DataBind();
            ddlContentType.Items.Insert(0, new ListItem(Localization.GetString("NoneSpecified", LocalResourceFile), "-1"));
            ddlContentType.Items.Insert(1, new ListItem(Localization.GetString("CurrentTab", LocalResourceFile), "0"));

            ddlSort.Items.Insert(0, new ListItem(Localization.GetString("NotSorted", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudSorting.NotSorted).ToString()));
            ddlSort.Items.Insert(1, new ListItem(Localization.GetString("AlphabeticAsc", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudSorting.AlphabeticAsc).ToString()));
            ddlSort.Items.Insert(2, new ListItem(Localization.GetString("AlphabeticDsc", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudSorting.AlphabeticDsc).ToString()));
            ddlSort.Items.Insert(3, new ListItem(Localization.GetString("WeightedAsc", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudSorting.WeightedAsc).ToString()));
            ddlSort.Items.Insert(4, new ListItem(Localization.GetString("WeightedDsc", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudSorting.WeightedDsc).ToString()));

            // Appearance
            ddlSkin.Items.Insert(0, new ListItem("Default", "Default"));
            ddlSkin.Items.Insert(1, new ListItem("Black", "Black"));
            ddlSkin.Items.Insert(2, new ListItem("Forest", "Forest"));
            ddlSkin.Items.Insert(3, new ListItem("Hay", "Hay"));
            ddlSkin.Items.Insert(4, new ListItem("Office2007", "Office2007"));
            ddlSkin.Items.Insert(5, new ListItem("Outlook", "Outlook"));
            ddlSkin.Items.Insert(6, new ListItem("Simple", "Simple"));
            ddlSkin.Items.Insert(7, new ListItem("Sitefinity", "Sitefinity"));
            ddlSkin.Items.Insert(8, new ListItem("Sunset", "Sunset"));
            ddlSkin.Items.Insert(9, new ListItem("Telerik", "Telerik"));
            ddlSkin.Items.Insert(10, new ListItem("Vista", "Vista"));
            ddlSkin.Items.Insert(11, new ListItem("Web20", "Web20"));
            ddlSkin.Items.Insert(12, new ListItem("WebBlue", "WebBlue"));
            ddlSkin.Items.Insert(13, new ListItem("Windows7", "Windows7"));

            rblstRenderWeight.Items.Insert(0, new ListItem(Localization.GetString("Yes", LocalResourceFile), "True"));
            rblstRenderWeight.Items.Insert(1, new ListItem(Localization.GetString("No", LocalResourceFile), "False"));

            //Advanced
            rblstDistro.Items.Insert(0, new ListItem(Localization.GetString("Linear", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudDistribution.Linear).ToString()));
            rblstDistro.Items.Insert(1, new ListItem(Localization.GetString("Logarithmic", LocalResourceFile), Convert.ToInt32(Telerik.Web.UI.TagCloudDistribution.Logarithmic).ToString()));
        }
        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);
        }
Exemple #12
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(RoleInfo objItem, int tabId)
        {
            var    typeController  = new ContentTypeController();
            string contentTypeName = "DNNCorp_SocialGroup";

            if (objItem.RoleID > 0)
            {
                contentTypeName = "DNNCorp_SocialGroup";
            }
            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       = objItem.RoleName,
                ContentTypeId = contentTypeID,
                Indexed       = false,
                ContentKey    = "GroupId=" + objItem.RoleID,
                ModuleID      = -1,
                TabID         = tabId
            };

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

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

            return(objContent);
        }
Exemple #13
0
        private static ContentItem CreateDnnContentItem()
        {
            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 dnnContentItem = new ContentItem
            {
                ContentTypeId = contentTypeFile.ContentTypeId,
                Indexed       = false,
            };

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

            return(dnnContentItem);
        }
        /// <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);
        }