Exemple #1
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());
            }
        }
        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");
        }
        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);
        }
Exemple #4
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;
            }
        }
Exemple #5
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;
            }
        }
        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());

            }
        }
        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;
                }
            }
        }