protected void Page_Load(object sender, EventArgs e) { ((BXAdminMasterPage)Page.Master).Title = Page.Title; Dictionary<string, string> selectorList = new Dictionary<string, string>(); BXCommand command = new BXCommand("Bitrix.Main.OnGlobalOptionsSubscribe"); command.Send(); List<KeyValuePair<string, BXCommandResult>> values = new List<KeyValuePair<string,BXCommandResult>>(); foreach (KeyValuePair<string, BXCommandResult> kvp in command.CommandResultDictionary) if (kvp.Value.CommandResult == BXCommandResultType.Ok) values.Add(kvp); values.Sort(delegate(KeyValuePair<string, BXCommandResult> a, KeyValuePair<string, BXCommandResult> b) { return string.Compare(a.Value.Result.ToString(), b.Value.Result.ToString(), true); }); foreach(KeyValuePair<string, BXCommandResult> kvp in values) selectorList.Add(kvp.Key, kvp.Value.Result.ToString()); if (!Page.IsPostBack) BindEntitySelector(selectorList); LoadSelectedControl(ddlEntitySelector.SelectedValue, selectorList); MasterTitle = GetMessageFormat("MasterTitle.GlobalSettings", selectorList[ddlEntitySelector.SelectedValue]); }
protected void Page_Init(object sender, EventArgs e) { if (!BXPrincipal.Current.IsCanOperate(BXRoleOperation.Operations.ProductSettingsManage)) BXAuthentication.AuthenticationRequired(); if (BXMediator.HasListeners("Bitrix.Search.IndexAll")) OldReindexTab.Visible = true; indexerIsRunning = BXSearchContentIndexer2.ReadState(indexersStatus); sites = new List<BXSite>(BXSite.GetAllSitesReadOnly()); BXCommand cmd = new BXCommand("Bitrix.Search.EnumerateIndexers"); cmd.Send(); // Get Indexers indexers = new List<IndexerInfo>(); foreach (BXCommandResult r in cmd.CommandResultDictionary.Values) { if (r.CommandResult != BXCommandResultType.Ok) continue; BXParamsBag<object> info = r.Result as BXParamsBag<object>; if (info == null) continue; string id = info.GetString("id"); if (id == null) continue; indexers.Add(new IndexerInfo(id, info, Request.Url)); } indexers.Sort(delegate(IndexerInfo a, IndexerInfo b) { return string.Compare(a.Id, b.Id, true); }); for (int i = 0; i < indexers.Count; i++) indexers[i].Num = i; if (!IsPostBack) { if (indexerIsRunning || indexersStatus.Count != 0) BXTabControl1.SelectedIndex = 1; allSitesSelected = true; allIndexersSelected = true; } else ReadPostData(); IndexerList.DataSource = indexers; IndexerList.DataBind(); ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(StatusTimer); }
protected void Button3_Click(object sender, EventArgs e) { if (Page.IsValid) { string login = lbLogin.Text; BXUser user = BXUserManager.GetByName(login, null, false); if (user != null && user.IsApproved) { try { string val = user.ResetPassword(tbAnswer.Text, null); BXCommand c = new BXCommand("Bitrix.Main.PasswordRecovery"); c.Parameters.Add("USER_ID", user.UserId); c.Parameters.Add("MESSAGE", GetMessage("YouHaveRequestedYourRegistrationData")); c.Parameters.Add("LOGIN", user.UserName); c.Parameters.Add("CHECKWORD", val); c.Parameters.Add("EMAIL", user.Email); c.Send(); successMessage.Visible = true; } catch (NotSupportedException exception) { errorMessage.AddErrorMessage(GetMessage("Error.AnErrorHasOccurredWhilePasswordChange") + Encode(exception.Message)); } catch (MembershipPasswordException exception) { if (exception.Message.Equals("WrongAnswer", StringComparison.InvariantCultureIgnoreCase)) errorMessage.AddErrorMessage(GetMessage("Error.AnswerIsNotCorrect")); else errorMessage.AddErrorMessage(GetMessage("Error.PasswordIsNotCorrect") + Encode(exception.Message)); } catch (ProviderException exception) { errorMessage.AddErrorMessage(GetMessage("Error.ProviderError") + Encode(exception.Message)); } catch (Exception exception) { errorMessage.AddErrorMessage(GetMessage("Error.Error") + Encode(exception.Message)); } } else { errorMessage.AddErrorMessage(GetMessage("Error.UserIsNotFound")); } } }
void Save() { bool changed = false; Dictionary<string, BXAuthorizationFile> fileCache = new Dictionary<string, BXAuthorizationFile>(); foreach (Entry entry in validItems) foreach (BXRole role in BXRoleManager.GetList(null, null)) { string roleId = role.RoleId.ToString(); bool deleteAll = !OperationsEdit.State.ContainsRole(roleId); foreach (string op in BXFileOperation.Operations) { BXOperationsEditOperationState opState = deleteAll ? BXOperationsEditOperationState.Inherited : OperationsEdit.State[roleId, op]; if (opState == BXOperationsEditOperationState.Inherited) BXFileAuthorizationManager.DeleteLocalRight(entry.Path, role.RoleName, op, fileCache, false); else if (opState != BXOperationsEditOperationState.DontModify) BXFileAuthorizationManager.SetLocalRight(entry.Path, role.RoleName, op, opState == BXOperationsEditOperationState.Allowed, fileCache, false); } } try { foreach (KeyValuePair<string, BXAuthorizationFile> file in fileCache) { file.Value.PlaceAllAndNotAuthorizedFirst(); file.Value.RemoveEmptyLocations(); List<string> messages = new List<string>(); BXCommand command = new BXCommand("Bitrix.Security.OnBeforeSaveAuthorizationFile"); command.Parameters.Add("path", file.Key); command.Parameters.Add("authorizationFile", file.Value); command.Send(); foreach (KeyValuePair<string, BXCommandResult> kvp in command.CommandResultDictionary) if (kvp.Value.CommandResult == BXCommandResultType.Cancel) messages.Add(kvp.Value.Result.ToString()); if (messages.Count > 0) throw new BXEventException(messages); command = new BXCommand("Bitrix.Security.OnSaveAuthorizationFile"); command.Parameters.Add("path", file.Key); command.Parameters.Add("authorizationFile", file.Value); command.Send(); foreach (KeyValuePair<string, BXCommandResult> kvp in command.CommandResultDictionary) if (kvp.Value.CommandResult == BXCommandResultType.Error) messages.Add(kvp.Value.Result.ToString()); if (messages.Count > 0) throw new BXEventException(messages); if (file.Value.Save(file.Key)) changed = true; command = new BXCommand("Bitrix.Security.OnAfterSaveAuthorizationFile"); command.Parameters.Add("path", file.Key); command.Parameters.Add("authorizationFile", file.Value); command.Send(); foreach (KeyValuePair<string, BXCommandResult> kvp in command.CommandResultDictionary) if (kvp.Value.CommandResult == BXCommandResultType.Error) messages.Add(kvp.Value.Result.ToString()); if (messages.Count > 0) throw new BXEventException(messages); } } finally { if (changed) new BXCommand("Bitrix.Security.FileAuthorizationStateChanged").Send(); } }
protected override void CreateChildControls() { BXCommand cmdCreate = new BXCommand("Bitrix.Modules.BXPublicPanel.CreateMenu"); BXPublicPanelMenuSectionList sectionList = new BXPublicPanelMenuSectionList(); cmdCreate.AddCommandResult("SectionList", new BXCommandResult(BXCommandResultType.Ok, sectionList)); cmdCreate.Send(); Visible = CalculateVisibility(sectionList); if (!Visible) return; if (BXConfigurationUtility.IsDesignMode) Response.Cache.SetCacheability(HttpCacheability.NoCache); BXCommand cmdFill = new BXCommand("Bitrix.Modules.BXPublicPanel.PopulateMenu"); cmdFill.Parameters.Add("ShowMode", Bitrix.Configuration.BXConfigurationUtility.ShowMode); cmdFill.AddCommandResult("SectionList", new BXCommandResult(BXCommandResultType.Ok, sectionList)); cmdFill.Send(); int count = sectionList.Count; if (count == 0) return; sectionList.SortByOrder(); bool firstSection = true; foreach (BXPublicPanelMenuSection section in sectionList) if (section.ShouldRender) { if (!firstSection) { HtmlGenericControl separator = new HtmlGenericControl("div"); separator.Attributes.Add("class", "bx-pnseparator"); panelButtonsPlaceHolder.Controls.Add(separator); } else firstSection = false; panelButtonsPlaceHolder.Controls.Add(section); } }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid ) { string login = tbLogin.Text; string email = tbEMail.Text; BXUser user; if (String.IsNullOrEmpty(login) && String.IsNullOrEmpty(email)) errorMessage.AddErrorMessage(GetMessage("Error.EmailIsRequierd")); else { if (String.IsNullOrEmpty(login)) { BXUserCollection userCollection = BXUserManager.GetUserNameByEmail(email); if (userCollection.Count == 1) login = userCollection[0].UserName; } if (!String.IsNullOrEmpty(login)) { user = BXUserManager.GetByName(login, null, false); if (user != null && user.IsApproved) { string newCheckWord = user.ChangeCheckWord(); BXCommand c = new BXCommand("Bitrix.Main.PasswordRecovery"); var site = Bitrix.BXSite.GetById(user.SiteId) ?? Bitrix.BXSite.DefaultSite; c.Parameters.Add("@site", site.TextEncoder.Decode(site.Id)); c.Parameters.Add("SERVER_NAME", Bitrix.Services.BXSefUrlManager.CurrentUrl.Host); c.Parameters.Add("NAME", user.FirstName); c.Parameters.Add("LAST_NAME", user.LastName); c.Parameters.Add("STATUS", string.Empty); c.Parameters.Add("USER_ID", user.UserId); c.Parameters.Add("MESSAGE", GetMessage("YouHaveRequestedYourRegistrationData")); c.Parameters.Add("LOGIN", user.UserName); c.Parameters.Add("CHECKWORD", Server.UrlEncode(newCheckWord)); c.Parameters.Add("EMAIL", user.Email); c.Parameters.Add("LINK", VirtualPathUtility.ToAbsolute("~/bitrix/admin/PasswordRecoveryAlt1.aspx") + "?checkword=" + Server.UrlEncode(newCheckWord)); c.Parameters.Add( "USER_NAME", (user.FirstName == null ? "" : user.FirstName) + ((!String.IsNullOrEmpty(user.FirstName) && !String.IsNullOrEmpty(user.LastName)) ? " " : "") + (user.LastName == null ? "" : user.LastName) + ((!String.IsNullOrEmpty(user.FirstName) || !String.IsNullOrEmpty(user.LastName)) ? "," : "") ); c.Send(); loginMessage.Visible = true; } else { errorMessage.AddErrorMessage(GetMessage("Error.UserIsNotfound")); } } else { errorMessage.AddErrorMessage(GetMessage("Error.EmailIsNotFound")); } } } }
private void LoadSelectedControl(string entityId, Dictionary<string, string> selectorList) { Dictionary<string, PlaceHolder> placeholderList = new Dictionary<string, PlaceHolder>(); foreach (KeyValuePair<string, string> kvp1 in selectorList) { PlaceHolder p = new PlaceHolder(); Settings.Controls.Add(p); placeholderList.Add(kvp1.Key, p); } //List<string> paths = new List<string>(); BXCommand command = new BXCommand("Bitrix.Main.OnGlobalOptionsEdit"); //command.FilterListeners = new string[] { entityId }; command.Parameters.Add("EntityId", entityId); command.Send(); BXCommandResult r; if (command.CommandResultDictionary.TryGetValue(entityId, out r) && r.CommandResult == BXCommandResultType.Ok) { string path = r.Result.ToString(); if (File.Exists(BXPath.MapPath(path))) { Control ctrl = LoadControl(path); placeholderList[entityId].Controls.Add(ctrl); } } }