Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnReject control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnReject_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;
            
            Photo photo = Photo.Fetch(photoID);
            MiscTemplates.RejectPhotoMessage rejectPhotoMessageTemplate =
                new MiscTemplates.RejectPhotoMessage(photo.User.LanguageId);
            string reasonMessage = rejectPhotoMessageTemplate.WithReasonMessage;

            if (txtReason.Text != "")
            {
                reasonMessage = reasonMessage.Replace("%%REASON%%", txtReason.Text);
                try
                {
                    Message.Send(Config.Users.SystemUsername, photo.User.Username, reasonMessage, 0);
                }
                catch (NotFoundException) { }
            }
            else
            {
                try
                {
                    Message.Send(Config.Users.SystemUsername, photo.User.Username,
                                 rejectPhotoMessageTemplate.WithNoReasonMessage, 0);
                }
                catch(NotFoundException){}
            }

            if (photo.ManualApproval)
            {
                Classes.User.SetPhotoModerationApprovalScore(photo.Id, false,
                                                                 Config.CommunityModeratedSystem.ScoresForCorrectOpinion,
                                                                 Config.CommunityModeratedSystem.PenaltyForIncorrectOpinion);
            }
            
            Photo.Delete(photoID);
            Classes.User.AddScore(photo.Username, Config.UserScores.RejectedPhoto, "RejectedPhoto");

            Response.Redirect("ApprovePhotos.aspx");
        }
Ejemplo n.º 2
0
        protected void btnReject_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;
            
            Photo photo = Photo.Fetch(photoID);
            MiscTemplates.RejectPhotoMessage rejectPhotoMessageTemplate =
                new MiscTemplates.RejectPhotoMessage(photo.User.LanguageId);
            string reasonMessage = rejectPhotoMessageTemplate.WithReasonMessage;

            if (txtReason.Text != "")
            {
                reasonMessage = reasonMessage.Replace("%%REASON%%", txtReason.Text);
                Message.Send(Config.Users.SystemUsername, photo.User.Username, reasonMessage, 0);
            }
            else
                Message.Send(Config.Users.SystemUsername, photo.User.Username,
                             rejectPhotoMessageTemplate.WithNoReasonMessage, 0);

            Photo.Delete(photoID);
            Classes.User.AddScore(photo.Username, Config.UserScores.RejectedPhoto, "RejectedPhoto");

            if (cbDeleteAccount.Checked)
            {
                Classes.User.Delete(photo.Username, txtReason.Text);
            }

            PopulateDataGrid();

            txtReason.Text = "";
            cbDeleteAccount.Checked = false;
        }
Ejemplo n.º 3
0
        public ApproveRejectPhotosResponse ApproveRejectPhotos(string username, string password,
                                                               ApproveRejectPhotosRequest req)
        {
            var resp = new ApproveRejectPhotosResponse();

            try
            {
                Classes.Admin admin = Classes.Admin.Authorize(username, password);

                if (Config.AdminSettings.ReadOnly
                    || (username != Config.Users.SystemUsername && Config.AdminSettings.AdminPermissionsEnabled
                        && (admin.Privileges.photoApproval & Classes.Admin.eAccess.Write) == 0))
                {
                    resp.Error = Lang.Trans("Access denied!");
                    return resp;
                }
            }
            catch (Exception err)
            {
                resp.Error = err.Message;
                return resp;
            }

            if (req.ApprovedPhotos != null)
            {
                foreach (ApprovedPhotoInfo photoInfo in req.ApprovedPhotos)
                {
                    Photo photo = Photo.Fetch(photoInfo.Id);
                    if (Config.Photos.EnableExplicitPhotos)
                    {
                        photo.ExplicitPhoto = photoInfo.Explicit;
                        if (photo.ExplicitPhoto && Config.Photos.MakeExplicitPhotosPrivate)
                        {
                            photo.PrivatePhoto = true;
                        }
                    }
                    photo.ApprovePhoto(username);
                    Classes.User.AddScore(photo.Username, Config.UserScores.ApprovedPhoto, "ApprovedPhoto");
                    try
                    {
                        var approvePhotoMessageTemplate =
                            new MiscTemplates.ApprovePhotoMessage(photo.User.LanguageId);
                        Message.Send(Config.Users.SystemUsername, photo.User.Username,
                                     approvePhotoMessageTemplate.Message, 0);
                    }
                    catch (NotFoundException ex)
                    {
                        Global.Logger.LogError(ex);
                    }
                }
            }

            if (req.RejectedPhotos != null)
            {
                foreach (RejectedPhotoInfo photoInfo in req.RejectedPhotos)
                {
                    Photo photo = Photo.Fetch(photoInfo.Id);
                    var rejectPhotoMessageTemplate =
                        new MiscTemplates.RejectPhotoMessage(photo.User.LanguageId);
                    string reasonMessage = rejectPhotoMessageTemplate.WithReasonMessage;

                    if (photoInfo.Reason != null && photoInfo.Reason.Trim().Length > 0)
                    {
                        reasonMessage = reasonMessage.Replace("%%REASON%%", photoInfo.Reason);
                        Message.Send(Config.Users.SystemUsername, photo.User.Username, reasonMessage, 0);
                    }
                    else
                        Message.Send(Config.Users.SystemUsername, photo.User.Username,
                                     rejectPhotoMessageTemplate.WithNoReasonMessage, 0);

                    Photo.Delete(photoInfo.Id);
                    Classes.User.AddScore(photo.Username, Config.UserScores.RejectedPhoto, "RejectedPhoto");

                    if (photoInfo.DeleteUser)
                    {
                        Classes.User.Delete(photo.Username, photoInfo.Reason);
                    }
                }
            }

            return resp;
        }
Ejemplo n.º 4
0
        private void determinePhotoState()
        {
            CommunityPhotoApproval[] approvals = CommunityPhotoApproval.FetchByPhotoID(CurrentPhotoID);
            int votes = approvals.Length;

            if (votes == Config.CommunityModeratedSystem.RequiredNumberOfVotesToDetermine)
            {
                Photo photo = null;
                int approved = 0;
                int rejected = 0;

                foreach (CommunityPhotoApproval approval in approvals)
                {
                    if (approval.Approved) approved++;
                    else rejected++;
                }

                try
                {
                    photo = Photo.Fetch(CurrentPhotoID);
                }
                catch (NotFoundException)
                {
                    return;
                }

                if ((approved * 100) / Config.CommunityModeratedSystem.RequiredNumberOfVotesToDetermine >= Config.CommunityModeratedSystem.RequiredPercentageToApprovePhoto)
                {
                    photo.Approved = true;
                    photo.ApprovedDate = DateTime.Now;
                    photo.Save(false);

                    Classes.User.SetPhotoModerationApprovalScore(CurrentPhotoID, true,
                                                                 Config.CommunityModeratedSystem.ScoresForCorrectOpinion,
                                                                 Config.CommunityModeratedSystem.PenaltyForIncorrectOpinion);

                    CommunityPhotoApproval.DeleteByPhotoID(CurrentPhotoID);

                    MiscTemplates.ApprovePhotoMessage approvePhotoMessageTemplate =
                    new MiscTemplates.ApprovePhotoMessage(photo.User.LanguageId);
                    Message.Send(Config.Users.SystemUsername, photo.User.Username, approvePhotoMessageTemplate.Message, 0);

                    if (!photo.PrivatePhoto)
                    {
                        #region Add Event

                        Event newEvent = new Event(photo.Username);

                        newEvent.Type = Event.eType.NewFriendPhoto;
                        NewFriendPhoto newFriendPhoto = new NewFriendPhoto();
                        newFriendPhoto.PhotoID = photo.Id;
                        newEvent.DetailsXML = Misc.ToXml(newFriendPhoto);

                        newEvent.Save();

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

                        foreach (string friendUsername in usernames)
                        {
                            if (Config.Users.NewEventNotification)
                            {
                                string text = String.Format("Your friend {0} has uploaded a new photo".Translate(),
                                                      "<b>" + photo.Username + "</b>");
                                string thumbnailUrl = ImageHandler.CreateImageUrl(photo.Id, 50, 50, false, true, true);
                                Classes.User.SendOnlineEventNotification(photo.Username, friendUsername,
                                                                         text, thumbnailUrl,
                                                                         UrlRewrite.CreateShowUserPhotosUrl(photo.Username));
                            }
                        }

                        #endregion
                    }
                    
                }
                else if ((rejected * 100) / Config.CommunityModeratedSystem.RequiredNumberOfVotesToDetermine >= Config.CommunityModeratedSystem.RequiredPercentageToRejectPhoto)
                {
                    Classes.User.SetPhotoModerationApprovalScore(CurrentPhotoID, false,
                                                                 Config.CommunityModeratedSystem.ScoresForCorrectOpinion,
                                                                 Config.CommunityModeratedSystem.PenaltyForIncorrectOpinion);

                    Photo.Delete(CurrentPhotoID);

                    MiscTemplates.RejectPhotoMessage rejectPhotoMessageTemplate =
                        new MiscTemplates.RejectPhotoMessage(photo.User.LanguageId);
                    Message.Send(Config.Users.SystemUsername, photo.User.Username,
                                 rejectPhotoMessageTemplate.WithNoReasonMessage, 0);
                }
                else
                {
                    photo.ManualApproval = true;
                    photo.Save(false);
                }
            }
        }