public static bool CheckAccess(string pluginName, bool menu = false, bool loan = false) { if (EncompassHelper.IsTest() || CDOHelper.CDO.CommunitySettings.SuperAdminRun) { return(true); } if (Plugins != null) { return(CheckAccessInPlugins(pluginName, menu, loan)); } PluginAccessRight right = Rights.Where(x => x.PluginName.Equals(pluginName)).FirstOrDefault(); if (right == null) { return(false); } bool isAllowedToRun = loan ? false : right.AllAccess; if (!isAllowedToRun && right.Personas != null) { isAllowedToRun = EncompassHelper.ContainsPersona(right.Personas); } if (!isAllowedToRun && right.UserIDs != null) { isAllowedToRun = right.UserIDs.Contains(EncompassHelper.User.ID); } return(isAllowedToRun); }
private void ComboBox1_TextChanged(object sender, EventArgs e) { string Name = comboBox1.Text; List <PluginAccessRight> plugins = CDO.Rights; right = CDO.Rights.FirstOrDefault(x => x.PluginName.Equals(Name)); bool newRight = right == null; chkAllAccess.Checked = newRight ? false : right.AllAccess; for (int i = 0; i < cbPersonas.Items.Count; i++) { cbPersonas.SetItemChecked(i, newRight ? false : right.Personas.Contains(cbPersonas.Items[i])); } for (int i = 0; i < cbUsers.Items.Count; i++) { cbUsers.SetItemChecked(i, newRight ? false : right.UserIDs.Contains(cbUsers.Items[i])); } }
private void btnSave_Click(object sender, EventArgs e) { string Name = comboBox1.Text; PluginAccessRight right = CDO.Rights.FirstOrDefault(x => x.PluginName.Equals(Name)); if (right == null) { right = new PluginAccessRight(); right.PluginName = Name; CDO.Rights.Add(right); } right.AllAccess = chkAllAccess.Checked; right.Personas = cbPersonas.CheckedItems.OfType <string>().ToList(); right.UserIDs = cbUsers.CheckedItems.OfType <string>().ToList(); CustomDataObject.Save <CommunitySettings>(CommunitySettings.Key, CDO); MessageBox.Show($"{CommunitySettings.Key} Saved"); }
public static bool CheckAccess(string pluginName) { CommunitySettings cdo = CustomDataObject.Get <CommunitySettings>(CommunitySettings.Key); List <PluginAccessRight> rights = cdo.Rights; if (rights.Count.Equals(0)) { rights.Add(new PluginAccessRight() { PluginName = nameof(TopMenuBase), AllAccess = true }); rights.Add(new PluginAccessRight() { PluginName = nameof(PluginManagement), AllAccess = true }); CustomDataObject.Save <CommunitySettings>(CommunitySettings.Key, cdo); } PluginAccessRight right = rights.Where(x => x.PluginName.Equals(pluginName)).FirstOrDefault(); if (right == null) { return(false); } bool isAllowedToRun = right.AllAccess; if (!isAllowedToRun && right.Personas != null) { isAllowedToRun = EncompassHelper.ContainsPersona(right.Personas); } if (!isAllowedToRun && right.UserIDs != null) { isAllowedToRun = right.UserIDs.Contains(EncompassHelper.User.ID); } return(isAllowedToRun); }