Ejemplo n.º 1
0
        protected void createMember(object sender, EventArgs e)
        {
            if (tb_email.Text != "")
                {
                    m = Member.GetMemberFromEmail(tb_email.Text);
                    if (m == null)
                    {
                        MemberType mt = MemberType.GetByAlias(memberType);
                        m = Member.MakeNew(tb_name.Text, mt, new umbraco.BusinessLogic.User(0));
                        m.Email = tb_email.Text;
                        m.Password = tb_password.Text;
                        m.LoginName = tb_email.Text;

                        //Standard values
                        m.getProperty("reputationTotal").Value = 20;
                        m.getProperty("reputationCurrent").Value = 20;
                        m.getProperty("forumPosts").Value = 0;

                        if (!string.IsNullOrEmpty(Group))
                        {
                            MemberGroup mg = MemberGroup.GetByName(Group);
                            if (mg != null)
                                m.AddGroup(mg.Id);
                        }

                        //set a default avatar
                        Api.CommunityController.SetAvatar(m.Id, "gravatar");

                        m.Save();
                        m.XmlGenerate(new System.Xml.XmlDocument());
                        Member.AddMemberToCache(m);
                        Response.Redirect(umbraco.library.NiceUrl(NextPage));
                    }
                }
        }
Ejemplo n.º 2
0
 new protected virtual void OnNewMember(NewMemberUIEventArgs e, string unencryptedPassword, Member m)
 {
     if (NewMember != null)
     {
         NewMember(m, unencryptedPassword, e);
     }
 }
        /// <summary>
        ///   Gets the image property.
        /// </summary>
        /// <returns></returns>
        internal static string GetOriginalUrl(int nodeId, ImageResizerPrevalueEditor imagePrevalueEditor)
        {
            Property imageProperty;
            var node = new CMSNode(nodeId);
            if (node.nodeObjectType == Document._objectType)
            {
                imageProperty = new Document(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }
            else if (node.nodeObjectType == Media._objectType)
            {
                imageProperty = new Media(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }
            else
            {
                if (node.nodeObjectType != Member._objectType)
                {
                    throw new Exception("Unsupported Umbraco Node type for Image Resizer (only Document, Media and Members are supported.");
                }
                imageProperty = new Member(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }

            try
            {
                return imageProperty.Value.ToString();
            }
            catch
            {
                return string.Empty;
            }
        }
Ejemplo n.º 4
0
        private void RegisterIP()
        {
            if (umbraco.library.IsLoggedOn())
            {
                string ip = HttpContext.Current.Request.UserHostAddress;
                umbraco.cms.businesslogic.member.Member mem = umbraco.cms.businesslogic.member.Member.GetCurrentMember();

                if (mem != null)
                {
                    if (mem.getProperty("ip") != null && mem.getProperty("ip").Value.ToString() != ip)
                    {
                        mem.getProperty("ip").Value = ip;
                        mem.Save();
                    }

                    if (mem.getProperty("blocked") != null && mem.getProperty("blocked").Value.ToString() == "1")
                    {
                        umbraco.cms.businesslogic.member.Member.RemoveMemberFromCache(mem);
                        umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(mem);
                        Response.Redirect(umbraco.library.NiceUrl(BlockedPage));
                    }


                    // if terms of service is not accepted and we're not on the Terms of Service page, redirect
                    if (!Request.Url.PathAndQuery.ToLower().StartsWith("/termsofservice") && mem.getProperty("tos") != null && mem.getProperty("tos").Value.ToString() == "")
                    {
                        Response.Redirect("/termsofservice");
                    }
                }
            }
        }
        protected void LinkBanMemberClick(object sender, EventArgs e)
        {
            if (CurrentMember.MemberIsAdmin && ProfileMember.MemberId != null)
            {
                string usermessage;
                var cMem = new Member((int)ProfileMember.MemberId);

                if(ProfileMember.MemberIsBanned)
                {
                    //Un ban member
                    cMem.getProperty("forumUserIsBanned").Value = "0";
                    usermessage = library.GetDictionaryItem("MemberIsNowNotBanned");
                }
                else
                {
                    // Ban the member
                    cMem.getProperty("forumUserIsBanned").Value = "1";
                    usermessage = library.GetDictionaryItem("MemberIsNowBanned");
                }

                //Save member
                cMem.Save();

                //Generate member Xml Cache
                cMem.XmlGenerate(new System.Xml.XmlDocument());

                // Redirect to show message
                Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", usermessage));
            }
        }
Ejemplo n.º 6
0
        public void MemberGroup_Add_Member_To_Group_And_Delete_Group()
        {
            var mt = MemberType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N"));
            var m = Member.MakeNew("TEST" + Guid.NewGuid().ToString("N"),
                "TEST" + Guid.NewGuid().ToString("N") + "@test.com", mt, m_User);

            var mg = MemberGroup.MakeNew("TEST" + Guid.NewGuid().ToString("N"), m_User);
            Assert.IsInstanceOfType(mg, typeof(MemberGroup));
            Assert.IsTrue(mg.Id > 0);          

            //add the member to the group
            m.AddGroup(mg.Id);

            //ensure they are added
            Assert.AreEqual(1, m.Groups.Count);
            Assert.AreEqual<int>(mg.Id, ((MemberGroup)m.Groups.Cast<DictionaryEntry>().First().Value).Id);

            //delete the group
            mg.delete();

            //make sure the member is no longer associated
            m = new Member(m.Id); //need to re-get the member
            Assert.AreEqual<int>(0, m.Groups.Count);
            
            //now cleanup...

            m.delete();
            Assert.IsFalse(Member.IsNode(m.Id));

            mt.delete();
            Assert.IsFalse(MemberType.IsNode(mt.Id));
        }
Ejemplo n.º 7
0
        public void delete(int id, string username, string password)
        {
            Authenticate(username, password);

            // We load the member
            umbraco.cms.businesslogic.member.Member deleteMember;
            try
            {
                deleteMember = new umbraco.cms.businesslogic.member.Member(id);
            }
            catch (Exception ex)
            {
                throw new Exception("Member not found" + ex.Message);
            }

            // We delete him (cruel world)
            try
            {
                deleteMember.delete();
            }
            catch (Exception ex)
            {
                throw new Exception("Member could not be deleted" + ex.Message);
            }
        }
        protected void bt_submit_Click(object sender, EventArgs e)
        {
            umbraco.presentation.nodeFactory.Node p = new umbraco.presentation.nodeFactory.Node(int.Parse(Request.QueryString["id"]));

            Member owner = new Member(int.Parse(p.GetProperty("owner").Value));
            Member m = Member.GetCurrentMember();

            MailMessage mm = new MailMessage();
            mm.Subject = "Umbraco community: Request to contribute to project";

            mm.Body =
                string.Format("The Umbraco Community member '{0}'  would like to contribute to your project '{1}'.  You can add the member to the project from your profile on our.umbraco.org.",
                m.Text, p.Name);

            mm.Body = mm.Body + string.Format("\n\r\n\rMessage from {0}: \n\r\n\r", m.Text) + tb_message.Text;

            mm.To.Add(owner.Email);
            mm.From = new MailAddress(m.Email);

            SmtpClient c = new SmtpClient();
            c.Send(mm);

            umbraco.presentation.nodeFactory.Node current = umbraco.presentation.nodeFactory.Node.GetCurrent();

            Response.Redirect(umbraco.library.NiceUrl(current.Children[0].Id));
        }
Ejemplo n.º 9
0
        private void SaveProject(Document project, Member user)
        {
            if (!string.IsNullOrWhiteSpace(Request["title"]))
            {
                project.getProperty("title").Value = Request["title"];
            }
            if (!string.IsNullOrWhiteSpace(Request["description"]))
                project.getProperty("description").Value = Request["description"];
            if (!string.IsNullOrWhiteSpace(Request["projectType"]))
                project.getProperty("projectType").Value = Convert.ToInt32(Request["projectType"]);
            if (!string.IsNullOrWhiteSpace(Request["area"]))
                project.getProperty("area").Value = Convert.ToInt32(Request["area"]);
            project.getProperty("allowComments").Value = !string.IsNullOrWhiteSpace(Request["allowComments"]) && Request["allowComments"].ToLower().Equals("on");

            project.getProperty("author").Value = user.Id;

            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                var uploadedFile = Request.Files[0];
                var fileName = Path.GetFileName(uploadedFile.FileName);
                var fileSavePath = Server.MapPath("~/media/projects/" + fileName);
                uploadedFile.SaveAs(fileSavePath);

                project.getProperty("image").Value = "/media/projects/" + fileName;
            }

            project.SaveAndPublish(user.User);
            umbraco.library.UpdateDocumentCache(project.Id);
        }
Ejemplo n.º 10
0
        public static string SetAvatar(int mId, string service)
        {
            string retval = "";
            Member m = new Member(mId);

            if (m != null) {
                switch (service) {

                    case "twitter":
                        if (m.getProperty("twitter") != null && m.getProperty("twitter").Value.ToString() != "") {
                            XPathNodeIterator twitData = Twitter.Profile(m.getProperty("twitter").Value.ToString());
                            if (twitData.MoveNext()) {
                                string imgUrl = twitData.Current.SelectSingleNode("//profile_image_url").Value;
                                return saveUrlAsBuddyIcon(imgUrl, m);
                            }
                        }
                        break;
                    case "gravatar":
                        string gUrl = "http://www.gravatar.com/avatar/" + umbraco.library.md5(m.Email) + "?s=48&d=monsterid";
                        return saveUrlAsBuddyIcon(gUrl, m);
                    default:
                        break;
                }
            }

            return retval;
        }
        public override bool SendNotification(System.Xml.XmlNode details, params object[] args)
        {
            try
            {
                SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText);
                c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText);

                MailAddress from = new MailAddress(
                    details.SelectSingleNode("//from/email").InnerText,
                    details.SelectSingleNode("//from/name").InnerText);

                string subject = details.SelectSingleNode("//subject").InnerText;
                string body = details.SelectSingleNode("//body").InnerText;

                string domain = details.SelectSingleNode("//domain").InnerText;

                int topicId = int.Parse(args[0].ToString());
                int memberId = int.Parse(args[1].ToString());

                uForum.Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId);

                Member m = new Member(memberId);

                body = string.Format(body,
                    t.Title,
                   "https://" + domain + args[2].ToString());

                if (m.getProperty("bugMeNot").Value.ToString() != "1")
                {
                    MailMessage mm = new MailMessage();
                    mm.Subject = subject;
                    mm.Body = body;

                    mm.To.Add(m.Email);
                    mm.From = from;

                    c.Send(mm);
                }

                SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"]);

                conn.Open();

                string insert =
                       "Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())";

                SqlCommand icomm = new SqlCommand(insert, conn);
                icomm.Parameters.AddWithValue("@topicId", topicId);
                icomm.Parameters.AddWithValue("@memberID", m.Id);
                icomm.ExecuteNonQuery();

                conn.Close();
            }
            catch (Exception e)
            {
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "[Notifications]" + e.Message);
            }
            return true;
        }
Ejemplo n.º 12
0
        public static Member GetMember(int id)
        {
            Member m = Member.GetMemberFromCache(id);
            if (m == null)
                m = new Member(id);

            return m;
        }
Ejemplo n.º 13
0
 private void Member_AfterSave(Member sender, SaveEventArgs e)
 {
     //ensure that only the providers are flagged to listen execute
     var xml = sender.ToXml(new System.Xml.XmlDocument(), false).ToXElement();
     var providers = ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
         .Where(x => x.EnableDefaultEventHandler);
     ExamineManager.Instance.ReIndexNode(xml, IndexTypes.Member, providers);
 }
Ejemplo n.º 14
0
        private static void MemberAfterSave(Member sender, SaveEventArgs e)
        {
            //ensure that only the providers are flagged to listen execute
            var xml       = ExamineXmlExtensions.ToXElement(sender.ToXml(new System.Xml.XmlDocument(), false));
            var providers = ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                            .Where(x => x.EnableDefaultEventHandler);

            ExamineManager.Instance.ReIndexNode(xml, IndexTypes.Member, providers);
        }
Ejemplo n.º 15
0
        private static void MemberAfterDelete(Member sender, DeleteEventArgs e)
        {
            var nodeId = sender.Id.ToString();

            //ensure that only the providers are flagged to listen execute
            ExamineManager.Instance.DeleteFromIndex(nodeId,
                                                    ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                                                    .Where(x => x.EnableDefaultEventHandler));
        }
Ejemplo n.º 16
0
        public static void SendMailFromPageToMember(string FromMail, Member member, string Subject, int PageId, string body, Dictionary<string, LinkedResource> imagedictionary)
        {
            MailMessage mail = Helper.BuildMail(member,Subject, body, imagedictionary);

            mail.From = new MailAddress(FromMail.Trim());
            mail.To.Add(new MailAddress(member.Email));

            SendMail(mail);
        }
Ejemplo n.º 17
0
        private void Member_AfterDelete(Member sender, DeleteEventArgs e)
        {
            var nodeId = sender.Id.ToString();

            //ensure that only the providers are flagged to listen execute
            ExamineManager.Instance.DeleteFromIndex(nodeId,
                ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                    .Where(x => x.EnableDefaultEventHandler));
        }
Ejemplo n.º 18
0
 private void SendAdminNotification(Member newmember)
 {
     var sb = new StringBuilder();
     sb.AppendFormat(library.GetDictionaryItem("MemberSignUpEmailText"), 
         Settings.Name, 
         newmember.LoginName, 
         newmember.Text, 
         newmember.Email);
     Helpers.SendMail(Settings.EmailNotification, Settings.EmailAdmin, library.GetDictionaryItem("NewMemberSignUp"), sb.ToString());
 }
        public memberCarrier readById(int memberId, string username, string password)
        {
            Authenticate(username, password);

            umbraco.cms.businesslogic.member.Member foundMember = new umbraco.cms.businesslogic.member.Member(memberId);
            if (foundMember == null)
                return null;

            return CreateMemberCarrier(foundMember);
        }
Ejemplo n.º 20
0
        void Member_AfterSave(Member sender, umbraco.cms.businesslogic.SaveEventArgs e)
        {

            string groups = "";
            foreach (MemberGroup mg in sender.Groups.Values)
            {
                groups += mg.Text + ",";
            }

            sender.getProperty("groups").Value = groups.Trim().Trim(','); ;
            sender.XmlGenerate(new System.Xml.XmlDocument());
        }
Ejemplo n.º 21
0
        private Document CreateProject(Member user)
        {
            if (!string.IsNullOrWhiteSpace(Request["title"]))
            {
                var project = Document.MakeNew(Request["title"], DocumentType.GetByAlias("project"), user.User, new Node(1133).Id);
                SaveProject(project, user);

                return project;
            }

            return null;
        }
Ejemplo n.º 22
0
        public memberCarrier readById(int memberId, string username, string password)
        {
            Authenticate(username, password);

            umbraco.cms.businesslogic.member.Member foundMember = new umbraco.cms.businesslogic.member.Member(memberId);
            if (foundMember == null)
            {
                return(null);
            }

            return(CreateMemberCarrier(foundMember));
        }
Ejemplo n.º 23
0
        void Member_AfterSave(umbraco.cms.businesslogic.member.Member sender, umbraco.cms.businesslogic.SaveEventArgs e)
        {
            string groups = "";

            foreach (MemberGroup mg in sender.Groups.Values)
            {
                groups += mg.Text + ",";
            }

            sender.getProperty("groups").Value = groups.Trim().Trim(',');;
            sender.XmlGenerate(new System.Xml.XmlDocument());
        }
Ejemplo n.º 24
0
        public memberCarrier readByLogin(string memberLoginName, string memberPassword, string username, string password)
        {
            Authenticate(username, password);

            umbraco.cms.businesslogic.member.Member foundMember = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginNameAndPassword(memberLoginName, memberPassword);
            if (foundMember == null)
            {
                return(null);
            }

            return(CreateMemberCarrier(foundMember));
        }
Ejemplo n.º 25
0
        protected void logout_click(object sender, EventArgs e)
        {
            if (umbraco.library.IsLoggedOn())
            {
                umbraco.cms.businesslogic.member.Member mem = umbraco.cms.businesslogic.member.Member.GetCurrentMember();
                umbraco.cms.businesslogic.member.Member.RemoveMemberFromCache(mem);
                umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(mem);

                uForum.Businesslogic.ForumEditor.ClearEditorChoiceCookie();

                Response.Redirect(umbraco.presentation.nodeFactory.Node.GetCurrent().Url);
            }
        }
Ejemplo n.º 26
0
        public static string ThumbsUpPost(string postId)
        {
            if (MembershipHelper.IsAuthenticated())
            {
                var m = Member.GetCurrentMember();
                var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(postId)));

                // If this current member id owns the post then ignore
                if (forumPost != null)
                {
                    if (m.Id != forumPost.Owner.MemberId)
                    {
                        // Get the member who wrote the post
                        var postMember = new Member(Convert.ToInt32(forumPost.Owner.MemberId));

                        // Get a user to save both documents with
                        var usr = new User(0);

                        // First update the karma on the post and add this logged in user to
                        // list if people who have voted on post
                        var p = new Document(forumPost.Id);
                        var votedUsers = p.getProperty("forumPostUsersVoted").Value.ToString();
                        var formattedMemberId = string.Format("{0}|", m.Id);

                        // Check to make sure they are not fiddling the system
                        if (forumPost.VotedMembersIds == null || !forumPost.VotedMembersIds.Contains(m.Id))
                        {
                            p.getProperty("forumPostKarma").Value = (forumPost.Karma + 1);
                            p.getProperty("forumPostUsersVoted").Value = formattedMemberId + votedUsers;
                            p.Publish(usr);
                            umbraco.library.UpdateDocumentCache(p.Id);
                            var newPostKarma = (forumPost.Karma + 1);

                            // Now update the members karma based on the forum settings
                            forumPost.Karma = Convert.ToInt32(postMember.getProperty("forumUserKarma").Value.ToString());
                            postMember.getProperty("forumUserKarma").Value = (forumPost.Karma + Helpers.MainForumSettings().KarmaPointsAddedForThumbUps);

                            // Save Member details
                            postMember.Save();

                            //Generate member Xml Cache
                            postMember.XmlGenerate(new System.Xml.XmlDocument());

                            return newPostKarma.ToString();
                        }
                    }
                }
            }

            return "0";
        } 
Ejemplo n.º 27
0
 public static bool UpdateSecretCode(Member member)
 {
     string secretCode = Upac.Core.Security.RandomPassword.Generate(CommonUtil.GetSetting("Membership/SecretCodeLength", 7));
     if (member != null)
     {
         Property property = member.getProperty("SecretCode");
         if (property != null)
         {
             property.Value = secretCode;
             member.Save();
         }
     }
     return false;
 }
Ejemplo n.º 28
0
        public static string IsEmailUnique(string email)
        {
            string e = email;

            //if user is already logged in and tries to re-enter his own email...
            umbraco.cms.businesslogic.member.Member mem = umbraco.presentation.umbracobase.library.library.GetCurrentMember();
            if (mem != null && mem.Email == email)
            {
                return("true");
            }
            else
            {
                return((umbraco.cms.businesslogic.member.Member.GetMemberFromEmail(e) == null).ToString().ToLower());
            }
        }
Ejemplo n.º 29
0
        void Topic_AfterCreate(object sender, uForum.Businesslogic.CreateEventArgs e)
        {
            uForum.Businesslogic.Topic t = (uForum.Businesslogic.Topic)sender;

            Member mem = new Member(t.MemberId);
            int posts = 0;
            int.TryParse(mem.getProperty("forumPosts").Value.ToString(), out posts);

            mem.getProperty("forumPosts").Value = posts++;
            mem.Save();

            mem.XmlGenerate(new System.Xml.XmlDocument());

            Member.RemoveMemberFromCache(mem.Id);
            Member.AddMemberToCache(mem);
        }
 void Member_New(Member sender, NewEventArgs e)
 {
     //This is a bit of a hack to ensure that the member is approved when created since many people will be using
     // this old api to create members on the front-end and they need to be approved - which is based on whether or not 
     // the Umbraco membership provider is configured.
     var provider = Membership.Provider as UmbracoMembershipProvider;
     if (provider != null)
     {
         var approvedField = provider.ApprovedPropertyTypeAlias;
         var property = sender.getProperty(approvedField);
         if (property != null)
         {
             property.Value = 1;
         }
     }            
 }
Ejemplo n.º 31
0
        public static Member GetMemberByUsernameOrGuid(string userNameOrGuid)
        {
            Member m = null;

            // test if username is a GUID (then it comes from member core login)
            if (GuidPseudoTryParse(userNameOrGuid))
            {
                m = new Member(new Guid(userNameOrGuid));
            }
            else
            {
                m = Member.GetMemberFromLoginName(userNameOrGuid);
            }

            return m;
        }
Ejemplo n.º 32
0
        public int create(memberCarrier carrier, int memberTypeId, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier == null)
            {
                throw new Exception("No carrier specified");
            }
            if (carrier.Id != 0)
            {
                throw new Exception("ID cannot be specifed when creating. Must be 0");
            }
            if (string.IsNullOrEmpty(carrier.DisplayedName))
            {
                carrier.DisplayedName = "unnamed";
            }

            // we fetch the membertype
            umbraco.cms.businesslogic.member.MemberType mtype = new umbraco.cms.businesslogic.member.MemberType(memberTypeId);

            // Check if the membertype exists
            if (mtype == null)
            {
                throw new Exception("Membertype " + memberTypeId + " not found");
            }

            // Get the user that creates
            umbraco.BusinessLogic.User user = GetUser(username, password);

            // Create the new member
            umbraco.cms.businesslogic.member.Member newMember = umbraco.cms.businesslogic.member.Member.MakeNew(carrier.DisplayedName, mtype, user);

            // We iterate the properties in the carrier
            if (carrier.MemberProperties != null)
            {
                foreach (memberProperty updatedproperty in carrier.MemberProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = newMember.getProperty(updatedproperty.Key);
                    if (property != null)
                    {
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }
            return(newMember.Id);
        }
Ejemplo n.º 33
0
        public void ProcessRequest(HttpContext context)
        {
            HttpPostedFile file = context.Request.Files["Filedata"];
            string userguid = context.Request.Form["USERGUID"];
            string projectguid = context.Request.Form["NODEGUID"];
            string nodeId = context.Request.Form["id"];
            string fileType = context.Request.Form["FILETYPE"];
            string fileName = context.Request.Form["FILENAME"];
            string umbraoVersion = (context.Request.Form["UMBRACOVERSION"] != null) ? context.Request.Form["UMBRACOVERSION"] : "nan";
            string dotNetVersion = (context.Request.Form["DOTNETVERSION"] != null) ? context.Request.Form["DOTNETVERSION"] : "nan";
            string trustLevel = (context.Request.Form["TRUSTLEVEL"] != null) ? context.Request.Form["TRUSTLEVEL"] : "nan";

            List<OurUmbraco.Wiki.BusinessLogic.UmbracoVersion> v = new List<OurUmbraco.Wiki.BusinessLogic.UmbracoVersion>() { OurUmbraco.Wiki.BusinessLogic.UmbracoVersion.DefaultVersion() };

            if (!string.IsNullOrEmpty(umbraoVersion))
            {
                v.Clear();
                v = WikiFile.GetVersionsFromString(umbraoVersion);
            }

            bool trust = false;
            if(trustLevel == "Medium"){
                trust = true;
            }

            if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(projectguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName))
            {
                var nodeListingProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider();
                var p = nodeListingProvider.GetListing(new Guid(projectguid));

                Member mem = new Member(new Guid(userguid));

                if (p.VendorId == mem.Id || Utils.IsProjectContributor(mem.Id, p.Id))
                {
                    var mediaProvider = new OurUmbraco.MarketPlace.Providers.MediaProvider();

                    var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType , true);
                    // TODO: Don't know how else to get the bloody version
                    var version = ApplicationContext.Current.Services.ContentService.GetById(p.Id).Version;
                    mediaProvider.CreateFile(fileName, version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust);

                } else {
                    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner");
                }

            }
        }
Ejemplo n.º 34
0
 protected void RecoverLoginInfo(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbEmail.Text))
     {
         MembershipUser user = Helper.GetMembershipUserViaEmail(tbEmail.Text);
         if (user == null)
         {
             ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ViewProvideDetails/ReceiptEmailNotFound");
         }
         else if (user.IsLockedOut)
         {
             ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ViewProvideDetails/ReceiptProfileIsLocked");
         }
         else if (!user.IsApproved)
         {
             ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ViewProvideDetails/ReceiptNotApproved");
         }
         else
         {
             umbraco.cms.businesslogic.member.Member member = Helper.GetMember(user);
             if (member == null)
             {
                 ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ViewProvideDetails/ReceiptEmailNotFound");
             }
             else
             {
                 Property property = member.getProperty("SecretCode");
                 if (property == null || string.IsNullOrEmpty(property.Value.ToString()))
                 {
                     throw new Exception("Could not find SecretCode on email: " + tbEmail.Text);
                 }
                 else
                 {
                     string  link    = string.Concat(GetBaseUrl(), HttpContext.Current.Request.Url.AbsolutePath, "?c=", HttpUtility.UrlEncode(property.Value.ToString()), "&u=", HttpUtility.UrlEncode(user.UserName));
                     Message message = new Message();
                     message.Body    = CommonUtil.GetSetting("Membership/PasswordRecovery/ReceiptEmailSendt/EmailBody");
                     message.Subject = CommonUtil.GetSetting("Membership/PasswordRecovery/ReceiptEmailSendt/EmailSubject");
                     message.To.Add(user.Email);
                     message.TemplateVariables.Add("link", link);
                     message.Send();
                     ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ReceiptEmailSendt/Screen");
                 }
             }
         }
     }
     multiView.SetActiveView(viewReceipt);
 }
Ejemplo n.º 35
0
        private void GetMessageCreds()
        {
            // Make sure we have a member id available to us
            MemberId = null;
            if (Request.QueryString["mem"] != null)
                MemberId = Request.QueryString["mem"].ToInt32();

            if (MemberId != null)
            {
                try
                {
                    MessageToMember = new Member((Int32)MemberId);

                    if (MembershipHelper.IsAuthenticated() && 
                        Settings.EnablePrivateMessaging && 
                        MessageToMember.getProperty("forumUserAllowPrivateMessages").Value.ToString() == "1" && 
                        !IsBanned)
                    {

                        //quick check to make sure the member is not PM'ing themselves
                        if (MessageToMember.Id == CurrentMember.MemberId) Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("CantMessageYourself")));

                        if (!Page.IsPostBack)
                        {
                            // See if there is a subject querystring, if so we know this is a reply
                            ReplySubject = null;
                            if (Request.QueryString["r"] != null)
                                ReplySubject = "RE: " + Request.QueryString["r"];
                            lvPrivateMessage.Visible = true;
                            //Now if this is a reply, prepopulate the subject textbox
                            var tbMessageSubject = (TextBox)lvPrivateMessage.FindControl("tbMessageSubject");
                            tbMessageSubject.Text = ReplySubject;
                        }

                            var litMemberTo = (Literal)lvPrivateMessage.FindControl("litMemberTo");
                            if (litMemberTo != null)
                                litMemberTo.Text = MessageToMember.LoginName;
                    }
                }
                catch(Exception)
                {
                    // Show friendly message
                    Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", "Unable to find that member"));
                }      
            }           
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Creates container-object for member
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        private memberCarrier CreateMemberCarrier(umbraco.cms.businesslogic.member.Member member)
        {
            memberCarrier carrier = new memberCarrier();

            carrier.Id = member.Id;

            carrier.LoginName     = member.LoginName;
            carrier.DisplayedName = member.Text;
            carrier.Email         = member.Email;
            carrier.Password      = member.Password;

            carrier.MembertypeId   = member.ContentType.Id;
            carrier.MembertypeName = member.ContentType.Text;

            // Adding groups to member-carrier
            IDictionaryEnumerator Enumerator;

            Enumerator = member.Groups.GetEnumerator();
            while (Enumerator.MoveNext())
            {
                memberGroup group = new memberGroup(Convert.ToInt32(Enumerator.Key), ((umbraco.cms.businesslogic.member.MemberGroup)Enumerator.Value).Text);
                carrier.Groups.Add(group);
            }

            // Loading properties to carrier
            var props = member.GenericProperties;

            foreach (umbraco.cms.businesslogic.property.Property prop in props)
            {
                memberProperty carrierprop = new memberProperty();

                if (prop.Value == System.DBNull.Value)
                {
                    carrierprop.PropertyValue = null;
                }
                else
                {
                    carrierprop.PropertyValue = prop.Value;
                }

                carrierprop.Key = prop.PropertyType.Alias;
                carrier.MemberProperties.Add(carrierprop);
            }
            return(carrier);
        }
Ejemplo n.º 37
0
        public void ProcessRequest(HttpContext context)
        {
            HttpPostedFile file = context.Request.Files["Filedata"];
            string userguid = context.Request.Form["USERGUID"];
            string projectguid = context.Request.Form["NODEGUID"];
            string fileType = context.Request.Form["FILETYPE"];
            string fileName = context.Request.Form["FILENAME"];
            string umbraoVersion = (context.Request.Form["UMBRACOVERSION"] != null) ? context.Request.Form["UMBRACOVERSION"] : "nan";
            string dotNetVersion = (context.Request.Form["DOTNETVERSION"] != null) ? context.Request.Form["DOTNETVERSION"] : "nan";
            string trustLevel = (context.Request.Form["TRUSTLEVEL"] != null) ? context.Request.Form["TRUSTLEVEL"] : "nan";

            List<UmbracoVersion> v = new List<UmbracoVersion>() { UmbracoVersion.DefaultVersion() };

            if (!string.IsNullOrEmpty(umbraoVersion))
            {
                v.Clear();
                v = GetVersionsFromString(umbraoVersion);
            }

            bool trust = false;
            if(trustLevel == "Medium"){
                trust = true;
            }

            if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(projectguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName)) {

                var provider = (IListingProvider)MarketplaceProviderManager.Providers["ListingProvider"];
                var p = provider.GetListing(new Guid(projectguid));
                Member mem = new Member(new Guid(userguid));

                if (p.Vendor != null && p.Vendor.Member.Id == mem.Id || Utils.IsProjectContributor(mem.Id, p.Id))
                {

                    var fileProvider = (IMediaProvider)MarketplaceProviderManager.Providers["MediaProvider"];

                    var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType , true);

                    fileProvider.CreateFile(fileName, p.Version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust);

                } else {
                    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner");
                }

            }
        }
        protected void CleanSpamClick(object s, EventArgs e)
        {
            //figure out who you are going to delete comments for.

            var mId = 0;
            if (Int32.TryParse(memberId.Text, out mId))
            {
                var member = new Member(mId);
                AreYouSurePanel.Visible = true;
                MemberName.Text = member.Text;

                FillGrid();
            }
            else
            {
                AreYouSurePanel.Visible = false;
            }
        }
        protected void BtnSubmitMessageClick(object sender, EventArgs e)
        {
            // Check user isn't spammer by checking flood control settings
            if (Helpers.TimeDifferenceInMinutes(DateTime.Now, CurrentMember.MemberLastPrivateMessageTime) > Settings.PrivateMessagingFloodControlTimeSpan)
            {
                var sb = new StringBuilder();

                var tbMessageSubject = (TextBox)lvPrivateMessage.FindControl("tbMessageSubject");
                var tbMessage = (TextBox)lvPrivateMessage.FindControl("txtPost");

                var replylink = string.Concat(Url(),
                                                "/privatemessage.aspx?mem=" + CurrentMember.MemberId,
                                                "&r=" + Helpers.GetSafeHtml(tbMessageSubject.Text).UrlEncode());

                replylink = string.Format("<a href='{0}'>{0}</a>", replylink);

                sb.AppendFormat(library.GetDictionaryItem("PrivateMessageEmailText"),
                                CurrentMember.MemberLoginName,
                                DateTime.Now.ToShortDateString(),
                                Helpers.GetSafeHtml(tbMessageSubject.Text));

                sb.Append(Helpers.GetSafeHtml(tbMessage.Text).ConvertBbCode());

                sb.AppendFormat("<p><b>{0}</b></p><p>{1}</p>", library.GetDictionaryItem("ClickLinkToReply"), replylink);
                Helpers.SendMail(Settings.EmailNotification, MessageToMember.Email, string.Concat(library.GetDictionaryItem("PrivateMessageOn"), Settings.Name), sb.ToString());

                // Lastly update last private message sent on this user
                var cMem = new Member(Convert.ToInt32(CurrentMember.MemberId));
                cMem.getProperty("forumUserLastPrivateMessage").Value = DateTime.Now;
                cMem.Save();
                cMem.XmlGenerate(new System.Xml.XmlDocument());

                // Show friendly message
                Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("MessageSent")));
            }
            else
            {
                // Show friendly message
                Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=",
                                                string.Format(library.GetDictionaryItem("SorryMustWaitBetween"),
                                                Settings.PrivateMessagingFloodControlTimeSpan)));
            }
        }
Ejemplo n.º 40
0
        protected void NotSpamTopic(Object sender, CommandEventArgs e)
        {
            var id = int.Parse(e.CommandArgument.ToString());
            var topic = Topic.GetTopic(id);
            topic.Save(false, true);

            // Set reputation to at least 50 so their next posts won't be automatically marked as spam
            var member = new Member(topic.MemberId);
            int reputation;
            int.TryParse(member.getProperty("reputationTotal").Value.ToString(), out reputation);
            if (reputation < 50)
                member.getProperty("reputationTotal").Value = 50;

            int.TryParse(member.getProperty("reputationCurrent").Value.ToString(), out reputation);
            if (reputation < 50)
                member.getProperty("reputationCurrent").Value = 50;

            FillSpamTopicGrid();
        }
Ejemplo n.º 41
0
        private static string SaveUrlAsBuddyIcon(string url, Member m)
        {
            var file = m.Id.ToString(CultureInfo.InvariantCulture);
            var path = HttpContext.Current.Server.MapPath("/media/avatar/" + file + ".jpg");

            if (File.Exists(path))
                File.Delete(path);

            var webClient = new System.Net.WebClient();
            webClient.DownloadFile(url, path);

            m.getProperty("avatar").Value = "/media/avatar/" + file + ".jpg";
            m.XmlGenerate(new XmlDocument());
            m.Save();

            Member.RemoveMemberFromCache(m);
            Member.AddMemberToCache(m);

            return "/media/avatar/" + file + ".jpg";
        }
        protected void rptMember_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
            {
                int id = Convert.ToInt32(e.CommandArgument);
                if (e.CommandName == "delete")
                {
                    Member memberToDelete = new Member(id);

                    foreach (MemberGroup memberGroup in memberToDelete.Groups)
                    {
                        memberToDelete.RemoveGroup(memberGroup.Id);
                    }

                    memberToDelete.delete();

                    this.lblResultInfo.Text = "Lid verwijderd uit alle groepen!";
                }
            }
        }
Ejemplo n.º 43
0
        private void SetupProvideNewPassword()
        {
            string username = Request.QueryString["u"];
            string code     = Request.QueryString["c"];

            MembershipUser user = Upac.Membership.Helper.GetMembershipUser(username, code);

            if (user == null)
            {
                ltrReceipt.Text = CommonUtil.GetSetting("Membership/PasswordRecovery/ViewProvideNewPassword/UrlError");
                multiView.SetActiveView(viewReceipt);
            }
            else
            {
                umbraco.cms.businesslogic.member.Member member = Upac.Membership.Helper.GetMember(user);

                multiView.SetActiveView(viewProvideNewPassword);

                hidddenCode.Value     = code;
                hidddenUsername.Value = username;
            }
        }
 static void MemberBeforeDelete(Member sender, DeleteEventArgs e)
 {
     DistributedCache.Instance.RemoveMemberCache(sender.Id);
 }
 static void MemberAfterSave(Member sender, SaveEventArgs e)
 {
     DistributedCache.Instance.RefreshMemberCache(sender.Id);
 }
        public override bool SendNotification(System.Xml.XmlNode details, params object[] args)
        {
            try
            {
                Comment com        = (Comment)args[0];
                Topic   topic      = (Topic)args[1];
                string  url        = (string)args[2];
                string  memberName = (string)args[3];


                if (com.IsSpam)
                {
                    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, string.Format("[Notifications] Comment Id {{0}} is marked as spam, no notification sent{0}", com.Id));
                    return(true);
                }


                //SMTP SETTINGS
                SmtpClient c = new SmtpClient();
                //c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText);

                //SENDER ADDRESS
                MailAddress from = new MailAddress(
                    details.SelectSingleNode("//from/email").InnerText,
                    details.SelectSingleNode("//from/name").InnerText);

                //Notification details
                var domain  = details.SelectSingleNode("//domain").InnerText;
                var subject = string.Format(details.SelectSingleNode("//subject").InnerText, topic.Title);
                var body    = details.SelectSingleNode("//body").InnerText;
                body = string.Format(body, topic.Title, "https://" + domain + url + "#comment-" + com.Id, memberName, HttpUtility.HtmlDecode(umbraco.library.StripHtml(com.Body)));


                //connect to DB

                SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString);
                SqlCommand    comm = new SqlCommand("Select memberId from forumTopicSubscribers where topicId = @topicId", conn);
                comm.Parameters.AddWithValue("@topicId", topic.Id);
                conn.Open();


                //shit this must be so f*****g slow
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    int mid = dr.GetInt32(0);
                    try
                    {
                        var m = new umbraco.cms.businesslogic.member.Member(mid);

                        if (m.Id != com.MemberId &&
                            m.getProperty("bugMeNot").Value.ToString() != "1")
                        {
                            MailMessage mm = new MailMessage();
                            mm.Subject = subject;
                            mm.Body    = body;

                            mm.To.Add(m.Email);
                            mm.From = from;

                            c.Send(mm);
                        }
                    }
                    catch (Exception e)
                    {
                        umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1,
                                                      "[Notifications] Error sending mail to " + mid.ToString() + " " + e.Message);
                    }
                }

                conn.Close();
            }
            catch (Exception e)
            {
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "[Notifications]" + e.Message);
            }
            return(true);
        }