예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ContactInfo ci = (ContactInfo)EditedObject;

        // Check permission read
        int siteID = ContactHelper.ObjectSiteID(EditedObject);

        CheckReadPermission(siteID);

        bool globalContact = (ci.ContactSiteID == 0);
        bool mergedContact = (ci.ContactMergedWithContactID > 0);

        listElem.ShowContactNameColumn = globalContact;
        listElem.ShowSiteNameColumn    = IsSiteManager && globalContact;
        listElem.ShowRemoveButton      = !mergedContact && !globalContact && ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);
        listElem.IsGlobalContact       = globalContact;
        listElem.IsMergedContact       = mergedContact;
        listElem.ContactID             = ci.ContactID;

        // Restrict site IDs in CMSDesk
        if (!IsSiteManager)
        {
            listElem.WhereCondition = "ContactSiteID = " + SiteContext.CurrentSiteID;
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")";
        }

        // Choose correct object ("query") according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALCUSTOMERLIST;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDCUSTOMERLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPCUSTOMERLIST;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Hide header actions for global contact
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;

        // Setup customer selector
        try
        {
            ucSelectCustomer = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/Ecommerce/FormControls/CustomerSelector.ascx");
            ucSelectCustomer.SetValue("Mode", "OnlineMarketing");
            ucSelectCustomer.SetValue("SiteID", ci.ContactSiteID);
            ucSelectCustomer.Changed   += new EventHandler(ucSelectCustomer_Changed);
            ucSelectCustomer.IsLiveSite = false;
            pnlSelectCustomer.Controls.Clear();
            pnlSelectCustomer.Controls.Add(ucSelectCustomer);
        }
        catch
        {
        }
    }
예제 #3
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        // Check permission
        ContactHelper.AuthorizedModifyContact(SiteID, true);

        switch (e.CommandName.ToLowerCSafe())
        {
        // Save contact
        case "save":
            if (EditForm.SaveData(null))
            {
                SetButtonsVisibility();
            }
            break;

        // Split from parent contact
        case "split":
        {
            var mergedContact = (ContactInfo)UIContext.EditedObject;
            List <ContactInfo> mergedContactList = new List <ContactInfo>(1)
            {
                mergedContact
            };

            ContactHelper.SplitContacts(parentContact, mergedContactList, false, false, false);
            SetButtonsVisibility();
            ShowConfirmation(GetString("om.contact.splitted"));
            ScriptHelper.RefreshTabHeader(Page, mergedContact.ContactDescriptiveName);
        }
        break;
        }
    }
예제 #4
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        // Check permission
        ContactHelper.AuthorizedModifyContact(SiteID, true);

        switch (e.CommandName.ToLowerCSafe())
        {
        // Save contact
        case "save":
            if (ValidateForm())
            {
                EditForm.SaveData(null);
                SetButtonsVisibility();
            }
            break;

        // Split from parent contact
        case "split":
            List <ContactInfo> mergedContact = new List <ContactInfo>(1)
            {
                (ContactInfo)CMSPage.EditedObject
            };
            ContactHelper.Split(parentContact, mergedContact, false, false, false, false);
            SetButtonsVisibility();
            ShowConfirmation(GetString("om.contact.splitted"));
            break;
        }
    }
예제 #5
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        // Check permission
        ContactHelper.AuthorizedModifyContact(this.SiteID, true);

        switch (e.CommandName.ToLower())
        {
        // Save contact
        case "save":
            if (ValidateForm())
            {
                EditForm.SaveData(null);
            }
            break;

        // Split from parent contact
        case "split":
            List <ContactInfo> mergedContact = new List <ContactInfo>();
            mergedContact.Add((ContactInfo)CMSPage.EditedObject);
            ContactHelper.Split(parentContact, mergedContact, false, false, false, false);
            ScriptHelper.RefreshTabHeader(this.Page, null);

            string url = URLHelper.AddParameterToUrl(URLHelper.CurrentURL, "split", "1");
            ScriptHelper.RegisterStartupScript(this.Page, typeof(string), "RefreshPage", ScriptHelper.GetScript("window.location.replace('" + url + "');"));
            break;
        }
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUIElementAccessHierarchical(ModuleName.ONLINEMARKETING, "ContactMembership.Subscribers");
        ci = (ContactInfo)EditedObject;
        if (ci == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where = " (ContactSiteID IS NULL OR ContactSiteID=" + SiteContext.CurrentSiteID + ")";
        }

        // Choose correct object ("query") according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = ContactMembershipGlobalSubscriberListInfo.OBJECT_TYPE;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = ContactMembershipMergedSubscriberListInfo.OBJECT_TYPE;
        }
        else
        {
            gridElem.ObjectType = ContactMembershipSubscriberListInfo.OBJECT_TYPE;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        // Hide header actions for global contact or merged contact.
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;

        // Setup subscriber selector
        selectSubscriber.UniSelector.SelectionMode     = SelectionModeEnum.MultipleButton;
        selectSubscriber.UniSelector.OnItemsSelected  += UniSelector_OnItemsSelected;
        selectSubscriber.UniSelector.ReturnColumnName  = "SubscriberID";
        selectSubscriber.UniSelector.DisplayNameFormat = "{%SubscriberFullName%} ({%SubscriberEmail%})";
        selectSubscriber.ShowSiteFilter = false;
        selectSubscriber.IsLiveSite     = false;
        selectSubscriber.SiteID         = ci.ContactSiteID;
    }
예제 #7
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        ContactHelper.AuthorizedModifyContact(contactSiteId, true);

        EnsureAsyncLog();
        RunAsyncDelete();
    }
예제 #8
0
 /// <summary>
 /// Checks modify contact permission for current contact group.
 /// If global, current site permission is also checked.
 /// </summary>
 private void CheckModifyContactPermission()
 {
     ContactHelper.AuthorizedModifyContact(contactGroupSiteID, true);
     if (contactGroupSiteID == 0)
     {
         ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, true);
     }
 }
예제 #9
0
    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();
    }
예제 #10
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");
    }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")";
        }

        // Choose correct query according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALUSERLIST;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDUSERLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPUSERLIST;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Setup user selector
        selectUser.UniSelector.SelectionMode       = SelectionModeEnum.MultipleButton;
        selectUser.UniSelector.OnItemsSelected    += new EventHandler(UniSelector_OnItemsSelected);
        selectUser.UniSelector.ReturnColumnName    = "UserID";
        selectUser.UniSelector.ButtonImage         = GetImageUrl("Objects/CMS_User/add.png");
        selectUser.UniSelector.DialogLink.CssClass = "MenuItemEdit";
        selectUser.ShowSiteFilter = false;
        selectUser.ResourcePrefix = "addusers";
        selectUser.UniSelector.DialogButton.CssClass = "LongButton";
        selectUser.IsLiveSite = false;
        selectUser.SiteID     = ci.ContactSiteID;

        // Hide header actions for global contact or merged contact
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;
    }
 /// <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);
 }
예제 #13
0
    private void ucSelectCustomer_Changed(object sender, EventArgs e)
    {
        // Check permissions
        if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true))
        {
            // Load value form dynamic control
            string values = null;
            if (ucSelectCustomer != null)
            {
                values = ValidationHelper.GetString(ucSelectCustomer.GetValue("OnlineMarketingValue"), null);
            }

            if (!String.IsNullOrEmpty(values))
            {
                // Store users one by one
                string[] customerIds   = values.Split(';');
                int      currentSiteID = SiteContext.CurrentSiteID;
                foreach (string customerId in customerIds)
                {
                    // Check if user ID is valid
                    int customerIdInt = ValidationHelper.GetInteger(customerId, 0);
                    if (customerIdInt <= 0)
                    {
                        continue;
                    }

                    // Only allow adding customers on the same site as contact or registered customers
                    var customer = BaseAbstractInfoProvider.GetInfoById(PredefinedObjectType.CUSTOMER, customerIdInt);
                    if ((customer == null) || ((customer.Generalized.ObjectSiteID != currentSiteID) && !customer.IsGlobal))
                    {
                        continue;
                    }

                    // Add new relation
                    int parentId = (ci.ContactMergedWithContactID == 0)
                   ? ci.ContactID
                   : ci.ContactMergedWithContactID;

                    ContactMembershipInfoProvider.SetRelationship(customerIdInt, MemberTypeEnum.EcommerceCustomer, ci.ContactID, parentId, true);
                    ci = ContactInfoProvider.GetContactInfo(contactId);
                }

                // When contact was merged then refresh complete page
                if ((ci != null) && (ci.ContactMergedWithContactID > 0))
                {
                    Page.Response.Redirect(RequestContext.URL.ToString(), true);
                }
                else
                {
                    gridElem.ReloadData();
                }
            }
        }
    }
예제 #14
0
    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();
    }
예제 #15
0
    /// <summary>
    /// UniGrid action handler.
    /// </summary>
    private void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "delete")
        {
            ContactInfo contact = ContactInfoProvider.GetContactInfo(ContactID);

            // Check permission
            if ((contact != null) && ContactHelper.AuthorizedModifyContact(contact.ContactSiteID, true))
            {
                int ipId = ValidationHelper.GetInteger(actionArgument, 0);
                IPInfoProvider.DeleteIPInfo(ipId);
            }
        }
    }
예제 #16
0
 /// <summary>
 /// Button merge selected click.
 /// </summary>
 void btnMerge_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(this.Contact.ContactSiteID, true))
     {
         if (gridElem.SelectedItems.Count > 0)
         {
             SetDialogParameters(false);
             OpenWindow();
         }
         else
         {
             lblError.Visible = true;
         }
     }
 }
예제 #17
0
 /// <summary>
 /// Button merge all click.
 /// </summary>
 private void btnMergeAll_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(Contact.ContactSiteID, true))
     {
         if (!DataHelper.DataSourceIsEmpty(gridElem.GridView.DataSource))
         {
             SetDialogParameters(true);
             OpenWindow();
         }
         else
         {
             ShowError(GetString("om.contact.selectcontacts"));
         }
     }
 }
예제 #18
0
 /// <summary>
 /// Button merge selected click.
 /// </summary>
 private void btnMerge_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(Contact.ContactSiteID, true))
     {
         if (gridElem.SelectedItems.Count > 0)
         {
             SetDialogParameters(false);
             OpenWindow();
         }
         else
         {
             ShowError(GetString("om.contact.selectcontacts"));
         }
     }
 }
예제 #19
0
 /// <summary>
 /// Button merge all click.
 /// </summary>
 void btnMergeAll_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(this.Contact.ContactSiteID, true))
     {
         if (!DataHelper.DataSourceIsEmpty(gridElem.GridView.DataSource))
         {
             SetDialogParameters(true);
             OpenWindow();
         }
         else
         {
             lblError.Visible = true;
         }
     }
 }
예제 #20
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
        mergedIntoSite    = ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0) != 0;
        mergedIntoGlobal  = ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0) != 0;
        mergedIntoGlobal &= ContactHelper.AuthorizedModifyContact(UniSelector.US_GLOBAL_RECORD, false);

        if (!ContactHelper.IsSiteManager)
        {
            mergedIntoGlobal &= SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalContacts");
        }

        btnSplit.Visible = mergedIntoGlobal || mergedIntoSite;

        // Get parent contact
        if (mergedIntoSite)
        {
            parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactMergedWithContactID"], 0));
            lblMergedInto.ResourceString = "om.contact.mergedintosite";
            lblMergedInto.Visible        = true;
        }
        else if (mergedIntoGlobal)
        {
            parentContact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(EditForm.Data["ContactGlobalContactID"], 0));
            lblMergedInto.ResourceString = "om.contact.mergedintoglobal";
            lblMergedInto.Visible        = true;
        }
        else
        {
            lblMergedInto.Visible = false;
        }

        if (mergedIntoSite || mergedIntoGlobal)
        {
            string contactFullName = parentContact.ContactFirstName + " " + parentContact.ContactMiddleName;
            contactFullName = contactFullName.Trim() + " " + parentContact.ContactLastName;
            ltlButton.Text  = string.Format(@" {0} <img class='UnigridActionButton' style='cursor:pointer;' onclick='EditContact({1});return false;' src='{2}' title='{3}'>",
                                            HTMLHelper.HTMLEncode(contactFullName.Trim()),
                                            parentContact.ContactID,
                                            GetImageUrl("Design/Controls/UniGrid/Actions/contactdetail.png"),
                                            GetString("om.contact.viewdetail"));
            ltlButton.Visible = true;
        }
        else
        {
            ltlButton.Visible = false;
        }
    }
예제 #21
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Disable actions for unauthorized users
        if (!ContactHelper.AuthorizedModifyContact(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;
        }
    }
예제 #22
0
 protected void gridElem_OnAction(string actionName, object actionArgument)
 {
     switch (actionName)
     {
     case "delete":
         int membershipId = ValidationHelper.GetInteger(actionArgument, 0);
         if (membershipId > 0)
         {
             // Check permissions
             if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true))
             {
                 MembershipInfoProvider.DeleteRelationship(membershipId);
             }
         }
         break;
     }
 }
예제 #23
0
    private void ucSelectCustomer_Changed(object sender, EventArgs e)
    {
        // Check permissions
        if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true))
        {
            // Load value form dynamic control
            string values = null;
            if (ucSelectCustomer != null)
            {
                values = ValidationHelper.GetString(ucSelectCustomer.GetValue("OnlineMarketingValue"), null);
            }

            if (!String.IsNullOrEmpty(values))
            {
                // Store users one by one
                string[] customerIds = values.Split(';');
                foreach (string customerId in customerIds)
                {
                    // Check if user ID is valid
                    int customerIdInt = ValidationHelper.GetInteger(customerId, 0);
                    if (customerIdInt <= 0)
                    {
                        continue;
                    }
                    // Add new relation
                    int parentId = (ci.ContactMergedWithContactID == 0)
                   ? ci.ContactID
                   : ci.ContactMergedWithContactID;

                    MembershipInfoProvider.SetRelationship(customerIdInt, MemberTypeEnum.EcommerceCustomer, ci.ContactID, parentId, true);
                    ci = ContactInfoProvider.GetContactInfo(contactId);
                }

                // When contact was merged then refresh complete page
                if ((ci != null) && (ci.ContactMergedWithContactID > 0))
                {
                    Page.Response.Redirect(URLHelper.Url.ToString(), true);
                }
                else
                {
                    gridElem.ReloadData();
                }
            }
        }
    }
예제 #24
0
 private void btnSplit_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(Contact.ContactSiteID, true))
     {
         if (gridElem.SelectedItems.Count > 0)
         {
             ContactHelper.Split(Contact, gridElem.SelectedItems, chkCopyMissingFields.Checked, chkCopyActivities.Checked, chkRemoveAccounts.Checked, chkRemoveContactGroups.Checked);
             gridElem.ReloadData();
             gridElem.ClearSelectedItems();
             ShowConfirmation(GetString("om.contact.splitting"));
             pnlUpdate.Update();
         }
         else
         {
             ShowError(GetString("om.contact.selectcontactssplit"));
         }
     }
 }
예제 #25
0
 void btnSplit_Click(object sender, EventArgs e)
 {
     if (ContactHelper.AuthorizedModifyContact(this.Contact.ContactSiteID, true))
     {
         if (gridElem.SelectedItems.Count > 0)
         {
             ContactHelper.Split(this.Contact, gridElem.SelectedItems, chkCopyMissingFields.Checked, chkCopyActivities.Checked, chkRemoveAccounts.Checked, chkRemoveContactGroups.Checked);
             gridElem.ReloadData();
             gridElem.ClearSelectedItems();
             lblInfo.Visible = true;
             pnlUpdate.Update();
         }
         else
         {
             lblError.Visible = true;
         }
     }
 }
예제 #26
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitHeaderActions()
    {
        // Find out if current contact is merged into another site or global contact
        mergedIntoSite    = ValidationHelper.GetInteger(this.EditForm.Data["ContactMergedWithContactID"], 0) != 0;
        mergedIntoGlobal  = ValidationHelper.GetInteger(this.EditForm.Data["ContactGlobalContactID"], 0) != 0;
        mergedIntoGlobal &= ContactHelper.AuthorizedModifyContact(UniSelector.US_GLOBAL_RECORD, false);

        if (!ContactHelper.IsSiteManager)
        {
            mergedIntoGlobal &= SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalContacts");
        }

        string[,] actions;
        if (mergedIntoSite || mergedIntoGlobal)
        {
            actions = new string[2, 11];
        }
        else
        {
            actions = new string[1, 11];
        }

        // Initialize SAVE button
        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = GetString("General.Save");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = "true";

        if (mergedIntoSite || mergedIntoGlobal)
        {
            // Initialize SPLIT button
            actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[1, 1] = GetString("om.contact.splitfromparent");
            actions[1, 5] = GetImageUrl("CMSModules/CMS_ContactManagement/split.png");
            actions[1, 6] = "split";
            actions[1, 8] = "false";
        }
        ((CMSPage)Page).CurrentMaster.HeaderActions.LinkCssClass     = "ContentSaveLinkButton";
        ((CMSPage)Page).CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        ((CMSPage)Page).CurrentMaster.HeaderActions.Actions          = actions;
    }
예제 #27
0
    private void btnSplit_Click(object sender, EventArgs e)
    {
        if (ContactHelper.AuthorizedModifyContact(Contact.ContactSiteID, true))
        {
            if (gridElem.SelectedItems.Count > 0)
            {
                var contacts = ContactInfoProvider.GetContacts().WhereIn("ContactID", gridElem.SelectedItems.Select(c => c.ToInteger(0)).ToList());

                ContactHelper.SplitContacts(Contact, contacts.ToList(), chkCopyMissingFields.Checked, chkCopyActivities.Checked, chkRemoveAccounts.Checked);
                gridElem.ReloadData();
                gridElem.ClearSelectedItems();
                ShowConfirmation(GetString("om.contact.splitting"));
                pnlUpdate.Update();
            }
            else
            {
                ShowError(GetString("om.contact.selectcontactssplit"));
            }
        }
    }
예제 #28
0
    /// <summary>
    /// Button merge click.
    /// </summary>
    private void btnMerge_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (ContactHelper.AuthorizedModifyContact(mParentContact.ContactSiteID, true))
        {
            // Validate form
            if (ValidateForm())
            {
                // Change parent contact values
                SaveChanges();
                // Update hash table with account-contact roles
                UpdateRoles();

                // Merge contacts
                ContactHelper.Merge(mParentContact, mMergedContacts, mRoles, GetContactGroups());

                // Close window and refresh parent window
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "WOpenerRefresh", ScriptHelper.GetScript(@"wopener.RefreshPage(); CloseDialog();"));
            }
        }
    }
예제 #29
0
    private void UniSelector_OnItemsSelected(object sender, EventArgs e)
    {
        // Check permissions
        if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true))
        {
            string values = ValidationHelper.GetString(selectUser.UniSelector.Value, null);
            if (!String.IsNullOrEmpty(values))
            {
                // Store users one by one
                string[] userIds = values.Split(';');
                foreach (string userId in userIds)
                {
                    // Check if user ID is valid
                    int userIdInt = ValidationHelper.GetInteger(userId, 0);
                    if (userIdInt <= 0)
                    {
                        continue;
                    }
                    // Add new relation
                    int parentId = (ci.ContactMergedWithContactID == 0)
                                       ? ci.ContactID
                                       : ci.ContactMergedWithContactID;
                    MembershipInfoProvider.SetRelationship(userIdInt, MemberTypeEnum.CmsUser, ci.ContactID, parentId, true);

                    // When contact was merged update contact info
                    ci = ContactInfoProvider.GetContactInfo(contactId);
                }

                // When contact was merged then refresh complete page
                if ((ci != null) && (ci.ContactMergedWithContactID > 0))
                {
                    Page.Response.Redirect(URLHelper.Url.ToString(), true);
                }
                else
                {
                    gridElem.ReloadData();
                }
            }
        }
    }
예제 #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Current contact is global object
        if (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;
            }
        }
        else
        {
            filter.SiteID = Contact.ContactSiteID;
        }
        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, "ContactMergedWithContactID = " + this.Contact.ContactID + " OR ContactGlobalContactID = " + this.Contact.ContactID);
        }
        else
        {
            // Get children for site contact
            where = SqlHelperClass.AddWhereCondition(where, "ContactID IN (SELECT * FROM Func_OM_Contact_GetChildren(" + this.Contact.ContactID + ", 0))");
        }
        gridElem.WhereCondition       = where;
        gridElem.ZeroRowsText         = GetString("om.contact.nocontacts");
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        btnSplit.Click += new EventHandler(btnSplit_Click);

        // Register JS scripts
        RegisterScripts();
    }