/// <summary> /// Unigrid button clicked. /// </summary> protected void gridElem_OnAction(string actionName, object actionArgument) { // Perform 'remove' action if (actionName == "remove") { // Delete the object int accountId = ValidationHelper.GetInteger(actionArgument, 0); AccountInfo account = AccountInfoProvider.GetAccountInfo(accountId); if (account != null) { // User has no permission to modify site accounts if (((account.AccountSiteID > 0) && !modifySiteAccounts) || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false)) { CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyAccounts"); } // User has no permission to modify global accounts else if ((account.AccountSiteID == 0) && !modifyGlobalAccounts || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false)) { CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyGlobalAccounts"); } // User has permission else { // Get the relationship object ContactGroupMemberInfo mi = ContactGroupMemberInfoProvider.GetContactGroupMemberInfoByData(cgi.ContactGroupID, accountId, ContactGroupMemberTypeEnum.Account); if (mi != null) { ContactGroupMemberInfoProvider.DeleteContactGroupMemberInfo(mi); } } } } }
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(); }
protected void Page_Init(object sender, EventArgs e) { // Get edited object (contact group) if (UIContext.EditedObject != null) { cgi = (ContactGroupInfo)UIContext.EditedObject; siteID = cgi.ContactGroupSiteID; // Check permissions readSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false); modifySiteCG = ContactGroupHelper.AuthorizedModifyContactGroup(SiteContext.CurrentSiteID, false); if (siteID <= 0) { readGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalCG = ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); } // Setup unigrid gridElem.WhereCondition = GetWhereCondition(); gridElem.OnAction += gridElem_OnAction; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); gridElem.OnBeforeDataReload += gridElem_OnBeforeDataReload; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; modifyCombined = ((siteID > 0) && modifySiteCG) || ((siteID <= 0) && (modifyGlobalCG)); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { // Display mass actions if (modifyCombined) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).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 (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Initialize contact selector accountSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; accountSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; accountSelector.UniSelector.DialogButton.ResourceString = "om.account.addaccount"; } else { StopProcessing = true; } }
protected void Page_Load(object sender, EventArgs e) { // Initialize score filter FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = " HAVING SUM(Value)"; ffi.DataType = FormFieldDataTypeEnum.Integer; ucScoreFilter.FieldInfo = ffi; ucScoreFilter.DefaultOperator = ">="; ucScoreFilter.WhereConditionFormat = "{0} {2} {1}"; // Get modify permission of current user modifyPermission = ContactHelper.AuthorizedModifyContact(SiteId, false); // Set where condition gridElem.WhereCondition = "(ScoreId = @ScoreID) AND (Expiration IS NULL OR Expiration > @CurrentDate) GROUP BY OM_SelectScoreContact.ContactID, ContactFullNameJoined, ContactStatusID" + ucScoreFilter.GetWhereCondition(); // Add parameters QueryDataParameters parameters = new QueryDataParameters(); parameters.AddDateTime("@CurrentDate", DateTime.Now); parameters.AddId("@CurrentSiteID", SiteId); parameters.AddId("@ScoreID", QueryHelper.GetInteger("ScoreID", 0)); gridElem.QueryParameters = parameters; // Register OnExternalDataBound gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.OnBeforeFiltering += new OnBeforeFiltering(gridElem_OnBeforeFiltering); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteId, false)) && ContactGroupHelper.AuthorizedReadContactGroup(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("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + 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; } } // Register JS scripts RegisterScripts(); }
/// <summary> /// Loads permissions for current user. /// </summary> private void LoadPermissions() { permissions.ReadGroup = ContactGroupHelper.AuthorizedReadContactGroup(siteID, false); permissions.ReadGlobalGroup = ContactGroupHelper.AuthorizedReadContactGroup(UniSelector.US_GLOBAL_RECORD, false); permissions.ReadContact = ContactHelper.AuthorizedReadContact(siteID, false); permissions.ReadGlobalContact = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); permissions.ModifyGroup = ContactGroupHelper.AuthorizedModifyContactGroup(siteID, false); permissions.ModifyGlobalGroup = ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); permissions.ModifyContact = ContactHelper.AuthorizedModifyContact(siteID, false); permissions.ModifyGlobalContact = ContactHelper.AuthorizedModifyContact(UniSelector.US_GLOBAL_RECORD, false); }
protected void Page_Load(object sender, EventArgs e) { gridElem.IsLiveSite = IsLiveSite; // Get score ID from query string scoreId = QueryHelper.GetInteger("ScoreID", 0); // Initialize score filter FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "SUM(Value)"; ffi.DataType = FieldDataType.Integer; ucScoreFilter.FieldInfo = ffi; ucScoreFilter.DefaultOperator = ">="; ucScoreFilter.WhereConditionFormat = "{0} {2} {1}"; // Get modify permission of current user modifyPermission = ContactHelper.AuthorizedModifyContact(SiteId, false); gridElem.DataSource = GetContactsWithScore(); // Register OnExternalDataBound gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.OnBeforeFiltering += gridElem_OnBeforeFiltering; // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteId, false)) && ContactGroupHelper.AuthorizedReadContactGroup(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("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Register JS scripts RegisterScripts(); }
/// <summary> /// Unigrid button clicked. /// </summary> protected void gridElem_OnAction(string actionName, object actionArgument) { if (actionName == "delete") { int groupId = ValidationHelper.GetInteger(actionArgument, 0); ContactGroupInfo cgi = ContactGroupInfoProvider.GetContactGroupInfo(groupId); // Check permission if ((cgi != null) && ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, true)) { // Delete contact group ContactGroupInfoProvider.DeleteContactGroupInfo(groupId); } } }
/// <summary> /// Actions handler. /// </summary> protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e) { if (ContactGroupHelper.AuthorizedModifyContactGroup(this.SiteID, true)) { switch (e.CommandName.ToLower()) { case "save": // Save changes in the contact group EditForm.SaveData(null); break; case "evaluate": if (EditForm.EditedObject != null) { ContactGroupInfo cgi = (ContactGroupInfo)EditForm.EditedObject; if (cgi != null) { // Set 'Rebuilding' status cgi.ContactGroupStatus = ContactGroupStatusEnum.Rebuilding; ContactGroupInfoProvider.SetContactGroupInfo(cgi); // Evaluate the membership of the contact group ContactGroupEvaluator evaluator = new ContactGroupEvaluator(); evaluator.ContactGroupID = cgi.ContactGroupID; evaluator.Execute(null); EditForm.InfoLabel.Text = GetString("om.contactgroup.evaluationstarted"); EditForm.InfoLabel.Visible = true; // Get scheduled task and update last run time if (cgi.ContactGroupScheduledTaskID > 0) { task = TaskInfoProvider.GetTaskInfo(cgi.ContactGroupScheduledTaskID); if (task != null) { task.TaskLastRunTime = DateTime.Now; TaskInfoProvider.SetTaskInfo(task); } } // Display basic info about dynamic contact group InitInfoPanel(cgi, false); } } break; } } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Disable actions for unauthorized users if (!ContactGroupHelper.AuthorizedModifyContactGroup(listElem.SiteID, false)) { hdrActions.Enabled = false; } // Allow new button only for particular sites or (global) site else if ((listElem.SiteID < 0) && (listElem.SiteID != UniSelector.US_GLOBAL_RECORD)) { hdrActions.Enabled = false; lblWarnNew.Visible = true; } }
/// <summary> /// Unigrid button clicked. /// </summary> protected void gridElem_OnAction(string actionName, object actionArgument) { // Perform 'remove' action if (actionName == "remove") { // Delete the object int contactId = ValidationHelper.GetInteger(actionArgument, 0); ContactInfo contact = ContactInfoProvider.GetContactInfo(contactId); if (contact != null) { // User has no permission to modify site contacts if (((contact.ContactSiteID > 0) && !modifySiteContacts) || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false)) { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyContacts"); } // User has no permission to modify global contacts else if ((contact.ContactSiteID == 0) && !modifyGlobalContacts || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false)) { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyGlobalContacts"); } // User has permission else { // Get the relationship object ContactGroupMemberInfo mi = ContactGroupMemberInfoProvider.GetContactGroupMemberInfoByData(cgi.ContactGroupID, contactId, ContactGroupMemberTypeEnum.Contact); if (mi != null) { ContactGroupMemberInfoProvider.DeleteContactGroupMemberInfo(mi); } } } // Check modify permission if ((siteID > 0) && !(CheckPermissions("cms.contactmanagement", "ModifyContactGroups"))) { return; } else if ((siteID == 0) && !(CheckPermissions("cms.contactmanagement", "ModifyGlobalContactGroups"))) { return; } } }
/// <summary> /// Performs contact group recalculation. /// Fires, when recalculate button is clicked. /// </summary> private void RecalculateContactGroup(object sender, EventArgs e) { if (ContactGroup == null || ContactGroup.ContactGroupStatus == ContactGroupStatusEnum.Rebuilding) { return; } if (ContactGroupHelper.AuthorizedModifyContactGroup(ContactGroup.ContactGroupSiteID, true)) { RebuildHeaderAction.Text = ResHelper.GetString("om.contactgroup.rebuilding"); RebuildHeaderAction.Enabled = false; StatusLabel.Visible = false; // Set status that the contact group is being rebuilt ContactGroup.ContactGroupStatus = ContactGroupStatusEnum.Rebuilding; ContactGroupInfoProvider.SetContactGroupInfo(ContactGroup); // Evaluate the membership of the contact group ContactGroupEvaluator evaluator = new ContactGroupEvaluator(); evaluator.ContactGroup = ContactGroup; Task.Factory.StartNew(CMSThread.Wrap(evaluator.Run), TaskCreationOptions.LongRunning); } }
/// <summary> /// Loads contact groups of merged contacts into checkboxlist. /// </summary> private void LoadContactGroups() { if (!RequestHelper.IsPostBack()) { StringBuilder idList = new StringBuilder("("); foreach (DataRow dr in mergedAccounts.Tables[0].Rows) { idList.Append(dr["AccountID"] + ","); } // Remove last comma idList.Remove(idList.Length - 1, 1); idList.Append(")"); // Remove site contact groups string addWhere = null; if (parentAccount.AccountSiteID == 0) { addWhere = " AND ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"; } string where = "ContactGroupMemberType = 1 AND ContactGroupMemberRelatedID IN " + idList.ToString() + " AND ContactGroupMemberContactGroupID NOT IN (SELECT ContactGroupMemberContactGroupID FROM OM_ContactGroupMember WHERE ContactGroupMemberRelatedID = " + parentAccount.AccountID + " AND ContactGroupMemberType = 1)" + addWhere; // Limit selection of contact groups according to current user's persmissions if (!CMSContext.CurrentUser.UserSiteManagerAdmin) { bool readModifySite = ContactGroupHelper.AuthorizedReadContactGroup(parentAccount.AccountSiteID, false) && ContactGroupHelper.AuthorizedModifyContactGroup(parentAccount.AccountSiteID, false); bool readGlobal = ContactGroupHelper.AuthorizedReadContactGroup(UniSelector.US_GLOBAL_RECORD, false) && ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); if (!readModifySite && !readGlobal) { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } else if (readModifySite && !readGlobal) { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID = " + CMSContext.CurrentSiteID + ")"); } else if (!readModifySite && readGlobal) { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"); } else { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL OR ContactGroupSiteID = " + CMSContext.CurrentSiteID + ")"); } } // Get contact group relations DataSet result = ContactGroupMemberInfoProvider.GetRelationships(where, null, -1, "DISTINCT ContactGroupMemberContactGroupID"); if (!DataHelper.DataSourceIsEmpty(result)) { ListItem contactGroup; ContactGroupInfo cg; foreach (DataRow dr in result.Tables[0].Rows) { contactGroup = new ListItem(); contactGroup.Value = ValidationHelper.GetString(dr["ContactGroupMemberContactGroupID"], "0"); contactGroup.Selected = true; // Fill in checkbox list cg = ContactGroupInfoProvider.GetContactGroupInfo(ValidationHelper.GetInteger(dr["ContactGroupMemberContactGroupID"], 0)); if (cg != null) { contactGroup.Text = HTMLHelper.HTMLEncode(cg.ContactGroupDisplayName); chkContactGroups.Items.Add(contactGroup); } } } else { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } } }
protected void Page_Load(object sender, EventArgs e) { filter.SiteID = SiteID; filter.DisableGeneratingSiteClause = true; modifyPermission = AccountHelper.AuthorizedModifyAccount(SiteID, false); if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { modifyGlobal = AccountHelper.AuthorizedModifyAccount(UniSelector.US_GLOBAL_RECORD, false); modifySite = AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false); } // Edit action URL string url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditAccount", false); url = URLHelper.AddParameterToUrl(url, "objectid", "{0}"); url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString()); if (ContactHelper.IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); } // Setup UniGrid gridElem.OnBeforeDataReload += gridElem_OnBeforeDataReload; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, WhereCondition); gridElem.EditActionUrl = url; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); gridElem.FilteredZeroRowsText = GetString("om.account.noaccountsfound.filtered"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteID, false)) && ContactGroupHelper.AuthorizedReadContactGroup(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())); 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 (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for UniGrid if mass action is performed gridElem.DelayedReload = true; } } if (Request.Params[Page.postEventArgumentID] == ACCOUNTS_MERGED) { ShowConfirmation(GetString("om.account.merginglist")); } // Register JS scripts RegisterScripts(); }
protected void Page_Load(object sender, EventArgs e) { // Get edited object (contact group) if (CMSContext.EditedObject != null) { currentUser = CMSContext.CurrentUser; cgi = (ContactGroupInfo)CMSContext.EditedObject; siteID = cgi.ContactGroupSiteID; // Check permissions readSiteContacts = ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, false); modifySiteContacts = ContactHelper.AuthorizedModifyContact(CMSContext.CurrentSiteID, false); modifySiteCG = ContactGroupHelper.AuthorizedModifyContactGroup(CMSContext.CurrentSiteID, false); if (siteID <= 0) { readGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalContacts = ContactHelper.AuthorizedModifyContact(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalCG = ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); } // Setup unigrid gridElem.WhereCondition = GetWhereCondition(); gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.ZeroRowsText = GetString("om.contact.nocontacts"); gridElem.OnBeforeDataReload += new OnBeforeDataReload(gridElem_OnBeforeDataReload); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); modifyCombined = // Site contact group -> only site Contacts can be added ((siteID > 0) && (modifySiteContacts || modifySiteCG)) // Global contact group -> both site and global Contacts can be added || ((siteID <= 0) && ( // User can display only global Contacts (readGlobalContacts && !readSiteContacts && (modifyGlobalContacts || modifyGlobalCG)) || // User can display only site Contacts (readSiteContacts && !readGlobalContacts && (modifySiteContacts || modifySiteCG)) || // User can display both site and global Contacts (readSiteContacts && readGlobalContacts && (modifySiteCG || modifySiteContacts) && (modifyGlobalCG || modifyGlobalContacts)) )); if (!string.IsNullOrEmpty(cgi.ContactGroupDynamicCondition)) { // Set specific confirmation to remove grid action CMS.UIControls.UniGridConfig.Action removeAction = (CMS.UIControls.UniGridConfig.Action)gridElem.GridActions.Actions[1]; removeAction.Confirmation = "$om.contactgroupmember.confirmremove$"; } // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { // Display mass actions if (modifyCombined) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + 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; } } // Initialize contact selector contactSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/OM_Contact/add.png"); contactSelector.ImageDialog.CssClass = "NewItemImage"; contactSelector.UniSelector.OnItemsSelected += new EventHandler(UniSelector_OnItemsSelected); contactSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; // Register JS scripts RegisterScripts(); } else { this.StopProcessing = true; } }
protected void Page_Load(object sender, EventArgs e) { // Get edited object (contact group) if (UIContext.EditedObject != null) { cgi = (ContactGroupInfo)UIContext.EditedObject; contactGroupSiteID = cgi.ContactGroupSiteID; // Check permissions readSiteContacts = ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false); modifySiteCG = ContactGroupHelper.AuthorizedModifyContactGroup(SiteContext.CurrentSiteID, false); if (contactGroupSiteID <= 0) { readGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalCG = ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); } // Setup unigrid gridElem.WhereCondition = GetWhereCondition(); gridElem.OnAction += gridElem_OnAction; gridElem.ZeroRowsText = GetString("om.contact.nocontacts"); gridElem.OnBeforeDataReload += gridElem_OnBeforeDataReload; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; modifyCombined = ((contactGroupSiteID > 0) && modifySiteCG) || ((contactGroupSiteID <= 0) && modifyGlobalCG); if (!string.IsNullOrEmpty(cgi.ContactGroupDynamicCondition)) { // Set specific confirmation to remove grid action var removeAction = (CMS.UIControls.UniGridConfig.Action)gridElem.GridActions.Actions[1]; removeAction.Confirmation = "$om.contactgroupmember.confirmremove$"; } // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString())); // Display mass actions if (modifyCombined) { drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); } if (ContactHelper.AuthorizedModifyContact(contactGroupSiteID, false)) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.ONLINEMARKETING, "StartProcess")) { drpAction.Items.Add(new ListItem(GetString("ma.automationprocess.select"), Convert.ToInt32(Action.StartNewProcess).ToString())); } } else { if (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Initialize contact selector contactSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; contactSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; // Register JS scripts RegisterScripts(); } else { StopProcessing = true; } }
/// <summary> /// Loads contact groups of merged contacts into checkboxlist. /// </summary> private void LoadContactGroups() { if (!RequestHelper.IsPostBack()) { StringBuilder idList = new StringBuilder("("); foreach (DataRow dr in mMergedContacts.Tables[0].Rows) { idList.Append(dr["ContactID"] + ","); } // Remove last comma idList.Remove(idList.Length - 1, 1); idList.Append(")"); // Remove site contact groups for global contact string addWhere = null; if (mParentContact.ContactSiteID == 0) { addWhere = " AND ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"; } string where = " ContactGroupMemberType = 0 AND ContactGroupMemberRelatedID IN " + idList + " AND ContactGroupMemberContactGroupID NOT IN (SELECT ContactGroupMemberContactGroupID FROM OM_ContactGroupMember WHERE ContactGroupMemberRelatedID = " + mParentContact.ContactID + " AND ContactGroupMemberType = 0)" + addWhere; // Show only manually added contact groups where = SqlHelper.AddWhereCondition(where, "ContactGroupMemberFromManual = 1"); // Limit selection of contact groups according to current user's permissions if (!MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { bool readModifySite = ContactGroupHelper.AuthorizedReadContactGroup(mParentContact.ContactSiteID, false) && ContactGroupHelper.AuthorizedModifyContactGroup(mParentContact.ContactSiteID, false); bool readModifyGlobal = ContactGroupHelper.AuthorizedReadContactGroup(UniSelector.US_GLOBAL_RECORD, false) && ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); if (!readModifySite && !readModifyGlobal) { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } else if (readModifySite && !readModifyGlobal) { where = SqlHelper.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID = " + SiteContext.CurrentSiteID + ")"); } else if (!readModifySite && readModifyGlobal) { where = SqlHelper.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"); } else { where = SqlHelper.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL OR ContactGroupSiteID = " + SiteContext.CurrentSiteID + ")"); } } // Get contact group relations DataSet result = ContactGroupMemberInfoProvider.GetRelationships().Where(where).Column("ContactGroupMemberContactGroupID").Distinct(); if (!DataHelper.DataSourceIsEmpty(result)) { ListItem contactGroup; ContactGroupInfo cg; foreach (DataRow dr in result.Tables[0].Rows) { contactGroup = new ListItem(); contactGroup.Value = ValidationHelper.GetString(dr["ContactGroupMemberContactGroupID"], "0"); contactGroup.Selected = true; cg = ContactGroupInfoProvider.GetContactGroupInfo(ValidationHelper.GetInteger(dr["ContactGroupMemberContactGroupID"], 0)); if (cg != null) { contactGroup.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(cg.ContactGroupDisplayName)); chkContactGroups.Items.Add(contactGroup); } } } else { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } } }