Beispiel #1
0
        /// <summary>
        /// Process Form Submission - Record Moderators Decision.
        /// </summary>
        private void ProcessSubmission(  )
        {
            ExternalLinkModeration modLink = new ExternalLinkModeration(AppContext.TheAppContext.Diagnostics, AppContext.ReaderCreator, AppContext.DnaCacheManager, AppContext.TheAppContext.TheSiteList);

            int count = InputContext.GetParamCountOrZero("modid", "ModerationId");
            for (int i = 0; i < count; ++i)
            {
                int decision = InputContext.GetParamIntOrZero("decision", i, "Moderation Decision");
                int modId = InputContext.GetParamIntOrZero("modid", i, "ModerationId");
                String notes = InputContext.GetParamStringOrEmpty("notes", i, "notes");
                int referTo = InputContext.GetParamIntOrZero("referTo", i, "referTo");
                String emailType = InputContext.GetParamStringOrEmpty("emailtype", i, "Email Template Insert Text");

                if (decision == (int)ModerationItemStatus.Refer && referTo == 0)
                {
                    AddErrorXml("MissingReferTo", "Please specify a referee to refer items to", RootElement);
                }
                else
                {
                    //Insert into mod queue
                    using (IDnaDataReader reader = InputContext.CreateDnaDataReader("moderateexlinks"))
                    {
                        reader.AddParameter("modid", modId);
                        reader.AddParameter("decision", decision);
                        reader.AddParameter("userid", InputContext.ViewingUser.UserID);
                        reader.AddParameter("notes", notes);
                        reader.AddParameter("referTo", referTo);
                        reader.AddParameter("emailType", emailType);
                        reader.Execute();
                    }
                }
            }

        }
Beispiel #2
0
        public void CreateModerationItem(string sitename, ModerationItem modItem)
        {
            try
            {
                ISite site = GetSite(sitename);
                CallingUser viewer = GetCallingUser(site);
                if (viewer.IsUserA(UserTypes.Editor))
                {
                    ExternalLinkModeration exLinkMod = new ExternalLinkModeration(base.dnaDiagnostic, base.readerCreator, base.cacheManager, base.siteList);

                    Uri source;
                    Uri callback;
                    if (Uri.TryCreate(modItem.Uri, UriKind.Absolute, out source) && Uri.TryCreate(modItem.CallBackUri, UriKind.Absolute, out callback))
                    {
                        exLinkMod.AddToModerationQueue(new Uri(modItem.Uri), new Uri(modItem.CallBackUri), modItem.ComplaintText, modItem.Notes, site.SiteID, modItem.BBCUserIdentity);
                    }
                    else
                    {
                        throw new DnaWebProtocolException(System.Net.HttpStatusCode.BadRequest, "Bad url format", null);
                    }
                }
                else
                {
                    throw new DnaWebProtocolException(System.Net.HttpStatusCode.Unauthorized, "User must be an editor", null);
                }
            }
            catch (DnaException ex)
            {
                throw new DnaWebProtocolException(System.Net.HttpStatusCode.InternalServerError, ex.Message, ex);
            }
        }
Beispiel #3
0
        public void CreateModerationItemInternal(string sitename, ModerationItem modItem)
        {
            try
            {
                ISite site = GetSite(sitename);
                CallingUser viewer = GetCallingUser(site);
                if (viewer.IsUserA(UserTypes.Editor))
                {
                    ExternalLinkModeration exLinkMod = new ExternalLinkModeration(base.dnaDiagnostic, base.readerCreator, base.cacheManager, base.siteList);

                    Guid keyHash = Guid.Empty;
                    string hashString = site.SiteID + "<:>" + viewer.IdentityUserID + "<:>" + modItem.Uri + "<:>" + DateTime.Now.ToString();
                    keyHash = DnaHasher.GenerateHash(hashString);
                    exLinkMod.AddToExLinkModHashInternal(keyHash, site.SiteID);

                    Uri source;
                    Uri callback;
                    string sourceURI = modItem.Uri + (modItem.Uri.IndexOf('?') > 0 ? "&" : "?") + "encryptionKey=" + keyHash;
                    string callbackURI = modItem.CallBackUri + (modItem.CallBackUri.IndexOf('?') > 0 ? "&" : "?") + "encryptionKey=" + keyHash;

                    if (Uri.TryCreate(sourceURI, UriKind.Absolute, out source) && Uri.TryCreate(callbackURI, UriKind.Absolute, out callback))
                    {
                        exLinkMod.AddToModerationQueue(new Uri(sourceURI), new Uri(callbackURI), modItem.ComplaintText, modItem.Notes, site.SiteID);
                    }
                    else
                    {
                        throw new DnaWebProtocolException(System.Net.HttpStatusCode.BadRequest, "Bad url format", null);
                    }
                }
                else
                {
                    throw new DnaWebProtocolException(System.Net.HttpStatusCode.Unauthorized, "User must be an editor", null);
                }
            }
            catch (DnaException ex)
            {
                throw new DnaWebProtocolException(System.Net.HttpStatusCode.InternalServerError, ex.Message, ex);
            }
        }
Beispiel #4
0
        public Stream GetCallbackItemInternal(string sitename)
        {
            try
            {
                ISite site = GetSite(sitename);
                CallingUser viewer = GetCallingUser(site);
                if (viewer.IsUserA(UserTypes.Editor))
                {
                    ExternalLinkModeration exLinkMod = new ExternalLinkModeration(base.dnaDiagnostic, base.readerCreator, base.cacheManager, base.siteList);

                    var exLinkModCallbackItemList = exLinkMod.GetCallbackItemInternal(site.SiteID);
                    return GetOutputStream(exLinkModCallbackItemList);
                }
                else
                {
                    throw new DnaWebProtocolException(System.Net.HttpStatusCode.Unauthorized, "User must be an editor", null);
                }
            }
            catch (DnaException ex)
            {
                throw new DnaWebProtocolException(System.Net.HttpStatusCode.InternalServerError, ex.Message, ex);
            }
        }
Beispiel #5
0
        public void CreateCallbackItemInternal(string sitename, ExLinkModCallbackItem exLinkModCallbackItem)
        {
            try
            {
                ISite site = GetSite(sitename);
                CallingUser viewer = GetCallingUser(site);
                if (viewer.IsUserA(UserTypes.Editor))
                {
                    ExternalLinkModeration exLinkMod = new ExternalLinkModeration(base.dnaDiagnostic, base.readerCreator, base.cacheManager, base.siteList);
                    string hash = QueryStringHelper.GetQueryParameterAsString("encryptionKey", "");

                    if (exLinkMod.IsValidHash(hash, site.SiteID))
                    {
                        exLinkMod.AddToExLinkModCallbackInternal(hash, site.SiteID, exLinkModCallbackItem);
                    }
                    else
                    {
                        throw new DnaWebProtocolException(System.Net.HttpStatusCode.Unauthorized, "Invalid encryption key", null);
                    }
                }
                else
                {
                    throw new DnaWebProtocolException(System.Net.HttpStatusCode.Unauthorized, "User must be an editor", null);
                }
            }
            catch (DnaException ex)
            {
                throw new DnaWebProtocolException(System.Net.HttpStatusCode.InternalServerError, ex.Message, ex);
            }
        }