Exemplo n.º 1
0
        private void LoadSettings()
        {
            userId = WebUtils.ParseInt32FromQueryString("userId", -1);
            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);

            forumUser = new SiteUser(siteSettings, userId);
            if (forumUser.UserId == -1) { forumUser = null; }

            threadList.SiteSettings = siteSettings;
            threadList.ForumUser = forumUser;
            threadList.PageNumber = pageNumber;
            threadList.SiteRoot = SiteRoot;
            threadList.ImageSiteRoot = ImageSiteRoot;

            threadListAlt.SiteSettings = siteSettings;
            threadListAlt.ForumUser = forumUser;
            threadListAlt.PageNumber = pageNumber;
            threadListAlt.SiteRoot = SiteRoot;
            threadListAlt.ImageSiteRoot = ImageSiteRoot;

            if (displaySettings.UseAltUserThreadList)
            {
                threadList.Visible = false;
                threadListAlt.Visible = true;
            }

            AddClassToBody("forumuserthreads");
        }
Exemplo n.º 2
0
        private void LoadSettings()
        {
            //spnAdmin.Visible = WebUser.IsAdminOrContentAdmin;

            currentUser = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);

            if (letterInfoGuid == Guid.Empty) return;

            letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.SiteGuid != siteSettings.SiteGuid)
            {
                letterInfo = null;
                letterInfoGuid = Guid.Empty;

            }

            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);

            lnkAdminMenu.Visible = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("eletterdrafts");
        }
        private void HandleWindowsLiveConfirmation(SiteUser siteUser)
        {
            if ((liveUser == null) || (windowsLive == null)) { return; }

            if (siteSettings.UseEmailForLogin)
            {
                FormsAuthentication.SetAuthCookie(
                    siteUser.Email, liveUser.UsePersistentCookie);
            }
            else
            {
                FormsAuthentication.SetAuthCookie(
                    siteUser.LoginName, liveUser.UsePersistentCookie);
            }

            if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
            {
                string cookieName = "siteguid" + siteSettings.SiteGuid;
                CookieHelper.SetCookie(cookieName, siteUser.UserGuid.ToString(), liveUser.UsePersistentCookie);
            }

            if (siteUser.UserId > -1 && siteSettings.AllowUserSkins && siteUser.Skin.Length > 0)
            {
                SiteUtils.SetSkinCookie(siteUser);
            }

            siteUser.UpdateLastLoginTime();

            //WebUtils.SetupRedirect(this, SiteRoot + "/Secure/UserProfile.aspx");
        }
Exemplo n.º 4
0
        private void LoadSettings()
        {
            currentUser = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);
            //spnAdmin.Visible = WebUser.IsAdminOrContentAdmin;
            ScriptConfig.IncludeColorBox = true;

            if (letterInfoGuid == Guid.Empty) return;

            letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.SiteGuid != siteSettings.SiteGuid)
            {
                letterInfo = null;
                letterInfoGuid = Guid.Empty;

            }

            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone = SiteUtils.GetUserTimeZone();

            lnkAdminMenu.Visible = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("eletterarchive");
        }
        public static int GetCountOfState(
            SiteSettings siteSettings,
            PersonalizationScope scope,
            PersonalizationStateQuery query)
        {
            int result = 0;

            if (siteSettings != null)
            {
                Guid userGuid = Guid.Empty;
                if ((query.UsernameToMatch != null) && (query.UsernameToMatch.Length > 0))
                {
                    SiteUser siteUser = new SiteUser(siteSettings, query.UsernameToMatch);
                    if (siteUser.UserId > 0)
                    {
                        userGuid = siteUser.UserGuid;
                    }

                }

                bool allUsersScope = (scope == PersonalizationScope.Shared);
                result = SitePersonalization.GetCountOfState(
                    siteSettings.SiteId,
                    query.PathToMatch,
                    allUsersScope,
                    userGuid,
                    query.UserInactiveSinceDate);

            }

            return result;
        }
Exemplo n.º 6
0
        /// <summary>
        /// people can subscribe to the newsletters without registering on the site. This method is used to attach those existing subscriptions to the user upon registration
        /// </summary>
        /// <param name="siteUser"></param>
        public static void ClaimExistingSubscriptions(SiteUser siteUser)
        {
            SubscriberRepository subscriptions = new SubscriberRepository();
            List<LetterSubscriber> userSubscriptions = subscriptions.GetListByEmail(siteUser.SiteGuid, siteUser.Email);

            foreach (LetterSubscriber s in userSubscriptions)
            {

                if (s.UserGuid != siteUser.UserGuid)
                {
                    s.UserGuid = siteUser.UserGuid;
                    subscriptions.Save(s);
                }

                if (!s.IsVerified)
                {
                    subscriptions.Verify(s.SubscribeGuid, true, Guid.Empty);
                    LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);

                }

            }

            List<LetterSubscriber> memberSubscriptions = subscriptions.GetListByUser(siteUser.SiteGuid, siteUser.UserGuid);

            RemoveDuplicates(memberSubscriptions);

            // commented out 2012-11-16 since we now give the user a chance to opt in the registration
            // then we should not force him in if he chose not to opt in

            //if (memberSubscriptions.Count == 0)
            //{
            //    string ipAddress = SiteUtils.GetIP4Address();
            //    //user has no previous subscriptions and just registered
            //    // lets give him the site subscriptions that are configured for opting in new users by default
            //    List<LetterInfo> allNewsletters = LetterInfo.GetAll(siteUser.SiteGuid);
            //    foreach (LetterInfo l in allNewsletters)
            //    {
            //        if ((l.ProfileOptIn) && (l.AvailableToRoles.Contains("All Users;")))
            //        {
            //            LetterSubscriber s = new LetterSubscriber();
            //            s.SiteGuid = siteUser.SiteGuid;
            //            s.LetterInfoGuid = l.LetterInfoGuid;
            //            s.UserGuid = siteUser.UserGuid;
            //            s.EmailAddress = siteUser.Email;
            //            s.IsVerified = true;
            //            s.UseHtml = true;
            //            s.IpAddress = ipAddress;
            //            subscriptions.Save(s);

            //        }

            //    }

            //}
        }
Exemplo n.º 7
0
        protected void btnLockUser_Click(object sender, EventArgs e)
        {
            if (this.userID > -1)
            {
                SiteUser user = new SiteUser(siteSettings, this.userID);
                user.LockoutAccount();
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
            return;
        }
Exemplo n.º 8
0
        private void LoadSettings()
        {
            //avatarPath = Page.ResolveUrl("~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/useravatars/");

            UntrustedContent2.TrustedImageUrlPattern = allowedImageUrlRegexPattern;

            allowView = WebUser.IsInRoles(siteSettings.RolesThatCanViewMemberList);
            userID = WebUtils.ParseInt32FromQueryString("userid", true, userID);
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone = SiteUtils.GetUserTimeZone();
            userGuid = WebUtils.ParseGuidFromQueryString("u", Guid.Empty);

            if (userID > -1)
            {
                siteUser = new SiteUser(siteSettings, userID);
                if (siteUser.UserGuid == Guid.Empty) { siteUser = null; }
            }
            else if(userGuid != Guid.Empty)
            {
                siteUser = new SiteUser(siteSettings, userGuid);
                if (siteUser.UserGuid == Guid.Empty) { siteUser = null; }
            }

            switch (siteSettings.AvatarSystem)
            {
                case "gravatar":
                    allowGravatars = true;
                    disableAvatars = false;
                    break;

                case "internal":
                    allowGravatars = false;
                    disableAvatars = false;

                    break;

                case "none":
                default:
                    allowGravatars = false;
                    disableAvatars = true;
                    break;

            }

            if (displaySettings.OverrideAvatarLabel.Length > 0)
            {
                lblAvatar.ConfigKey = displaySettings.OverrideAvatarLabel;
            }

            if (displaySettings.HidePostCount) { divForumPosts.Visible = false; }

            AddClassToBody("profileview");
        }
        public static void LoadPersonalizationBlobs(
            SiteSettings siteSettings,
            WebPartManager webPartManager,
            string path,
            string userName,
            ref byte[] sharedDataBlob,
            ref byte[] userDataBlob)
        {
            if (siteSettings != null)
            {
                if ((userName != null) && (userName.Length > 0))
                {
                    SiteUser siteUser = new SiteUser(siteSettings, userName);
                    Guid userID = Guid.Empty;
                    if (siteUser.UserId > 0)
                    {
                        userID = siteUser.UserGuid;
                    }

                    if (userID != Guid.Empty)
                    {
                        userDataBlob = SitePersonalization.GetPersonalizationBlob(
                            siteSettings.SiteId,
                            path,
                            userID);

                        siteUser.UpdateLastActivityTime();

                        sharedDataBlob = SitePersonalization.GetPersonalizationBlobAllUsers(
                            siteSettings.SiteId,
                            path);

                    }
                }
                else
                {
                    //TODO: tracking/personalization for unauthenticated users?

                    sharedDataBlob = SitePersonalization.GetPersonalizationBlobAllUsers(
                            siteSettings.SiteId,
                            path);

                }

            }
        }
        private void LoadSettings()
        {
            IsAdmin = WebUser.IsAdmin;
            isSiteEditor = SiteUtils.UserIsSiteEditor();
            isCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);

            userGuid = WebUtils.ParseGuidFromQueryString("u", userGuid);

            customerUser = new SiteUser(siteSettings, userGuid);

            UserCommerceHistory commerceHistory = purchaseHx as UserCommerceHistory;

            commerceHistory.UserGuid = userGuid;
            commerceHistory.ShowAdminOrderLink = true;

            AddClassToBody("administration");
            AddClassToBody("commercereports");
        }
Exemplo n.º 11
0
        public void InstallContent(Module module, string configInfo)
        {
            HtmlContent htmlContent = new HtmlContent();
            htmlContent.ModuleId = module.ModuleId;
            if (configInfo.StartsWith("~/"))
            {
                if (File.Exists(HostingEnvironment.MapPath(configInfo)))
                {
                    htmlContent.Body = File.ReadAllText(HostingEnvironment.MapPath(configInfo), Encoding.UTF8);
                }
            }
            else
            {
                htmlContent.Body = ResourceHelper.GetMessageTemplate(CultureInfo.CurrentUICulture, configInfo);
            }

            htmlContent.ModuleGuid = module.ModuleGuid;

            SiteSettings siteSettings = new SiteSettings(module.SiteId);
            SiteUser adminUser = null;
            if (siteSettings.UseEmailForLogin)
            {
                adminUser = new SiteUser(siteSettings, "*****@*****.**");
                if (adminUser.UserId == -1) { adminUser = null; }
            }
            else
            {
                adminUser = new SiteUser(siteSettings, "admin");
                if (adminUser.UserId == -1) { adminUser = null; }
            }

            if (adminUser != null)
            {
                htmlContent.UserGuid = adminUser.UserGuid;
                htmlContent.LastModUserGuid = adminUser.UserGuid;
            }

            HtmlRepository repository = new HtmlRepository();
            repository.Save(htmlContent);
        }
Exemplo n.º 12
0
 public MojoPortalUser()
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             //UserInfo info = UserController.GetUserByName(((PortalSettings) HttpContext.Current.Items["PortalSettings"]).get_PortalId(), HttpContext.Current.User.Identity.Name, false);
             siteUser = SiteUtils.GetCurrentSiteUser();
             this.m_userID = siteUser.UserId;
             this.m_userName = siteUser.LoginName;
             this.m_email = siteUser.Email;
             this.m_firstName = siteUser.Name;
             this.m_lastName = "";
             this.m_location = siteUser.Country;
             this.m_isSuperAdmin = siteUser.IsInRoles("Administrators");
             this.m_isAuthenticated = true;
         }
     }
     catch (Exception exception)
     {
         throw new Exception("Failed to find user info from mojoPortal.", exception);
     }
 }
Exemplo n.º 13
0
        private void LoadSettings()
        {
            currentUser = SiteUtils.GetCurrentSiteUser();
            config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId));

            lnkCategories.NavigateUrl = SiteRoot + "/Blog/EditCategory.aspx?pageid="
                + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString();

            lnkNewPost.NavigateUrl = SiteRoot + "/Blog/EditPost.aspx?pageid="
                + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString();

            lnkDrafts.NavigateUrl = SiteRoot + "/Blog/Drafts.aspx?pageid="
                + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString();

            lnkClosedPosts.NavigateUrl = SiteRoot + "/Blog/ClosedPosts.aspx?pageid="
                + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString();

            if (currentUser == null) { return; }

            if (BlogConfiguration.SecurePostsByUser)
            {
                if (WebUser.IsInRoles(config.ApproverRoles))
                {
                    countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty);
                }
                else
                {
                    countOfDrafts = Blog.GetCountOfDrafts(moduleId, currentUser.UserGuid);
                }
            }
            else
            {
                countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty);
            }

            countOfExpiredPosts = Blog.GetCountClosed(moduleId);
        }
        private void LoadSettings()
        {
            PageId = WebUtils.ParseInt32FromQueryString("pageid", -1);
            ModuleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            payPalGetExpressCheckoutLogGuid = WebUtils.ParseGuidFromQueryString("plog", payPalGetExpressCheckoutLogGuid);

            if (payPalGetExpressCheckoutLogGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            checkoutDetailsLog = new PayPalLog(payPalGetExpressCheckoutLogGuid);

            if (checkoutDetailsLog.RowGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), checkoutDetailsLog.SerializedObject);

            if (cart == null)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }
            cart.DeSerializeCartOffers();

            cart.RefreshTotals();

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            siteUser = SiteUtils.GetCurrentSiteUser();
            //if (siteUser == null)
            //{
            //    Response.Redirect(SiteUtils.GetCurrentPageUrl());
            //}

            if ((siteUser != null)&&(cart.UserGuid == Guid.Empty))
            {
                // user wasn't logged in when express checkout was called
                cart.UserGuid = siteUser.UserGuid;
                cart.Save();
                //if (checkoutDetailsLog.UserGuid == Guid.Empty)
                //{
                //    // we need to make sure we have the user in the log and serialized cart
                //    checkoutDetailsLog.UserGuid = siteUser.UserGuid;
                //    cart.SerializeCartOffers();
                //    checkoutDetailsLog.SerializedObject = SerializationHelper.SerializeToSoap(cart);
                //    checkoutDetailsLog.Save();

                //}
            }

            if ((siteUser != null)&&(cart.UserGuid != siteUser.UserGuid))
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            if (ModuleId == -1)
            {
                ModuleId = StoreHelper.FindStoreModuleId(CurrentPage);
            }

            store = StoreHelper.GetStore();

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (siteUser != null)
            {
                pnlRequireLogin.Visible = false;
            }
            else
            {
                btnMakePayment.Visible = false;
            }

            AddClassToBody("webstore webstoreexpresscheckout");
        }
Exemplo n.º 15
0
        private void UserRoles_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            int roleID = Convert.ToInt32(userRoles.DataKeys[e.Item.ItemIndex]);
            SiteUser user = new SiteUser(siteSettings, userId);

            Role.RemoveUser(roleID, userId);
            userRoles.EditItemIndex = -1;
            if (user.UserId > -1)
            {
                user.RolesChanged = true;
                user.Save();
            }

            BindRoles();

            upRoles.Update();

            //WebUtils.SetupRedirect(this, Request.RawUrl);
            //return;
        }
Exemplo n.º 16
0
        private void AddRole_Click(Object sender, EventArgs e)
        {
            if ((userId > -1)&&(siteSettings != null))
            {
                SiteUser user = new SiteUser(siteSettings, userId);
                int roleID = int.Parse(allRoles.SelectedItem.Value, CultureInfo.InvariantCulture);
                Role role = new Role(roleID);
                Role.AddUser(roleID, userId, role.RoleGuid, user.UserGuid);
                user.RolesChanged = true;
                user.Save();

                BindRoles();

                upRoles.Update();

            }

            //WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Exemplo n.º 17
0
 private bool TestCurrentUserLdap(LdapSettings testLdapSettings)
 {
     String uid = Context.User.Identity.Name;
     SiteUser user = new SiteUser(this.selectedSite, uid);
     return LdapHelper.TestUser(testLdapSettings, user.LoginName, txtLdapTestPassword.Text);
 }
Exemplo n.º 18
0
        //public static Cart GetCart(Guid storeGuid)
        //{
        //    if (HttpContext.Current != null)
        //    {
        //        string cartKey = "cart" + storeGuid.ToString();
        //        if (HttpContext.Current.Items[cartKey] != null)
        //        {
        //            return (Cart)HttpContext.Current.Items[cartKey];
        //        }
        //        else
        //        {
        //            if (UserHasCartCookie(storeGuid))
        //            {
        //                string cartCookie = GetCartCookie(storeGuid);
        //                if (cartCookie.Length == 36)
        //                {
        //                    Guid cartGuid = new Guid(cartCookie);
        //                    Cart cart = new Cart(cartGuid);
        //                    if (!cart.Exists)
        //                    {
        //                        return CreateCartAndSetCookie(storeGuid);
        //                    }
        //                    HttpContext.Current.Items[cartKey] = cart;
        //                    return cart;
        //                }
        //                else
        //                {
        //                    // cookie is invalid
        //                    return CreateCartAndSetCookie(storeGuid);
        //                }
        //            }
        //            else
        //            {
        //                // TODO: handle use case where user adds to cart on 1 machine
        //                // then comes back to site on another machine and has no cart cookie
        //                // look for a cart that has the userguid,
        //                // if found set cookie for that cart
        //                // new cart
        //                return CreateCartAndSetCookie(storeGuid);
        //            }
        //        }
        //    }
        //    return null;
        //}
        public static void InitializeOrderInfo(Cart cart, SiteUser siteUser)
        {
            if (cart.OrderInfo.CustomerLastName.Length == 0)
            {
                if(siteUser.LastName.Length > 0)
                {
                    cart.OrderInfo.CustomerLastName = siteUser.LastName;
                }
                else
                {
                    cart.OrderInfo.CustomerLastName = siteUser.Name;
                }
                cart.OrderInfo.CustomerFirstName = siteUser.FirstName;

            }
            cart.OrderInfo.CustomerTelephoneDay = siteUser.PhoneNumber;
            cart.OrderInfo.CustomerEmail = siteUser.Email;
            cart.OrderInfo.Save();
            cart.UserGuid = siteUser.UserGuid;
            cart.Save();
        }
Exemplo n.º 19
0
        private static void SendConfirmEmail(
            CultureInfo defaultCulture,
            CultureInfo currencyCulture,
            SiteSettings siteSettings,
            int pageId,
            CommerceConfiguration commerceConfig, 
            Store store, 
            Order order,
            string subjectTemplate,
            string textBodyTemplate)
        {
            if (store == null) { return; }
            if (order == null) { return; }
            if(siteSettings == null) { return; }

            if (!ShouldSendConfirmation(siteSettings.SiteId, order))
            {
                log.Info("confirmation email for order " + order.OrderGuid.ToString() + " not sent due to disabled by configuration");
                return;
            }

            //SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            //CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            //EmailMessageTask messageTask = new EmailMessageTask(SiteUtils.GetSmtpSettings());
            //messageTask.EmailFrom = store.SalesEmail;
            // TODO: implement from alias for store
            //messageTask.EmailFromAlias = siteSettings.DefaultFromEmailAlias;
            string email;
            if (order.CustomerEmail.Length > 0)
            {
                //messageTask.EmailTo = order.CustomerEmail;
                email = order.CustomerEmail;
            }
            else
            {
                SiteUser siteUser = new SiteUser(siteSettings, order.UserGuid);
                //messageTask.EmailTo = siteUser.Email;

                email = siteUser.Email;

            }

            //if (store.OrderBccEmail.Length > 0)
            //{
            //    messageTask.EmailBcc = store.OrderBccEmail;
            //}

            PageSettings page = new PageSettings(siteSettings.SiteId, pageId);

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storeLink = string.Empty;

            if (page.Url.StartsWith("~/"))
            {
                storeLink = siteRoot + page.Url.Replace("~/", "/");
            }
            else
            {
                storeLink = siteRoot;
            }

            string orderLink = siteRoot +
                "/WebStore/OrderDetail.aspx?pageid="
                + pageId.ToInvariantString()
                + "&mid=" + store.ModuleId.ToInvariantString()
                + "&orderid=" + order.OrderGuid.ToString();

            StringBuilder orderDetails = new StringBuilder();
            DataSet dsOffers = Order.GetOrderOffersAndProducts(store.Guid, order.OrderGuid);

            foreach (DataRow row in dsOffers.Tables["Offers"].Rows)
            {
                string og = row["OfferGuid"].ToString();
                orderDetails.Append(row["Name"].ToString() + " ");
                orderDetails.Append(row["Quantity"].ToString() + " @ ");
                orderDetails.Append(string.Format(currencyCulture, "{0:c}", Convert.ToDecimal(row["OfferPrice"])));
                orderDetails.Append("\r\n");

                string whereClause = string.Format("OfferGuid = '{0}'", og);
                DataView dv = new DataView(dsOffers.Tables["Products"], whereClause, "", DataViewRowState.CurrentRows);

                if (dv.Count > 1)
                {
                    foreach (DataRow r in dsOffers.Tables["Products"].Rows)
                    {
                        string pog = r["OfferGuid"].ToString();
                        if (og == pog)
                        {
                            orderDetails.Append(r["Name"].ToString() + " ");
                            orderDetails.Append(r["Quantity"].ToString() + "  \r\n");

                        }

                    }
                }

            }

            //messageTask.Subject = string.Format(
            //    defaultCulture,
            //    subjectTemplate,
            //    store.Name,
            //    order.OrderGuid.ToString()
            //    );

            //messageTask.TextBody = string.Format(
            //    defaultCulture,
            //    textBodyTemplate,
            //    order.CustomerFirstName + " " + order.CustomerLastName,
            //    store.Name,
            //    order.OrderGuid.ToString(),
            //    storeLink,
            //    orderLink,
            //    orderDetails.ToString(),
            //    order.OrderTotal.ToString("c", currencyCulture),
            //    order.ShippingTotal.ToString("c", currencyCulture),
            //    order.TaxTotal.ToString("c", currencyCulture),
            //    order.SubTotal.ToString("c", currencyCulture),
            //    order.Discount.ToString("c", currencyCulture)
            //    ).ToAscii();

            //messageTask.SiteGuid = siteSettings.SiteGuid;
            //messageTask.QueueTask();

            //WebTaskManager.StartOrResumeTasks();

            string fromAddress = store.EmailFrom;
            if (fromAddress.Length == 0) { fromAddress = siteSettings.DefaultEmailFromAddress; }

            Email.Send(
                        SiteUtils.GetSmtpSettings(),
                        fromAddress,
                        string.Empty,
                        string.Empty,
                        email,
                        string.Empty,
                        store.OrderBccEmail,
                        string.Format(defaultCulture, subjectTemplate, store.Name, order.OrderGuid.ToString()),
                        string.Format(
                                defaultCulture,
                                textBodyTemplate,
                                order.CustomerFirstName + " " + order.CustomerLastName,
                                store.Name,
                                order.OrderGuid.ToString(),
                                storeLink,
                                orderLink,
                                orderDetails.ToString(),
                                order.OrderTotal.ToString("c", currencyCulture),
                                order.ShippingTotal.ToString("c", currencyCulture),
                                order.TaxTotal.ToString("c", currencyCulture),
                                order.SubTotal.ToString("c", currencyCulture),
                                order.Discount.ToString("c", currencyCulture)
                                ),
                        false,
                        Email.PriorityNormal);
        }
Exemplo n.º 20
0
        private void LoadSettings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            TimeOffset = SiteUtils.GetUserTimeOffset();
            timeZone = SiteUtils.GetUserTimeZone();
            //pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);

            notificationUrl = SiteRoot + "/Forums/EditSubscriptions.aspx?mid="
                + ModuleId.ToInvariantString()
                + "&pageid=" + PageId.ToInvariantString() +"#forum" + ItemId.ToInvariantString();

            lnkNotify.ImageUrl = ImageSiteRoot + "/Data/SiteImages/FeatureIcons/email.png";
            lnkNotify.NavigateUrl = notificationUrl;
            lnkNotify2.NavigateUrl = notificationUrl;

            if (WebConfigSettings.LoginPageRelativeUrl.Length > 0)
            {
                lnkLogin.NavigateUrl = SiteRoot + WebConfigSettings.LoginPageRelativeUrl + "?returnurl=" + Server.UrlEncode(Request.RawUrl);
            }
            else
            {
                lnkLogin.NavigateUrl = SiteRoot + "/Secure/Login.aspx?returnurl=" + Server.UrlEncode(Request.RawUrl);
            }

            if (Request.IsAuthenticated)
            {
                currentUser = SiteUtils.GetCurrentSiteUser();
                if ((currentUser != null) && (ItemId > -1))
                {
                    isSubscribedToForum = Forum.IsSubscribed(ItemId, currentUser.UserId);
                }

                if (!isSubscribedToForum) { pnlNotify.Visible = true; }

            }
        }
Exemplo n.º 21
0
        public static List<SiteUser> GetPage(
            int siteId,
            int pageNumber, 
            int pageSize, 
            string userNameBeginsWith,
            int sortMode,
            out int totalPages)
        {
            //sortMode: 0 = DisplayName asc, 1 = JoinDate desc, 2 = Last, First

            totalPages = 1;

            List<SiteUser> userList
                = new List<SiteUser>();

            if (UseRelatedSiteMode) { siteId = RelatedSiteID; }

            using (IDataReader reader
                = DBSiteUser.GetUserListPage(
                    siteId, pageNumber, pageSize, userNameBeginsWith, sortMode, out totalPages))
            {

                while (reader.Read())
                {
                    SiteUser user = new SiteUser();
                    PopulateFromReaderRow(user, reader);
                    userList.Add(user);
                    //totalPages = Convert.ToInt32(reader["TotalPages"]);
                }
            }

            return userList;
        }
Exemplo n.º 22
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();
            if (store == null) { return; }

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            if (StoreHelper.UserHasCartCookie(store.Guid))
            {
                cart = StoreHelper.GetCart();
                if (cart != null)
                {
                    cartOffers = cart.GetOffers();

                    canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);

                    if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
                    {
                        StoreHelper.EnsureValidDiscounts(store, cart);
                    }

                    if ((cart.UserGuid == Guid.Empty)&&(siteUser != null))
                    {
                        cart.UserGuid = siteUser.UserGuid;
                        cart.Save();
                    }
                    cart.RefreshTotals();
                }
            }

            ConfigureCheckoutButtons();

            AddClassToBody("webstore webstorecheckout");
        }
Exemplo n.º 23
0
        private static SiteUser EnsureAdminUser(SiteSettings site)
        {
            // if using related sites mode there is a problem if we already have user [email protected]
            // and we create another one in the child site with the same email and login so we need to make it different
            // we could just skip creating this user since in related sites mode all users come from the first site
            // but then if the config were changed to not related sites mode there would be no admin user
            // so in related sites mode we create one only as a backup in case settings are changed later
            int countOfSites = SiteSettings.SiteCount();
            string siteDifferentiator = string.Empty;
            if (
                (countOfSites >= 1)
                && (WebConfigSettings.UseRelatedSiteMode)
                )
            {
                siteDifferentiator = site.SiteId.ToString(CultureInfo.InvariantCulture);
            }

            mojoMembershipProvider membership = Membership.Provider as mojoMembershipProvider;
            bool overridRelatedSiteMode = true;
            SiteUser adminUser = new SiteUser(site, overridRelatedSiteMode);
            adminUser.Email = "admin" + siteDifferentiator + "@admin.com";
            adminUser.Name = "Admin";
            adminUser.LoginName = "admin" + siteDifferentiator;
            bool userExists = false;
            if (site.UseEmailForLogin)
            {
                userExists = SiteUser.EmailExistsInDB(site.SiteId, adminUser.Email);
            }
            else
            {
                userExists = SiteUser.LoginExistsInDB(site.SiteId, adminUser.LoginName);
            }

            if (!userExists)
            {
                adminUser.Password = "******";

                if (membership != null)
                {
                    adminUser.Password = membership.EncodePassword(site, adminUser, "admin");
                }

                adminUser.PasswordQuestion = "What is your user name?";
                adminUser.PasswordAnswer = "admin";
                adminUser.Save();

                //Role.AddUser(adminRole.RoleId, adminUser.UserId, adminRole.RoleGuid, adminUser.UserGuid);
            }
            else
            {
                if (site.UseEmailForLogin)
                {
                    adminUser = new SiteUser(site, adminUser.Email);
                }
                else
                {
                    adminUser = new SiteUser(site, adminUser.LoginName);
                }
            }

            return adminUser;
        }
        private void DoExistingUserLogic(Guid userGuid)
        {
            // user found so login if allowed
            SiteUser user = new SiteUser(siteSettings, userGuid);

            if (
                (siteSettings.UseSecureRegistration)
                && (user.RegisterConfirmGuid != Guid.Empty)
                )
            {
                Notification.SendRegistrationConfirmationLink(
                    SiteUtils.GetSmtpSettings(),
                    ResourceHelper.GetMessageTemplate("RegisterConfirmEmailMessage.config"),
                    siteSettings.DefaultEmailFromAddress,
                    siteSettings.DefaultFromEmailAlias,
                    user.Email,
                    siteSettings.SiteName,
                    WebUtils.GetSiteRoot() + "/ConfirmRegistration.aspx?ticket=" +
                    user.RegisterConfirmGuid.ToString());

                lblError.Text = Resource.LoginUnconfirmedEmailMessage;
                log.Info("User " + user.Name + " tried to login but email address is not confirmed.");

                return;
            }

            if (user.IsLockedOut)
            {
                lblError.Text = Resource.LoginAccountLockedMessage;
                log.Info("User " + user.Name + " tried to login but account is locked.");

                return;
            }

            if (siteSettings.UseEmailForLogin)
            {
                FormsAuthentication.SetAuthCookie(
                    user.Email, true);
            }
            else
            {
                FormsAuthentication.SetAuthCookie(
                    user.LoginName, true);
            }

            if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
            {
                string cookieName = "siteguid" + siteSettings.SiteGuid;
                CookieHelper.SetCookie(cookieName, user.UserGuid.ToString(), true);
            }

            user.UpdateLastLoginTime();

            // track user ip address
            UserLocation userLocation = new UserLocation(user.UserGuid, SiteUtils.GetIP4Address());
            userLocation.SiteGuid = siteSettings.SiteGuid;
            userLocation.Hostname = Page.Request.UserHostName;
            userLocation.Save();

            string redirectUrl = GetRedirectPath();
            CookieHelper.ExpireCookie(returnUrlCookieName);

            UserSignInEventArgs u = new UserSignInEventArgs(user);
            OnUserSignIn(u);

            WebUtils.SetupRedirect(this, redirectUrl);
            return;
        }
        private void DoNewUserLogic(OpenIdEventArgs e)
        {
            if (e == null) { return; }

            ClaimsResponse claim = e.Response.GetExtension<ClaimsResponse>();
            if (claim == null) { return; }

            if (IsValidForUserCreation(e, claim))
            {
                if (SiteUser.EmailExistsInDB(siteSettings.SiteId, claim.Email))
                {
                    // show message that user should login and associate
                    // their open id account on their profile page.
                    lblError.Text = Resource.OpenIDRegisterUserEmailExistsMessage;
                    return;
                }
                else
                {
                    // create user automagically since we have all
                    // the needed data
                    SiteUser newUser = new SiteUser(siteSettings);
                    newUser.Email = claim.Email;
                    newUser.Name = claim.FullName;
                    string loginName = newUser.Name.Replace(" ", ".").ToLower();
                    if (loginName.Length > 50) loginName = loginName.Substring(0, 50);

                    if (SiteUser.LoginExistsInDB(
                        siteSettings.SiteId, loginName))
                    {
                        loginName = e.ClaimedIdentifier.ToString().Replace("http://", string.Empty).Replace("https://", string.Empty).Replace("/", string.Empty);
                        if (loginName.Length > 50) loginName = loginName.Substring(0, 50);

                        int i = 1;
                        while (SiteUser.LoginExistsInDB(
                            siteSettings.SiteId, loginName))
                        {
                            loginName += i.ToString();
                            if (loginName.Length > 50) loginName = loginName.Remove(40, 1);
                            i++;

                        }

                    }

                    newUser.LoginName = loginName;
                    newUser.Password = SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars);
                    newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
                    newUser.PasswordAnswer = Resource.ManageUsersDefaultSecurityAnswer;
                    newUser.OpenIdUri = e.ClaimedIdentifier.ToString();
                    newUser.Save();
                    if (siteSettings.UseSecureRegistration)
                    {
                        newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
                    }

                    // track user ip address
                    UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
                    userLocation.SiteGuid = siteSettings.SiteGuid;
                    userLocation.Hostname = Page.Request.UserHostName;
                    userLocation.Save();

                    if (
                        (siteSettings.UseSecureRegistration)
                        && (newUser.RegisterConfirmGuid != Guid.Empty)
                        )
                    {
                        Notification.SendRegistrationConfirmationLink(
                            SiteUtils.GetSmtpSettings(),
                            ResourceHelper.GetMessageTemplate("RegisterConfirmEmailMessage.config"),
                            siteSettings.DefaultEmailFromAddress,
                            siteSettings.DefaultFromEmailAlias,
                            newUser.Email,
                            siteSettings.SiteName,
                            WebUtils.GetSiteRoot() + "/ConfirmRegistration.aspx?ticket=" +
                            newUser.RegisterConfirmGuid.ToString());

                        lblError.Text = Resource.LoginUnconfirmedEmailMessage;
                        log.Info("Automatically created User " + newUser.Name + " on login from open id. Tried to login but email address is not confirmed.");

                        return;
                    }

                    if (siteSettings.UseEmailForLogin)
                    {
                        FormsAuthentication.SetAuthCookie(
                            newUser.Email, true);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(
                            newUser.LoginName, true);
                    }

                    if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
                    {
                        string cookieName = "siteguid" + siteSettings.SiteGuid;
                        CookieHelper.SetCookie(cookieName, newUser.UserGuid.ToString(), true);
                    }

                    newUser.UpdateLastLoginTime();

                    string redirectUrl = GetRedirectPath();
                    CookieHelper.ExpireCookie(returnUrlCookieName);
                    WebUtils.SetupRedirect(this, redirectUrl);
                    return;

                }

            }
            else
            {
                // user not found
                // required fields not available from open id
                // redirect to register page?
                // Or show message with Link to
                // register page
                string registerLinkHref = siteRoot
                    + "/Secure/RegisterWithOpenID.aspx";

                litNotRegisteredYetMessage.Text
                    = string.Format(
                    Resource.OpenIDMustRegisterBeforeLoginMesage,
                    registerLinkHref);

            }
        }
Exemplo n.º 26
0
        public static SiteUser GetByLoginName(SiteSettings siteSettings, string userName, bool allowEmailFallback)
        {
            if (siteSettings == null) { return null; }
            if (string.IsNullOrEmpty(userName)) { return null; }

            SiteUser siteUser = new SiteUser();
            int siteId = siteSettings.SiteId;

            if (UseRelatedSiteMode) { siteId = RelatedSiteID; }

            using (IDataReader reader = GetUserByLoginName(siteId, userName, allowEmailFallback))
            {
                siteUser.GetUser(reader);
            }

            if (siteUser.UserGuid != Guid.Empty) { return siteUser; }

            return null;
        }
Exemplo n.º 27
0
        public static void CreateRequiredRolesAndAdminUser(SiteSettings site)
        {
            Role adminRole = new Role();
            adminRole.RoleName = "Admins";
            adminRole.SiteId = site.SiteId;
            adminRole.SiteGuid = site.SiteGuid;
            adminRole.Save();
            adminRole.RoleName = "Administrators";
            adminRole.Save();

            Role roleAdminRole = new Role();
            roleAdminRole.RoleName = "Role Admins";
            roleAdminRole.SiteId = site.SiteId;
            roleAdminRole.SiteGuid = site.SiteGuid;
            roleAdminRole.Save();
            roleAdminRole.RoleName = "Role Administrators";
            roleAdminRole.Save();

            Role contentAdminRole = new Role();
            contentAdminRole.RoleName = "Content Administrators";
            contentAdminRole.SiteId = site.SiteId;
            contentAdminRole.SiteGuid = site.SiteGuid;
            contentAdminRole.Save();

            Role authenticatedUserRole = new Role();
            authenticatedUserRole.RoleName = "Authenticated Users";
            authenticatedUserRole.SiteId = site.SiteId;
            authenticatedUserRole.SiteGuid = site.SiteGuid;
            authenticatedUserRole.Save();

            Role contentPublisherRole = new Role();
            contentPublisherRole.RoleName = "Content Publishers";
            contentPublisherRole.SiteId = site.SiteId;
            contentPublisherRole.SiteGuid = site.SiteGuid;
            contentPublisherRole.Save();

            Role contentAuthorRole = new Role();
            contentAuthorRole.RoleName = "Content Authors";
            contentAuthorRole.SiteId = site.SiteId;
            contentAuthorRole.SiteGuid = site.SiteGuid;
            contentAuthorRole.Save();

            Role newsletterAdminRole = new Role();
            newsletterAdminRole.RoleName = "Newsletter Administrators";
            newsletterAdminRole.SiteId = site.SiteId;
            newsletterAdminRole.SiteGuid = site.SiteGuid;
            newsletterAdminRole.Save();

            // if using related sites mode there is a problem if we already have user [email protected]
            // and we create another one in the child site with the same email and login so we need to make it different
            // we could just skip creating this user since in related sites mode all users come from the first site
            // but then if the config were changed to not related sites mode there would be no admin user
            // so in related sites mode we create one only as a backup in case settings are changed later
            int countOfSites = SiteSettings.SiteCount();
            string siteDifferentiator = string.Empty;
            if (
                (countOfSites >= 1)
                && (WebConfigSettings.UseRelatedSiteMode)
                )
            {
                if (site.SiteId > 1)
                {
                    siteDifferentiator = site.SiteId.ToInvariantString();
                }
            }

            mojoMembershipProvider membership = Membership.Provider as mojoMembershipProvider;
            bool overridRelatedSiteMode = true;
            SiteUser adminUser = new SiteUser(site, overridRelatedSiteMode);
            adminUser.Email = "admin" + siteDifferentiator + "@admin.com";
            adminUser.Name = "Admin";
            adminUser.LoginName = "admin" + siteDifferentiator;
            adminUser.Password = "******";

            if (membership != null)
            {
                adminUser.Password = membership.EncodePassword(site, adminUser, "admin");
            }

            adminUser.PasswordQuestion = "What is your user name?";
            adminUser.PasswordAnswer = "admin";
            adminUser.Save();

            Role.AddUser(adminRole.RoleId, adminUser.UserId, adminRole.RoleGuid, adminUser.UserGuid);
        }
Exemplo n.º 28
0
        public static SiteUser GetNewestUser(SiteSettings siteSettings)
        {
            int userID = GetNewestUserId(siteSettings.SiteId);
            SiteUser siteUser = new SiteUser(siteSettings, userID);
            if (siteUser.UserId == userID)
            {
                return siteUser;
            }

            return null;
        }
Exemplo n.º 29
0
        private void LoadSettings()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, -1);

            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            store = StoreHelper.GetStore();
            if (store == null) { return; }

            siteUser = SiteUtils.GetCurrentSiteUser();

            productGuid = WebUtils.ParseGuidFromQueryString("prod", productGuid);

            virtualRoot = WebUtils.GetApplicationRoot();

            upLoadPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
                + "/webstoreproductfiles/";

            teaserFileBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
                + "/webstoreproductpreviewfiles/";

            AddClassToBody("webstore webstoreproductedit");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];
            if (p == null)
            {
                log.Error("Could not load file system provider " + WebConfigSettings.FileSystemProvider);
                return;
            }

            fileSystem = p.GetFileSystem();
            if (fileSystem == null)
            {
                log.Error("Could not load file system from provider " + WebConfigSettings.FileSystemProvider);
                return;
            }

            if (!fileSystem.FolderExists(upLoadPath))
            {
                fileSystem.CreateFolder(upLoadPath);
            }

            if (!fileSystem.FolderExists(teaserFileBasePath))
            {
                fileSystem.CreateFolder(teaserFileBasePath);
            }

            if (productGuid == Guid.Empty) { return; }

            productUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?pageid=" + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString()
                + "&prod=" + productGuid.ToString() ;

            productUploader.UploadButtonClientId = btnUpload.ClientID;

            productUploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                    + " (data, errorsOccurred) { if(errorsOccurred === false) { $('#" + btnSave.ClientID + "').click(); } } ";

            productUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);

            teaserUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?type=teaser&pageid=" + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString()
                + "&prod=" + productGuid.ToString();

            teaserUploader.UploadButtonClientId = btnUploadTeaser.ClientID;
            teaserUploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form
            teaserUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();
        }
Exemplo n.º 30
0
        public static List<SiteUser> GetNotApprovedUsers(
            int siteId,
            int pageNumber,
            int pageSize,
            out int totalPages)
        {
            List<SiteUser> userList
                = new List<SiteUser>();

            if (UseRelatedSiteMode) { siteId = RelatedSiteID; }

            using (IDataReader reader = DBSiteUser.GetPageNotApprovedUsers(
                siteId,
                pageNumber,
                pageSize,
                out totalPages))
            {

                while (reader.Read())
                {
                    SiteUser user = new SiteUser();
                    PopulateFromReaderRow(user, reader);
                    userList.Add(user);

                }
            }

            return userList;
        }