private void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        switch (e.Tab.TabName.ToLowerCSafe())
        {
        case "account.customfields":
            // Check if contact has any custom fields
            var formInfo = FormHelper.GetFormInfo("OM.Account", false);
            if (!formInfo.GetFields(true, false, false).Any())
            {
                e.Tab = null;
            }
            break;

        case "account.contacts":
            // Display contacts tab only if user is authorized to read contacts
            if (!ContactHelper.AuthorizedReadContact(Account.AccountSiteID, false) && !AccountHelper.AuthorizedReadAccount(Account.AccountSiteID, false))
            {
                e.Tab = null;
            }
            break;

        case "account.merge":
        case "account.subsidiaries":
            if (Account.AccountMergedWithAccountID != 0)
            {
                e.Tab = null;
            }
            break;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check read permission
        ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, true);

        string siteName = CMSContext.CurrentSiteName;

        // Get bounce limit
        mBounceLimit = NewsletterHelper.BouncedEmailsLimit(siteName);
        // Get info if bounced e-mail tracking is available
        mBounceInfoAvailable = NewsletterHelper.MonitorBouncedEmails(siteName);

        // Check if parent object exist
        SubscriberInfo sb = SubscriberInfoProvider.GetSubscriberInfo(QueryHelper.GetInteger("subscriberid", 0));

        EditedObject = sb;

        // Initialize unigrid
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += uniGrid_OnExternalDataBound;
        UniGrid.WhereCondition       = "ContactID IN (SELECT ContactGroupMemberRelatedID FROM OM_ContactGroupMember WHERE ContactGroupMemberContactGroupID = "
                                       + QueryHelper.GetInteger("groupid", 0) + " AND ContactGroupMemberType = 0) AND ContactSiteID = " + CMSContext.CurrentSiteID
                                       + " AND ContactMergedWithContactID IS NULL";
        UniGrid.ShowObjectMenu = false;
    }
Esempio n. 3
0
    /// <summary>
    /// Sets visibility of buttons that are connected to merged contact - split button and link to his parent.
    /// </summary>
    private void SetButtonsVisibility()
    {
        // Find out if current contact is merged into another site or global contact
        bool mergedIntoSite   = ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0) != 0;
        bool mergedIntoGlobal = ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0) != 0 &&
                                ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false);
        bool globalContactsVisible = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalContacts") || CurrentUser.IsGlobalAdministrator;

        if (mergedIntoSite || (mergedIntoGlobal && globalContactsVisible))
        {
            if (mergedIntoSite)
            {
                parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0));
                headingMergedInto.ResourceString = "om.contact.mergedintosite";
            }
            else
            {
                parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0));
                headingMergedInto.ResourceString = "om.contact.mergedintoglobal";
            }

            lblMergedIntoContactName.Text = HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(parentContact));

            string contactDetailDialogURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", parentContact.ContactID);
            string openDialogScript       = ScriptHelper.GetModalDialogScript(contactDetailDialogURL, "ContactDetail");

            btnMergedContact.IconCssClass  = "icon-edit";
            btnMergedContact.OnClientClick = openDialogScript;
            btnMergedContact.ToolTip       = GetString("om.contact.viewdetail");
        }
        else
        {
            panelMergedContactDetails.Visible = btnSplit.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check read permission
        ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, true);

        string siteName = CMSContext.CurrentSiteName;

        // Get bounce limit
        mBounceLimit = SettingsKeyProvider.GetIntValue(siteName + ".CMSBouncedEmailsLimit");
        // Get info if bounced e-mail tracking is available
        mBounceInfoAvailable = SettingsKeyProvider.GetBoolValue(siteName + ".CMSMonitorBouncedEmails") &&
                               NewsletterProvider.OnlineMarketingEnabled(siteName);

        CurrentMaster.HeaderActions.HelpTopicName = "subscribercontacts_tab";
        CurrentMaster.HeaderActions.HelpName      = "helpTopic";

        // Check if parent object exist
        Subscriber sb = SubscriberProvider.GetSubscriber(QueryHelper.GetInteger("subscriberid", 0));

        EditedObject = sb;

        // Initialize unigrid
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += uniGrid_OnExternalDataBound;
        UniGrid.WhereCondition       = "ContactID IN (SELECT ContactGroupMemberRelatedID FROM OM_ContactGroupMember WHERE ContactGroupMemberContactGroupID = "
                                       + QueryHelper.GetInteger("groupid", 0) + " AND ContactGroupMemberType = 0) AND ContactSiteID = " + CMSContext.CurrentSiteID
                                       + " AND ContactMergedWithContactID IS NULL";
        UniGrid.ShowObjectMenu = false;
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        chkEmail.Enabled      = !String.IsNullOrEmpty(ContactHelper.GetEmailDomain(this.CurrentContact.ContactEmail));
        chkAddress.Enabled    = !String.IsNullOrEmpty(this.CurrentContact.ContactAddress1) || !String.IsNullOrEmpty(this.CurrentContact.ContactAddress2) || !String.IsNullOrEmpty(this.CurrentContact.ContactCity) || !String.IsNullOrEmpty(this.CurrentContact.ContactZIP);
        chkBirthDay.Enabled   = (this.CurrentContact.ContactBirthday != DateTimeHelper.ZERO_TIME);
        chkPhone.Enabled      = !String.IsNullOrEmpty(this.CurrentContact.ContactBusinessPhone) || !String.IsNullOrEmpty(this.CurrentContact.ContactHomePhone) || !String.IsNullOrEmpty(this.CurrentContact.ContactMobilePhone);
        chkMembership.Visible = chkIPaddress.Visible = ci.ContactSiteID != 0;

        // Current contact is global object
        if (ci.ContactSiteID == 0)
        {
            plcSite.Visible = true;
            // Display site selector in site manager
            if (ContactHelper.IsSiteManager)
            {
                siteOrGlobalSelector.Visible = false;
            }
            // Display 'site or global' selector in CMS desk for global objects
            else if (ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(CMSContext.CurrentSiteID, false))
            {
                siteSelector.Visible = false;
            }
            else
            {
                plcSite.Visible = false;
            }
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Ensure, that it is going to be rendered
        pnlRole.Visible = true;

        ScriptHelper.RegisterWOpenerScript(Page);
        ScriptHelper.RegisterJQuery(Page);

        // Try to get parameters
        string    identifier = QueryHelper.GetString("params", null);
        Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier);

        // Validate hash
        if ((QueryHelper.ValidateHash("hash", "selectedvalue")) && (parameters != null))
        {
            int siteID = ValidationHelper.GetInteger(parameters["SiteID"], -1);
            if (siteID != -1)
            {
                // Check permissions
                ContactHelper.AuthorizedReadContact(siteID, true);
                if (AccountHelper.AuthorizedModifyAccount(siteID, false) || ContactHelper.AuthorizedModifyContact(siteID, false))
                {
                    contactRoleSelector.SiteID     = siteID;
                    contactRoleSelector.IsLiveSite = false;
                    contactRoleSelector.UniSelector.DialogWindowName = "SelectContactRole";
                    contactRoleSelector.IsSiteManager = ValidationHelper.GetBoolean(parameters["IsSiteManager"], false);

                    selectionDialog.LocalizeItems = QueryHelper.GetBoolean("localize", true);

                    // Load resource prefix
                    string resourcePrefix = ValidationHelper.GetString(parameters["ResourcePrefix"], "general");

                    // Set the page title
                    string titleText = GetString(resourcePrefix + ".selectitem|general.selectitem");

                    // Validity group text
                    lblAddAccounts.ResourceString = resourcePrefix + ".contactsrole";
                    pnlRoleHeading.Visible        = true;

                    PageTitle.TitleText = titleText;
                    Page.Title          = titleText;
                }
                // No permission modify
                else
                {
                    RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyAccount");
                }
            }
            else
            {
                // Redirect to error page
                URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("dialogs.badhashtitle") + "&text=" + ResHelper.GetString("dialogs.badhashtext")));
            }
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
    }
Esempio n. 7
0
    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();
    }
Esempio n. 8
0
    /// <summary>
    /// Check read permissions.
    /// </summary>
    protected override void CheckReadPermission()
    {
        // Check read permission for score or contact
        int             siteID = ContactHelper.ObjectSiteID(EditedObject);
        CurrentUserInfo user   = CMSContext.CurrentUser;

        if (!ContactHelper.AuthorizedReadContact(siteID, false) && !user.IsAuthorizedPerResource("CMS.Scoring", "Read"))
        {
            RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ReadContacts");
        }
    }
 /// <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);
 }
Esempio n. 10
0
    /// <summary>
    /// Check read permissions.
    /// </summary>
    protected override void CheckReadPermission()
    {
        // Check read permission for score or contact
        int siteID = ContactHelper.ObjectSiteID(EditedObject);
        var user   = MembershipContext.AuthenticatedUser;

        if (!ContactHelper.AuthorizedReadContact(siteID, false) && !user.IsAuthorizedPerResource("CMS.Scoring", "Read"))
        {
            RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadContacts");
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.PanelContent.CssClass = String.Empty;

        int siteID = ContactHelper.ObjectSiteID(EditedObject);

        // Check read permission
        if (!AccountHelper.AuthorizedReadAccount(siteID, false) && !ContactHelper.AuthorizedReadContact(siteID, false))
        {
            RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ReadContacts");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.PanelContent.CssClass = "";

        int siteID = AccountHelper.ObjectSiteID(EditedObject);

        // Check read permission
        if (!AccountHelper.AuthorizedReadAccount(siteID, false) && !ContactHelper.AuthorizedReadContact(siteID, false))
        {
            RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ReadAccounts");
        }
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash") || Parameters == null)
        {
            StopProcessing = true;
            return;
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");

        var siteId = ValidationHelper.GetInteger(Parameters["siteid"], 0);
        var excludedContactIDsCondition = ValidationHelper.GetString(Parameters["where"], null);

        // Check read permission
        if (ContactHelper.AuthorizedReadContact(siteId, true))
        {
            if ((siteId == UniSelector.US_GLOBAL_RECORD) || (siteId == UniSelector.US_ALL_RECORDS))
            {
                PageTitle.TitleText = GetString("om.contact.selectglobal");
            }
            else
            {
                PageTitle.TitleText = GetString("om.contact.selectsite");
            }
            Page.Title = PageTitle.TitleText;

            // Load header actions
            InitHeaderActions();

            if (siteId > 0)
            {
                gridElem.WhereCondition = "(ContactMergedWithContactID IS NULL AND ContactSiteID = " + siteId + ")";
            }
            else
            {
                gridElem.WhereCondition = "(ContactGlobalContactID IS NULL AND ContactSiteID IS NULL)";
            }

            if (!String.IsNullOrEmpty(excludedContactIDsCondition))
            {
                var excludedContactsCondition = "ContactID NOT IN (SELECT ContactID FROM OM_Contact WHERE " + excludedContactIDsCondition + ")";
                gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, excludedContactsCondition);
            }

            gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
            gridElem.ShowActionsMenu      = false;
            if (!RequestHelper.IsPostBack())
            {
                gridElem.Pager.DefaultPageSize = 10;
            }
        }
    }
Esempio n. 14
0
    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;
        }
    }
Esempio n. 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI elements
        CheckUIElementAccessHierarchical(ModuleName.ONLINEMARKETING, "account.contacts");

        CurrentMaster.PanelContent.CssClass = "";

        int siteID = AccountHelper.ObjectSiteID(EditedObject);

        // Check read permission
        if (!AccountHelper.AuthorizedReadAccount(siteID, false) && !ContactHelper.AuthorizedReadContact(siteID, false))
        {
            RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadAccounts");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash") || Parameters == null)
        {
            StopProcessing = true;
            return;
        }

        siteId = ValidationHelper.GetInteger(Parameters["siteid"], 0);
        where  = ValidationHelper.GetString(Parameters["where"], null);

        // Check read permission
        if (ContactHelper.AuthorizedReadContact(siteId, true))
        {
            if (siteId == UniSelector.US_GLOBAL_RECORD)
            {
                CurrentMaster.Title.TitleText = GetString("om.contact.selectglobal");
            }
            else
            {
                CurrentMaster.Title.TitleText = GetString("om.contact.selectsite");
            }

            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Contact/object.png");
            Page.Title = CurrentMaster.Title.TitleText;

            imgNew.ImageUrl        = GetImageUrl("Objects/OM_Contact/add.png");
            btnNew.Click          += new EventHandler(btn_Click);
            btnNew.CommandArgument = null;

            if (siteId > 0)
            {
                gridElem.WhereCondition = "(ContactMergedWithContactID IS NULL AND ContactSiteID = " + siteId + ")";
            }
            else
            {
                gridElem.WhereCondition = "(ContactGlobalContactID IS NULL AND ContactSiteID IS NULL)";
            }
            gridElem.WhereCondition       = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "ContactID NOT IN (SELECT ContactID FROM OM_Contact WHERE " + where + ")");
            gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
            gridElem.ShowActionsMenu      = false;
            if (!RequestHelper.IsPostBack())
            {
                gridElem.Pager.DefaultPageSize = 10;
            }
        }
    }
Esempio n. 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(CMControlsHelper.UniGridOnExternalDataBound);
        if (this.Contact != null)
        {
            // Current contact is global object
            if (this.Contact.ContactSiteID == 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 (ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(CMSContext.CurrentSiteID, false))
                {
                    filter.DisplayGlobalOrSiteSelector = true;
                }
                filter.HideMergedIntoGlobal = true;
            }
            else
            {
                filter.SiteID = Contact.ContactSiteID;
            }
            filter.ShowGlobalStatuses =
                ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) &&
                (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager);
            gridElem.WhereCondition = filter.WhereCondition;
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "ContactID <> " + this.Contact.ContactID);
            gridElem.ZeroRowsText   = GetString("om.contact.nocontacts");
            btnMergeSelected.Click += new EventHandler(btnMerge_Click);
            btnMergeAll.Click      += new EventHandler(btnMergeAll_Click);

            if (QueryHelper.GetBoolean("saved", false))
            {
                lblInfo.Visible = true;
            }
        }
        else
        {
            this.StopProcessing = true;
            this.Visible        = false;
        }
    }
Esempio n. 18
0
    /// <summary>
    /// Items changed event handler.
    /// </summary>
    void UniSelector_OnItemsSelected(object sender, EventArgs e)
    {
        if (AccountHelper.AuthorizedModifyAccount(this.SiteID, false) || ContactHelper.AuthorizedReadContact(this.SiteID, false))
        {
            // Get new items from selector
            string newValues = ValidationHelper.GetString(contactSelector.Value, null);

            if (!String.IsNullOrEmpty(newValues))
            {
                string[] newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                if (newItems != null)
                {
                    int previousStop = 0;
                    string where = FetchNextContacts(ref previousStop, newItems, 1000);

                    while (!String.IsNullOrEmpty(where))
                    {
                        AccountContactInfoProvider.SetContactsIntoAccount(ai.AccountID, "ContactID IN (" + where + ")", ValidationHelper.GetInteger(hdnRoleID.Value, 0));

                        where = FetchNextContacts(ref previousStop, newItems, 1000);
                    }
                }

                gridElem.ReloadData();
                pnlUpdate.Update();
                contactSelector.Value = null;
            }
        }
        // No permission modify
        else
        {
            if (this.SiteID > 0)
            {
                CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyAccounts");
            }
            else
            {
                CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyGlobalAccounts");
            }
        }
    }
Esempio n. 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        chkEmail.Enabled      = !String.IsNullOrEmpty(ContactHelper.GetEmailDomain(CurrentContact.ContactEmail));
        chkAddress.Enabled    = !String.IsNullOrEmpty(CurrentContact.ContactAddress1) || !String.IsNullOrEmpty(CurrentContact.ContactAddress2) || !String.IsNullOrEmpty(CurrentContact.ContactCity) || !String.IsNullOrEmpty(CurrentContact.ContactZIP);
        chkBirthDay.Enabled   = (CurrentContact.ContactBirthday != DateTimeHelper.ZERO_TIME);
        chkPhone.Enabled      = !String.IsNullOrEmpty(CurrentContact.ContactBusinessPhone) || !String.IsNullOrEmpty(CurrentContact.ContactHomePhone) || !String.IsNullOrEmpty(CurrentContact.ContactMobilePhone);
        chkMembership.Visible = chkIPaddress.Visible = ci.ContactSiteID != 0;

        if (chkMembership.Visible)
        {
            var relationships = ContactMembershipInfoProvider.GetRelationships()
                                .WhereEquals("ActiveContactID", CurrentContact.ContactID);
            chkMembership.Enabled = relationships.Any();

            var ips = IPInfoProvider.GetIps()
                      .WhereEquals("IPActiveContactID", CurrentContact.ContactID);
            chkIPaddress.Enabled = ips.Any();
        }

        // Current contact is global object
        if (ci.ContactSiteID == 0)
        {
            plcSite.Visible = true;
            // Display site selector in site manager
            if (ContactHelper.IsSiteManager)
            {
                siteOrGlobalSelector.Visible = false;
            }
            // Display 'site or global' selector in CMS desk for global objects
            else if (ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, false))
            {
                siteSelector.Visible = false;
            }
            else
            {
                plcSite.Visible = false;
            }
        }
    }
    /// <summary>
    /// Reloads the data in the selector.
    /// </summary>
    public void ReloadData()
    {
        string where = null;
        currentUser  = CMSContext.CurrentUser;

        if (string.IsNullOrEmpty(uniSelector.AdditionalSearchColumns))
        {
            uniSelector.FilterControl        = "~/CMSModules/ContactManagement/FormControls/SearchContactFullName.ascx";
            uniSelector.UseDefaultNameFilter = false;
        }

        bool authorizedSiteContacts   = false;
        bool authorizedGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false);

        if (SiteID > 0)
        {
            authorizedSiteContacts = ContactHelper.AuthorizedReadContact(SiteID, false);
        }
        else
        {
            authorizedSiteContacts = ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, false);
        }

        // Filter site objects
        if (SiteID > 0)
        {
            if (authorizedSiteContacts)
            {
                where = "(ContactSiteID = " + SiteID + " AND ContactMergedWithContactID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Filter only global objects
        else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0))
        {
            if (authorizedGlobalContacts)
            {
                where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display current site and global contacts
        else if (SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD)
        {
            if (authorizedSiteContacts && authorizedGlobalContacts)
            {
                where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID = " + CMSContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)";
                uniSelector.AddGlobalObjectSuffix = true;
            }
            else if (authorizedGlobalContacts)
            {
                where = "(ContactSiteID IS NULL AND ContactMergedWithContactID IS NULL)";
            }
            else if (authorizedSiteContacts)
            {
                where = "(ContactSiteID = " + CMSContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display all objects
        else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.UserSiteManagerAdmin)
        {
            where = "((ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID > 0 AND ContactMergedWithContactID IS NULL))";
            uniSelector.AddGlobalObjectSuffix = true;
        }
        // Not enough permissions
        else
        {
            where = "(1=0)";
        }

        where = SqlHelperClass.AddWhereCondition(where, WhereCondition);

        uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(uniSelector.WhereCondition, where);
        uniSelector.Reload(true);
    }
Esempio n. 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject != null)
        {
            // Register script for unimenu button selection
            AddMenuButtonSelectScript(this, "Accounts", null, "menu");

            // Get account info object
            AccountInfo ai     = (AccountInfo)EditedObject;
            string      append = null;

            // Check permission
            AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, true);

            // Check if running under site manager (and distribute "site manager" flag to other tabs)
            string siteManagerParam = string.Empty;
            if (IsSiteManager)
            {
                siteManagerParam = "&issitemanager=1";
            }

            // Set default help topic
            SetHelp("onlinemarketing_account_general", "helpTopic");

            // register scripts in modal dialog
            if (isDialogMode)
            {
                RegisterModalPageScripts();
            }

            // Append '(merged)' behind account name in breadcrumbs
            if (ai.AccountMergedWithAccountID != 0)
            {
                append = " " + GetString("om.account.mergedsuffix");
            }
            // Append '(global)'
            else if (ai.AccountSiteID == 0)
            {
                append = " " + GetString("om.account.globalsuffix");
            }

            // Modify header appearance in modal dialog (display title instead of breadcrumbs)
            if (QueryHelper.GetBoolean("dialogmode", false))
            {
                CurrentMaster.Title.TitleText  = GetString("om.account.edit") + " - " + HTMLHelper.HTMLEncode(ai.AccountName) + append;
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Account/object.png");
            }
            else
            {
                // Get url for breadcrumbs
                string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/Account/List.aspx");
                url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString());
                if (IsSiteManager)
                {
                    url = URLHelper.AddParameterToUrl(url, "issitemanager", "1");
                }

                CurrentPage.InitBreadcrumbs(2);
                CurrentPage.SetBreadcrumb(0, GetString("om.account.list"), url, "_parent", null);
                CurrentPage.SetBreadcrumb(1, HTMLHelper.HTMLEncode(CMSContext.ResolveMacros("{%EditedObject.DisplayName%}")) + append, null, null, null);
            }

            // Check if account has any custom fields
            int i = 0;

            FormInfo formInfo = FormHelper.GetFormInfo(ai.ClassName, false);
            if (formInfo.GetFormElements(true, false, true).Any())
            {
                i = 1;
            }

            // Initialize tabs
            InitTabs("content");
            SetTab(0, GetString("general.general"), "Tab_General.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_general');");
            if (i > 0)
            {
                // Add tab for custom fields
                SetTab(1, GetString("general.customfields"), "Tab_CustomFields.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_customfields');");
            }

            // Display contacts tab only if user is authorized to read contacts
            if (ContactHelper.AuthorizedReadContact(ai.AccountSiteID, false) || AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, false))
            {
                SetTab(1 + i, GetString("om.contact.list"), "Tab_Contacts.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_contacts');");
            }

            // Hide last 2 tabs if the account is merged
            if (ai.AccountMergedWithAccountID == 0)
            {
                SetTab(2 + i, GetString("om.account.subsidiaries"), "Tab_Subsidiaries.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_subsidiaries');");
                SetTab(3 + i, GetString("om.account.merge"), "Tab_Merge.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_merge');");
            }

            // Data.com
            SetTab(4 + i, "Data.com", "Tab_DataCom.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_datacom');");
        }
    }
Esempio n. 22
0
    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)
    {
        // Ensure, that it is going to be rendered
        pnlRole.Visible = true;

        ScriptHelper.RegisterWOpenerScript(Page);
        ScriptHelper.RegisterJQuery(Page);

        // Try to get parameters
        string    identifier = QueryHelper.GetString("params", null);
        Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier);

        // Validate hash
        if ((QueryHelper.ValidateHash("hash", "selectedvalue")) && (parameters != null))
        {
            int siteID = ValidationHelper.GetInteger(parameters["SiteID"], -1);
            if (siteID != -1)
            {
                // Check permissions
                ContactHelper.AuthorizedReadContact(siteID, true);
                if (AccountHelper.AuthorizedModifyAccount(siteID, false) || ContactHelper.AuthorizedModifyContact(siteID, false))
                {
                    contactRoleSelector.SiteID     = siteID;
                    contactRoleSelector.IsLiveSite = ValidationHelper.GetBoolean("IsLiveSite", false);
                    contactRoleSelector.UniSelector.DialogWindowName = "SelectContactRole";
                    contactRoleSelector.IsSiteManager = ValidationHelper.GetBoolean(parameters["IsSiteManager"], false);

                    selectionDialog.LocalizeItems = QueryHelper.GetBoolean("localize", true);

                    // Load resource prefix
                    string resourcePrefix = ValidationHelper.GetString(parameters["ResourcePrefix"], "general");

                    // Set the page title
                    string titleText = GetString(resourcePrefix + ".selectitem|general.selectitem");

                    // Validity group text
                    pnlRole.GroupingText = GetString(resourcePrefix + ".contactsrole");

                    CurrentMaster.Title.TitleText = titleText;
                    Page.Title = titleText;

                    string imgPath = ValidationHelper.GetString(parameters["IconPath"], null);
                    if (String.IsNullOrEmpty(imgPath))
                    {
                        string objectType = ValidationHelper.GetString(parameters["ObjectType"], null);

                        CurrentMaster.Title.TitleImage = GetObjectIconUrl(objectType, null);
                    }
                    else
                    {
                        CurrentMaster.Title.TitleImage = imgPath;
                    }

                    // Cancel button
                    btnCancel.ResourceString = "general.cancel";
                    btnCancel.Attributes.Add("onclick", "return US_Cancel();");
                }
                // No permission modify
                else
                {
                    RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyAccount");
                }
            }
            else
            {
                // Redirect to error page
                URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("dialogs.badhashtitle") + "&text=" + ResHelper.GetString("dialogs.badhashtext")));
            }
        }
    }
Esempio n. 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");

        // Set title
        PageTitle.TitleText = GetString("om.contact.collision");
        // Validate hash
        Regex re = RegexHelper.GetRegex(@"[\w\d_$$]*");

        mIdentifier = QueryHelper.GetString("params", "");
        if (!QueryHelper.ValidateHash("hash") || !re.IsMatch(mIdentifier))
        {
            pnlContent.Visible = false;
            return;
        }

        // Load dialog parameters
        Hashtable parameters = (Hashtable)WindowHelper.GetItem(mIdentifier);

        if (parameters != null)
        {
            mMergedContacts = (DataSet)parameters["MergedContacts"];
            mParentContact  = (ContactInfo)parameters["ParentContact"];

            if (!mParentContact.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser))
            {
                RedirectToAccessDenied(mParentContact.TypeInfo.ModuleName, "Read");
            }

            mIsSitemanager = ValidationHelper.GetBoolean(parameters["issitemanager"], false);

            if (mIsSitemanager)
            {
                mStamp = SettingsKeyInfoProvider.GetValue("CMSCMStamp");
            }
            else
            {
                mStamp = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSCMStamp");
            }
            mStamp = MacroResolver.Resolve(mStamp);

            if (mParentContact != null)
            {
                // Check permissions
                ContactHelper.AuthorizedReadContact(mParentContact.ContactSiteID, true);

                // Load data
                Initialize();
                LoadContactCollisions();
                LoadContactGroups();
                LoadCustomFields();

                // Init controls
                btnMerge.Click        += new EventHandler(btnMerge_Click);
                btnStamp.OnClientClick = "AddStamp('" + htmlNotes.CurrentEditor.ClientID + "'); return false;";
                ScriptHelper.RegisterTooltip(Page);
                RegisterScripts();

                // Set tabs
                tabFields.HeaderText        = GetString("om.contact.fields");
                tabContacts.HeaderText      = GetString("om.account.list");
                tabContactGroups.HeaderText = GetString("om.contactgroup.list");
                tabCustomFields.HeaderText  = GetString("general.customfields");
            }
        }

        // User relative messages placeholder so that JQueryTab isn't moved a bit
        MessagesPlaceHolder.UseRelativePlaceHolder = false;

        // Do not let the editor overflow dialog window
        htmlNotes.SetValue("width", "520");
    }
Esempio n. 25
0
    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;
        }
    }
Esempio n. 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for unimenu button selection
        AddMenuButtonSelectScript(this, "Contacts", null, "menu");

        // Get current user info
        CurrentUserInfo user = CMSContext.CurrentUser;

        // Get contact info object
        ContactInfo ci = (ContactInfo)EditedObject;

        if (ci == null)
        {
            return;
        }

        // Check permission read
        ContactHelper.AuthorizedReadContact(ci.ContactSiteID, true);

        // Check if running under site manager (and distribute "site manager" flag to other tabs)
        string siteManagerParam = string.Empty;

        if (IsSiteManager)
        {
            siteManagerParam = "&issitemanager=1";
        }

        // Set default help topic
        SetHelp("onlinemarketing_contact_general", "helpTopic");

        // register scripts in modal dialog
        if (isDialogMode)
        {
            RegisterModalPageScripts();
        }

        string append = null;

        if (ci.ContactMergedWithContactID != 0)
        {
            // Append '(merged)' behind contact name in breadcrumbs
            append = " " + GetString("om.contact.mergedsuffix");
        }
        else if (ci.ContactSiteID == 0)
        {
            // Append '(global)' behind contact name in breadcrumbs
            append = " " + GetString("om.contact.globalsuffix");
        }

        // Modify header appearance in modal dialog (display title instead of breadcrumbs)
        if (QueryHelper.GetBoolean("dialogmode", false))
        {
            CurrentMaster.Title.TitleText  = GetString("om.contact.edit") + " - " + HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(ci)) + append;
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Contact/object.png");
        }
        else
        {
            // Get url for breadcrumbs
            string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/Contact/List.aspx");
            url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString());
            if (IsSiteManager)
            {
                url = URLHelper.AddParameterToUrl(url, "issitemanager", "1");
            }

            CurrentPage.InitBreadcrumbs(2);
            CurrentPage.SetBreadcrumb(0, GetString("om.contact.list"), url, "_parent", null);
            CurrentPage.SetBreadcrumb(1, ContactInfoProvider.GetContactFullName(ci) + append, null, null, null);
        }

        // Check if contact has any custom fields
        int i = 0;

        FormInfo formInfo = FormHelper.GetFormInfo(ci.Generalized.DataClass.ClassName, false);

        if (formInfo.GetFormElements(true, false, true).Any())
        {
            i = 1;
        }

        int  contactId      = ci.ContactID;
        bool ipTabAvailable = ActivitySettingsHelper.IPLoggingEnabled(CMSContext.CurrentSiteName) || ContactHelper.IsSiteManager;
        int  counter        = 0;

        // Initialize tabs
        InitTabs("content");

        SetTab(counter++, GetString("general.general"), "Tab_General.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_general');");

        if (i > 0)
        {
            // Add tab for custom fields
            SetTab(counter++, GetString("general.customfields"), "Tab_CustomFields.aspx?contactid=" + ci.ContactID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_customfields');");
        }

        if (AccountHelper.AuthorizedReadAccount(ci.ContactSiteID, false) || ContactHelper.AuthorizedReadContact(ci.ContactSiteID, false))
        {
            SetTab(counter++, GetString("om.account.list"), "Tab_Accounts.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_accounts');");
        }

        SetTab(counter++, GetString("om.membership.list"), "Membership/Tab_Membership.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_membership');");

        SetTab(counter++, GetString("om.activity.list"), "Tab_Activities.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_activities');");

        if (ipTabAvailable)
        {
            SetTab(counter++, GetString("om.activity.iplist"), "Tab_IPs.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_ips');");
        }

        // Show contact groups
        SetTab(counter++, GetString("om.contactgroup.list"), "Tab_ContactGroups.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_contactgroups');");

        // Show scoring tab for site contacts
        if (ci.ContactSiteID > 0)
        {
            SetTab(counter++, GetString("om.score.list"), "Tab_Scoring.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_scoring');");
        }

        // Hide last 3 tabs if the contact is merged
        if (ci.ContactMergedWithContactID == 0)
        {
            SetTab(counter++, GetString("om.contact.merge"), "Tab_Merge.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_merge');");
        }

        // Data.com
        SetTab(counter++, "Data.com", "Tab_DataCom.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_datacom');");

        // Marketing automation
        if (WorkflowInfoProvider.IsMarketingAutomationAllowed())
        {
            string stateUrl = String.Format("{0}?objectid={1}{2}", "Tab_Processes.aspx", contactId, siteManagerParam);
            SetTab(counter++, GetString("ma.contact.processes"), stateUrl, "SetHelpTopic('helpTopic', 'automation_state_list');");
        }
    }
    private void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        switch (e.Tab.TabName.ToLowerCSafe())
        {
        case "contactcustomfields":
            // Check if contact has any custom fields
            var formInfo = FormHelper.GetFormInfo("OM.Contact", false);
            if (!formInfo.GetFields(true, false, false).Any())
            {
                e.Tab = null;
            }
            break;

        case "contactaccounts":
            if (!AccountHelper.AuthorizedReadAccount(Contact.ContactSiteID, false) && !ContactHelper.AuthorizedReadContact(Contact.ContactSiteID, false))
            {
                e.Tab = null;
            }
            break;

        case "ips":
            if (!ActivitySettingsHelper.IPLoggingEnabled(SiteContext.CurrentSiteName))
            {
                e.Tab = null;
            }
            break;

        case "contactprocesses":
            // Marketing automation
            if (!WorkflowInfoProvider.IsMarketingAutomationAllowed())
            {
                e.Tab = null;
            }
            break;
        }
    }
 private void Page_Load(object sender, EventArgs e)
 {
     // Check permission read
     ContactHelper.AuthorizedReadContact(Contact.ContactSiteID, true);
 }