示例#1
0
    protected object inboxGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLower())
        {
        case "messagesendernickname":
        case "messagesubject":
            // Avoid XSS
            return(HTMLHelper.HTMLEncode(Convert.ToString(parameter)));

        case "messagesent":
            if (currentUserInfo == null)
            {
                currentUserInfo = CMSContext.CurrentUser;
            }
            if (currentSiteInfo == null)
            {
                currentSiteInfo = CMSContext.CurrentSite;
            }
            DateTime currentDateTime = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
            if (IsLiveSite)
            {
                return(CMSContext.ConvertDateTime(currentDateTime, this));
            }
            else
            {
                return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(currentDateTime, currentUserInfo, currentSiteInfo, out usedTimeZone));
            }
        }
        return(parameter);
    }
示例#2
0
    /// <summary>
    /// Rloads the form data.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();

        if (this.mMessageID > 0)
        {
            messageInfo = BoardMessageInfoProvider.GetBoardMessageInfo(this.mMessageID);
            if (messageInfo != null)
            {
                // Check whether edited message belongs to a board from current site
                if ((Board != null) && (Board.BoardSiteID != CMSContext.CurrentSiteID))
                {
                    EditedObject = null;
                }

                // Set textfields and checkboxes
                txtEmail.Text       = messageInfo.MessageEmail;
                txtMessage.Text     = messageInfo.MessageText;
                txtURL.Text         = messageInfo.MessageURL;
                txtUserName.Text    = messageInfo.MessageUserName;
                chkApproved.Checked = messageInfo.MessageApproved;
                chkSpam.Checked     = messageInfo.MessageIsSpam;
                lblInserted.Text    = CMSContext.ConvertDateTime(messageInfo.MessageInserted, this).ToString();
            }
        }
        else
        {
            ClearForm();
        }
    }
示例#3
0
    /// <summary>
    /// OnPreview handler.
    /// </summary>
    protected void forumEdit_OnPreview(object sender, EventArgs e)
    {
        // Preview title
        ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Preview");
        // Display placeholder
        plcPreview.Visible = true;

        // Post properties
        ForumPostInfo fpi = sender as ForumPostInfo;

        if (fpi != null)
        {
            ltrAvatar.Text   = AvatarImage(fpi);
            ltrSubject.Text  = HTMLHelper.HTMLEncode(fpi.PostSubject);
            ltrText.Text     = ResolvePostText(fpi.PostText);
            ltrUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName);
            ltrTime.Text     = CMSContext.ConvertDateTime(fpi.PostTime, this).ToString();

            BadgeInfo bi            = null;
            string    badgeName     = null;
            string    badgeImageUrl = null;

            bi = BadgeInfoProvider.GetBadgeInfo(CMSContext.CurrentUser.UserSettings.UserBadgeID);
            if (bi != null)
            {
                badgeName     = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL);
            }

            ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) +
                            GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge);
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.IsAdHocForum)
        {
            plcHeader.Visible = false;
        }

        // Check whether subscription is for forum or post
        if (ForumContext.CurrentSubscribeThread == null)
        {
            ltrTitle.Text = GetString("ForumSubscription.SubscribeForum");
        }
        else
        {
            plcPreview.Visible = true;

            ltrTitle.Text = GetString("ForumSubscription.SubscribePost");

            ltrAvatar.Text   = AvatarImage(ForumContext.CurrentSubscribeThread);
            ltrSubject.Text  = HTMLHelper.HTMLEncode(ForumContext.CurrentSubscribeThread.PostSubject);
            ltrText.Text     = ResolvePostText(ForumContext.CurrentSubscribeThread.PostText);
            ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentSubscribeThread.PostUserName);
            ltrTime.Text     = CMSContext.ConvertDateTime(ForumContext.CurrentSubscribeThread.PostTime, this).ToString();
        }
    }
示例#5
0
    protected string GetDateRead(object messageReadDate)
    {
        DateTime messageRead = ValidationHelper.GetDateTime(messageReadDate, DateTimeHelper.ZERO_TIME);

        if (currentUserInfo == null)
        {
            currentUserInfo = CMSContext.CurrentUser;
        }
        if (currentSiteInfo == null)
        {
            currentSiteInfo = CMSContext.CurrentSite;
        }
        DateTime currentDateTime = ValidationHelper.GetDateTime(messageReadDate, DateTimeHelper.ZERO_TIME);

        if (messageRead != DateTimeHelper.ZERO_TIME)
        {
            if (IsLiveSite)
            {
                return(CMSContext.ConvertDateTime(currentDateTime, this).ToString());
            }
            else
            {
                return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(currentDateTime, currentUserInfo, currentSiteInfo, out usedTimeZone));
            }
        }
        else
        {
            return(GetString("Messaging.OutboxMessageUnread"));
        }
    }
示例#6
0
    /// <summary>
    /// Loads the data.
    /// </summary>
    private void LoadData()
    {
        // Get the forum post
        ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0));
        ForumInfo     fi  = null;

        if (fpi != null)
        {
            fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
        }
        else
        {
            return;
        }

        if (fi.ForumEnableAdvancedImage)
        {
            ltrText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
        }
        else
        {
            ltrText.AllowedControls = "none";
        }

        // Display converted datetime for live site
        lblDate.Text = CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString();

        lblUser.Text    = HTMLHelper.HTMLEncode(fpi.PostUserName);
        lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject);

        DiscussionMacroHelper dmh = new DiscussionMacroHelper();

        dmh.EnableBold          = fi.ForumEnableFontBold;
        dmh.EnableItalics       = fi.ForumEnableFontItalics;
        dmh.EnableStrikeThrough = fi.ForumEnableFontStrike;
        dmh.EnableUnderline     = fi.ForumEnableFontUnderline;
        dmh.EnableCode          = fi.ForumEnableCodeSnippet;
        dmh.EnableColor         = fi.ForumEnableFontColor;
        dmh.EnableImage         = fi.ForumEnableImage || fi.ForumEnableAdvancedImage;
        dmh.EnableQuote         = fi.ForumEnableQuote;
        dmh.EnableURL           = fi.ForumEnableURL || fi.ForumEnableAdvancedURL;
        dmh.MaxImageSideSize    = fi.ForumImageMaxSideSize;
        dmh.QuotePostText       = GetString("DiscussionMacroResolver.QuotePostText");

        if (fi.ForumHTMLEditor)
        {
            dmh.EncodeText = false;
            dmh.ConvertLineBreaksToHTML = false;
        }
        else
        {
            dmh.EncodeText = true;
            dmh.ConvertLineBreaksToHTML = true;
        }

        // Resolve the macros and display the post text
        ltrText.Text = dmh.ResolveMacros(fpi.PostText);
    }
示例#7
0
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        bool approve = false;

        switch (sourceName.ToLower())
        {
        case "messageapproved":
            return(UniGridFunctions.ColoredSpanYesNo(parameter));

        case "messageisspam":
            return(UniGridFunctions.ColoredSpanYesNoReversed(parameter));

        case "messagetext":
            string text = parameter.ToString();
            if (text.Length > 30)
            {
                text = text.Substring(0, 30) + "...";
            }
            return(HTMLHelper.HTMLEncode(text));

        case "messagetooltip":
            return(HTMLHelper.HTMLEncodeLineBreaks(parameter.ToString()));

        case "edit":
            ImageButton editButton = ((ImageButton)sender);
            int         boardID    = ValidationHelper.GetInteger(((DataRowView)((GridViewRow)parameter).DataItem).Row["BoardID"], 0);

            string url = "~/CMSModules/MessageBoards/Tools/Messages/Message_Edit.aspx";
            if (this.IsLiveSite)
            {
                url = "~/CMSModules/MessageBoards/CMSPages/Message_Edit.aspx";
            }

            editButton.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl(((this.EditPageUrl == "") ? url : this.EditPageUrl)) +
                                       "?messageboardid=" + boardID + "&messageId=" + editButton.CommandArgument + "', 'MessageEdit', 500, 400); return false;";
            break;

        case "approve":
            approve = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["MessageApproved"], false);
            if (!approve)
            {
                ImageButton button = ((ImageButton)sender);
                button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Approve.png");
                button.ToolTip  = GetString("general.approve");
            }
            else
            {
                ImageButton button = ((ImageButton)sender);
                button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Reject.png");
                button.ToolTip  = GetString("general.reject");
            }
            break;

        case "messageinserted":
            return(CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(parameter, DataHelper.DATETIME_NOT_SELECTED), this).ToString());
        }
        return(parameter);
    }
示例#8
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public void LoadData()
    {
        if (this.mCommentsDataRow != null)
        {
            // Load comment data
            BlogCommentInfo bci = new BlogCommentInfo(this.mCommentsDataRow);
            if (bci != null)
            {
                this.CommentID = bci.CommentID;

                // Set user picture
                if (this.BlogpPoperties.EnableUserPictures)
                {
                    userPict.UserID           = bci.CommentUserID;
                    userPict.Width            = this.BlogpPoperties.UserPictureMaxWidth;
                    userPict.Height           = this.BlogpPoperties.UserPictureMaxHeight;
                    userPict.Visible          = true;
                    userPict.RenderOuterDiv   = true;
                    userPict.OuterDivCSSClass = "CommentUserPicture";
                }
                else
                {
                    userPict.Visible = false;
                }

                if (!String.IsNullOrEmpty(bci.CommentUrl))
                {
                    lnkName.Text        = HTMLHelper.HTMLEncode(bci.CommentUserName);
                    lnkName.NavigateUrl = bci.CommentUrl;
                    lblName.Visible     = false;
                }
                else
                {
                    lblName.Text    = HTMLHelper.HTMLEncode(bci.CommentUserName);
                    lnkName.Visible = false;
                }

                lblText.Text = GetHTMLEncodedCommentText(bci);
                lblDate.Text = CMSContext.ConvertDateTime(bci.CommentDate, this).ToString();

                string url = "~/CMSModules/Blogs/Controls/Comment_Edit.aspx";
                if (this.IsLiveSite)
                {
                    url = "~/CMSModules/Blogs/CMSPages/Comment_Edit.aspx";
                }

                lnkEdit.OnClientClick = "EditComment('" + ResolveUrl(url) + "?commentID=" + this.CommentID + "');return false;";

                // Initialize report abuse
                ucInlineAbuseReport.ReportTitle             = CMS.GlobalHelper.ResHelper.GetString("BlogCommentDetail.AbuseReport", CMS.SettingsProvider.SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCulture")) + bci.CommentText;
                ucInlineAbuseReport.ReportObjectID          = this.CommentID;
                ucInlineAbuseReport.CMSPanel.Roles          = AbuseReportRoles;
                ucInlineAbuseReport.CMSPanel.SecurityAccess = AbuseReportSecurityAccess;
                ucInlineAbuseReport.CMSPanel.OwnerID        = AbuseReportOwnerID;
            }
        }
    }
    /// <summary>
    /// Add timezone settings to given time. Return empty string if no time set.
    /// </summary>
    /// <param name="time">Time to convert</param>
    protected string GetConvertedTime(object time)
    {
        DateTime dt = ValidationHelper.GetDateTime(time, DateTimeHelper.ZERO_TIME);

        if (dt == DateTimeHelper.ZERO_TIME)
        {
            return(String.Empty);
        }
        return(Convert.ToString(CMSContext.ConvertDateTime(dt, this)));
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CopyValues(forumEdit);

        if (IsAdHocForum)
        {
            plcHeader.Visible = false;
        }

        forumEdit.OnPreview            += forumEdit_OnPreview;
        forumEdit.OnModerationRequired += new EventHandler(forumEdit_OnModerationRequired);

        // Check whether subscription is for forum or post
        if (ForumContext.CurrentReplyThread == null)
        {
            ltrTitle.Text = GetString("Forums_ForumNewPost_Header.NewThread");

            if (ForumContext.CurrentPost != null && ForumContext.CurrentMode == ForumMode.Edit)
            {
                ltrTitle.Text = GetString("Forums_ForumNewPost_Header.EditPost");
            }
        }
        else
        {
            plcPreview.Visible = true;
            ltrTitle.Text      = GetString("Forums_ForumNewPost_Header.Reply");
            ltrAvatar.Text     = AvatarImage(ForumContext.CurrentReplyThread);
            ltrSubject.Text    = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostSubject);
            ltrText.Text       = ResolvePostText(ForumContext.CurrentReplyThread.PostText);
            ltrUserName.Text   = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName);
            ltrTime.Text       = CMSContext.ConvertDateTime(ForumContext.CurrentReplyThread.PostTime, this).ToString();

            UserSettingsInfo usi           = UserSettingsInfoProvider.GetUserSettingsInfoByUser(ForumContext.CurrentReplyThread.PostUserID);
            BadgeInfo        bi            = null;
            string           badgeName     = null;
            string           badgeImageUrl = null;

            if (usi != null)
            {
                bi = BadgeInfoProvider.GetBadgeInfo(usi.UserBadgeID);
                if (bi != null)
                {
                    badgeName     = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                    badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL);
                }
            }

            ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) +
                            GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge);
        }
    }
    protected object gridBoards_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName)
        {
        case "enabled":
            bool enabled = ValidationHelper.GetBoolean(parameter, false);

            return(UniGridFunctions.ColoredSpanYesNo(enabled));

        case "opened":
            bool opened = IsBoardOpened((DataRowView)parameter);

            return(UniGridFunctions.ColoredSpanYesNo(opened));

        case "moderated":
            bool moderated = ValidationHelper.GetBoolean(parameter, false);

            return(UniGridFunctions.ColoredSpanYesNo(moderated));

        case "document":
            DataRowView dr = parameter as DataRowView;
            if (dr != null)
            {
                // If the document path is empty alter it with the default '/'
                string   documentPath = ValidationHelper.GetString(dr["DocumentNamePath"], "");
                int      siteId       = ValidationHelper.GetInteger(dr["NodeSiteID"], 0);
                SiteInfo site         = SiteInfoProvider.GetSiteInfo(siteId);
                if (string.IsNullOrEmpty(documentPath))
                {
                    documentPath = "/";
                }

                if (site.Status == SiteStatusEnum.Running)
                {
                    // Make url for site in form 'http(s)://sitedomain/application/cmsdesk'.
                    string url = URLHelper.Url.Scheme + "://" + site.DomainName + ResolveUrl("~/cmsdesk/default.aspx") + "?section=content&nodeid=" + ValidationHelper.GetInteger(dr["NodeID"], 0) +
                                 "&culture=" + ValidationHelper.GetString(dr["DocumentCulture"], "");
                    return("<a href=\"" + url + "\" target=\"_blank\">" + HTMLHelper.HTMLEncode(documentPath) + "</a>");
                }
            }
            return("");

        case "lastpost":
            return(CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(parameter, DataHelper.DATETIME_NOT_SELECTED), this).ToString());

        default:
            return("");
        }
    }
示例#12
0
    /// <summary>
    /// Returns the approval text in format "date (approved by user full name)".
    /// </summary>
    /// <param name="date">Date time</param>
    /// <param name="userId">User id</param>
    private string GetApprovalInfoText(DateTime date, int userId)
    {
        string retval = "";

        if (date != DataHelper.DATETIME_NOT_SELECTED)
        {
            // Get current time
            retval = CMSContext.ConvertDateTime(date, this).ToString();

            UserInfo ui = UserInfoProvider.GetUserInfo(userId);
            if (ui != null)
            {
                // Add user's full name
                retval += " (" + HTMLHelper.HTMLEncode(ui.FullName) + ")";
            }
        }
        return(retval);
    }
示例#13
0
    /// <summary>
    /// Fills the data into form for specified Group member.
    /// </summary>
    private void HandleExistingMember(GroupMemberInfo gmi)
    {
        if (gmi != null)
        {
            // Fill controls with data from existing user
            int      userId = ValidationHelper.GetInteger(gmi.MemberUserID, 0);
            UserInfo ui     = UserInfoProvider.GetUserInfo(userId);
            if (ui != null)
            {
                this.lblFullName.Text = HTMLHelper.HTMLEncode(ui.FullName);
            }

            this.txtComment.Text        = gmi.MemberComment;
            this.lblMemberApproved.Text = GetApprovalInfoText(gmi.MemberApprovedWhen, gmi.MemberApprovedByUserID);
            this.lblMemberRejected.Text = GetApprovalInfoText(gmi.MemberRejectedWhen, gmi.MemberApprovedByUserID);
            this.lblMemberJoined.Text   = CMSContext.ConvertDateTime(gmi.MemberJoined, this).ToString();
        }
    }
示例#14
0
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName)
        {
        case "reject":
            if (sender is ImageButton)
            {
                // Get action button
                ImageButton rejectBtn = (ImageButton)sender;
                // Get full row view
                DataRowView drv = UniGridFunctions.GetDataRowView((DataControlFieldCell)rejectBtn.Parent);
                // Add custom reject action
                rejectBtn.Attributes["onclick"] = "return FM_Reject_" + ClientID + "('" + drv["FriendID"] + "',null,'" + DialogUrl + "');";
                return(rejectBtn);
            }
            else
            {
                return(string.Empty);
            }

        case "friendapprovedwhen":
            if (currentUserInfo == null)
            {
                currentUserInfo = CMSContext.CurrentUser;
            }
            if (currentSiteInfo == null)
            {
                currentSiteInfo = CMSContext.CurrentSite;
            }
            DateTime currentDateTime = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
            if (IsLiveSite)
            {
                return(CMSContext.ConvertDateTime(currentDateTime, this));
            }
            else
            {
                return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(currentDateTime, currentUserInfo, currentSiteInfo, out usedTimeZone));
            }

        case "formattedusername":
            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), this.IsLiveSite)));
        }
        return(parameter);
    }
示例#15
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        // In design mode is pocessing of control stoped
        if (StopProcessing)
        {
            calItems.StopProcessing = true;
        }
        else
        {
            // Set properties from Webpart form
            calItems.CacheItemName             = CacheItemName;
            calItems.CacheDependencies         = CacheDependencies;
            calItems.CacheMinutes              = CacheMinutes;
            calItems.CheckPermissions          = CheckPermissions;
            calItems.ClassNames                = ClassNames;
            calItems.CategoryName              = CategoryName;
            calItems.CombineWithDefaultCulture = CombineWithDefaultCulture;

            calItems.CultureCode                = CultureCode;
            calItems.MaxRelativeLevel           = MaxRelativeLevel;
            calItems.OrderBy                    = OrderBy;
            calItems.Path                       = Path;
            calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide;

            calItems.RelationshipName         = RelationshipName;
            calItems.RelationshipWithNodeGuid = RelationshipWithNodeGuid;
            calItems.SelectOnlyPublished      = SelectOnlyPublished;
            calItems.SiteName = SiteName;

            calItems.TransformationName = TransformationName;
            calItems.WhereCondition     = WhereCondition;
            calItems.DayField           = DayField;
            calItems.FilterName         = FilterName;

            calItems.SelectedColumns = Columns;

            calItems.HideDefaultDayNumber     = HideDefaultDayNumber;
            calItems.DisplayOnlySingleDayItem = DisplayOnlySingleDayItem;

            calItems.NoEventTransformationName = NoEventTransformationName;
            calItems.TodaysDate = CMSContext.ConvertDateTime(DateTime.Now, this);
        }
    }
    private void GridView_DataBound(object sender, EventArgs e)
    {
        //convert boolean values from DB to user-friendly information strings in the list
        for (int i = 0; i < gridElem.GridView.Rows.Count; i++)
        {
            // Date time string
            string dateTime = String.Empty;

            // Change timezone for live site
            DateTime dt = CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(gridElem.GridView.Rows[i].Cells[6].Text, DateTimeHelper.ZERO_TIME), this);
            if (dt != DateTimeHelper.ZERO_TIME)
            {
                dateTime = dt.ToString();
            }

            // Set value to the grid
            gridElem.GridView.Rows[i].Cells[6].Text = dateTime;
        }
    }
    /// <summary>
    /// Fill form with the comment data.
    /// </summary>
    protected void LoadCommentData()
    {
        // Get comment info from database
        BlogCommentInfo bci = BlogCommentInfoProvider.GetBlogCommentInfo(mCommentId);

        if (bci != null)
        {
            txtName.Text        = bci.CommentUserName;
            txtUrl.Text         = bci.CommentUrl;
            txtComments.Text    = bci.CommentText;
            txtEmail.Text       = bci.CommentEmail;
            chkApproved.Checked = bci.CommentApproved;
            chkSpam.Checked     = bci.CommentIsSpam;

            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && (CMSContext.CurrentUser != null))
            {
                lblInsertedDate.Text = CMSContext.ConvertDateTime(bci.CommentDate, this).ToString();
            }
            else
            {
                lblInsertedDate.Text = bci.CommentDate.ToString();
            }
        }
    }
示例#18
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;
            }
        }
    }
示例#19
0
    /// <summary>
    /// Handles UniGrid's OnExternalDataBound event.
    /// </summary>
    /// <param name="sender">Sender object (image button if it is an external databoud for action button)</param>
    /// <param name="sourceName">External source name of the column specified in the grid XML</param>
    /// <param name="parameter">Source parameter (original value of the field)</param>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = null;

        switch (sourceName.ToLower())
        {
        case "projectdisplayname":
            string displayname = parameter.ToString();
            if (displayname.Length > MAX_TITLE_LENGTH)
            {
                return("<span title=\"" + HTMLHelper.HTMLEncode(displayname) + "\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayname, MAX_TITLE_LENGTH)) + "</span>");
            }
            else
            {
                return(HTMLHelper.HTMLEncode(displayname));
            }

        case "projectprogress":
            row = (DataRowView)parameter;
            int progress = ValidationHelper.GetInteger(row["ProjectProgress"], 0);
            return(ProjectTaskInfoProvider.GenerateProgressHtml(progress, true));

        case "statusicon":
            row = (DataRowView)parameter;
            string statusText = ValidationHelper.GetString(row["ProjectStatus"], "");
            statusText = HTMLHelper.HTMLEncode(statusText);
            string iconUrl = ValidationHelper.GetString(row["ProjectStatusIcon"], "");
            // Get row color
            rowColor = ValidationHelper.GetString(row["ProjectStatusColor"], "");

            if (!String.IsNullOrEmpty(iconUrl))
            {
                return("<div style=\"text-align:center;\"><img alt=\"" + statusText + "\" title=\"" + statusText + "\" src=\"" + URLHelper.ResolveUrl(HTMLHelper.HTMLEncode(iconUrl)) + "\" style=\"max-width:50px; max-height: 50px;\"  /></div>");
            }
            return("");

        case "ownerfullname":
            row = (DataRowView)parameter;
            string userName = ValidationHelper.GetString(row["ProjectOwnerUserName"], String.Empty);
            string fullName = ValidationHelper.GetString(row["ProjectOwnerFullName"], String.Empty);
            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, fullName, IsLiveSite)));

        case "projectdeadline":
            DateTime dt = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
            if (dt == DateTimeHelper.ZERO_TIME)
            {
                return(String.Empty);
            }
            return(CMSContext.ConvertDateTime(dt, this));

        case "linkeddisplayname":
            row = (DataRowView)parameter;
            string displayName = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["ProjectDisplayName"], String.Empty));
            string path        = ValidationHelper.GetString(row["NodeAliasPath"], String.Empty);
            int    projectId   = ValidationHelper.GetInteger(row["ProjectID"], 0);
            if (!String.IsNullOrEmpty(path))
            {
                string target = String.Empty;
                if (!String.IsNullOrEmpty(this.ProjectLinkTarget))
                {
                    target = " target=\"" + this.ProjectLinkTarget + "\" ";
                }

                path = URLHelper.ResolveUrl(CMSContext.GetUrl(path));
                return(String.Format("<a href=\"{1}?projectid={2}\" {3} title=\"{4}\">{0}</a>", TextHelper.LimitLength(displayName, MAX_TITLE_LENGTH), path, projectId, target, HTMLHelper.HTMLEncode(displayName)));
            }
            else
            {
                return(displayName);
            }

        case "editlinkdisplayname":
            row = (DataRowView)parameter;
            string editDisplayName = ValidationHelper.GetString(row["ProjectDisplayName"], String.Empty);
            editDisplayName = TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH);
            int editProjectTaskID = ValidationHelper.GetInteger(row["ProjectID"], 0);
            return(String.Format("<a href=\"javascript:" + ControlsHelper.GetPostBackEventReference(this, editProjectTaskID.ToString()) + "\" title=\"{0}\">{1}</a>", HTMLHelper.HTMLEncode(editDisplayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH))));
        }

        return(parameter);
    }
示例#20
0
    /// <summary>
    /// OnPrerender check whether.
    /// </summary>
    protected override void OnPreRender(EventArgs e)
    {
        postTreeElem.Selected = ValidationHelper.GetInteger(hdnSelected.Value, SelectedPost);
        if ((mSelectedPost == 0) && (RequestHelper.IsAJAXRequest()))
        {
            mSelectedPost = postTreeElem.Selected;
        }

        if (mSelectedPost > 0)
        {
            ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(mSelectedPost);
            if ((fpi != null) && (ForumContext.CurrentForum != null) && (fpi.PostForumID == ForumContext.CurrentForum.ForumID))
            {
                plcPostPreview.Visible = true;
                ltlPostSubject.Text    = HTMLHelper.HTMLEncode(fpi.PostSubject);
                ltlPostText.Text       = ResolvePostText(fpi.PostText);
                ltlSignature.Text      = GetSignatureArea(fpi, "<div class=\"SignatureArea\">", "</div>");
                ltlPostTime.Text       = CMSContext.ConvertDateTime(fpi.PostTime, this).ToString();
                ltlPostUser.Text       = "<span class=\"PostUserName\">" + GetUserName(fpi) + "</span>";
                ltlAvatar.Text         = AvatarImage(fpi);
                mUnapproved            = !fpi.PostApproved ? " Unapproved" : "";

                if (ForumContext.CurrentForum.ForumEnableAdvancedImage)
                {
                    ltlPostText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
                }
                else
                {
                    ltlPostText.AllowedControls = "none";
                }

                attachmentDisplayer.ClearData();
                attachmentDisplayer.PostID = fpi.PostId;
                attachmentDisplayer.PostAttachmentCount = fpi.PostAttachmentCount;
                attachmentDisplayer.ReloadData();

                #region "Badge"

                if (this.DisplayBadgeInfo)
                {
                    if (fpi.PostUserID > 0)
                    {
                        UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID);
                        if ((ui != null) && (!ui.IsPublic()))
                        {
                            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID);
                            if (bi != null)
                            {
                                ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>";
                                if (!String.IsNullOrEmpty(bi.BadgeImageURL))
                                {
                                    ltlBadge.Text += "<div class=\"BadgeImage\"><img alt=\"" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "\" src=\"" + ResolveUrl(HTMLHelper.HTMLEncode(bi.BadgeImageURL)) + "\" /></div>";
                                }
                            }
                        }
                    }

                    // Set public badge if no badge is set
                    if (String.IsNullOrEmpty(ltlBadge.Text))
                    {
                        ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>";
                    }
                }

                #endregion

                #region "Post actions"

                // Get the parent thread ID (for reply and quote)
                int threadId = ForumPostInfoProvider.GetPostRootFromIDPath(fpi.PostIDPath);

                ltlReply.Text     = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.replyLinkText"), "PostActionLink", ForumActionType.Reply, threadId);
                ltlQuote.Text     = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.quoteLinkText"), "PostActionLink", ForumActionType.Quote, threadId);
                ltlSubscribe.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.Subscribe"), "PostActionLink", ForumActionType.SubscribeToPost, threadId);

                ltlAnswer.Text    = GetLink(fpi, GetString("general.yes"), "ActionLink", ForumActionType.IsAnswer);
                ltlNotAnswer.Text = GetLink(fpi, GetString("general.no"), "ActionLink", ForumActionType.IsNotAnswer);

                if (ltlAnswer.Text != String.Empty)
                {
                    ltlWasHelpful.Text = GetString("Forums_WebInterface_ForumPost.Washelpful") + "&nbsp;";
                    ltlAnswer.Text    += "|";
                }

                ltlAddPostToFavorites.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.AddPostToFavorites"), "ActionLink", ForumActionType.AddPostToFavorites);

                ltlDelete.Text      = GetLink(fpi, GetString("general.delete"), "ActionLink", ForumActionType.Delete);
                ltlEdit.Text        = GetLink(fpi, GetString("general.edit"), "ActionLink", ForumActionType.Edit);
                ltlAttachments.Text = GetLink(fpi, GetString("general.attachments"), "ActionLink", ForumActionType.Attachment);

                #endregion

                #region "Extended actions"

                if ((this.EnableFriendship || this.EnableMessaging) && (fpi.PostUserID > 0))
                {
                    this.GenerateActionScripts = true;

                    ltlActions.Text = "<div class=\"PostExtendedActions\">";

                    if (this.EnableMessaging)
                    {
                        ltlActions.Text += "<a class=\"SendMessage\" onclick=\"PrivateMessage(" + fpi.PostUserID + "); return false;\" title=\"" + GetString("sendmessage.sendmessage") + "\"  href=\"#\"><span>" + GetString("sendmessage.sendmessage") + "</span></a>";
                    }

                    if (this.EnableFriendship)
                    {
                        ltlActions.Text += "<a class=\"Friendship\" onclick=\"FriendshipRequest(" + fpi.PostUserID + "); return false;\" title=\"" + GetString("friends.requestfriendship") + "\" href=\"#\"><span>" + GetString("friends.requestfriendship") + "</span></a>";
                    }

                    ltlActions.Text += "</div>";
                }

                #endregion

                // Hide separators
                if ((ltlReply.Text == "") || (ltlReply.Text != "" && ltlQuote.Text == ""))
                {
                    plcFirstSeparator.Visible = false;
                }

                if ((ltlSubscribe.Text == "") || (ltlSubscribe.Text != "" && ltlQuote.Text == ""))
                {
                    plcSecondSeparator.Visible = false;
                }

                if (ltlReply.Text != "" && ltlSubscribe.Text != "")
                {
                    plcFirstSeparator.Visible = true;
                }

                pnlManage.Visible = (this.EnableOnSiteManagement && (ForumContext.CurrentForum != null)) ? ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, this.CommunityGroupID) : false;
                if (pnlManage.Visible)
                {
                    ltlApprove.Text    = GetLink(fpi, GetString("general.approve"), "ActionLink", ForumActionType.Appprove);
                    ltlApproveAll.Text = GetLink(fpi, GetString("forums.approveall"), "ActionLink", ForumActionType.ApproveAll);
                    ltlReject.Text     = GetLink(fpi, GetString("general.reject"), "ActionLink", ForumActionType.Reject);
                    ltlRejectAll.Text  = GetLink(fpi, GetString("forums.rejectall"), "ActionLink", ForumActionType.RejectAll);
                    ltlSplit.Text      = GetLink(fpi, GetString("forums.splitthread"), "ActionLink", ForumActionType.SplitThread);
                    ltlMove.Text       = GetLink(fpi, GetString("forums.movethread"), "ActionLink", ForumActionType.MoveToTheOtherForum, threadId);
                }
            }
        }
        else
        {
            plcPostPreview.Visible = false;
        }

        if (ControlsHelper.IsInUpdatePanel(this))
        {
            ControlsHelper.GetUpdatePanel(this).Update();
        }

        base.OnPreRender(e);
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    public void LoadData()
    {
        if (mCommentsDataRow != null)
        {
            // Load comment data
            BlogCommentInfo bci = new BlogCommentInfo(mCommentsDataRow);
            if (bci != null)
            {
                CommentID = bci.CommentID;

                // Set user picture
                if (BlogpPoperties.EnableUserPictures)
                {
                    userPict.UserID           = bci.CommentUserID;
                    userPict.Width            = BlogpPoperties.UserPictureMaxWidth;
                    userPict.Height           = BlogpPoperties.UserPictureMaxHeight;
                    userPict.Visible          = true;
                    userPict.RenderOuterDiv   = true;
                    userPict.OuterDivCSSClass = "CommentUserPicture";

                    // Gravatar support
                    string avType = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSAvatarType");
                    if (avType == AvatarInfoProvider.USERCHOICE)
                    {
                        UserInfo ui = UserInfoProvider.GetUserInfo(bci.CommentUserID);
                        if (ui != null)
                        {
                            avType = ui.UserSettings.UserAvatarType;
                        }
                        else
                        {
                            avType = AvatarInfoProvider.GRAVATAR;
                        }
                    }

                    userPict.UserEmail      = bci.CommentEmail;
                    userPict.UserAvatarType = avType;
                }
                else
                {
                    userPict.Visible = false;
                }

                if (!String.IsNullOrEmpty(bci.CommentUrl))
                {
                    lnkName.Text        = HTMLHelper.HTMLEncode(bci.CommentUserName);
                    lnkName.NavigateUrl = bci.CommentUrl;
                    // Add no follow attribute if it is required
                    if (HTMLHelper.UseNoFollowForUsersLinks(CMSContext.CurrentSiteName))
                    {
                        lnkName.Attributes.Add("rel", "nofollow");
                    }
                    lblName.Visible = false;
                }
                else
                {
                    lblName.Text    = HTMLHelper.HTMLEncode(bci.CommentUserName);
                    lnkName.Visible = false;
                }

                lblText.Text = GetHTMLEncodedCommentText(bci);
                lblDate.Text = CMSContext.ConvertDateTime(bci.CommentDate, this).ToString();

                string url = "~/CMSModules/Blogs/Controls/Comment_Edit.aspx";
                if (IsLiveSite)
                {
                    url = "~/CMSModules/Blogs/CMSPages/Comment_Edit.aspx";
                }

                lnkEdit.OnClientClick = "EditComment('" + ResolveUrl(url) + "?commentID=" + CommentID + "');return false;";

                // Initialize report abuse
                ucInlineAbuseReport.ReportTitle             = ResHelper.GetString("BlogCommentDetail.AbuseReport", SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCulture")) + bci.CommentText;
                ucInlineAbuseReport.ReportObjectID          = CommentID;
                ucInlineAbuseReport.CMSPanel.Roles          = AbuseReportRoles;
                ucInlineAbuseReport.CMSPanel.SecurityAccess = AbuseReportSecurityAccess;
                ucInlineAbuseReport.CMSPanel.OwnerID        = AbuseReportOwnerID;
            }
        }
    }
示例#22
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        ForumPostInfo fpi = null;
        ForumInfo     fi  = null;


        #region "Load data"

        if (PostData != null)
        {
            fpi = new ForumPostInfo(PostData);
        }

        if (fpi == null)
        {
            fpi = PostInfo;
        }

        if (fpi != null)
        {
            PostData = fpi.Generalized.DataClass;
            fi       = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
        }
        else
        {
            return;
        }

        #endregion


        if (fi.ForumEnableAdvancedImage)
        {
            ltlText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
        }
        else
        {
            ltlText.AllowedControls = "none";
        }

        lnkUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName);

        // Display converted datetime for live site
        lblDate.Text = " (" + CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString() + ")";

        lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject);
        DiscussionMacroHelper dmh = new DiscussionMacroHelper();
        dmh.EnableBold          = fi.ForumEnableFontBold;
        dmh.EnableItalics       = fi.ForumEnableFontItalics;
        dmh.EnableStrikeThrough = fi.ForumEnableFontStrike;
        dmh.EnableUnderline     = fi.ForumEnableFontUnderline;
        dmh.EnableCode          = fi.ForumEnableCodeSnippet;
        dmh.EnableColor         = fi.ForumEnableFontColor;
        dmh.EnableImage         = fi.ForumEnableImage || fi.ForumEnableAdvancedImage;
        dmh.EnableQuote         = fi.ForumEnableQuote;
        dmh.EnableURL           = fi.ForumEnableURL || fi.ForumEnableAdvancedURL;
        dmh.MaxImageSideSize    = fi.ForumImageMaxSideSize;
        dmh.QuotePostText       = GetString("DiscussionMacroResolver.QuotePostText");

        if (fi.ForumHTMLEditor)
        {
            dmh.EncodeText = false;
            dmh.ConvertLineBreaksToHTML = false;
        }
        else
        {
            dmh.EncodeText = true;
            dmh.ConvertLineBreaksToHTML = true;
        }

        ltlText.Text = "<div class=\"PostText\">" + dmh.ResolveMacros(fpi.PostText) + "</div>";

        userAvatar.Text = AvatarImage(fpi);

        if (DisplayBadgeInfo)
        {
            if (fpi.PostUserID > 0)
            {
                UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID);
                if ((ui != null) && !ui.IsPublic())
                {
                    BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID);
                    if (bi != null)
                    {
                        ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>";
                    }
                }
            }

            // Set public badge if no badge is set
            if (String.IsNullOrEmpty(ltlBadge.Text))
            {
                ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>";
            }
        }

        if (EnableSignature)
        {
            if (fpi.PostUserSignature.Trim() != "")
            {
                plcSignature.Visible = true;
                ltrSignature.Text    = HTMLHelper.HTMLEncode(fpi.PostUserSignature);
            }
        }

        if (!DisplayOnly)
        {
            string threadId = ForumPostInfoProvider.GetPostRootFromIDPath(ValidationHelper.GetString(GetData(PostData, "PostIdPath"), "")).ToString();

            // Reply
            if (IsAvailable(PostData, ForumActionType.Reply))
            {
                lnkReply.Visible     = true;
                lnkReply.Text        = GetString("Forums_WebInterface_ForumPost.replyLinkText");
                lnkReply.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Reply), "threadid", threadId);
            }
            else
            {
                lnkReply.Visible = false;
            }

            // Quote
            if (IsAvailable(PostData, ForumActionType.Quote))
            {
                lnkQuote.Visible     = true;
                lnkQuote.Text        = GetString("Forums_WebInterface_ForumPost.quoteLinkText");
                lnkQuote.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Quote), "threadid", threadId);
            }
            else
            {
                lnkQuote.Visible = false;
            }

            // Display subscribe link
            if (IsAvailable(PostData, ForumActionType.SubscribeToPost))
            {
                lnkSubscribe.Visible     = true;
                lnkSubscribe.Text        = GetString("Forums_WebInterface_ForumPost.Subscribe");
                lnkSubscribe.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.SubscribeToPost), "threadid", threadId);
            }
            else
            {
                lnkSubscribe.Visible = false;
            }

            lnkUserName.CssClass = "PostUserLink";

            if (!String.IsNullOrEmpty(fpi.PostUserMail) && (fi.ForumDisplayEmails))
            {
                lnkUserName.NavigateUrl = "mailto:" + HTMLHelper.HTMLEncode(fpi.PostUserMail) + "?subject=" + HTMLHelper.HTMLEncode(fpi.PostSubject);
                lnkUserName.CssClass    = "PostUser";
            }
        }

        // Display action panel only if reply to link or subscription link are visible
        plcActions.Visible = ((lnkReply.Visible || lnkSubscribe.Visible || lnkQuote.Visible) & !DisplayOnly);

        if ((lnkReply.Visible) && (lnkQuote.Visible || lnkSubscribe.Visible))
        {
            lblActionSeparator.Visible = true;
        }

        if ((lnkQuote.Visible) && (lnkSubscribe.Visible))
        {
            lblActionSeparator2.Visible = true;
        }
    }
示例#23
0
    /// <summary>
    /// Item data bound handler.
    /// </summary>
    protected void gridItems_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (mGlobalNameID != null)
        {
            foreach (var globalName in mGlobalNameID)
            {
                if (!string.IsNullOrEmpty(globalName))
                {
                    Control ctrl = e.Item.FindControl(globalName);
                    if (ctrl != null)
                    {
                        ((HyperLink)ctrl).Text = ((DataRowView)e.Item.DataItem)[globalName].ToString();
                        int    itemId    = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue((DataRowView)e.Item.DataItem, "ItemID"), 0);
                        string detailUrl = URLHelper.CurrentURL;

                        // Use current page by default
                        if (!string.IsNullOrEmpty(DetailPagePath))
                        {
                            detailUrl = CMSContext.GetUrl(DetailPagePath);
                        }

                        // Add querystring parametr
                        detailUrl = URLHelper.AddParameterToUrl(detailUrl, "id", itemId.ToString());

                        ((HyperLink)ctrl).NavigateUrl = detailUrl;
                    }
                }
            }
        }
        // Timezones
        if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            object dataItem = e.Item.DataItem;
            if (dataItem.GetType() == typeof(DataRowView))
            {
                // Get data row
                DataRow dr = ((DataRowView)dataItem).Row;

                // Get count of columns (depends whether columns are automatically generated)
                int columnCount = gridItems.AutoGenerateColumns ? dr.Table.Columns.Count : gridItems.Columns.Count;

                // Go through all grid columns
                int j = 0;
                for (int i = 0; i < columnCount; i++)
                {
                    // Get column of current index
                    object column = gridItems.AutoGenerateColumns ? dr[i] : gridItems.Columns[i];

                    if (((column.GetType() == typeof(BoundColumn)) && !gridItems.AutoGenerateColumns) || ((column is DateTime) && gridItems.AutoGenerateColumns))
                    {
                        // Get cell or actual value
                        object cell = gridItems.AutoGenerateColumns ? column : dr[((BoundColumn)column).DataField];

                        // Apply timezone settings
                        if (cell is DateTime)
                        {
                            e.Item.Cells[j].Text = CMSContext.ConvertDateTime((DateTime)cell, this).ToString();
                        }
                    }
                    // DataGrid doesn't show the GUID columns if the columns are autogenerated
                    else if (gridItems.AutoGenerateColumns && (column is Guid))
                    {
                        --j;
                    }

                    ++j;
                }
            }
        }
    }
示例#24
0
    /// <summary>
    /// Unigrid OnExternalDataBound event.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        GroupMemberStatus status = GroupMemberStatus.Approved;
        DataRowView       drv    = null;
        GridViewRow       gvr    = null;
        bool current             = false;

        switch (sourceName.ToLowerCSafe())
        {
        case "memberapprovedwhen":
        case "memberrejectedwhen":
            if (parameter != DBNull.Value)
            {
                // Get current dateTime
                return(CMSContext.ConvertDateTime(Convert.ToDateTime(parameter), this));
            }
            break;

        case "approve":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Check for current user
                    if (IsLiveSite && (CMSContext.CurrentUser.UserID == ValidationHelper.GetInteger(drv["MemberUserID"], 0)))
                    {
                        current = true;
                    }

                    // Do not allow approve hidden or disabled users
                    bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv);

                    status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0);

                    // Enable or disable Approve button
                    if (!current && (status != GroupMemberStatus.Approved) && !hiddenOrDisabled)
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Approve.png");
                        button.ToolTip  = GetString("general.approve");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/approvedisabled.png");
                        button.ToolTip  = GetString("general.approve");
                        button.Enabled  = false;
                    }
                }
            }

            break;

        case "reject":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Check for current user
                    if (IsLiveSite && (CMSContext.CurrentUser.UserID == ValidationHelper.GetInteger(drv.Row["MemberUserID"], 0)))
                    {
                        current = true;
                    }

                    status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0);

                    // Enable or disable Reject button
                    if (!current && (status != GroupMemberStatus.Rejected))
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Reject.png");
                        button.ToolTip  = GetString("general.reject");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/rejectdisabled.png");
                        button.ToolTip  = GetString("general.reject");
                        button.Enabled  = false;
                    }
                }
            }
            break;

        case "formattedusername":
            // Format username
            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite)));

        case "edit":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Do not allow approve hidden or disabled users
                    bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv);

                    // Enable or disable Edit button
                    if (!hiddenOrDisabled)
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Edit.png");
                        button.ToolTip  = GetString("general.edit");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/editdisabled.png");
                        button.ToolTip  = GetString("general.edit");
                        button.Enabled  = false;
                    }
                }
            }
            break;
        }
        return(parameter);
    }
示例#25
0
    /// <summary>
    /// Handles UniGrid's OnExternalDataBound event.
    /// </summary>
    /// <param name="sender">Sender object (image button if it is an external databoud for action button)</param>
    /// <param name="sourceName">External source name of the column specified in the grid XML</param>
    /// <param name="parameter">Source parameter (original value of the field)</param>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = null;

        switch (sourceName.ToLower())
        {
        case "up":
        case "down":
            ImageButton button = ((ImageButton)sender);
            button.Visible = showArrows;
            break;

        case "taskprogress":
            row = (DataRowView)parameter;
            int progress = ValidationHelper.GetInteger(row["ProjectTaskProgress"], 0);
            return(ProjectTaskInfoProvider.GenerateProgressHtml(progress, true));

        case "projecttaskdisplayname":
        case "projectdisplayname":
            string displayname = parameter.ToString();
            if (displayname.Length > MAX_TITLE_LENGTH)
            {
                return("<span title=\"" + HTMLHelper.HTMLEncode(displayname) + "\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayname, MAX_TITLE_LENGTH)) + "</span>");
            }
            else
            {
                return(HTMLHelper.HTMLEncode(displayname));
            }

        case "projecttaskdeadline":
            DateTime dt = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
            if (dt == DateTimeHelper.ZERO_TIME)
            {
                return(String.Empty);
            }
            return(CMSContext.ConvertDateTime(dt, this));

        case "taskstatus":
            row = parameter as DataRowView;
            if (row != null)
            {
                string statusName = ValidationHelper.GetString(row["TaskStatusDisplayName"], String.Empty);
                statusName = HTMLHelper.HTMLEncode(statusName);
                string iconPath = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["TaskStatusIcon"], String.Empty));
                // Get row color
                rowColor = ValidationHelper.GetString(row["TaskStatusColor"], "");

                switch (StatusDisplayType)
                {
                // Text
                case StatusDisplayTypeEnum.Text:
                    return(statusName);

                // Icon
                case StatusDisplayTypeEnum.Icon:
                    if (!String.IsNullOrEmpty(iconPath))
                    {
                        return("<div style=\"text-align:center;\"><img src=\"" + URLHelper.ResolveUrl(iconPath) + "\" alt=\"" + statusName + "\" title=\"" + statusName + "\" class=\"StatusImage\" style=\"max-width:50px; max-height: 50px;\"  /></div>");
                    }
                    return(statusName);

                // Icon and text
                case StatusDisplayTypeEnum.IconAndText:
                    if (!String.IsNullOrEmpty(iconPath))
                    {
                        return("<img src=\"" + URLHelper.ResolveUrl(iconPath) + "\" title=\"" + statusName + "\" class=\"StatusImage\" style=\"max-width:50px; max-height: 50px;\"  />&nbsp;" + statusName);
                    }
                    return(statusName);
                }
            }

            return(row.ToString());

        case "assigneeformattedfullname":
            row = (DataRowView)parameter;
            string assigneeUserName = ValidationHelper.GetString(row["AssigneeUserName"], String.Empty);
            string assigneeFullName = ValidationHelper.GetString(row["AssigneeFullName"], String.Empty);

            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(assigneeUserName, assigneeFullName, IsLiveSite)));

        case "ownerformattedfullname":
            row = (DataRowView)parameter;
            string ownerUserName = ValidationHelper.GetString(row["OwnerUserName"], String.Empty);
            string ownerFullName = ValidationHelper.GetString(row["OwnerFullName"], String.Empty);

            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ownerUserName, ownerFullName, IsLiveSite)));

        // Display name with link - used in webparts
        case "linkeddisplayname":
            row = (DataRowView)parameter;
            string displayName   = ValidationHelper.GetString(row["ProjectTaskDisplayName"], String.Empty);
            int    projectTaskID = ValidationHelper.GetInteger(row["ProjectTaskID"], 0);
            string url           = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSTaskDetailPage");

            return(String.Format("<a href=\"{0}\" title=\"{1}\">{2}</a>", url + "?ProjectTaskID=" + projectTaskID, HTMLHelper.HTMLEncode(displayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayName, MAX_TITLE_LENGTH))));

        // Display name with link to ajax window
        case "editlinkdisplayname":
            row = (DataRowView)parameter;
            string editDisplayName   = ValidationHelper.GetString(row["ProjectTaskDisplayName"], String.Empty);
            int    editProjectTaskID = ValidationHelper.GetInteger(row["ProjectTaskID"], 0);
            return(String.Format("<a href=\"javascript:" + ControlsHelper.GetPostBackEventReference(this, editProjectTaskID.ToString()) + "\" title=\"{0}\">{1}</a>", HTMLHelper.HTMLEncode(editDisplayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH))));
        }

        return(parameter);
    }
示例#26
0
    public void ReloadData()
    {
        if (StopProcessing)
        {
            // Do nothing
            ucMessageUserButtons.StopProcessing = true;
            ucUserPicture.StopProcessing        = true;
        }
        else
        {
            ucMessageUserButtons.StopProcessing = false;
            ucUserPicture.StopProcessing        = false;

            if (Message != null)
            {
                // Get current user info
                currentUserInfo = CMSContext.CurrentUser;
                // Get message user info
                if (MessageMode == MessageModeEnum.Inbox)
                {
                    messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageSenderUserID);
                }
                else
                {
                    messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageRecipientUserID);
                }

                // Display only to authorized user
                if ((currentUserInfo.UserID == Message.MessageRecipientUserID) || (currentUserInfo.UserID == Message.MessageSenderUserID) || currentUserInfo.IsGlobalAdministrator)
                {
                    pnlViewMessage.Visible = true;
                    lblDateCaption.Text    = GetString("Messaging.Date");
                    lblSubjectCaption.Text = GetString("general.subject");
                    lblFromCaption.Text    = (MessageMode == MessageModeEnum.Inbox) ? GetString("Messaging.From") : GetString("Messaging.To");

                    // Sender exists
                    if (messageUserInfo != null)
                    {
                        ucUserPicture.Visible = true;
                        ucUserPicture.UserID  = messageUserInfo.UserID;

                        // Disable message user buttons on live site for hidden or disabled users
                        if (IsLiveSite && !currentUserInfo.IsGlobalAdministrator && (!messageUserInfo.Enabled || messageUserInfo.UserIsHidden))
                        {
                            ucMessageUserButtons.RelatedUserId = 0;
                        }
                        else
                        {
                            ucMessageUserButtons.RelatedUserId = messageUserInfo.UserID;
                        }
                        lblFrom.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(messageUserInfo.UserName, messageUserInfo.FullName, messageUserInfo.UserNickName, IsLiveSite));
                    }
                    else
                    {
                        ucMessageUserButtons.RelatedUserId = 0;
                        lblFrom.Text = HTMLHelper.HTMLEncode(Message.MessageSenderNickName);
                    }
                    string body = Message.MessageBody;
                    // Resolve macros
                    DiscussionMacroHelper dmh = new DiscussionMacroHelper();
                    body = dmh.ResolveMacros(body);

                    lblSubject.Text = HTMLHelper.HTMLEncodeLineBreaks(Message.MessageSubject);
                    if (IsLiveSite)
                    {
                        lblDate.Text = CMSContext.ConvertDateTime(Message.MessageSent, this).ToString();
                    }
                    else
                    {
                        lblDate.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(Message.MessageSent, currentUserInfo, CMSContext.CurrentSite, out usedTimeZone);
                    }
                    lblBody.Text = body;
                }
            }
            else
            {
                lblError.Text    = GetString("Messaging.MessageDoesntExist");
                lblError.Visible = true;
            }
        }
    }