Exemplo n.º 1
0
        private void dgPendingApproval_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (!HasWriteAccess)
                return;

            if (e.CommandName == "Approve")
            {
                string[] parameters = ((string) e.CommandArgument).Split(':');
                if (parameters.Length == 2)
                {
                    ProfileAnswer answer = ProfileAnswer.Fetch(parameters[0], Convert.ToInt32(parameters[1]));
                    answer.Approved = true;
                    answer.Save();

                    #region Add FriendUpdatedProfile Event

                    Event newEvent = new Event(parameters[0]);

                    newEvent.Type = Event.eType.FriendUpdatedProfile;
                    UpdatedProfile updatedProfile = new UpdatedProfile();
                    updatedProfile.QuestionIDs = new List<int>() { answer.Question.Id };
                    newEvent.DetailsXML = Misc.ToXml(updatedProfile);

                    newEvent.Save();

                    string[] usernames = Classes.User.FetchMutuallyFriends(parameters[0]);

                    foreach (string friendUsername in usernames)
                    {
                        if (Config.Users.NewEventNotification)
                        {
                            string text = String.Format("Your friend {0} has updated the \"{1}\" section in their profile".TranslateA(),
                                            "<b>" + parameters[0] + "</b>", answer.Question.Name);
                            int imageID = 0;
                            try
                            {
                                imageID = Photo.GetPrimary(parameters[0]).Id;
                            }
                            catch (NotFoundException)
                            {
                                User user = null;
                                try
                                {
                                    user = Classes.User.Load(parameters[0]);
                                    imageID = ImageHandler.GetPhotoIdByGender(user.Gender);
                                }
                                catch (NotFoundException)
                                {
                                    continue;
                                }
                            }
                            string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                            Classes.User.SendOnlineEventNotification(parameters[0], friendUsername, text, thumbnailUrl,
                                                                     UrlRewrite.CreateShowUserUrl(parameters[0]));
                        }
                    }

                    #endregion

                    PopulateDataGrid();
                }
            }
            else if (e.CommandName == "Reject")
            {
                string[] parameters = ((string) e.CommandArgument).Split(':');
                if (parameters.Length == 2)
                {
                    ProfileAnswer.Delete(parameters[0], Convert.ToInt32(parameters[1]));
                    PopulateDataGrid();
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var toSave = new List<ProfileAnswer>();
                var toDelete = new List<ProfileAnswer>();
                List<int> modifiedQuestionIDs = new List<int>();
                List<Control> parentControls = new List<Control>();
                GetParentControls(plhProfile, parentControls);
                GetAnswers(plhProfile, parentControls, toSave, toDelete, modifiedQuestionIDs);

                if (modifiedQuestionIDs.Count > 0)
                {
                    var newEvent = new Event(CurrentUserSession.Username);

                    newEvent.Type = Event.eType.FriendUpdatedProfile;
                    var friendUpdatedProfile = new UpdatedProfile();
                    friendUpdatedProfile.QuestionIDs = modifiedQuestionIDs;
                    newEvent.DetailsXML = Misc.ToXml(friendUpdatedProfile);

                    newEvent.Save();
                }

                foreach (ProfileAnswer answer in toSave)
                {
                    answer.Save();
                }
                foreach (ProfileAnswer answer in toDelete)
                {
                    answer.Delete();
                }

                if (CurrentUserSession != null)
                {
                    CurrentUserSession.HasProfile = true;
                    CurrentUserSession.HasApprovedProfile =
                        Classes.User.HasProfile(CurrentUserSession.Username, true);
                }

                string message = Lang.Trans
                    ("<br><b>Your profile has been updated successfully!</b><br><br>");

                message = message +
                          Lang.Trans("Profiles with photos get 20 times more Response!");

                StatusPageMessage = message;

//                ((PageBase)Page).StatusPageLinkSkindId = "UploadPhotos";
//                ((PageBase)Page).StatusPageLinkText = Lang.Trans("Upload photos now!");
//                ((PageBase)Page).StatusPageLinkURL = "~/ManageProfile.aspx?sel=photos";

//                Response.Redirect("ShowStatus.aspx");
            }
            catch (AnswerRequiredException)
            {
            }
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text = String.Empty;
            litAlert.Text = String.Empty;
            IsNext = true;
            try
            {
                var toSave = new List<ProfileAnswer>();
                var toDelete = new List<ProfileAnswer>();
                var modifiedQuestionIDs = new List<int>();
                var parentControls = new List<Control>();
                GetParentControls(topicsPanels[CurrentTopicName], parentControls);
                GetAnswers(topicsPanels[CurrentTopicName], parentControls, toSave, toDelete, modifiedQuestionIDs);

                if (modifiedQuestionIDs.Count > 0)
                {
                    var newEvent = new Event(CurrentUserSession.Username) { Type = Event.eType.FriendUpdatedProfile };
                    var friendUpdatedProfile = new UpdatedProfile { QuestionIDs = modifiedQuestionIDs };
                    newEvent.DetailsXML = Misc.ToXml(friendUpdatedProfile);
                    newEvent.Save();
                }

                foreach (ProfileAnswer answer in toSave)
                    answer.Save();

                foreach (ProfileAnswer answer in toDelete)
                    answer.Delete();

                if (CurrentUserSession != null)
                {
                    CurrentUserSession.HasProfile = true;
                    CurrentUserSession.HasApprovedProfile =
                        User.HasProfile(CurrentUserSession.Username, true);
                }

                string message = "<br><b>" +
                                Lang.Trans("Your profile has been updated successfully!") +
                                "</b><br><br>";

                message = message +
                          Lang.Trans("Profiles with photos get 20 times more Response!");

                ((PageBase)Page).StatusPageMessage = message;

                ((PageBase)Page).StatusPageLinkSkindId = "UploadPhotos";
                ((PageBase)Page).StatusPageLinkText = Lang.Trans("Upload photos now!");
                ((PageBase)Page).StatusPageLinkURL = "~/ManageProfile.aspx?sel=photos";
            }
            catch (AnswerRequiredException)
            {
            }
        }
Exemplo n.º 4
0
        protected void btnSaveAndApprove_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;
            
            ProfileAnswer answer = new ProfileAnswer(username, questionID);

            if (txtAnswer.Text.Trim() == String.Empty)
                btnReject_Click(null, null);
            else
                answer.Value = txtAnswer.Text;
            answer.Approved = true;
            answer.Save();

            #region Add FriendUpdatedProfile Event

            Event newEvent = new Event(username);

            newEvent.Type = Event.eType.FriendUpdatedProfile;
            UpdatedProfile updatedProfile = new UpdatedProfile();
            updatedProfile.QuestionIDs = new List<int>() {answer.Question.Id };
            newEvent.DetailsXML = Misc.ToXml(updatedProfile);

            newEvent.Save();

            string[] usernames = Classes.User.FetchMutuallyFriends(username);

            foreach (string friendUsername in usernames)
            {
                if (Config.Users.NewEventNotification)
                {
                    string text = String.Format("Your friend {0} has updated the \"{1}\" section in their profile".TranslateA(),
                                            "<b>" + username + "</b>", answer.Question.Name);
                    int imageID = 0;
                    try
                    {
                        imageID = Photo.GetPrimary(username).Id;
                    }
                    catch (NotFoundException)
                    {
                        User user = null;
                        try
                        {
                            user = Classes.User.Load(username);
                            imageID = ImageHandler.GetPhotoIdByGender(user.Gender);
                        }
                        catch (NotFoundException)
                        {
                            break;
                        }
                    }
                    string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                    Classes.User.SendOnlineEventNotification(username, friendUsername, text, thumbnailUrl,
                                                             UrlRewrite.CreateShowUserUrl(username));
                }
            }

            #endregion

            Response.Redirect("ApproveAnswers.aspx");
        }