コード例 #1
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Disable manual creation of activity if no custom activity type is available
        var activityType = ActivityTypeInfoProvider.GetActivityTypes()
                           .WhereEquals("ActivityTypeIsCustom", 1)
                           .WhereEquals("ActivityTypeEnabled", 1)
                           .WhereEquals("ActivityTypeManualCreationAllowed", 1)
                           .TopN(1)
                           .Column("ActivityTypeID")
                           .FirstOrDefault();

        bool aCustomActivityExists = (activityType != null);

        // Disable actions for unauthorized users
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ManageActivities"))
        {
            hdrActions.Enabled = false;
        }
        // Allow new button only if custom activity exists
        else if (!aCustomActivityExists)
        {
            lblWarnNew.ResourceString = "om.activities.nocustomactivity";
            hdrActions.Enabled        = false;
            lblWarnNew.Visible        = true;
        }
        // Allow new button only for particular sites
        else if (currSiteId <= 0)
        {
            lblWarnNew.ResourceString = "om.choosesite";
            hdrActions.Enabled        = false;
            lblWarnNew.Visible        = true;
        }
    }
コード例 #2
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Disable manual creation of activity if no custom activity type is available
        DataSet ds = ActivityTypeInfoProvider.GetActivityTypes("ActivityTypeIsCustom=1 AND ActivityTypeEnabled=1 AND ActivityTypeManualCreationAllowed=1", null, 1, "ActivityTypeID");
        bool    aCustomActivityExists = !DataHelper.DataSourceIsEmpty(ds);

        // Disable actions for unauthorized users
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ContactManagement", "ManageActivities"))
        {
            hdrActions.Enabled = false;
        }
        // Allow new button only if custom activity exists
        else if (!aCustomActivityExists)
        {
            lblWarnNew.ResourceString = "om.activities.nocustomactivity";
            hdrActions.Enabled        = false;
            lblWarnNew.Visible        = true;
        }
        // Allow new button only for particular sites
        else if (currSiteId <= 0)
        {
            lblWarnNew.ResourceString = "om.choosesite";
            hdrActions.Enabled        = false;
            lblWarnNew.Visible        = true;
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject != null)
        {
            ContactInfo ci = (ContactInfo)EditedObject;

            ucDisabledModule.TestSettingKeys = "CMSEnableOnlineMarketing;CMSCMActivitiesEnabled";
            ucDisabledModule.ParentPanel     = pnlDis;

            pnlDis.Visible = !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteID);

            listElem.ShowSiteNameColumn = true;
            listElem.SiteID             = UniSelector.US_ALL_RECORDS;
            listElem.ContactID          = ci.ContactID;
            listElem.OrderBy            = "ActivityCreated DESC";

            // Init header action for new custom activities only if contact is not global, a custom activity type exists and user is authorized to manage activities
            if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.ACTIVITIES, "ManageActivities"))
            {
                // Disable manual creation of activity if no custom activity type is available
                var activityType = ActivityTypeInfoProvider.GetActivityTypes()
                                   .WhereEquals("ActivityTypeIsCustom", 1)
                                   .WhereEquals("ActivityTypeEnabled", 1)
                                   .WhereEquals("ActivityTypeManualCreationAllowed", 1)
                                   .TopN(1)
                                   .Column("ActivityTypeID")
                                   .FirstOrDefault();

                if (activityType != null)
                {
                    // Prepare target URL
                    string url = ResolveUrl(string.Format("~/CMSModules/Activities/Pages/Tools/Activities/Activity/New.aspx?contactId={0}", ci.ContactID));

                    // Init header action
                    HeaderAction action = new HeaderAction()
                    {
                        Text        = GetString("om.activity.newcustom"),
                        RedirectUrl = url
                    };
                    CurrentMaster.HeaderActions.ActionsList.Add(action);
                }
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
            {
                // Display 'Save' message after new custom activity was created
                ShowChangesSaved();
            }
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject != null)
        {
            ContactInfo ci = (ContactInfo)EditedObject;

            // Check permission
            CheckReadPermission(ci.ContactSiteID);

            bool isGlobal = (ci.ContactSiteID == 0);
            bool isMerged = (ci.ContactMergedWithContactID > 0);

            // Show warning if activity logging is disabled
            string siteName = SiteInfoProvider.GetSiteName(ci.ContactSiteID);

            ucDisabledModule.SettingsKeys = "CMSEnableOnlineMarketing";
            ucDisabledModule.InfoText     = GetString("om.onlinemarketing.disabled");
            ucDisabledModule.ParentPanel  = pnlDis;

            pnlDis.Visible = !isGlobal && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName);

            // Show IP addresses if enabled
            listElem.ShowIPAddressColumn = ActivitySettingsHelper.IPLoggingEnabled(siteName);
            listElem.ShowSiteNameColumn  = IsSiteManager && isGlobal;

            // Restrict WHERE condition for activities of current site (if not in site manager)
            if (!IsSiteManager)
            {
                listElem.SiteID = SiteContext.CurrentSiteID;
            }
            else
            {
                // Show all records in Site Manager
                listElem.SiteID = UniSelector.US_ALL_RECORDS;
            }

            listElem.ContactID             = ci.ContactID;
            listElem.IsMergedContact       = isMerged;
            listElem.IsGlobalContact       = isGlobal;
            listElem.ShowContactNameColumn = isGlobal;
            listElem.ShowSiteNameColumn    = IsSiteManager && isGlobal;
            listElem.ShowRemoveButton      = !isMerged && !isGlobal;
            listElem.OrderBy = "ActivityCreated DESC";

            // Init header action for new custom activities only if contact is not global, a custom activity type exists and user is authorized to manage activities
            if (!isGlobal && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ManageActivities"))
            {
                // Disable manual creation of activity if no custom activity type is available
                var activityType = ActivityTypeInfoProvider.GetActivityTypes()
                                   .WhereEquals("ActivityTypeIsCustom", 1)
                                   .WhereEquals("ActivityTypeEnabled", 1)
                                   .WhereEquals("ActivityTypeManualCreationAllowed", 1)
                                   .TopN(1)
                                   .Column("ActivityTypeID")
                                   .FirstOrDefault();

                if (activityType != null)
                {
                    // Prepare target URL
                    string url = ResolveUrl(string.Format("~/CMSModules/ContactManagement/Pages/Tools/Activities/Activity/New.aspx?contactId={0}", ci.ContactID));
                    url = AddSiteQuery(url, ci.ContactSiteID);

                    // Init header action
                    HeaderAction action = new HeaderAction()
                    {
                        Text        = GetString("om.activity.newcustom"),
                        RedirectUrl = url
                    };
                    CurrentMaster.HeaderActions.ActionsList.Add(action);
                }
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
            {
                // Display 'Save' message after new custom activity was created
                ShowChangesSaved();
            }
        }
    }