コード例 #1
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        lblInfo.Text                  = ApprovedCaption;
        friendship.FriendStatus       = FriendshipStatusEnum.Approved;
        friendship.FriendApprovedBy   = friendship.FriendRequestedUserID;
        friendship.FriendApprovedWhen = DateTime.Now;
        FriendInfoProvider.SetFriendInfo(friendship);

        plcConfirm.Visible = false;
        plcMessage.Visible = true;

        action = FriendsActionEnum.Approve;

        // Send notification
        SentNotification();
    }
コード例 #2
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                // Get requested action
                action = (FriendsActionEnum)Enum.Parse(typeof(FriendsActionEnum), QueryHelper.GetString("action", "request"), true);
                friendship = CommunityContext.CurrentFriendship;
                friend = CommunityContext.CurrentFriend;

                // Prepare My Friends link
                lnkMyFriends.Text = MyFriendsCaption;
                if (MyFriendsPath != string.Empty)
                {
                    lnkMyFriends.NavigateUrl = URLHelper.GetAbsoluteUrl(TreePathUtils.GetUrl(MyFriendsPath));
                }
                else
                {
                    lnkMyFriends.Visible = false;
                }

                // Validate requested action
                if (!ValidateAction())
                {
                    return;
                }

                btnApprove.Click += btnApprove_Click;
                btnReject.Click += btnReject_Click;

                if (friendship != null)
                {
                    // If friendship is rejected -> display error
                    switch (friendship.FriendStatus)
                    {
                        case FriendshipStatusEnum.Rejected:
                            plcMessage.Visible = true;
                            plcConfirm.Visible = false;
                            lblInfo.Text = AlreadyRejectedCaption;
                            lblInfo.ForeColor = Color.Red;
                            break;

                        case FriendshipStatusEnum.Approved:
                            plcMessage.Visible = true;
                            plcConfirm.Visible = false;
                            lblInfo.Text = AlreadyApprovedCaption;
                            lblInfo.ForeColor = Color.Red;
                            break;
                        default:
                            plcMessage.Visible = false;
                            plcConfirm.Visible = true;
                            btnApprove.Text = GetString("general.approve");
                            btnReject.Text = GetString("general.reject");

                            string profilePath = GroupMemberInfoProvider.GetMemberProfilePath(friend.UserName, CMSContext.CurrentSiteName);
                            string profileUrl = ResolveUrl(TreePathUtils.GetUrl(profilePath));
                            string link = "<a href=\"" + profileUrl + "\" >" + HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(friend.UserName, friend.FullName, true)) + "</a>";
                            lblConfirm.Text = string.Format(GetString("friends.approvaltext"), link);
                            break;
                    }
                }
                else
                {
                    Visible = false;
                }
            }
            else
            {
                plcMessage.Visible = true;
                plcConfirm.Visible = false;
                lblInfo.ForeColor = Color.Red;
                lblInfo.Text = GetString("friends.notloggedin");
            }
        }
    }
コード例 #3
0
    protected void btnReject_Click(object sender, EventArgs e)
    {
        lblInfo.Text = RejectedCaption;
        friendship.FriendStatus = FriendshipStatusEnum.Rejected;
        friendship.FriendRejectedBy = friendship.FriendRequestedUserID;
        friendship.FriendRejectedWhen = DateTime.Now;
        FriendInfoProvider.SetFriendInfo(friendship);

        plcConfirm.Visible = false;
        plcMessage.Visible = true;

        action = FriendsActionEnum.Reject;

        // Send notification
        SentNotification();
    }
コード例 #4
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (AuthenticationHelper.IsAuthenticated())
            {
                // Get requested action
                action     = (FriendsActionEnum)Enum.Parse(typeof(FriendsActionEnum), QueryHelper.GetString("action", "request"), true);
                friendship = CommunityContext.CurrentFriendship;
                friend     = CommunityContext.CurrentFriend;

                // Prepare My Friends link
                lnkMyFriends.Text = MyFriendsCaption;
                if (MyFriendsPath != string.Empty)
                {
                    lnkMyFriends.NavigateUrl = URLHelper.GetAbsoluteUrl(DocumentURLProvider.GetUrl(MyFriendsPath));
                }
                else
                {
                    lnkMyFriends.Visible = false;
                }

                // Validate requested action
                if (!ValidateAction())
                {
                    return;
                }

                btnApprove.Click += btnApprove_Click;
                btnReject.Click  += btnReject_Click;

                if (friendship != null)
                {
                    // If friendship is rejected -> display error
                    switch (friendship.FriendStatus)
                    {
                    case FriendshipStatusEnum.Rejected:
                        plcMessage.Visible = true;
                        plcConfirm.Visible = false;
                        lblInfo.Text       = AlreadyRejectedCaption;
                        lblInfo.ForeColor  = Color.Red;
                        break;

                    case FriendshipStatusEnum.Approved:
                        plcMessage.Visible = true;
                        plcConfirm.Visible = false;
                        lblInfo.Text       = AlreadyApprovedCaption;
                        lblInfo.ForeColor  = Color.Red;
                        break;

                    default:
                        plcMessage.Visible = false;
                        plcConfirm.Visible = true;
                        btnApprove.Text    = GetString("general.approve");
                        btnReject.Text     = GetString("general.reject");

                        string profilePath = GroupMemberInfoProvider.GetMemberProfilePath(friend.UserName, SiteContext.CurrentSiteName);
                        string profileUrl  = ResolveUrl(DocumentURLProvider.GetUrl(profilePath));
                        string link        = "<a href=\"" + profileUrl + "\" >" + HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(friend.UserName, friend.FullName, true)) + "</a>";
                        lblConfirm.Text = string.Format(GetString("friends.approvaltext"), link);
                        break;
                    }
                }
                else
                {
                    Visible = false;
                }
            }
            else
            {
                plcMessage.Visible = true;
                plcConfirm.Visible = false;
                lblInfo.ForeColor  = Color.Red;
                lblInfo.Text       = GetString("friends.notloggedin");
            }
        }
    }