Example #1
0
        public static ImageInfo GetProfileImage(ProviderMember aMember)
        {
            bool useDefault = true;
            ProviderPhotoRecord profileImage = null;
            ImageInfo profileImageInfo = null;

            if (aMember.ProfilePhotoId != null)
            {
                profileImage = (new ProviderPhotoRecord(aMember.ProfilePhotoId.Value)).Thumbnail(ProviderPhotoRecord.ImageTypeEnum.ProfileThumbnail);
                if (profileImage != null)
                {
                    useDefault = false;
                }
            }

            if (useDefault)
            {
                profileImageInfo = ImageLibrary.DefaultProfile;
            }
            else
            {
                profileImageInfo = profileImage.PhotoInfo;
                profileImageInfo.Alt = "Author Profile Image";
            }
            return profileImageInfo;
        }
Example #2
0
        public bool Refresh(ProviderMember aMember, List<ProviderCategory> categoryList)
        {
            CategoryList = new List<SelectList>();
            AlternateCategoryMapList = new List<AlternateCategoryMapVM>();

            List<KeyValuePair<long, string>> ddList = new List<KeyValuePair<long, string>>();
            ddList.Add(_nullCategory);
            ddList.AddRange(categoryList.ToDictionary(aCategory => aCategory.Id.Value, aCategory => aCategory.Title));

            foreach (ProviderAlternateCategoryId altCategory in aMember.AlternateCategoryList)
            {
                if(!string.IsNullOrEmpty(altCategory.DisplayName))
                {
                    long selectedCatId = altCategory.CategoryId ?? -1;
                    AlternateCategoryMapList.Add(new AlternateCategoryMapVM
                    {
                        AlternateTitle = altCategory.DisplayName,
                        AlternateId = altCategory.AlternateId,
                        MapId = selectedCatId
                    });

                    CategoryList.Add(new SelectList(ddList, "key", "value", selectedCatId));
                }
            }
            return true;
        }
Example #3
0
        /// <summary>
        /// Function creates a ProviderPhoto class from a raw image file and assigns it to the member that created/uploaded it
        /// </summary>
        /// <param name="owningMember">owning member of the article/photo</param>
        /// <param name="filePhoto">raw image file of the photo</param>
        /// <returns>photo url</returns>
        public static ProviderPhoto CreatePhoto(ProviderMember owningMember, HttpPostedFileBase filePhoto)
        {
            ProviderPhoto originalPhoto = null;

            // check if there is any data to attach
            if (filePhoto.ContentLength > 0)
            {
                string subFolder = (owningMember.IsNew) ? "anonymous" : owningMember.Id.ToString();
                originalPhoto = new ProviderPhoto(filePhoto, subFolder);
                originalPhoto.AdjustToDimensions(InsideWordProvider.ProviderPhotoRecord.ImageTypeEnum.Original);
                originalPhoto.Save();

                List<ProviderPhoto> thumbnails = ProviderPhoto.CreateThumbnails(originalPhoto);
                foreach (ProviderPhoto thumbnail in thumbnails)
                {
                    thumbnail.Save();
                }
            }
            else
            {
                throw new Exception("no uploaded photo data");
            }

            return originalPhoto;
        }
Example #4
0
        public static JqGridResponse Edit(EditMemberManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderMember aMember = new ProviderMember(model.Id);

            if (currentMember.CanEdit(aMember))
            {
                aMember.IsArticleAdmin = model.IsArticleAdmin;
                aMember.IsBanned = model.IsBanned;
                aMember.IsCategoryAdmin = model.IsCategoryAdmin;
                aMember.IsMasterAdmin = model.IsMasterAdmin;
                aMember.IsMemberAdmin = model.IsMemberAdmin;
                aMember.IsSuperAdmin = model.IsSuperAdmin;

                try
                {
                    aMember.Save();
                    aResponse.Success = true;
                }
                catch (Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Example #5
0
        public virtual ActionResult Account(long memberId, string issuedKey)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

            // If we have all of the required data then try an authentication with the issued key
            if (!currentMember.IsLoggedOn && !string.IsNullOrEmpty(issuedKey))
            {
                List<string> errorList = new List<string>();
                if (currentMember.Login(issuedKey, null, false, ref errorList) != ProviderCurrentMember.LoginEnum.success)
                {
                    // failed for whatever reason
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Failed to login: "******"Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null)),
                    };

                    returnValue = View("Message", viewModel);
                }
            }

            if (returnValue == null)
            {
                ProviderMember aMember = new ProviderMember(memberId);
                if (!currentMember.CanEdit(aMember))
                {
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Authorization Failure.  You may need to login or obtain access privileges to view this page.",
                        Title = "Authorization Failure",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null))
                    };

                    returnValue = View("Message", viewModel);
                }
                else
                {
                    returnValue = View(new AccountVM(aMember, currentMember));
                }
            }

            return returnValue;
        }
Example #6
0
        public virtual JsonResult EditAlternateCategory(long memberId, AlternateCategoryListVM model)
        {
            PartialPostVM returnValue = null;
            ProviderMember aMember = new ProviderMember(model.MemberId);
            if (ModelState.IsValid)
            {
                try
                {
                    ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
                    if (!currentMember.CanEdit(aMember))
                    {
                        // TODO: Replace this by throwing a real HTML 401 status code
                        Redirect(Url.Action(MVC.Error.Index(401)));
                    }
                    else if (!MemberBL.SaveAlternateCategories(model, aMember))
                    {
                        ModelState.AddModelError("", "Failed to save the alternate category changes. An administrator will contact you through e-mail regarding this issue.");
                    }
                    else
                    {
                        returnValue = new PartialPostVM
                        {
                            Action = PartialPostVM.ActionType.redirect,
                            Message = String.Empty,
                            Content = Request.UrlReferrer.AbsoluteUri
                        };
                    }
                }
                catch (Exception caughtException)
                {
                    InsideWordWebLog.Instance.Log.Error(caughtException);
                    ModelState.AddModelError("", "Failed to save the alternate category changes. An administrator will contact you through e-mail regarding this issue.");
                }
            }

            if (returnValue == null)
            {
                model.Refresh(aMember, ProviderCategory.Root.Children());
                returnValue = new PartialPostVM
                {
                    Action = PartialPostVM.ActionType.refresh,
                    Message = String.Empty,
                    Content = ControllerExtension.RenderPartialViewToString(this, MVC.Child.Views.EditAlternateCategory, (object)model)
                };
            }

            return Json(returnValue);
        }
Example #7
0
        public virtual ActionResult EditAlternateCategory(long memberId)
        {
            ActionResult returnValue = null;
            ProviderMember aMember = new ProviderMember(memberId);
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            if (currentMember.CanEdit(aMember))
            {
                returnValue = PartialView(new AlternateCategoryListVM(aMember,
                                                                      ProviderCategory.Root.Children()));
            }
            else
            {
                // TODO: Replace this by throwing a real HTML 401 status code
                returnValue = RedirectToAction(MVC.Error.Index(401));
            }

            return returnValue;
        }
Example #8
0
        public static JqGridResponse Delete(EditMemberManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderMember aMember = new ProviderMember(model.Id);
            if (currentMember.CanEdit(aMember))
            {
                if (aMember.Delete())
                {
                    aResponse.Success = true;
                }
                else
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Example #9
0
 public bool Parse(ProviderMember aMember, ProviderCurrentMember currentMember)
 {
     AllGroups = ProviderGroup.LoadAll().ConvertAll<GroupVM>(aGroup => new GroupVM(aGroup, currentMember));
     if (aMember != null)
     {
         MemberGroups = aMember.Groups.ConvertAll<GroupVM>(aGroup => new GroupVM(aGroup, currentMember)); ;
     }
     return true;
 }
Example #10
0
        public static bool SaveAlternateCategories(AlternateCategoryListVM model, ProviderMember aMember)
        {
            List<ProviderAlternateCategoryId> alternateList = aMember.AlternateCategoryList;
            ProviderCategory defaultCategory = new ProviderCategory(InsideWordSettingsDictionary.Instance.DefaultCategoryId.Value);
            foreach(AlternateCategoryMapVM aMap in model.AlternateCategoryMapList)
            {
                ProviderAlternateCategoryId altCategory = null;
                if (alternateList.Exists(altId => altId.AlternateId == aMap.AlternateId))
                {
                    altCategory = alternateList.Find(altId => altId.AlternateId == aMap.AlternateId);
                }
                else
                {
                    altCategory = new ProviderAlternateCategoryId();
                    altCategory.AlternateId = aMap.AlternateId;
                    altCategory.MemberId = aMember.Id.Value;
                }

                if (aMap.MapId.HasValue)
                {
                    if (aMap.MapId == -1)
                    {
                        aMap.MapId = defaultCategory.Id;
                    }

                    if (altCategory.CategoryId != aMap.MapId)
                    {
                        altCategory.CategoryId = aMap.MapId;
                        if (!altCategory.IsNew)
                        {
                            // The category map changed. Re-categorize all articles related to this alternate category.
                            AsyncRefreshArticleManager.Instance.AddBy(AsyncRefreshArticleManager.LoadEnum.AltCategory, altCategory.Id.Value);
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(aMap.AlternateTitle))
                {
                    altCategory.DisplayName = aMap.AlternateTitle;
                }
                altCategory.OverrideFlag = model.OverrideFlag;
                altCategory.Save();
            }

            return true;
        }
Example #11
0
 public AlternateCategoryListVM(ProviderMember aMember, List<ProviderCategory> categoryList)
 {
     OverrideFlag = false;
     MemberId = aMember.Id.Value;
     Refresh(aMember, categoryList);
 }
Example #12
0
 public PersonalInfoVM(ProviderMember aMember)
 {
     MemberId = aMember.Id.Value;
     Bio = aMember.Bio;
     if (aMember.UserNames.Count > 0)
     {
         UserName = aMember.UserNames[0].UserName;
     }
     else
     {
         UserName = "";
     }
 }
Example #13
0
        // GET: member/profile/{memberId}/{page}
        public virtual ActionResult Profile(long memberId, int? page)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            ProviderMember aMember = new ProviderMember(memberId);
            if (aMember.IsAnonymous && !currentMember.CanEdit(aMember))
            {
                if (currentMember.Owns(aMember))
                {
                    MessageVM viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "success",
                        Message = "Your profile doesn't exist yet! Choose a password and finish <a href='" + Url.Action(MVC.Member.ChangePassword()) + "' class='button'>activating</a> your account to get one.",
                        Title = "Info",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null))
                    };
                    return View(MVC.Shared.Views.Message, viewModel);
                }
                else
                {
                    returnValue = RedirectToAction(MVC.Error.Index(404));
                }
            }
            else
            {
                int nPage = page ?? 0;
                returnValue = View(new ProfileVM(aMember, currentMember, nPage));
            }

            return returnValue;
        }
Example #14
0
        public virtual ActionResult RequestValidateEmail(string newEmail, long memberId)
        {
            ActionResult returnValue = null;
            MailAddress mailAddress = null;

            // check if email is unique and try to parse it
            // if unique (not taken) and valid format (and thus not validated) then send activation email
            if (!IWStringUtility.TryParse(newEmail, out mailAddress))
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "Invalid e-mail",
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else if (ProviderEmail.FindOwner(mailAddress, true) != null)
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "E-mail is already taken.",
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else if (!ProviderMember.Exists(memberId))
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "No member with id "+memberId,
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else
            {
                ProviderMember member = new ProviderMember(memberId);
                ProviderEmail anEmail = new ProviderEmail();
                anEmail.MemberId = memberId;
                anEmail.IsValidated = false;
                anEmail.CreateDate = DateTime.UtcNow;
                anEmail.EditDate = DateTime.UtcNow;
                anEmail.Email = mailAddress;
                anEmail.Save();

                EmailManager.Instance.SendActivationEmail(mailAddress, member);

                returnValue = RedirectToAction(MVC.Member.EmailValidationSent());
            }

            return returnValue;
        }
Example #15
0
        public static bool Save(RegisterVM model, ref ProviderMember registerMember)
        {
            registerMember.Password = model.Password;
            registerMember.CreateDate = DateTime.UtcNow;
            registerMember.EditDate = DateTime.UtcNow;
            registerMember.Save();

            if (!string.IsNullOrWhiteSpace(model.Email))
            {
                ProviderEmail anEmail = new ProviderEmail();
                anEmail.MemberId = registerMember.Id.Value;
                anEmail.IsValidated = false;
                anEmail.CreateDate = DateTime.UtcNow;
                anEmail.EditDate = DateTime.UtcNow;
                anEmail.Email = new MailAddress(model.Email);
                anEmail.Save();
            }

            if(!string.IsNullOrWhiteSpace(model.UserName))
            {
                ProviderUserName aUserName = new ProviderUserName();
                aUserName.MemberId = registerMember.Id.Value;
                aUserName.CreateDate = DateTime.UtcNow;
                aUserName.EditDate = DateTime.UtcNow;
                aUserName.UserName = model.UserName;
                aUserName.Save();
            }

            return true;
        }
Example #16
0
        /// <summary>
        /// Function to send an Edit/Delete e-mail to a member.
        /// </summary>
        /// <param name="anArticle">Article that member would like to edit/delete</param>
        /// <param name="aMember">Member that will receive the e-mail</param>
        /// <returns>true if the e-mail was sent successfully and false otherwise.</returns>
        public bool SendEditArticleEmail(MailAddress email, ProviderArticle anArticle, ProviderMember aMember)
        {
            ProviderIssuedKey nonceIssuedKey = new ProviderIssuedKey();
            nonceIssuedKey.LoadOrCreate(aMember.Id.Value, email.Address, true, null, true);

            // create a month issued key for editing the article
            ProviderIssuedKey monthExpiry = new ProviderIssuedKey();
            monthExpiry.LoadOrCreate(aMember.Id.Value, email.Address, false, 1, true);

            string editUrl = HttpHost + "article/edit/" + anArticle.Id.Value + "/" + monthExpiry.IssuedKey;
            string activateUrl = HttpHost + "member/change_password/" + nonceIssuedKey.IssuedKey;
            string deleteUrl = HttpHost + "member/delete/" + nonceIssuedKey.IssuedKey;
            string submitState = "";
            if (anArticle.IsPublished)
            {
                submitState = "Your article was submited to our system.";
            }
            else
            {
                submitState = "Your article was submited to our system as a draft.";
            }
            string category;
            if(anArticle.CategoryIds.Count > 0)
            {
                category = (new ProviderCategory(anArticle.CategoryIds[0])).Title;
            }
            else
            {
                category = "none";
            }

            string emailBody = "DO NOT SHARE THIS E-MAIL OR REPLY TO THIS E-MAIL<br />"
                            + "<br />"
                            + "<br />"
                            + submitState + "<br />"
                            + "Id: "+anArticle.Id.Value.ToString()+"<br />"
                            + "Title: "+anArticle.Title +"<br />"
                            + "Category: " + category + "<br />"
                            + "<br />"
                            + "Click the link below to edit/delete your article at InsideWord:<br />"
                            + "<a href='" + editUrl + "'>EDIT ARTICLE</a><br />"
                            + "<br />";

            if (!aMember.IsActive)
            {
                emailBody += "Click the link below to finish activating your account:<br />"
                            + "<a href='" + activateUrl + "'>FINISH ACTIVATING ACCOUNT</a><br />"
                            + "<br />"
                            + "Don't know what this e-mail is about? Chances are someone used your e-mail by accident. Select the link below to delete the account:<br />"
                            + "<a href='" + deleteUrl + "'>DELETE ACCOUNT</a><br />"
                            + "<br />";
            }

            emailBody += "<br />"
                        + "<br />"
                        + "<br />";
                        //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - edit article " + anArticle.Title,
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
            return true;
        }
Example #17
0
        public bool SendHelpEmail(MailAddress email, ProviderMember aMember)
        {
            const string helpText = "DO NOT REPLY TO THIS E-MAIL<br />"
                                    + "<br />"
                                    + "<br />"
                                    + "<h1>Publish-by-E-mail Help, Tips & Tricks</h1>"
                                    + "<p>"
                                    + "When publishing by e-mail there are some special commands and tricks you should know about. "
                                    + "For starters, the subject line of the e-mail will be the Title of your article."
                                    + "The body of the e-mail is the text of your article and where you also write the special commands that will be discussed below."
                                    + "</p><p>"
                                    + "These special commands must be written first in the e-mail before the text of your article. "
                                    + "Some of these commands help only when editing an article by e-mail."
                                    + "</p><p>"
                                    + "To edit an article by e-mail you write the article's unique id number in the subject line instead of a title. "
                                    + "The unique article number id indicates to InsideWord which article you'd like to edit. "
                                    + "The unique number of an article is provided for you in the e-mail sent back to you when your article is accepted. "
                                    + "It can also be found in the web address when viewing the article."
                                    + "</p><p>"
                                    + "Below is the list of all valid commands when publishing by e-mail. "
                                    + "It is important that you write the square brackets [ and ]:"
                                    + "</p>"
                                    + "<ul>"
                                    + "    <li>"
                                    + "        [help] - This command will cause InsideWord to send you the help e-mail you're reading right now.<br />"
                                    + "        <br />Shorthand: [h]. Also for this command you can type [help], help, [h] or h in the subject of the e-mail.<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [category <i>category name</i>] - This command allows you to set the category for your article based on what you write for <i>category name</i>. "
                                    + "        The <i>category name</i> can be the name of the category or its unique id number. "
                                    + "        If you don't include a category when you initially publish an article by e-mail then the article will be saved as Draft (i.e. not visible to other people) until you set a category.<br />"
                                    + "        <br />Shorthand: [c <i>category name</i>]<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [blurb <i>your blurb</i>] - This command allows you to set the blurb of your article based on what you write for <i>your blurb</i>. "
                                    + "        By default if you don't include the blurb command then the blurb will be auto-generated after you publish the article from the first few sentences of your article.<br />"
                                    + "        <br />Shorthand: [b <i>your blurb</i>]<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [status draft] - This command allows you to save the article as a Draft. "
                                    + "        By default an article that is submitted by e-mail is automatically published on InsideWord (i.e. everyone can see it). "
                                    + "        So use this command if you want to edit the article a little more before publishing it at a late time. "
                                    + "        You can also use this command to change an article from Publish back to Draft.<br />"
                                    + "        <br />Shorthand: [draft] or [s d] or simply [d]<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [status publish] - This command allows you to save the article as Publish. "
                                    + "        By default an article that is submitted by e-mail is automatically published on InsideWord (i.e. everyone can see it). "
                                    + "        So typically this command is used to change an existing article you've written as Draft to Publish.<br />"
                                    + "        <br />Shorthand: [publish] or [s p] or simply [p]<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [append] - This command allows you to add additional text to the end of an existing article you've previously submitted. "
                                    + "        By default, when editing an article you will overwrite (i.e. completely erase and replace) your previous text. "
                                    + "        So typically this command is used when you want to incrementally add to the end of an existing article over time.<br / >"
                                    + "        <br />Shorthand: [a]<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [delete] - This command allows you to delete an existing article you've previously submitted. "
                                    + "        Use this command with caution as it will completely remove the article and everything related to it such as conversations and comments.<br />"
                                    + "        <br />Shorthand: To avoid accidental deletes, there is no shorthand for this command<br /><br />"
                                    + "    </li>"
                                    + "    <li>"
                                    + "        [read <i>unique article number</i>] - This command will cause InsideWord to e-mail you a specific article. "
                                    + "        If you omit an article id number then it will e-mail you the article you're currently submiting. "
                                    + "        Use this command and the [status draft] command to help you preview your article before Publishing it. <br />"
                                    + "        <br />Shorthand: [r <i>unique article number</i>]. You can also send a blank e-mail with just the article id number in the subject<br /><br />"
                                    + "    </li>"
                                    + "</ul>"
                                    + "<br />"
                                    + "<h2>Examples</h2>"
                                    + "<p>"
                                    + "    <u>Note:</u> The terms <b>Subject</b> and <b>Body</b> are being used to indicate where the commands should be written in the e-mail. "
                                    + "     You should not actually write <b>Subject</b> or <b>Body</b>."
                                    + "</p>"
                                    + "<p>"
                                    + "    Here is an example e-mail that publishes a new article with the Title \"Hello world!\" and with the text \"This is an article\". "
                                    + "    The category command was not used so it will have no category and will be saved by InsideWord as a Draft."
                                    + "</p>"
                                    + _tab + "<b>Subject:</b> Hello world!<br />"
                                    + _tab + "<b>Body:</b> This is an article!<br />"
                                    + "<br />"
                                    + "<br />"
                                    + "<p>"
                                    + "    Here is an example e-mail that adds to the previous article (let's pretend the previous article's id was 11). "
                                    + "    The article's new body after this will be \"This is an article with more text\". "
                                    + "    Note the article still has no category."
                                    + "</p>"
                                    + _tab + "<b>Subject:</b> 11<br />"
                                    + _tab + "<b>Body:</b> [append]<br />"
                                    + _tab + "with more text<br />"
                                    + "<br />"
                                    + "<br />"
                                    + "<p>This example e-mail will finally add a category to the previous article and will publish it.</p>"
                                    + _tab + "<b>Subject:</b> 11<br />"
                                    + _tab + "<b>Body:</b> [category politics]<br />"
                                    + _tab + "[status publish]<br />"
                                    + "<br />"
                                    + "<br />"
                                    + "<p>This example e-mail will return to us the article with id 23.</p>"
                                    + _tab + "<b>Subject:</b> 23<br />"
                                    + _tab + "<b>Body:</b>"
                                    + "<br />"
                                    + "<p>Below is the article returned by this e-mail.</p>"
                                    + _tab + "<b>Subject:</b> 23<br />"
                                    + _tab + "<b>Body:</b> [title example article]<br />"
                                    + _tab + "[category fun]<br />"
                                    + _tab + "[status draft]<br />"
                                    + _tab + "I have yet to publish this article... will do it at some later date.<br />"
                                    + "<p>"
                                    + "    The article as you can see is already formated for editing purposes and can be resent. "
                                    + "    It should be mentioned however that only articles that are yours or have been published can be retrieved this way. "
                                    + "    You also cannot edit this article unless you are the owner."
                                    + "</p>"
                                    + "<br />"
                                    + "<p>To help avoid some confusion, do note that an article that is published on our main site and an article that is published by e-mail are the same thing. You can edit an article that was published by e-mail using our website AND you can edit an article published on our site by using e-mail.</p>";

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - help",
                                                        helpText);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
            return true;
        }
Example #18
0
        /// <summary>
        /// Function to send an notification that the article was commented on
        /// </summary>
        /// <param name="anArticle">Article that was commented on</param>
        /// <param name="aMember">Member that will receive the e-mail</param>
        /// <returns>true if the e-mail was sent successfully and false otherwise.</returns>
        public bool SendCommentNotificationEmail(MailAddress email, ProviderArticle anArticle, ProviderMember commentAuthor)
        {
            string articleUrl = HttpHost + "article/" + anArticle.Id;
            string memberUrl = string.Empty;
            if (commentAuthor.IsAnonymous)
            {
                memberUrl = "Anonymous";
            }
            else
            {
                memberUrl = "<a href='"+HttpHost + "member/profile/" + commentAuthor.Id.Value+"'>" + commentAuthor.DisplayName + "</a>";
            }

            string emailBody = "DO NOT REPLY TO THIS E-MAIL<br />"
                + "<br />"
                + "<br />"
                + memberUrl + " has left a comment on your article, <a href='" + articleUrl + "'>" + anArticle.Title + "</a>"
                + "<br />"
                + "<br />"
                + "<br />";
                //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - Someone commented on your article! " + anArticle.Title,
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
            return true;
        }
Example #19
0
        /// <summary>
        /// Function to send an Edit/Delete e-mail to a member.
        /// </summary>
        /// <param name="anArticle">Article that member would like to edit/delete</param>
        /// <param name="aMember">Member that will receive the e-mail</param>
        /// <returns>true if the e-mail was sent successfully and false otherwise.</returns>
        public bool SendArticleEmail(MailAddress email, ProviderArticle anArticle, ProviderMember aMember)
        {
            string emailText = "[title " + anArticle.Title + "]<br />";

            if (anArticle.IsPublished)
            {
                emailText += "[status publish]<br />";
            }
            else
            {
                emailText += "[status draft]<br />";
            }

            if (anArticle.CategoryIds.Count > 0)
            {
                emailText += "[category "+(new ProviderCategory(anArticle.CategoryIds[0])).Title+"]<br />";
            }

            if (!anArticle.BlurbIsAutoGenerated)
            {
                emailText += "[blurb " + anArticle.Blurb+"]<br />";
            }

            emailText += "<br />" + anArticle.ParsedText;

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        anArticle.Id.ToString(),
                                                        emailText);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);

            return true;
        }
Example #20
0
        public void SendActivationEmail(MailAddress email, ProviderMember aMember)
        {
            ProviderIssuedKey nonceIssuedKey = new ProviderIssuedKey();
            nonceIssuedKey.LoadOrCreate(aMember.Id.Value, email.Address, true, null, true);

            string activateUrl = HttpHost + "member/validate_email/" + nonceIssuedKey.IssuedKey;
            string deleteUrl = HttpHost + "member/delete/" + nonceIssuedKey.IssuedKey;
            string emailBody = "DO NOT SHARE THIS E-MAIL OR REPLY TO THIS E-MAIL<br />"
                            + "<br />"
                            + "<br />"
                            + "Click the link below to validate your e-mail with InsideWord:<br />"
                            + "<a href='" + activateUrl + "'>VALIDATE E-MAIL</a><br />"
                            + "<br />"
                            + "Don't know what this e-mail is about? Chances are someone used your e-mail by accident. Select the link below to delete the account:<br />"
                            + "<a href='" + deleteUrl + "'>DELETE ACCOUNT</a><br />"
                            + "<br />"
                            + "<br />"
                            + "<br />";
                            //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - e-mail validation",
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
        }
Example #21
0
 public GroupIndexVM(ProviderMember aMember, ProviderCurrentMember currentMember)
 {
     Parse(aMember, currentMember);
 }
Example #22
0
        public static bool SavePersonalInfo(PersonalInfoVM model, ProviderMember aMember)
        {
            // save username and bio.  everything else is saved asynchronously through other methods
            aMember.Bio = model.Bio;
            aMember.Save();

            if (string.IsNullOrWhiteSpace(model.UserName))
            {
                // If someone blanked out their username then delete it.
                // Otherwise it was just blank so do nothing.
                if (aMember.UserNames.Count > 0)
                {
                    aMember.UserNames[0].Delete();
                }
            }
            else
            {
                // If the user name was not blank then create it
                ProviderUserName userName;
                if (aMember.UserNames.Count > 0)
                {
                    userName = aMember.UserNames[0];
                }
                else
                {
                    userName = new ProviderUserName();
                    userName.MemberId = aMember.Id.Value;
                    userName.CreateDate = DateTime.UtcNow;
                }
                userName.EditDate = DateTime.UtcNow;
                userName.UserName = model.UserName;
                userName.Save();
            }

            return true;
        }
Example #23
0
 public static void Delete(long id)
 {
     ProviderMember aMember = new ProviderMember(id);
     aMember.Delete();
 }
Example #24
0
        public AccountVM(ProviderMember aMember, ProviderCurrentMember currentMember)
        {
            Member = new MemberVM(aMember, currentMember);
            PageTitle = aMember.DisplayAdministrativeName + " Account";
            EmailAddresses = aMember.Emails.Select(email => email.Email.Address).ToList();
            OpenIds = aMember.OpenIds;

            ProfileImage = MemberBL.GetProfileImage(aMember);

            if (currentMember.CanEdit(aMember) && currentMember.HasAdminRights)
            {
                ArticleList = ProviderArticle.LoadBy(aMember.Id.Value, null, null).ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            else
            {
                ArticleList = ProviderArticle.LoadBy(aMember.Id.Value, null, false).ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            NoArticles = ArticleList.Count == 0;
            DisplayAlternateCategories = aMember.HasAlternateCategories && currentMember.HasAdminRights;
        }
Example #25
0
        // POST: /member/delete
        public virtual ActionResult Delete(string key)
        {
            MessageVM returnMessageVM;
            ProviderIssuedKey issuedKey = new ProviderIssuedKey();

            if (issuedKey.Load(key) && !issuedKey.HasExpired && issuedKey.IsValidated)
            {
                ProviderMember aMember = new ProviderMember(issuedKey.MemberId);
                ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

                // if the person is currently logged on with the account that is being deleted then log them off
                if (currentMember.Id == aMember.Id)
                {
                    currentMember.LogOff();
                }

                aMember.Delete();

                returnMessageVM = new MessageVM
                {
                    Image = ImageLibrary.Success,
                    CssClassContainer = "success",
                    Message = "Success! Member Acount deleted.",
                    Title = "Acount Deleted",
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Home.Index())
                };
            }
            else
            {
                returnMessageVM = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "Failed to delete member account.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                    Title = "Account Deletion Failure",
                    LinkText = "Continue",
                    LinkHref = Url.Action( MVC.Home.Index() )
                };
            }

            return View("Message", returnMessageVM);
        }
Example #26
0
        public ProfileVM(ProviderMember aMember, ProviderCurrentMember currentMember, int page)
        {
            string userName = null;
            CurrentMember = new CurrentMemberVM(currentMember, aMember);

            if (CurrentMember.CanEdit)
            {
                userName = aMember.DisplayAdministrativeName;
            }
            else
            {
                userName = aMember.DisplayName;
            }

            int skip = page * BLURBS_PER_PAGE;
            if(skip > MAX_BLURBS)
            {
                ArticleList = new List<ArticleVM>();
            }
            else
            {
                bool? showPublished = true;
                if (CurrentMember.CanEdit)
                {
                    showPublished = null;
                }
                bool? showHidden = false;
                if (CurrentMember.CanEdit)
                {
                    showHidden = null;
                }
                ArticleList = ProviderArticle.LoadNewestBy(aMember, skip, BLURBS_PER_PAGE, showHidden, showPublished)
                                               .ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            IsLastPage = ArticleList.Count < BLURBS_PER_PAGE;
            NextPage = page + 1;

            if (aMember.HasValidAltId(ProviderAlternateMemberId.AlternateType.Domain))
            {
                ProviderDomain aDomain = aMember.Domains[0];
                HasWeb = true;
                WebUri = aDomain.Domain.AbsoluteUri;
                WebDisplay = IWStringUtility.TruncateClean(aDomain.DisplayName, ProviderMember.UserNameSize);
            }

            PageTitle = userName + " Profile";
            HeaderTitle = IWStringUtility.TruncateClean(userName, 28);
            Birthday = String.Format("{0:MMMM d, yyyy}", aMember.CreateDate);
            MemberId = aMember.Id;
            UserName = userName;
            ProfileImage = MemberBL.GetProfileImage(aMember);
            HasBio = !string.IsNullOrWhiteSpace(aMember.Bio);
            Bio = aMember.Bio;
        }
Example #27
0
        public void SendPasswordResetEmail(MailAddress email, ProviderMember aMember)
        {
            string passwordResetUrl = HttpHost + "member/change_password/" + aMember.CurrentMonthIssuedKey.IssuedKey;

            string emailBody = "DO NOT SHARE THIS E-MAIL OR REPLY TO THIS E-MAIL<br />"
                            + "<br />"
                            + "<br />"
                            + "Click the link below to choose your new password:<br />"
                            + "<a href='" + passwordResetUrl + "'>RESET PASSWORD</a><br />"
                            + "<br />"
                            + "<br />"
                            + "<br />";
                            //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - reset password e-mail",
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
        }
Example #28
0
        /// <summary>
        /// Function to update or create an member account with openId information.
        /// </summary>
        /// <param name="openId">openId of the member account we wish to create or update</param>
        /// <param name="email">e-mail information of the member</param>
        /// <param name="host">the open id provider hostname (www.google.com for instance)</param>
        /// <returns>true if the member was successfully updated/created.</returns>
        public static bool UpdateMemberOpenId(string openId, MailAddress email, string host)
        {
            // check if this member exists already
            ProviderMember aMember;
            ProviderEmail anEmailId = new ProviderEmail();
            ProviderOpenId anOpenId = new ProviderOpenId();

            // Prepare the e-mail
            if (email != null)
            {
                if (!anEmailId.Load(email.Address))
                {
                    anEmailId.CreateDate = DateTime.UtcNow;
                    anEmailId.EditDate = DateTime.UtcNow;
                    anEmailId.Email = email;
                    anEmailId.IsValidated = true;
                }
            }

            // Prepare the openId
            if (!anOpenId.Load(openId))
            {
                anOpenId.CreateDate = DateTime.UtcNow;
                anOpenId.EditDate = DateTime.UtcNow;
                anOpenId.OpenId = openId;
                anOpenId.DisplayName = host;
                anOpenId.IsValidated = true;
            }

            // TODO: my gut tells me these if statements can possibly be reduced to something simpler
            if (anOpenId.IsNew && anEmailId.IsNew)
            {
                // This person doesn't exist yet so create them
                aMember = new ProviderMember();
                aMember.CreateDate = DateTime.UtcNow;
                aMember.EditDate = DateTime.UtcNow;
                aMember.Save();

                // create the e-mail
                if (email != null)
                {
                    anEmailId.MemberId = aMember.Id.Value;
                    anEmailId.Save();
                }

                // create the openId
                anOpenId.MemberId = aMember.Id.Value;
                anOpenId.Save();
            }
            else if (!anOpenId.IsNew && anEmailId.IsNew && email != null)
            {
                // this person has an account already with an open id but no e-mail so just add the e-mail to the account
                aMember = new ProviderMember(anOpenId.MemberId);
                aMember.EditDate = DateTime.UtcNow;
                aMember.Save();

                anEmailId.MemberId = aMember.Id.Value;
                anEmailId.Save();
            }
            else if (anOpenId.IsNew && !anEmailId.IsNew)
            {
                // this person has an account already with an e-mail but no openId so just add the openId to the account
                aMember = new ProviderMember(anEmailId.MemberId);
                aMember.EditDate = DateTime.UtcNow;
                aMember.Save();

                anOpenId.MemberId = aMember.Id.Value;
                anOpenId.Save();
            }
            else if ( !anOpenId.IsNew && !anEmailId.IsNew && anOpenId.MemberId != anEmailId.MemberId)
            {
                // TODO: Crap two different accounts!
                // Do nothing for now but what we really want to do is try and merge the two accounts (with user permission of course).
            }
            else
            {
                // No updates are required
            }

            return true;
        }
Example #29
0
        public virtual JsonResult _GetJqGridArticleList(long memberId, AccountArticleFilterVM model)
        {
            ProviderMember aMember = new ProviderMember(memberId);
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            if (currentMember.CanEdit(aMember))
            {
                model.MemberId = memberId;
                JqGridList<ProviderArticle> jqGridList;
                if (ModelState.IsValid)
                {
                    List<ProviderArticle> articleList = ProviderArticle.LoadBy(model.GetFilter);
                    jqGridList = new JqGridList<ProviderArticle>(model.GetFilter,
                                                                articleList,
                                                                JqGridConverter.Article,
                                                                ProviderArticle.Count(model.GetFilter));
                }
                else
                {
                    jqGridList = new JqGridList<ProviderArticle>();
                }

                return Json(jqGridList, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return null;
            }
        }
Example #30
0
        public static List<ProviderArticle> LoadNewestBy(ProviderMember aMember, int skipAmount, int takeAmount, bool? isHidden = null, bool? isPublished = null)
        {
            if (_loadNewestBy == null)
            {
                // compile this query
                _loadNewestBy = CompiledQuery.Compile<InsideWordEntities, long, int, int, bool?, bool?, IQueryable<Article>>(
                    (ctx, memberId, skip, take, hidden, published) => ctx.Articles
                                    .Include("Member.AlternateMemberIds")
                                    .Include("Photos.Thumbnails")
                                    .Include("ArticleScores")
                                    .Include("ArticleTexts")
                                    .Where(article => (article.MemberId != null && article.MemberId == memberId) &&
                                                      (hidden == null || article.IsHidden == hidden) &&
                                                      (published == null || article.IsPublished == published)
                                          )
                                    .OrderByDescending(article => article.SystemCreateDate)
                                    .Skip(skip)
                                    .Take(take)
                );
            }

            //Checking the article's categories against the the FUllPath will ensure that we include the subcategories
            List<ProviderArticle> articleList = _loadNewestBy.Invoke(DbCtx.Instance, aMember.Id.Value, skipAmount, takeAmount, isHidden, isPublished)
                                                                   .ToList()
                                                                   .ConvertAll(_converterEntityToProvider);
            return articleList;
        }