Пример #1
0
        private void PopulateControls()
        {
            Forum forum = new Forum(itemId);

            if (forum.ModuleId != moduleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            this.lblCreatedDate.Text = forum.CreatedDate.AddHours(timeOffset).ToString();
            edContent.Text           = forum.Description;
            this.txtTitle.Text       = forum.Title;
            this.chkIsActive.Checked = forum.IsActive;
            //this.chkAllowAnonymousPosts.Checked = forum.AllowAnonymousPosts;
            this.chkIsModerated.Checked = forum.IsModerated;
            this.txtSortOrder.Text      = forum.SortOrder.ToString();
            this.txtPostsPerPage.Text   = forum.PostsPerPage.ToString();
            this.txtThreadsPerPage.Text = forum.ThreadsPerPage.ToString();
            allowedPostRolesSetting     = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);

            moderatorRolesSetting = moderatorRoles as AllowedRolesSetting;
            moderatorRolesSetting.SetValue(forum.RolesThatCanModerate);

            chkRequireModForNotify.Checked      = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            txtModeratorNotifyEmail.Text        = forum.ModeratorNotifyEmail;
            chkIncludeInGoogleMap.Checked       = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked           = forum.AddNoIndexMeta;
            chkClosed.Checked  = forum.Closed;
            chkVisible.Checked = forum.Visible;
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Forum forum = new Forum(itemId);

            if ((forum.ItemId > -1) && (forum.ModuleId != moduleId))
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            //SiteUser siteUser = new SiteUser(siteSettings, Context.User.Identity.Name);
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser != null)
            {
                forum.CreatedByUserId = siteUser.UserId;
            }

            forum.ModuleId    = moduleId;
            forum.Description = edContent.Text;
            forum.Title       = this.txtTitle.Text;
            forum.IsActive    = this.chkIsActive.Checked;
            //forum.AllowAnonymousPosts = this.chkAllowAnonymousPosts.Checked;
            forum.IsModerated    = this.chkIsModerated.Checked;
            forum.SortOrder      = int.Parse(this.txtSortOrder.Text);
            forum.PostsPerPage   = int.Parse(this.txtPostsPerPage.Text);
            forum.ThreadsPerPage = int.Parse(this.txtThreadsPerPage.Text);

            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            forum.RolesThatCanPost  = allowedPostRolesSetting.GetValue();

            moderatorRolesSetting      = moderatorRoles as AllowedRolesSetting;
            forum.RolesThatCanModerate = moderatorRolesSetting.GetValue();

            forum.RequireModForNotify      = chkRequireModForNotify.Checked;
            forum.AllowTrustedDirectNotify = chkAllowTrustedDirectNotify.Checked;
            forum.ModeratorNotifyEmail     = txtModeratorNotifyEmail.Text;
            forum.IncludeInGoogleMap       = chkIncludeInGoogleMap.Checked;
            forum.AddNoIndexMeta           = chkAddNoIndexMeta.Checked;
            forum.Closed  = chkClosed.Checked;
            forum.Visible = chkVisible.Checked;

            if (forum.Save())
            {
                CurrentPage.UpdateLastModifiedTime();
                //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                CacheHelper.ClearModuleCache(forum.ModuleId);

                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
        }
Пример #3
0
        private void PopulateControls()
        {
            if (Page.IsPostBack)
            {
                return;
            }

            BindImageList();

            ISettingControl rolesControl = this.arTemplate as ISettingControl;

            if (templateGuid == Guid.Empty)
            {
                if (rolesControl != null)
                {
                    rolesControl.SetValue(defaultTemplateRoles);
                }
                return;
            }

            ContentTemplate contentTemplate = ContentTemplate.Get(templateGuid);

            if (contentTemplate == null)
            {
                return;
            }

            if (contentTemplate.SiteGuid != siteSettings.SiteGuid)
            {
                contentTemplate = null; return;
            }


            txtTitle.Text      = contentTemplate.Title.ToString();
            edDescription.Text = contentTemplate.Description.ToString();
            edTemplate.Text    = contentTemplate.Body.ToString();

            if (rolesControl != null)
            {
                rolesControl.SetValue(contentTemplate.AllowedRoles);
            }

            ListItem item = ddImage.Items.FindByValue(contentTemplate.ImageFileName);

            if (item != null)
            {
                ddImage.ClearSelection();
                item.Selected = true;
            }

            imgTemplate.Src = imageBaseUrl + contentTemplate.ImageFileName;
        }
Пример #4
0
 public static void Save(Control.ControlCollection controls)
 {
     Guard.NullArgument(controls, "controls");
     foreach (Control control in controls)
     {
         ISettingControl settingControl = control as ISettingControl;
         if (settingControl != null)
         {
             settingControl.SaveSetting();
         }
         Save(control.Controls);
     }
 }
Пример #5
0
 public bool ValidateControls(IEnumerable <Control> controls, bool isValid)
 {
     foreach (Control control in controls)
     {
         ISettingControl settingControl = control as ISettingControl;
         if (settingControl != null && control.Enabled)
         {
             string text = settingControl.Validate();
             if (SetError(control, text) && isValid)
             {
                 control.Focus();
                 isValid = false;
             }
         }
     }
     return(isValid);
 }
Пример #6
0
        private void ShowNewForumControls()
        {
            this.btnDelete.Visible      = false;
            this.btnUpdate.Text         = ForumResources.ForumEditCreateButton;
            this.chkIsActive.Checked    = true;
            this.txtSortOrder.Text      = "100";
            this.txtPostsPerPage.Text   = "10";
            this.txtThreadsPerPage.Text = "40";
            Forum forum = new Forum();

            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);
            chkIncludeInGoogleMap.Checked       = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked           = forum.AddNoIndexMeta;
            chkRequireModForNotify.Checked      = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            chkVisible.Checked = forum.Visible;
        }
        void btnSave_Click(object sender, EventArgs e)
        {
            ContentTemplate template;

            if (templateGuid != Guid.Empty)
            {
                template = ContentTemplate.Get(templateGuid);
            }
            else
            {
                template = ContentTemplate.GetNew(siteSettings.SiteGuid);
            }

            if (template == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/Admin/ContentTemplates.aspx");
                return;
            }

            template.Title       = txtTitle.Text;
            template.Body        = edTemplate.Text;
            template.Description = edDescription.Text;
            ISettingControl rolesControl = this.arTemplate as ISettingControl;

            if (rolesControl != null)
            {
                template.AllowedRoles = rolesControl.GetValue();
            }

            template.ImageFileName = ddImage.SelectedValue;

            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();

            if (currentUser != null)
            {
                template.LastModUser = currentUser.UserGuid;
            }
            template.Save();

            WebUtils.SetupRedirect(this, SiteRoot + "/Admin/ContentTemplates.aspx");
        }
Пример #8
0
        void btnSaveStatusChange_Click(object sender, EventArgs e)
        {
            if (order != null)
            {
                ISettingControl setting = orderStatusControl as ISettingControl;
                string          status  = setting.GetValue();
                if (status.Length == 36)
                {
                    Guid newStatusGuid = new Guid(status);
                    order.StatusGuid = newStatusGuid;
                    order.Save();

                    if ((newStatusGuid == OrderStatus.OrderStatusCancelledGuid) || (newStatusGuid == OrderStatus.OrderStatusNoneGuid))
                    {
                        FullfillDownloadTicket.DeleteByOrder(order.OrderGuid);
                        CommerceReport.DeleteOrder(order.OrderGuid);
                    }
                }
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Пример #9
0
 private void ShowNewForumControls()
 {
     this.btnDelete.Visible = false;
     this.btnUpdate.Text = ForumResources.ForumEditCreateButton;
     this.chkIsActive.Checked = true;
     this.txtSortOrder.Text = "100";
     this.txtPostsPerPage.Text = "10";
     this.txtThreadsPerPage.Text = "40";
     Forum forum = new Forum();
     allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
     allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);
     chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap;
     chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta;
     chkRequireModForNotify.Checked = forum.RequireModForNotify;
     chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
     chkVisible.Checked = forum.Visible;
 }
        public static void SetupPropertyControl(
            Page currentPage,
            Panel parentControl,
            CProfilePropertyDefinition propertyDefinition,
            String propertyValue,
            Double timeZoneOffset,
            string siteRoot)
        {
            if (propertyValue == null)
            {
                propertyValue = String.Empty;
            }

            Literal rowOpenTag = new Literal();

            rowOpenTag.Text = "<div class='settingrow'>";
            parentControl.Controls.Add(rowOpenTag);

            SiteLabel label = new SiteLabel();

            label.ResourceFile = propertyDefinition.ResourceFile;
            // if key isn't in resource file use assume the resource hasn't been
            //localized and just use the key as the resource
            label.ShowWarningOnMissingKey = false;
            label.ConfigKey = propertyDefinition.LabelResourceKey;
            label.CssClass  = "settinglabel";

            if (propertyDefinition.ISettingControlSrc.Length > 0)
            {
                Control c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc);

                if ((c != null) && (c is ISettingControl))
                {
                    c.ID = "isc" + propertyDefinition.Name;
                    parentControl.Controls.Add(label);

                    ISettingControl settingControl = (ISettingControl)c;

                    settingControl.SetValue(propertyValue);
                    parentControl.Controls.Add(c);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }
                }
            }
            else if (propertyDefinition.OptionList.Count > 0)
            {
                // add a dropdownlist with the options

                DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue);
                dd.ID            = "dd" + propertyDefinition.Name;
                dd.EnableTheming = false;
                dd.CssClass      = "forminput";

                dd.TabIndex      = 10;
                label.ForControl = dd.ID;
                parentControl.Controls.Add(label);

                parentControl.Controls.Add(dd);

                if (propertyDefinition.IncludeHelpLink)
                {
                    AddHelpLink(parentControl, propertyDefinition);
                }
            }
            else
            {
                switch (propertyDefinition.Type)
                {
                case "System.Boolean":
                    CheckBox checkBox = new CheckBox();
                    checkBox.TabIndex = 10;
                    checkBox.ID       = "chk" + propertyDefinition.Name;
                    checkBox.CssClass = "forminput";
                    label.ForControl  = checkBox.ID;
                    parentControl.Controls.Add(label);
                    parentControl.Controls.Add(checkBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.ToLower() == "true")
                    {
                        checkBox.Checked = true;
                    }
                    break;

                case "System.DateTime":
                    // TODO: to really make this culture aware we should store the users
                    // culture as well and use the user's culture to
                    // parse the date
                    DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, timeZoneOffset, siteRoot);

                    datePicker.TabIndex = 10;
                    datePicker.ID       = "dp" + propertyDefinition.Name;
                    datePicker.CssClass = "forminput";
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(datePicker);


                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDate = new RequiredFieldValidator();
                        rfvDate.ControlToValidate = datePicker.ID;

                        rfvDate.ErrorMessage    = Resources.ProfileResource.RequiredLabel;
                        rfvDate.Display         = ValidatorDisplay.Dynamic;
                        rfvDate.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDate);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator();
                        regexValidatorDate.ControlToValidate    = datePicker.ID;
                        regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidatorDate.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);

                            //object o = HttpContext.GetGlobalResourceObject(
                            //    propertyDefinition.ResourceFile,
                            //    propertyDefinition.RegexValidationErrorResourceKey);

                            //if (o != null)
                            //{
                            //    regexValidatorDate.ErrorMessage = o.ToString();
                            //}
                            //else
                            //{
                            //    regexValidatorDate.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey;
                            //}
                        }

                        regexValidatorDate.Display = ValidatorDisplay.Dynamic;
                        parentControl.Controls.Add(regexValidatorDate);
                    }

                    break;

                case "System.String":
                default:

                    TextBox textBox = new TextBox();
                    textBox.TabIndex = 10;
                    textBox.ID       = "txt" + propertyDefinition.Name;
                    textBox.CssClass = "forminput";
                    label.ForControl = textBox.ID;
                    parentControl.Controls.Add(label);

                    if (propertyDefinition.MaxLength > 0)
                    {
                        textBox.MaxLength = propertyDefinition.MaxLength;
                    }

                    if (propertyDefinition.Columns > 0)
                    {
                        textBox.Columns = propertyDefinition.Columns;
                    }

                    if (propertyDefinition.Rows > 1)
                    {
                        textBox.TextMode = TextBoxMode.MultiLine;
                        textBox.Rows     = propertyDefinition.Rows;
                    }

                    parentControl.Controls.Add(textBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.Length > 0)
                    {
                        textBox.Text = propertyValue;
                    }
                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                        rfv.ControlToValidate = textBox.ID;

                        rfv.ErrorMessage    = Resources.ProfileResource.RequiredLabel;
                        rfv.Display         = ValidatorDisplay.Dynamic;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.ControlToValidate    = textBox.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);

                            //object o = HttpContext.GetGlobalResourceObject(
                            //    propertyDefinition.ResourceFile,
                            //    propertyDefinition.RegexValidationErrorResourceKey);

                            //if (o != null)
                            //{
                            //    regexValidator.ErrorMessage = o.ToString();
                            //}
                            //else
                            //{
                            //    regexValidator.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey;
                            //}
                        }

                        regexValidator.Display = ValidatorDisplay.Dynamic;
                        parentControl.Controls.Add(regexValidator);
                    }

                    break;
                }
            }


            Literal rowCloseTag = new Literal();

            rowCloseTag.Text = "</div>";
            parentControl.Controls.Add(rowCloseTag);
        }
        private void AddSettingControl(CustomModuleSetting s)
        {
            if (s.SettingName == "WebPartModuleWebPartSetting")
            {
                // Special handling for this one
                this.divWebParts.Visible = true;
                using (IDataReader reader = WebPartContent.SelectBySite(siteSettings.SiteId))
                {
                    this.ddWebParts.DataSource = reader;
                    this.ddWebParts.DataBind();
                }
                if (s.SettingValue.Length == 36)
                {
                    ListItem listItem = ddWebParts.Items.FindByValue(s.SettingValue);
                    if (listItem != null)
                    {
                        ddWebParts.ClearSelection();
                        listItem.Selected = true;
                    }
                }
            }
            else
            {
                if (s.SettingControlType == string.Empty)
                {
                    return;
                }

                String settingLabel = s.SettingName;
                String resourceFile = "Resource";
                if (s.ResourceFile.Length > 0)
                {
                    resourceFile = s.ResourceFile;
                }

                try
                {
                    settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString();
                }
                catch (NullReferenceException ex)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("ModuleSettings.aspx.cs error getting resource for s.SettingName " + s.SettingName, ex);
                    }
                }

                Panel panel = new Panel();
                panel.CssClass = "settingrow";
                Literal label = new Literal();
                label.Text = "<label class='settinglabel' >" + settingLabel + "</label>";
                panel.Controls.Add(label);

                if ((s.SettingControlType == "TextBox") || (s.SettingControlType == string.Empty))
                {
                    Literal textBox = new Literal();
                    textBox.Text = "<input name=\""
                                   + s.SettingName + this.moduleId.ToInvariantString()
                                   + "\" type='text' class=\"forminput\" value=\"" + s.SettingValue.HtmlEscapeQuotes()
                                   + "\" size=\"45\" id=\"" + s.SettingName + this.moduleId.ToInvariantString() + "\" />";

                    panel.Controls.Add(textBox);
                }

                if (s.SettingControlType == "CheckBox")
                {
                    Literal checkBox  = new Literal();
                    String  isChecked = String.Empty;

                    if (string.Equals(s.SettingValue, "true", StringComparison.InvariantCultureIgnoreCase))
                    {
                        isChecked = "checked";
                    }

                    checkBox.Text = "<input id='"
                                    + s.SettingName + this.moduleId.ToInvariantString()
                                    + "' type='checkbox' class='forminput' " + isChecked
                                    + " name='" + s.SettingName + this.moduleId.ToInvariantString() + "' />";

                    panel.Controls.Add(checkBox);
                }

                if (s.SettingControlType == "ISettingControl")
                {
                    if (s.ControlSrc.Length > 0)
                    {
                        Control uc = Page.LoadControl(s.ControlSrc);
                        if (uc is ISettingControl)
                        {
                            ISettingControl sc = uc as ISettingControl;
                            if (!IsPostBack)
                            {
                                sc.SetValue(s.SettingValue);
                            }

                            uc.ID = "uc" + moduleId.ToString(CultureInfo.InvariantCulture) + s.SettingName;
                            panel.Controls.Add(uc);
                        }
                    }
                    else
                    {
                        log.Error("could not add setting control for ISettingControl, missing controlsrc for " + s.SettingName);
                    }
                }

                if (s.HelpKey.Length > 0)
                {
                    CHelpLink.AddHelpLink(panel, s.HelpKey);
                }

                this.PlaceHolderAdvancedSettings.Controls.Add(panel);
            }
        }
        public static void SetupPropertyControl(
            Page currentPage,
            Panel parentControl,
            mojoProfilePropertyDefinition propertyDefinition,
            String propertyValue,
            Double legacyTimeZoneOffset,
            TimeZoneInfo timeZone,
            string siteRoot)
        {
            if (propertyValue == null)
            {
                propertyValue = String.Empty;
            }

            string validatorSkinID = "Profile";

            if (currentPage is mojoPortal.Web.UI.Pages.Register)
            {
                validatorSkinID = "Registration";
            }

            Literal rowOpenTag = new Literal();

            rowOpenTag.Text = "<div class='settingrow " + propertyDefinition.CssClass + "'>";
            parentControl.Controls.Add(rowOpenTag);

            SiteLabel label = new SiteLabel();

            label.ResourceFile = propertyDefinition.ResourceFile;
            // if key isn't in resource file use assume the resource hasn't been
            //localized and just use the key as the resource
            label.ShowWarningOnMissingKey = false;
            label.ConfigKey = propertyDefinition.LabelResourceKey;
            label.CssClass  = "settinglabel";

            if (propertyDefinition.ISettingControlSrc.Length > 0)
            {
                Control c = null;
                if (propertyDefinition.ISettingControlSrc.EndsWith(".ascx"))
                {
                    c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc);
                }
                else
                {
                    try
                    {
                        c = Activator.CreateInstance(System.Type.GetType(propertyDefinition.ISettingControlSrc)) as Control;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }

                if ((c != null) && (c is ISettingControl))
                {
                    c.ID = "isc" + propertyDefinition.Name;
                    parentControl.Controls.Add(label);

                    ISettingControl settingControl = (ISettingControl)c;

                    settingControl.SetValue(propertyValue);
                    parentControl.Controls.Add(c);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }
                }
            }
            else if (propertyDefinition.OptionList.Count > 0)
            {
                if (propertyDefinition.Type == "CheckboxList")
                {
                    CheckBoxList cbl = CreateCheckBoxListQuestion(propertyDefinition, propertyValue);
                    cbl.ID            = "cbl" + propertyDefinition.Name;
                    cbl.EnableTheming = false;
                    cbl.CssClass      = "forminput";

                    cbl.TabIndex     = 10;
                    label.ForControl = cbl.ID;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(cbl);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        CheckBoxListValidator rfv = new CheckBoxListValidator();
                        rfv.SkinID            = validatorSkinID;
                        rfv.ControlToValidate = cbl.ID;

                        rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                         ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfv.Display = ValidatorDisplay.None;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }
                }
                else
                {
                    // add a dropdownlist with the options

                    DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue);
                    dd.ID            = "dd" + propertyDefinition.Name;
                    dd.EnableTheming = false;
                    dd.CssClass      = "forminput " + propertyDefinition.CssClass;

                    dd.TabIndex      = 10;
                    label.ForControl = dd.ID;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(dd);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDd = new RequiredFieldValidator();
                        rfvDd.SkinID            = validatorSkinID;
                        rfvDd.ControlToValidate = dd.ID;
                        //if(dd.Items.Count > 0)
                        //{
                        //    rfvDd.InitialValue = dd.Items[0].Value;
                        //}


                        rfvDd.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                           ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));


                        rfvDd.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDd);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.SkinID               = validatorSkinID;
                        regexValidator.ControlToValidate    = dd.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidator.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidator);
                    }
                }
            }
            else
            {
                switch (propertyDefinition.Type)
                {
                case "System.Boolean":
                    CheckBox checkBox = new CheckBox();
                    checkBox.TabIndex = 10;
                    checkBox.ID       = "chk" + propertyDefinition.Name;
                    checkBox.CssClass = "forminput " + propertyDefinition.CssClass;
                    label.ForControl  = checkBox.ID;
                    parentControl.Controls.Add(label);
                    parentControl.Controls.Add(checkBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.ToLower() == "true")
                    {
                        checkBox.Checked = true;
                    }
                    break;

                case "System.DateTime":
                    // TODO: to really make this culture aware we should store the users
                    // culture as well and use the user's culture to
                    // parse the date
                    DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, legacyTimeZoneOffset, timeZone, siteRoot);

                    datePicker.TabIndex = 10;
                    datePicker.ID       = "dp" + propertyDefinition.Name;
                    datePicker.CssClass = "forminput " + propertyDefinition.CssClass;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(datePicker);


                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDate = new RequiredFieldValidator();
                        rfvDate.SkinID            = validatorSkinID;
                        rfvDate.ControlToValidate = datePicker.ID;

                        rfvDate.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                             ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfvDate.Display = ValidatorDisplay.None;
                        rfvDate.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDate);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator();
                        regexValidatorDate.SkinID               = validatorSkinID;
                        regexValidatorDate.ControlToValidate    = datePicker.ID;
                        regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidatorDate.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidatorDate.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidatorDate);
                    }

                    break;

                case "System.String":
                default:

                    TextBox textBox = new TextBox();
                    textBox.TabIndex = 10;
                    textBox.ID       = "txt" + propertyDefinition.Name;
                    textBox.CssClass = "forminput " + propertyDefinition.CssClass;
                    label.ForControl = textBox.ID;
                    parentControl.Controls.Add(label);

                    if (propertyDefinition.MaxLength > 0)
                    {
                        textBox.MaxLength = propertyDefinition.MaxLength;
                    }

                    if (propertyDefinition.Columns > 0)
                    {
                        textBox.Columns = propertyDefinition.Columns;
                    }

                    if (propertyDefinition.Rows > 1)
                    {
                        textBox.TextMode = TextBoxMode.MultiLine;
                        textBox.Rows     = propertyDefinition.Rows;
                    }

                    parentControl.Controls.Add(textBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.Length > 0)
                    {
                        textBox.Text = propertyValue;
                    }
                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                        rfv.SkinID            = validatorSkinID;
                        rfv.ControlToValidate = textBox.ID;

                        rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                         ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfv.Display = ValidatorDisplay.None;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.SkinID               = validatorSkinID;
                        regexValidator.ControlToValidate    = textBox.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidator.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidator);
                    }

                    break;
                }
            }


            Literal rowCloseTag = new Literal();

            rowCloseTag.Text = "</div>";
            parentControl.Controls.Add(rowCloseTag);
        }
Пример #13
0
        private void UpdateUser()
        {
            userEmail = siteUser.Email;

            if (
                (siteUser.Email != txtEmail.Text) &&
                (SiteUser.EmailExistsInDB(siteSettings.SiteId, txtEmail.Text))
                )
            {
                message.ErrorMessage = ResourceHelper.GetResourceString("Resource", "DuplicateEmailMessage");
                return;
            }

            if ((siteSettings.AllowUserEditorPreference) && (divEditorPreference.Visible))
            {
                siteUser.EditorPreference = ddEditorProviders.SelectedValue;
            }

            if (siteSettings.AllowUserFullNameChange)
            {
                siteUser.Name = txtName.Text;
            }
            siteUser.Email = txtEmail.Text;

            if (WebConfigSettings.LogIpAddressForEmailChanges)
            {
                if ((siteUser.UserId != -1) && (userEmail != siteUser.Email))
                {
                    log.Info("email for user changed from " + userEmail + " to " + siteUser.Email + " from ip address " + SiteUtils.GetIP4Address());
                }
            }

            if (pnlSecurityQuestion.Visible)
            {
                siteUser.PasswordQuestion = this.txtPasswordQuestion.Text;
                siteUser.PasswordAnswer   = this.txtPasswordAnswer.Text;
            }
            else
            {
                if (siteUser.PasswordQuestion.Length == 0)
                {
                    siteUser.PasswordQuestion = ResourceHelper.GetResourceString("Resource", "ManageUsersDefaultSecurityQuestion");
                    siteUser.PasswordAnswer   = ResourceHelper.GetResourceString("Resource", "ManageUsersDefaultSecurityAnswer");
                }
            }

            if (siteUser.LiveMessengerId.Length > 0)
            {
                siteUser.EnableLiveMessengerOnProfile = chkEnableLiveMessengerOnProfile.Checked;
            }
            else
            {
                siteUser.EnableLiveMessengerOnProfile = false;
            }

#if !MONO
            ISettingControl setting = timeZoneSetting as ISettingControl;
            if (setting != null)
            {
                siteUser.TimeZoneId = setting.GetValue();
            }
#endif

            if (siteUser.Save())
            {
                gbProfileConfiguration profileConfig = gbProfileConfiguration.GetConfig();

                foreach (gbProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.EditableByUser) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        gbProfilePropertyDefinition.SaveProperty(
                            siteUser,
                            pnlProfileProperties,
                            propertyDefinition,
                            timeOffset,
                            timeZone);
                    }
                }

                siteUser.UpdateLastActivityTime();
                if ((userEmail != siteUser.Email) && (siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
                {
                    FormsAuthentication.SetAuthCookie(siteUser.Email, false);
                }

                ProfileUpdatedEventArgs u = new ProfileUpdatedEventArgs(siteUser, false);
                OnUserUpdated(u);

                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }
        }
Пример #14
0
        private void PopulateControls()
        {
            if (Page.IsPostBack)
            {
                return;
            }

            if ((store != null) && (order != null))
            {
                if (orderUser != null)
                {
                    lblSiteUser.Text = orderUser.LoginName + " " + orderUser.Name + " " + orderUser.Email;
                    if (WebUser.IsAdmin)
                    {
                        lnkUser.Text        = WebStoreResources.ManageUserLink;
                        lnkUser.NavigateUrl = SiteRoot + "/Admin/ManageUsers.aspx?userid=" + orderUser.UserId.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        lnkUser.Text        = WebStoreResources.UserProfileLink;
                        lnkUser.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + orderUser.UserId.ToString(CultureInfo.InvariantCulture);
                    }
                }

                Title           = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
                lblOrderId.Text = order.OrderGuid.ToString();
                ISettingControl setting = orderStatusControl as ISettingControl;
                setting.SetValue(order.StatusGuid.ToString());

                litSubTotal.Text      = order.SubTotal.ToString("c", currencyCulture);
                litDiscount.Text      = order.Discount.ToString("c", currencyCulture);
                litShippingTotal.Text = order.ShippingTotal.ToString("c", currencyCulture);
                litTaxTotal.Text      = order.TaxTotal.ToString("c", currencyCulture);
                litOrderTotal.Text    = order.OrderTotal.ToString("c", currencyCulture);

                pnlDiscount.Visible      = (order.Discount > 0);
                pnlShippingTotal.Visible = (order.ShippingTotal > 0);
                pnlTaxTotal.Visible      = (order.TaxTotal > 0);

                if ((order.ShippingTotal == 0) && (order.TaxTotal == 0) && (order.Discount == 0))
                {
                    pnlSubTotal.Visible = false;
                }

                lblCustomerAddressLine1.Text   = order.CustomerAddressLine1;
                lblCustomerAddressLine2.Text   = order.CustomerAddressLine2;
                lblCustomerCity.Text           = order.CustomerCity;
                lblCustomerCompany.Text        = order.CustomerCompany;
                lblCustomerCountry.Text        = order.CustomerCountry;
                lblCustomerEmail.Text          = order.CustomerEmail;
                lblCustomerGeoZone.Text        = order.CustomerState;
                lblCustomerName.Text           = order.CustomerFirstName + " " + order.CustomerLastName;
                lblCustomerPostalCode.Text     = order.CustomerPostalCode;
                lblCustomerSuburb.Text         = order.CustomerSuburb;
                lblCustomerTelephoneDay.Text   = order.CustomerTelephoneDay;
                lblCustomerTelephoneNight.Text = order.CustomerTelephoneNight;
                lblDiscountCodes.Text          = order.DiscountCodesCsv;
                lblCustomData.Text             = order.CustomData;

                using (IDataReader reader = order.GetProducts())
                {
                    rptOrderItems.DataSource = reader;
                    rptOrderItems.DataBind();
                }

                grdDownloadTickets.DataSource = order.GetDownloadTickets();
                grdDownloadTickets.DataBind();
                pnlDownloadTickets.Visible = (grdDownloadTickets.Rows.Count > 0);

                litPaymentMethod.Text = ResourceHelper.GetResourceString("WebStoreResources", order.PaymentMethod);

                Control c = Page.LoadControl("~/Controls/GCheckoutLogList.ascx");
                if (c != null)
                {
                    GCheckoutLogList googleLog = c as GCheckoutLogList;
                    googleLog.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(googleLog);
                }

                c = Page.LoadControl("~/Controls/PayPalLogList.ascx");
                if (c != null)
                {
                    PayPalLogList logList = c as PayPalLogList;
                    logList.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(logList);
                }

                c = Page.LoadControl("~/Controls/PaymentLogList.ascx");
                if (c != null)
                {
                    PaymentLogList logList = c as PaymentLogList;
                    logList.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(logList);
                }

                //c = Page.LoadControl("~/Controls/AuthorizeNetLogList.ascx");
                //if (c != null)
                //{
                //    AuthorizeNetLogList logList = c as AuthorizeNetLogList;
                //    logList.CartGuid = order.OrderGuid;
                //    pnlCheckoutLog.Controls.Add(logList);
                //}
                //c = Page.LoadControl("~/Controls/PlugNPayLogList.ascx");
                //if (c != null)
                //{
                //    PlugNPayLogList logList = c as PlugNPayLogList;
                //    logList.CartGuid = order.OrderGuid;
                //    pnlCheckoutLog.Controls.Add(logList);
                //}
            }
        }
        private void btnSave_Click(Object sender, EventArgs e)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("ModuleSettingsPage about to call Page.Validate()");
            }

            Page.Validate();
            if (Page.IsValid)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("ModuleSettingsPage about to call Page IsValid = true");
                }

                bool ok            = true;
                bool needToReIndex = false;
                int  currentPageId = module.PageId;
                int  newPageId     = module.PageId;


                if (module.ModuleId > -1)
                {
                    if (isAdmin)
                    {
                        string viewRoles = string.Empty;

                        foreach (ListItem item in cblViewRoles.Items)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage inside loop of Role ListItems");
                            }
                            if (item.Selected == true)
                            {
                                viewRoles = viewRoles + item.Value + ";";
                            }
                        }
                        string previousViewRoles = this.module.ViewRoles;
                        this.module.ViewRoles = viewRoles;
                        if (previousViewRoles != viewRoles)
                        {
                            needToReIndex = true;
                        }

                        string editRoles = string.Empty;
                        if (log.IsDebugEnabled)
                        {
                            log.Debug("ModuleSettingsPage about to loop through Role ListItems");
                        }

                        foreach (ListItem item in authEditRoles.Items)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage inside loop of Role ListItems");
                            }
                            if (item.Selected == true)
                            {
                                editRoles = editRoles + item.Value + ";";
                            }
                        }

                        this.module.AuthorizedEditRoles = editRoles;

                        string draftEdits = string.Empty;

                        foreach (ListItem item in draftEditRoles.Items)
                        {
                            if (item.Selected == true)
                            {
                                draftEdits = draftEdits + item.Value + ";";
                            }
                        }

                        this.module.DraftEditRoles = draftEdits;
                    }

                    if (tabGeneralSettings.Visible)
                    {
                        this.module.ModuleTitle = moduleTitle.Text;
                        this.module.CacheTime   = int.Parse(cacheTime.Text);

                        this.module.ShowTitle                      = chkShowTitle.Checked;
                        this.module.AvailableForMyPage             = this.chkAvailableForMyPage.Checked;
                        this.module.AllowMultipleInstancesOnMyPage = this.chkAllowMultipleInstancesOnMyPage.Checked;
                        this.module.Icon = this.ddIcons.SelectedValue;
                        this.module.HideFromAuthenticated   = chkHideFromAuth.Checked;
                        this.module.HideFromUnauthenticated = chkHideFromUnauth.Checked;

                        if (this.divParentPage.Visible)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage about to check Page dropdown");
                            }
                            newPageId = int.Parse(this.ddPages.SelectedValue);
                            if (newPageId != currentPageId)
                            {
                                needToReIndex = true;
                                Module.UpdatePage(currentPageId, newPageId, this.module.ModuleId);
                            }
                            this.module.PageId = newPageId;
                        }

                        if (this.isAdmin)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.Debug("ModuleSettingsPage about to check user dropdown");
                            }
                            if (this.scUser.Value.Length > 0)
                            {
                                try
                                {
                                    this.module.EditUserId = int.Parse(this.scUser.Value);
                                }
                                catch (ArgumentException) { }
                                catch (FormatException) { }
                                catch (OverflowException) { }
                            }
                            else
                            {
                                this.module.EditUserId = 0;
                            }
                        }
                    }

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("ModuleSettingsPage about to Save Module");
                    }
                    this.module.Save();

                    if (needToReIndex)
                    {
                        // if content is moved from 1 page to another, need to reindex both pages
                        // to keep view permissions in sync

                        IndexHelper.RebuildPageIndexAsync(CurrentPage);

                        PageSettings newPage = new PageSettings(siteSettings.SiteId, newPageId);
                        newPage.PageIndex = 0;
                        IndexHelper.RebuildPageIndexAsync(newPage);
                    }

                    ArrayList defaultSettings = ModuleSettings.GetDefaultSettings(this.module.ModuleDefId);
                    foreach (CustomModuleSetting s in defaultSettings)
                    {
                        if (s.SettingControlType == string.Empty)
                        {
                            continue;
                        }
                        ok = true;

                        Object oSettingLabel = GetGlobalResourceObject("Resource", s.SettingName + "RegexWarning");
                        String settingLabel  = String.Empty;
                        if (oSettingLabel == null)
                        {
                            settingLabel = "Regex Warning";
                        }
                        else
                        {
                            settingLabel = oSettingLabel.ToString();
                        }

                        string settingValue = string.Empty;

                        if (s.SettingName == "WebPartModuleWebPartSetting")
                        {
                            ModuleSettings.UpdateModuleSetting(this.module.ModuleGuid, moduleId, s.SettingName, ddWebParts.SelectedValue);
                        }
                        else
                        {
                            if (s.SettingControlType == "ISettingControl")
                            {
                                string  controlID = "uc" + moduleId.ToString(CultureInfo.InvariantCulture) + s.SettingName;
                                Control c         = PlaceHolderAdvancedSettings.FindControl(controlID);
                                if (c != null)
                                {
                                    if (c is ISettingControl)
                                    {
                                        ISettingControl isc = c as ISettingControl;
                                        settingValue = isc.GetValue();
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                }
                                else
                                {
                                    log.Error("could not find control for " + s.SettingName);
                                    ok = false;
                                }
                            }
                            else
                            {
                                settingValue = Request.Params.Get(s.SettingName + this.moduleId.ToString(CultureInfo.InvariantCulture));

                                if (s.SettingControlType == "CheckBox")
                                {
                                    if (settingValue == "on")
                                    {
                                        settingValue = "true";
                                    }
                                    else
                                    {
                                        settingValue = "false";
                                    }
                                }
                                else
                                {
                                    if (s.SettingValidationRegex.Length > 0)
                                    {
                                        if (!Regex.IsMatch(settingValue, s.SettingValidationRegex))
                                        {
                                            ok = false;
                                            this.lblValidationSummary.Text += "<br />"
                                                                              + settingLabel;
                                        }
                                    }
                                }
                            }

                            if (ok)
                            {
                                ModuleSettings.UpdateModuleSetting(this.module.ModuleGuid, moduleId, s.SettingName, settingValue);
                            }
                        }
                    }
                }

                if (ok)
                {
                    CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                    return;
                }
            }
        }
Пример #16
0
        private void PopulateControls()
        {
            this.lnkChangePassword.NavigateUrl = SiteRoot + "/Secure/ChangePassword.aspx";
            this.lnkChangePassword.Text        = Resource.UserChangePasswordLabel;
            ListItem listItem;

            if (allowUserSkin)
            {
                if (siteUser != null)
                {
                    SkinSetting.SetValue(siteUser.Skin);
                }
            }

            if ((siteSettings.AllowUserEditorPreference) && (siteUser != null) && (siteUser.EditorPreference.Length > 0))
            {
                listItem = ddEditorProviders.Items.FindByValue(siteUser.EditorPreference);
                if (listItem != null)
                {
                    ddEditorProviders.ClearSelection();
                    listItem.Selected = true;
                }
            }



            if (siteUser != null)
            {
#if !MONO
                ISettingControl setting = timeZoneSetting as ISettingControl;
                if (setting != null)
                {
                    setting.SetValue(siteUser.TimeZoneId);
                }
#endif

                txtName.Text      = SecurityHelper.RemoveMarkup(siteUser.Name);
                txtName.Enabled   = siteSettings.AllowUserFullNameChange;
                lblLoginName.Text = SecurityHelper.RemoveMarkup(siteUser.LoginName);
                txtEmail.Text     = siteUser.Email;
                //gravatar1.Email = siteUser.Email;
                lblOpenID.Text           = siteUser.OpenIdUri;
                txtPasswordQuestion.Text = siteUser.PasswordQuestion;
                txtPasswordAnswer.Text   = siteUser.PasswordAnswer;
                lblCreatedDate.Text      = siteUser.DateCreated.AddHours(timeOffset).ToString();
                lblTotalPosts.Text       = siteUser.TotalPosts.ToString();
                lnkUserPosts.UserId      = siteUser.UserId;
                lnkUserPosts.TotalPosts  = siteUser.TotalPosts;
                //lnkPublicProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();
                lnkPubProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();

                if (divLiveMessenger.Visible)
                {
                    WindowsLiveLogin     wl = WindowsLiveHelper.GetWindowsLiveLogin();
                    WindowsLiveMessenger m  = new WindowsLiveMessenger(wl);

                    if (WebConfigSettings.TestLiveMessengerDelegation)
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.ConsentOptInUrl;
                    }
                    else
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.NonDelegatedSignUpUrl;
                    }

                    if (siteUser.LiveMessengerId.Length > 0)
                    {
                        chkEnableLiveMessengerOnProfile.Checked = siteUser.EnableLiveMessengerOnProfile;
                        chkEnableLiveMessengerOnProfile.Enabled = true;
                    }
                    else
                    {
                        chkEnableLiveMessengerOnProfile.Checked = false;
                        chkEnableLiveMessengerOnProfile.Enabled = false;
                    }
                }


                //if ((!allowGravatars)&&(!disableAvatars))
                //{
                //    if (siteUser.AvatarUrl.Length > 0)
                //    {
                //        imgAvatar.Src = avatarPath + siteUser.AvatarUrl;
                //    }
                //    else
                //    {
                //        imgAvatar.Src = Page.ResolveUrl(WebConfigSettings.DefaultBlankAvatarPath);
                //    }
                //}

                userAvatar.UseGravatar      = allowGravatars;
                userAvatar.Email            = siteUser.Email;
                userAvatar.UserName         = siteUser.Name;
                userAvatar.UserId           = siteUser.UserId;
                userAvatar.AvatarFile       = siteUser.AvatarUrl;
                userAvatar.MaxAllowedRating = MaxAllowedGravatarRating;
                userAvatar.Disable          = disableAvatars;
                userAvatar.SiteId           = siteSettings.SiteId;
                userAvatar.UseLink          = false;
            }

            // this doesn't work
            //DoTabSelection();
        }
Пример #17
0
        private void PopulateControls()
        {
            Forum forum = new Forum(itemId);

            if (forum.ModuleId != moduleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            this.lblCreatedDate.Text = forum.CreatedDate.AddHours(timeOffset).ToString();
            edContent.Text = forum.Description;
            this.txtTitle.Text = forum.Title;
            this.chkIsActive.Checked = forum.IsActive;
            //this.chkAllowAnonymousPosts.Checked = forum.AllowAnonymousPosts;
            this.chkIsModerated.Checked = forum.IsModerated;
            this.txtSortOrder.Text = forum.SortOrder.ToString();
            this.txtPostsPerPage.Text = forum.PostsPerPage.ToString();
            this.txtThreadsPerPage.Text = forum.ThreadsPerPage.ToString();
            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);

            moderatorRolesSetting = moderatorRoles as AllowedRolesSetting;
            moderatorRolesSetting.SetValue(forum.RolesThatCanModerate);

            chkRequireModForNotify.Checked = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            txtModeratorNotifyEmail.Text = forum.ModeratorNotifyEmail;
            chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta;
            chkClosed.Checked = forum.Closed;
            chkVisible.Checked = forum.Visible;
        }
Пример #18
0
        private void UpdateUser()
        {
            userEmail = siteUser.Email;

            if (
                (siteUser.Email != txtEmail.Text) &&
                (SiteUser.EmailExistsInDB(siteSettings.SiteId, siteUser.UserId, txtEmail.Text))
                )
            {
                lblErrorMessage.Text = Resource.DuplicateEmailMessage;
                return;
            }

            if ((siteSettings.AllowUserEditorPreference) && (divEditorPreference.Visible))
            {
                siteUser.EditorPreference = ddEditorProviders.SelectedValue;
            }

            if (siteSettings.AllowUserFullNameChange)
            {
                siteUser.Name = txtName.Text;
            }
            siteUser.Email = txtEmail.Text;

            if (WebConfigSettings.LogIpAddressForEmailChanges)
            {
                if ((siteUser.UserId != -1) && (userEmail != siteUser.Email))
                {
                    log.Info("email for user changed from " + userEmail + " to " + siteUser.Email + " from ip address " + SiteUtils.GetIP4Address());
                }
            }

            if (pnlSecurityQuestion.Visible)
            {
                siteUser.PasswordQuestion = this.txtPasswordQuestion.Text;
                siteUser.PasswordAnswer   = this.txtPasswordAnswer.Text;
            }
            else
            {
                //in case it is ever changed later to require password question and answer after making it not required
                // we need to ensure there is some question and answer.
                if (siteUser.PasswordQuestion.Length == 0)
                {
                    siteUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
                    siteUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
                }
            }


            if (siteUser.LiveMessengerId.Length > 0)
            {
                siteUser.EnableLiveMessengerOnProfile = chkEnableLiveMessengerOnProfile.Checked;
            }
            else
            {
                siteUser.EnableLiveMessengerOnProfile = false;
            }

            if (allowUserSkin)
            {
                siteUser.Skin = SkinSetting.GetValue();
                //if (ddSkins.SelectedValue != "printerfriendly")
                //{
                //    siteUser.Skin = ddSkins.SelectedValue;
                //}
            }

#if !MONO
            ISettingControl setting = timeZoneSetting as ISettingControl;
            if (setting != null)
            {
                siteUser.TimeZoneId = setting.GetValue();
            }
#endif

            //if ((!disableOldAvatars)&&(!WebConfigSettings.OnlyAdminsCanEditCheesyAvatars))
            //{ siteUser.AvatarUrl = ddAvatars.SelectedValue; }
            siteUser.PasswordFormat = siteSettings.PasswordFormat;

            if (siteUser.Save())
            {
                mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

                foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.EditableByUser) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        mojoProfilePropertyDefinition.SaveProperty(
                            siteUser,
                            pnlProfileProperties,
                            propertyDefinition,
                            timeOffset,
                            timeZone);
                    }
                }

                siteUser.UpdateLastActivityTime();
                if ((userEmail != siteUser.Email) && (siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
                {
                    FormsAuthentication.SetAuthCookie(siteUser.Email, false);
                }

                ProfileUpdatedEventArgs u = new ProfileUpdatedEventArgs(siteUser, false);
                OnUserUpdated(u);

                SiteUtils.SetSkinCookie(siteUser);
                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }
        }
Пример #19
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Forum forum = new Forum(itemId);
            if ((forum.ItemId > -1)&&(forum.ModuleId != moduleId))
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            //SiteUser siteUser = new SiteUser(siteSettings, Context.User.Identity.Name);
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
            if(siteUser != null)
            forum.CreatedByUserId = siteUser.UserId;

            forum.ModuleId = moduleId;
            forum.Description = edContent.Text;
            forum.Title = this.txtTitle.Text;
            forum.IsActive = this.chkIsActive.Checked;
            //forum.AllowAnonymousPosts = this.chkAllowAnonymousPosts.Checked;
            forum.IsModerated = this.chkIsModerated.Checked;
            forum.SortOrder = int.Parse(this.txtSortOrder.Text);
            forum.PostsPerPage = int.Parse(this.txtPostsPerPage.Text);
            forum.ThreadsPerPage = int.Parse(this.txtThreadsPerPage.Text);

            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            forum.RolesThatCanPost = allowedPostRolesSetting.GetValue();

            moderatorRolesSetting = moderatorRoles as AllowedRolesSetting;
            forum.RolesThatCanModerate = moderatorRolesSetting.GetValue();

            forum.RequireModForNotify = chkRequireModForNotify.Checked;
            forum.AllowTrustedDirectNotify = chkAllowTrustedDirectNotify.Checked;
            forum.ModeratorNotifyEmail = txtModeratorNotifyEmail.Text;
            forum.IncludeInGoogleMap = chkIncludeInGoogleMap.Checked;
            forum.AddNoIndexMeta = chkAddNoIndexMeta.Checked;
            forum.Closed = chkClosed.Checked;
            forum.Visible = chkVisible.Checked;

            if(forum.Save())
            {
                CurrentPage.UpdateLastModifiedTime();
                //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                CacheHelper.ClearModuleCache(forum.ModuleId);

                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());

            }
        }