protected void Page_Load(object sender, EventArgs e) { modifyPermission = AccountHelper.AuthorizedModifyAccount(this.SiteID, false); if (this.SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD) { modifyGlobal = AccountHelper.AuthorizedModifyAccount(UniSelector.US_GLOBAL_RECORD, false); modifySite = AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false); } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // Setup unigrid gridElem.OnBeforeDataReload += new OnBeforeDataReload(gridElem_OnBeforeDataReload); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.WhereCondition = filter.WhereCondition; gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, this.WhereCondition); gridElem.EditActionUrl = "Frameset.aspx?accountId={0}&siteId=" + this.SiteID; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); if (ContactHelper.IsSiteManager) { gridElem.EditActionUrl = URLHelper.AddParameterToUrl(gridElem.EditActionUrl, "issitemanager", "1"); } // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(this.SiteID, false)) && ContactGroupHelper.AuthorizedReadContactGroup(this.SiteID, false)) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.AddToGroup), Convert.ToInt32(Action.AddToGroup).ToString())); } if (modifyPermission) { drpAction.Items.Add(new ListItem(GetString("general.delete"), Convert.ToInt32(Action.Delete).ToString())); drpAction.Items.Add(new ListItem(GetString("om.account." + Action.Merge), Convert.ToInt32(Action.Merge).ToString())); if (SiteID >= 0) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } } drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (RequestHelper.CausedPostback(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } if (Request.Params["__EVENTARGUMENT"] == ACCOUNTS_MERGED) { lblInfo.Text = GetString("om.account.merginglist"); } // Register JS scripts RegisterScripts(); }
void gridElem_OnFilterFieldCreated(string columnName, UniGridFilterField filterDefinition) { filter = filterDefinition.ValueControl as CMSModules_ContactManagement_Controls_UI_Account_Filter; if (filter != null) { filter.NotMerged = true; filter.IsLiveSite = IsLiveSite; filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); } }
protected void Page_Load(object sender, EventArgs e) { // Current contact is global object if (Contact.ContactSiteID == 0) { filter.SiteID = SiteContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { filter.SiteID = UniSelector.US_GLOBAL_RECORD; filter.DisplaySiteSelector = true; } // Display 'site or global' selector in CMS desk for global objects else if (ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, false)) { filter.DisplayGlobalOrSiteSelector = true; } } else { filter.SiteID = Contact.ContactSiteID; } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); filter.ShowChildren = ShowChildrenOption; string where = String.Empty; if (!filter.ChildrenSelected) { // Display only direct children ("first level") if (Contact.ContactSiteID == 0) { where = SqlHelper.AddWhereCondition(where, "ContactMergedWithContactID IS NULL AND ContactGlobalContactID = " + Contact.ContactID); } else { where = SqlHelper.AddWhereCondition(where, "ContactMergedWithContactID = " + Contact.ContactID); } } else { // Get children for site contact where = SqlHelper.AddWhereCondition(where, "ContactID IN (SELECT * FROM Func_OM_Contact_GetChildren(" + Contact.ContactID + ", 0))"); } gridElem.WhereCondition = where; gridElem.ZeroRowsText = GetString("om.contact.nocontacts"); gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; btnSplit.Click += btnSplit_Click; // Register JS scripts RegisterScripts(); }
protected void Page_Load(object sender, EventArgs e) { bool isGlobal = Account.AccountSiteID == 0; // Current contact is global object if (isGlobal) { filter.SiteID = CMSContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { filter.SiteID = UniSelector.US_GLOBAL_RECORD; filter.DisplaySiteSelector = true; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false)) { filter.DisplayGlobalOrSiteSelector = true; } } else { filter.SiteID = Account.AccountSiteID; } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); filter.ShowChildren = ShowChildrenOption; string where = filter.WhereCondition; if (!filter.ChildrenSelected) { // Display only direct children ("first level") where = SqlHelperClass.AddWhereCondition(where, "AccountGlobalAccountID = " + Account.AccountID + " OR AccountMergedWithAccountID = " + Account.AccountID); } else if (isGlobal) { // Get children for global contact where = SqlHelperClass.AddWhereCondition(where, "AccountID IN (SELECT * FROM Func_OM_Account_GetChildren_Global(" + Account.AccountID + ", 0))"); } else { // Get children for site contact where = SqlHelperClass.AddWhereCondition(where, "AccountID IN (SELECT * FROM Func_OM_Account_GetChildren(" + Account.AccountID + ", 0))"); } gridElem.WhereCondition = where; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); btnSplit.Click += new EventHandler(btnSplit_Click); // Register JS scripts RegisterScripts(); }
protected void Page_Load(object sender, EventArgs e) { if (Contact != null) { // Current contact is global object if (Contact.ContactSiteID == 0) { mFilter.SiteID = SiteContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { mFilter.DisplaySiteSelector = true; mFilter.SiteID = UniSelector.US_GLOBAL_RECORD; } // Display 'site or global' selector in CMS desk for global objects else if (ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, false)) { mFilter.DisplayGlobalOrSiteSelector = true; } mFilter.HideMergedIntoGlobal = true; } else { mFilter.SiteID = Contact.ContactSiteID; } mFilter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "ContactID <> " + Contact.ContactID); gridElem.ZeroRowsText = GetString("om.contact.nocontacts"); btnMergeSelected.Click += btnMerge_Click; btnMergeAll.Click += btnMergeAll_Click; if (Request[Page.postEventArgumentID] == "saved") { ShowConfirmation(GetString("om.contact.merging")); // Clear selected items gridElem.ResetSelection(); } } else { StopProcessing = true; Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (this.Account != null) { // Current account is global object if (this.Account.AccountSiteID == 0) { filter.SiteID = CMSContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { filter.SiteID = UniSelector.US_GLOBAL_RECORD; filter.DisplaySiteSelector = true; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false)) { filter.DisplayGlobalOrSiteSelector = true; } filter.HideMergedIntoGlobal = true; } else { filter.SiteID = Account.AccountSiteID; } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(CMControlsHelper.UniGridOnExternalDataBound); gridElem.WhereCondition = filter.WhereCondition; gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "AccountID <> " + this.Account.AccountID); gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); btnMergeSelected.Click += new EventHandler(btnMergeSelected_Click); btnMergeAll.Click += new EventHandler(btnMergeAll_Click); if (QueryHelper.GetBoolean("saved", false)) { lblInfo.Visible = true; } } else { this.StopProcessing = true; this.Visible = false; } }
/// <summary> /// Reloads control. /// </summary> public void ReloadData() { string where = WhereCondition; CurrentUserInfo user = CMSContext.CurrentUser; bool allowSite = false; // Show all global configuration to authorized users .. bool allowGlobal = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // .. but just in SiteManager - fake it in CMSDesk so that even Global Admin sees user configuration // as Site Admins (depending on settings). allowGlobal &= (IsSiteManager || SettingsKeyProvider.GetBoolValue(SiteInfoProvider.GetSiteName(SiteID) + ".cmscmglobalconfiguration")); if (SiteID > 0) { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(SiteID, false); } else { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(CMSContext.CurrentSiteID, false); } // Current site roles and lgobal roles if ((SiteID > 0) && allowSite && allowGlobal) { where = SqlHelperClass.AddWhereCondition(where, "ContactRoleSiteID IS NULL OR ContactRoleSiteID = " + (SiteID == 0 ? CMSContext.CurrentSiteID : SiteID)); } // Current site roles only else if (allowSite && (SiteID > 0)) { where = SqlHelperClass.AddWhereCondition(where, "ContactRoleSiteID = " + SiteID); } // Global roles only else if (allowGlobal && (SiteID == 0)) { where = SqlHelperClass.AddWhereCondition(where, "ContactRoleSiteID IS NULL "); } // Don't display anything if (String.IsNullOrEmpty(where)) { where = "(1=0)"; } uniSelector.WhereCondition = where; uniSelector.Reload(true); }
/// <summary> /// Reloads control. /// </summary> public void ReloadData() { string where = WhereCondition; bool globalInCMSDesk = (SiteID == UniSelector.US_GLOBAL_RECORD) && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".cmscmglobalconfiguration"); bool settingEnabledForSite = SettingsKeyProvider.GetBoolValue(SiteInfoProvider.GetSiteName(SiteID) + ".cmscmglobalconfiguration"); bool userInSiteManager = (IsSiteManager == true); bool userAuthorized = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); bool allowGlobal = userAuthorized && (userInSiteManager || globalInCMSDesk || settingEnabledForSite); bool allowSite = ConfigurationHelper.AuthorizedReadConfiguration(SiteID > 0 ? SiteID : CMSContext.CurrentSiteID, false); uniselector.AllowAll = AllowAllItem; if (DisplayAll || DisplaySiteOrGlobal) { // Display all site and global statuses if (DisplayAll && allowSite && allowGlobal) { // No WHERE condition required } // Display current site and global statuses else if (DisplaySiteOrGlobal && allowSite && allowGlobal && (SiteID > 0)) { where = SqlHelperClass.AddWhereCondition(where, "ContactStatusSiteID IS NULL OR ContactStatusSiteID = " + (SiteID == 0 ? CMSContext.CurrentSiteID : SiteID)); } // Current site else if (allowSite && (SiteID > 0)) { where = SqlHelperClass.AddWhereCondition(where, "ContactStatusSiteID = " + SiteID); } // Display global statuses else if (allowGlobal) { where = SqlHelperClass.AddWhereCondition(where, "ContactStatusSiteID IS NULL "); } // Don't display anything if (String.IsNullOrEmpty(where) && !DisplayAll) { where = "(1=0)"; } } // Display either global or current site statuses else { // Current site if ((SiteID > 0) && allowSite) { where = SqlHelperClass.AddWhereCondition(where, "ContactStatusSiteID = " + SiteID); } // Display global statuses else if (((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == UniSelector.US_NONE_RECORD)) && allowGlobal) { where = SqlHelperClass.AddWhereCondition(where, "ContactStatusSiteID IS NULL "); } // Don't display anything if (String.IsNullOrEmpty(where)) { where = "(1=0)"; } } uniselector.WhereCondition = where; uniselector.Reload(true); }
protected void Page_Load(object sender, EventArgs e) { if (!QueryHelper.ValidateHash("hash") || Parameters == null) { StopProcessing = true; return; } CurrentMaster.Title.TitleText = GetString("om.contactstatus.select"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_ContactStatus/object.png"); Page.Title = CurrentMaster.Title.TitleText; siteId = ValidationHelper.GetInteger(Parameters["siteid"], 0); // Show all global configuration to authorized users .. bool allowGlobal = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // .. but just in SiteManager - fake it in CMSDesk so that even Global Admin sees user configuration // as Site Admins (depending on settings). bool isSiteManager = ValidationHelper.GetBoolean(Parameters["issitemanager"], false); allowGlobal &= (isSiteManager || SettingsKeyProvider.GetBoolValue(SiteInfoProvider.GetSiteName(siteId) + ".cmscmglobalconfiguration")); bool allowSite; if (siteId > 0) { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(siteId, false); } else { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(CMSContext.CurrentSiteID, false); } // Check read permission if ((siteId > 0) && !allowSite && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadConfiguration"); return; } else if ((siteId <= 0) && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadGlobalConfiguration"); return; } if (siteId > 0) { if (allowSite) { gridElem.WhereCondition = "ContactStatusSiteID = " + siteId; } // Check if global config is allowed for the site if (allowGlobal) { // Add contact statuses from global configuration gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "ContactStatusSiteID IS NULL", "OR"); } } else if ((siteId <= 0) && allowGlobal) { gridElem.WhereCondition = "ContactStatusSiteID IS NULL"; } gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.Pager.DefaultPageSize = 10; // Add 'Reset' button when 'none' status is allowed if (ValidationHelper.GetBoolean(Parameters["allownone"], false)) { btnReset.Visible = true; btnReset.Click += btn_Click; btnReset.CommandArgument = "0"; } }
protected void Page_Load(object sender, EventArgs e) { if (!QueryHelper.ValidateHash("hash") || Parameters == null) { StopProcessing = true; return; } PageTitle.TitleText = GetString("om.contactrole.select"); Page.Title = PageTitle.TitleText; // Check if the dialog was opened from mass actions isMassAction = Parameters.ContainsKey("ismassaction"); if (isMassAction) { siteId = ValidationHelper.GetInteger(Parameters["siteid"], 0); } else { int accountContactId = ValidationHelper.GetInteger(Parameters["accountcontactid"], 0); aci = AccountContactInfoProvider.GetAccountContactInfo(accountContactId); if (aci != null) { AccountInfo ai = AccountInfoProvider.GetAccountInfo(aci.AccountID); if (ai != null) { siteId = ai.AccountSiteID; } } } // Show all global configuration to authorized users .. bool allowGlobal = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // .. but just in SiteManager - fake it in CMSDesk so that even Global Admin sees user configuration // as Site Admins (depending on settings). bool isSiteManager = ValidationHelper.GetBoolean(Parameters["issitemanager"], false); allowGlobal &= (isSiteManager || SettingsKeyInfoProvider.GetBoolValue(SiteInfoProvider.GetSiteName(siteId) + ".cmscmglobalconfiguration")); bool allowSite; if (siteId > 0) { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(siteId, false); } else { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(SiteContext.CurrentSiteID, false); } // Check read permission if ((siteId > 0) && !allowSite && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadConfiguration"); return; } else if ((siteId == 0) && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadGlobalConfiguration"); return; } if (siteId > 0) { if (allowSite) { gridElem.WhereCondition = "ContactRoleSiteID = " + siteId; } // Check if global config is allowed for the site if (allowGlobal) { // Add contact roles from global configuration gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "ContactRoleSiteID IS NULL", "OR"); } } else if ((siteId == 0) && allowGlobal) { gridElem.WhereCondition = "ContactRoleSiteID IS NULL"; } gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.Pager.DefaultPageSize = 10; // Display 'Reset' button when 'none' role is allowed if (ValidationHelper.GetBoolean(Parameters["allownone"], false)) { btnReset.Visible = true; btnReset.Click += btn_Click; btnReset.CommandArgument = "0"; } }