예제 #1
0
 public ExtendedUserData(string UserName)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         vw_carrot_UserData rc = CompiledQueries.cqFindUserByName(_db, UserName);
         LoadUserData(rc);
     }
 }
예제 #2
0
        public static int GetHistoryListCount(Guid siteID, bool showLatestOnly, DateTime?editDate, Guid?editUserID)
        {
            Guid userID = Guid.Empty;

            if (editUserID.HasValue)
            {
                userID = editUserID.Value;
            }

            DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2);
            DateTime dateEnd   = DateTime.UtcNow.Date.AddDays(1);

            if (editDate.HasValue)
            {
                dateStart = editDate.Value.Date.AddDays(-8);
                dateEnd   = editDate.Value.Date.AddDays(1);
            }

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                return((from h in _db.vw_carrot_EditHistories
                        where h.SiteID == siteID &&
                        (!showLatestOnly || h.IsLatestVersion == true) &&
                        (!editDate.HasValue ||
                         (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date)) &&
                        (!editUserID.HasValue || h.EditUserId == userID)
                        select h).Count());
            }
        }
예제 #3
0
        public void Save()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                bool bNew           = false;
                carrot_ContentTag s = CompiledQueries.cqGetContentTagByID(_db, this.ContentTagID);

                if (s == null || (s != null && s.ContentTagID == Guid.Empty))
                {
                    s = new carrot_ContentTag();
                    s.ContentTagID = Guid.NewGuid();
                    s.SiteID       = this.SiteID;
                    bNew           = true;
                }

                s.TagSlug  = ContentPageHelper.ScrubSlug(this.TagSlug);
                s.TagText  = this.TagText;
                s.IsPublic = this.IsPublic;

                if (bNew)
                {
                    _db.carrot_ContentTags.InsertOnSubmit(s);
                }

                _db.SubmitChanges();

                this.ContentTagID = s.ContentTagID;
            }
        }
예제 #4
0
 public static int GetCommentCountByContent(Guid siteID, Guid rootContentID, DateTime postDate, string postIP)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from c in CannedQueries.FindCommentsByDate(_db, siteID, rootContentID, postDate, postIP)
                 select c).Count());
     }
 }
예제 #5
0
 public static int GetAllCommentCountBySite(Guid siteID)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from c in CannedQueries.GetSiteContentComments(_db, siteID)
                 select c).Count());
     }
 }
예제 #6
0
 public static int GetCommentCountByContent(Guid rootContentID, bool bActiveOnly)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from c in CannedQueries.GetContentPageComments(_db, rootContentID, bActiveOnly)
                 select c).Count());
     }
 }
예제 #7
0
 public static int GetCommentCountByContent(Guid rootContentID, bool?approved, bool?spam)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from c in CannedQueries.GetContentPageComments(_db, rootContentID, approved, spam)
                 select c).Count());
     }
 }
예제 #8
0
        public bool VerifyUserHasSiteAccess(Guid siteID, Guid userID)
        {
            //all admins have rights to all sites
            if (SecurityData.IsAdmin)
            {
                return(true);
            }

            // if user is neither admin nor editor, they should not be in the backend of the site
            if (!(SecurityData.IsSiteEditor || SecurityData.IsAdmin))
            {
                return(false);
            }
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                // by this point, the user is probably an editor, make sure they have rights to this site
                IQueryable <Guid> lstSiteIDs = (from l in _db.carrot_UserSiteMappings
                                                where l.UserId == userID &&
                                                l.SiteID == siteID
                                                select l.SiteID);

                if (lstSiteIDs.Count() > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #9
0
 public static int GetCommentCountBySiteAndType(Guid siteID, ContentPageType.PageType pageType, bool?approved, bool?spam)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from c in CannedQueries.GetSiteContentCommentsByPostType(_db, siteID, pageType, approved, spam)
                 select c).Count());
     }
 }
예제 #10
0
        public void Save()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                bool            bNew = false;
                carrot_UserData usr  = CompiledQueries.cqFindUserTblByID(_db, this.UserId);

                if (usr == null)
                {
                    usr        = new carrot_UserData();
                    usr.UserId = this.UserId;
                    bNew       = true;
                }

                usr.UserNickName = this.UserNickName;
                usr.FirstName    = this.FirstName;
                usr.LastName     = this.LastName;
                usr.UserBio      = this.UserBio;

                if (bNew)
                {
                    _db.carrot_UserDatas.InsertOnSubmit(usr);
                }

                _db.SubmitChanges();

                this.UserId = usr.UserId;
            }
        }
예제 #11
0
        public bool AddToSite(Guid siteID)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_UserSiteMapping map = (from m in _db.carrot_UserSiteMappings
                                              where m.UserId == this.UserId &&
                                              m.SiteID == siteID
                                              select m).FirstOrDefault();

                if (map == null)
                {
                    _siteIDs = null;

                    map = new carrot_UserSiteMapping();
                    map.UserSiteMappingID = Guid.NewGuid();
                    map.SiteID            = siteID;
                    map.UserId            = this.UserId;

                    _db.carrot_UserSiteMappings.InsertOnSubmit(map);
                    _db.SubmitChanges();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #12
0
 public int GetSitePageCount(ContentPageType.PageType entryType)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         int iCount = CannedQueries.GetAllByTypeList(_db, this.SiteID, false, entryType).Count();
         return(iCount);
     }
 }
예제 #13
0
 public ExtendedUserData(Guid UserID)
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, UserID);
         LoadUserData(rc);
     }
 }
예제 #14
0
        public void Save()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                bool bNew           = false;
                carrot_TextWidget s = CompiledQueries.cqTextWidgetByID(_db, this.TextWidgetID);

                if (s == null)
                {
                    bNew                 = true;
                    s                    = new carrot_TextWidget();
                    s.TextWidgetID       = Guid.NewGuid();
                    s.SiteID             = this.SiteID;
                    s.TextWidgetAssembly = this.TextWidgetAssembly;
                }

                s.ProcessBody      = this.ProcessBody;
                s.ProcessPlainText = this.ProcessPlainText;
                s.ProcessHTMLText  = this.ProcessHTMLText;
                s.ProcessComment   = this.ProcessComment;
                s.ProcessSnippet   = this.ProcessSnippet;

                if (bNew)
                {
                    _db.carrot_TextWidgets.InsertOnSubmit(s);
                }

                _db.SubmitChanges();

                this.TextWidgetID = s.TextWidgetID;
            }
        }
예제 #15
0
 public static IQueryable <ExtendedUserData> GetUsers()
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         IQueryable <ExtendedUserData> lstUsr = (from u in CompiledQueries.cqGetUserList(_db)
                                                 select new ExtendedUserData(u));
         return(lstUsr);
     }
 }
예제 #16
0
        public static int GetSimilar(Guid SiteID, Guid TagID, string tagSlug)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <carrot_ContentTag> query = CompiledQueries.cqGetContentTagNoMatch(_db, SiteID, TagID, tagSlug);

                return(query.Count());
            }
        }
예제 #17
0
        public static int GetSimilar(Guid SiteID, Guid CategoryID, string categorySlug)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <carrot_ContentCategory> query = CompiledQueries.cqGetContentCategoryNoMatch(_db, SiteID, CategoryID, categorySlug);

                return(query.Count());
            }
        }
예제 #18
0
        public static int GetSimilar(Guid siteID, Guid rootSnippetID, string categorySlug)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_ContentSnippet> query = CompiledQueries.cqGetContentSnippetNoMatch(_db, siteID, rootSnippetID, categorySlug);

                return(query.Count());
            }
        }
예제 #19
0
 public List <SiteData> GetSiteList()
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from m in _db.carrot_UserSiteMappings
                 join s in _db.carrot_Sites on m.SiteID equals s.SiteID
                 where m.UserId == this.UserId
                 select new SiteData(s)).ToList());
     }
 }
예제 #20
0
        public static List <PostComment> GetCommentsByContentPage(Guid rootContentID, bool bActiveOnly)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_Comment> lstComments = (from c in CannedQueries.GetContentPageComments(_db, rootContentID, bActiveOnly)
                                                              select c);

                return(lstComments.Select(x => new PostComment(x)).ToList());
            }
        }
예제 #21
0
 public List <ExtendedUserData> GetMappedUsers()
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
         return((from l in _db.carrot_UserSiteMappings
                 join u in _db.vw_carrot_UserDatas on l.UserId equals u.UserId
                 where l.SiteID == this.SiteID
                 select new ExtendedUserData(u)).ToList());
     }
 }
예제 #22
0
        public List <ContentSnippet> GetContentSnippetList()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                List <ContentSnippet> _types = (from d in CompiledQueries.cqGetSnippetsBySiteID(_db, this.SiteID)
                                                select new ContentSnippet(d)).ToList();

                return(_types);
            }
        }
예제 #23
0
        public static List <PostComment> GetAllCommentsBySite(Guid siteID)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <PostComment> s = (from c in CannedQueries.GetSiteContentComments(_db, siteID)
                                              select new PostComment(c));

                return(s.ToList());
            }
        }
예제 #24
0
        public static List <ContentSnippet> GetHistory(Guid rootSnippetID)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                List <ContentSnippet> _types = (from d in CompiledQueries.cqGetSnippetVersionHistory(_db, rootSnippetID)
                                                select new ContentSnippet(d)).ToList();

                return(_types);
            }
        }
예제 #25
0
        public void ResetHeartbeatLock()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID);

                rc.EditHeartbeat    = DateTime.UtcNow.AddHours(-2);
                rc.Heartbeat_UserId = null;
                _db.SubmitChanges();
            }
        }
예제 #26
0
        public void Save()
        {
            using (CarrotCMSDataContext db = CarrotCMSDataContext.GetDataContext()) {
                string xml = this.GetXml();

                xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", string.Empty);

                db.carrot_UpdateGoLiveLocal(this.SiteID, XElement.Parse(xml));
            }
        }
예제 #27
0
        public static int GetSiteCount(Guid siteID)
        {
            int iCt = -1;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                iCt = CompiledQueries.cqGetContentTagCountBySiteID(_db, siteID);
            }

            return(iCt);
        }
예제 #28
0
        public List <BasicContentData> GetFullSiteFileList()
        {
            List <BasicContentData> map = new List <BasicContentData>();

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_Content> queryAllFiles = CompiledQueries.cqGetAllContent(_db, this.SiteID);
                map = queryAllFiles.Select(x => new BasicContentData(x)).ToList();
            }

            return(map);
        }
예제 #29
0
        public void Save()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_Site s = CompiledQueries.cqGetSiteByID(_db, this.SiteID);

                bool bNew = false;
                if (s == null)
                {
                    s = new carrot_Site();
                    if (this.SiteID == Guid.Empty)
                    {
                        this.SiteID = Guid.NewGuid();
                    }
                    bNew = true;
                }

                // if updating the current site then blank out its cache
                if (CurrentSiteID == this.SiteID)
                {
                    CurrentSite = null;
                }

                s.SiteID = this.SiteID;

                s.TimeZone = this.TimeZoneIdentifier;

                FixMeta();
                s.MetaKeyword     = this.MetaKeyword.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ").Replace("  ", " ");
                s.MetaDescription = this.MetaDescription.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ").Replace("  ", " ");

                s.SiteName            = this.SiteName;
                s.SiteTagline         = this.SiteTagline;
                s.SiteTitlebarPattern = this.SiteTitlebarPattern;
                s.MainURL             = this.MainURL;
                s.BlockIndex          = this.BlockIndex;
                s.SendTrackbacks      = this.SendTrackbacks;
                s.AcceptTrackbacks    = this.AcceptTrackbacks;

                s.Blog_FolderPath   = ContentPageHelper.ScrubSlug(this.Blog_FolderPath);
                s.Blog_CategoryPath = ContentPageHelper.ScrubSlug(this.Blog_CategoryPath);
                s.Blog_TagPath      = ContentPageHelper.ScrubSlug(this.Blog_TagPath);
                s.Blog_EditorPath   = ContentPageHelper.ScrubSlug(this.Blog_EditorPath);
                s.Blog_DatePath     = ContentPageHelper.ScrubSlug(this.Blog_DatePath);

                s.Blog_Root_ContentID = this.Blog_Root_ContentID;
                s.Blog_DatePattern    = String.IsNullOrEmpty(this.Blog_DatePattern) ? "yyyy/MM/dd" : this.Blog_DatePattern;

                if (bNew)
                {
                    _db.carrot_Sites.InsertOnSubmit(s);
                }
                _db.SubmitChanges();
            }
        }
예제 #30
0
        public void RecordHeartbeatLock(Guid currentUserID)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID);

                rc.Heartbeat_UserId = currentUserID;
                rc.EditHeartbeat    = DateTime.UtcNow;

                _db.SubmitChanges();
            }
        }