コード例 #1
0
    /// <summary>
    /// Returns number of comments of given blog.
    /// </summary>
    /// <param name="postId">Post document id</param>
    /// <param name="postAliasPath">Post alias path</param>
    /// <param name="includingTrackbacks">Indicates if trackback comments should be included</param>
    public static int GetBlogCommentsCount(object postId, object postAliasPath, bool includingTrackbacks)
    {
        int             docId       = ValidationHelper.GetInteger(postId, 0);
        string          aliasPath   = ValidationHelper.GetString(postAliasPath, "");
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // There has to be the current site
        if (CMSContext.CurrentSite == null)
        {
            throw new Exception("[BlogFunctions.GetBlogCommentsCount]: There is no current site!");
        }

        bool isOwner = false;

        // Is user authorized to manage comments?
        bool     selectOnlyPublished = (CMSContext.ViewMode == ViewModeEnum.LiveSite);
        TreeNode blogNode            = BlogHelper.GetParentBlog(aliasPath, CMSContext.CurrentSiteName, selectOnlyPublished);

        if (blogNode != null)
        {
            isOwner = (currentUser.UserID == ValidationHelper.GetInteger(blogNode.GetValue("NodeOwner"), 0));
        }

        bool isUserAuthorized = (currentUser.IsAuthorizedPerResource("cms.blog", "Manage") || isOwner || BlogHelper.IsUserBlogModerator(currentUser.UserName, blogNode));

        // Get post comments
        return(BlogCommentInfoProvider.GetPostCommentsCount(docId, !isUserAuthorized, isUserAuthorized, includingTrackbacks));
    }
コード例 #2
0
    /// <summary>
    /// Loads the data to the control.
    /// </summary>
    protected void LoadData()
    {
        SetContext();
        string   text = string.Empty;
        TreeNode node = null;

        if (Path == string.Empty)
        {
            node = CMSContext.CurrentDocument;
        }
        else
        {
            // Try to get data from cache
            using (CachedSection <TreeNode> cs = new CachedSection <TreeNode>(ref node, this.CacheMinutes, true, this.CacheItemName, "pagedtext", CacheHelper.GetBaseCacheKey(this.CheckPermissions, false), SiteName, Path, CultureCode, CombineWithDefaultCulture, SelectOnlyPublished))
            {
                if (cs.LoadData)
                {
                    // Ensure that the path is only for one single document
                    Path = CMSContext.CurrentResolver.ResolvePath(Path.TrimEnd('%').TrimEnd('/'));
                    node = TreeHelper.GetDocument(SiteName, Path, CultureCode, CombineWithDefaultCulture, null, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser);

                    // Prepare the cache dependency
                    if (cs.Cached)
                    {
                        cs.CacheDependency = GetCacheDependency();
                        cs.Data            = node;
                    }
                }
            }
        }

        if ((node != null) && (ColumnName != string.Empty))
        {
            text = ValidationHelper.GetString(node.GetValue(ColumnName), string.Empty);

            if (text != string.Empty)
            {
                textPager.TextSource = text;
                textPager.ReloadData(false);
            }
            else
            {
                Visible = false;
            }
        }
        else
        {
            Visible = false;
        }

        ReleaseContext();
    }
コード例 #3
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (!IsCallback)
        {
            string action = QueryHelper.GetString("action", "");

            switch (action.ToLower())
            {
            case "movenode":
            case "movenodeposition":
            case "movenodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.movedoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlemove.png");
            }
            break;

            case "copynode":
            case "copynodeposition":
            case "copynodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.copydoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlecopy.png");
            }
            break;

            case "linknode":
            case "linknodeposition":
            case "linknodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.linkdoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlelink.png");
            }
            break;
            }

            TreeNode node = opDrag.Node;
            if (node != null)
            {
                string documentName = ValidationHelper.GetString(node.GetValue("DocumentLastVersionName"), node.DocumentName);
                CurrentMaster.Title.TitleText += " \"" + HTMLHelper.HTMLEncode(documentName) + "\"";
            }

            ((Panel)CurrentMaster.PanelBody.FindControl("pnlContent")).CssClass = string.Empty;
        }
    }
コード例 #4
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            calItems.StopProcessing = true;
        }
        else
        {
            calItems.ControlContext = repEvent.ControlContext = ControlContext;

            // Calendar properties
            calItems.CacheItemName = CacheItemName;

            calItems.CacheDependencies         = CacheDependencies;
            calItems.CacheMinutes              = CacheMinutes;
            calItems.CheckPermissions          = CheckPermissions;
            calItems.ClassNames                = ClassNames;
            calItems.CombineWithDefaultCulture = CombineWithDefaultCulture;

            calItems.CultureCode         = CultureCode;
            calItems.MaxRelativeLevel    = MaxRelativeLevel;
            calItems.OrderBy             = OrderBy;
            calItems.WhereCondition      = WhereCondition;
            calItems.Columns             = Columns;
            calItems.Path                = Path;
            calItems.SelectOnlyPublished = SelectOnlyPublished;
            calItems.SiteName            = SiteName;
            calItems.FilterName          = FilterName;

            calItems.RelationshipName           = RelationshipName;
            calItems.RelationshipWithNodeGuid   = RelationshipWithNodeGuid;
            calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide;

            calItems.TransformationName        = TransformationName;
            calItems.NoEventTransformationName = NoEventTransformationName;

            calItems.DayField             = DayField;
            calItems.EventEndField        = EventEndField;
            calItems.HideDefaultDayNumber = HideDefaultDayNumber;

            calItems.TodaysDate = CMSContext.ConvertDateTime(DateTime.Now, this);

            bool detail = false;

            // If calendar event path is defined event is loaded in accordance to the selected path
            string eventPath = QueryHelper.GetString("CalendarEventPath", null);
            if (!String.IsNullOrEmpty(eventPath))
            {
                detail        = true;
                repEvent.Path = eventPath;

                // Set selected date to specific document
                TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser);
                if (node != null)
                {
                    object value = node.GetValue(DayField);
                    if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                    {
                        calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    }
                }
            }

            // By default select current event from current document value
            PageInfo currentPage = CMSContext.CurrentPageInfo;
            if ((currentPage != null) && (ClassNames.ToLower().Contains(currentPage.ClassName.ToLower())))
            {
                detail        = true;
                repEvent.Path = currentPage.NodeAliasPath;

                // Set selected date to current document
                object value = CMSContext.CurrentDocument.GetValue(DayField);
                if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                {
                    calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    // Get name of coupled class ID column
                    string idColumn = CMSContext.CurrentDocument.CoupledClassIDColumn;
                    if (!string.IsNullOrEmpty(idColumn))
                    {
                        // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar
                        calItems.SelectedItemIDColumn = idColumn;
                        calItems.SelectedItemID       = ValidationHelper.GetInteger(CMSContext.CurrentDocument.GetValue(idColumn), 0);
                    }
                }
            }

            if (detail)
            {
                // Setup the detail repeater
                repEvent.Visible        = true;
                repEvent.StopProcessing = false;

                repEvent.SelectedItemTransformationName = EventDetailTransformation;
                repEvent.ClassNames = ClassNames;
                repEvent.Columns    = Columns;

                if (!String.IsNullOrEmpty(CacheItemName))
                {
                    repEvent.CacheItemName = CacheItemName + "|detail";
                }

                repEvent.CacheDependencies         = CacheDependencies;
                repEvent.CacheMinutes              = CacheMinutes;
                repEvent.CheckPermissions          = CheckPermissions;
                repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture;

                repEvent.CultureCode = CultureCode;

                repEvent.SelectOnlyPublished = SelectOnlyPublished;
                repEvent.SiteName            = SiteName;

                repEvent.WhereCondition = WhereCondition;
            }
        }
    }