Beispiel #1
0
    /// <summary>
    /// Initializes the system.
    /// </summary>
    public static void Init()
    {
        // Init CMS environment
        CMSContext.Init(mAsyncInit);

        // Register the events
        RegisterEvents();

        // Register module methods and transformation methods to macro resolver
        CMSModuleLoader loader = new CMSModuleLoader();

        loader.RegisterTransformationMethods();

        MacroMethods.RegisterMethods();
        CMSMacroMethods.RegisterMethods();
    }
    /// <summary>
    /// Returns if activity is linked to object of type given in parameter and codename given in second parameter.
    /// </summary>
    /// <param name="activityInfo">Activity that should be checked</param>
    /// <param name="objectType">Object type</param>
    /// <param name="identifier">Code name or GUID of object</param>
    public static bool ActivityLinkedToObject(ActivityInfo activityInfo, string objectType, string identifier)
    {
        if (activityInfo == null)
        {
            return(false);
        }

        int id = 0;

        switch (objectType)
        {
        case PredefinedObjectType.POLL:
        case PredefinedObjectType.NEWSLETTER:
        case PredefinedObjectType.BIZFORM:
        case PredefinedObjectType.FORUM:
        case PredefinedObjectType.GROUPMEMBER:
        case PredefinedObjectType.BOARDMESSAGE:
        case PredefinedObjectType.BOARD:
        case PredefinedObjectType.SKU:
            id = activityInfo.ActivityItemID;
            break;

        case PredefinedObjectType.NEWSLETTERISSUE:
            var issue = IssueInfoProvider.GetOriginalIssue(activityInfo.ActivityItemDetailID);
            if (issue != null)
            {
                id = issue.IssueID;
            }
            break;

        case PredefinedObjectType.BLOGDOCUMENT:
            id         = activityInfo.ActivityItemDetailID;
            objectType = PredefinedObjectType.NODE;
            break;

        case PredefinedObjectType.DOCUMENT:
        case PredefinedObjectType.NODE:
            id = activityInfo.ActivityNodeID;
            break;

        default:
            id = activityInfo.ActivityItemID;
            break;
        }

        return(id == ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(objectType, identifier, CMSContext.CurrentSiteName, true), -1));
    }
Beispiel #3
0
    /// <summary>
    /// Initializes the system.
    /// </summary>
    public static void Init()
    {
        // Init CMS environment
        CMSContext.Init(mAsyncInit);

        // Register the events
        RegisterEvents();

        // Register module methods and transformation methods to macro resolver
        CMSModuleLoader.InitializeModules();

        MacroMethods.RegisterMethods();
        CMSMacroMethods.RegisterMethods();
        TransformationMacroMethods.RegisterMethods();

        Functions.RegisterUniGridTransformations();
    }
    /// <summary>
    /// Returns true if the contact voted in the poll.
    /// </summary>
    /// <param name="contact">Contact which should be checked</param>
    /// <param name="pollName">Poll name</param>
    /// <param name="answer">Poll answer text</param>
    /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param>
    public static bool VotedInPoll(object contact, string pollName, string answer, int lastXDays)
    {
        int pollId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.POLL, pollName, CMSContext.CurrentSiteName, true), 0);

        if (!string.IsNullOrEmpty(answer))
        {
            ContactInfo ci = contact as ContactInfo;
            if (ci == null)
            {
                return(false);
            }

            string where = GetActivityWhere(PredefinedActivityType.POLL_VOTING, null, lastXDays, "ActivityItemID = " + pollId, ci.ContactID);
            DataSet ds = ActivityInfoProvider.GetActivities(where, null, 0, "ActivityValue");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string[] answers = ValidationHelper.GetString(dr[0], "").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string a in answers)
                    {
                        BaseInfo pollAnswer = CMSObjectHelper.GetObjectById("polls.pollanswer", ValidationHelper.GetInteger(a, 0));
                        if (pollAnswer != null)
                        {
                            if (pollAnswer.GetStringValue("AnswerText", "").EqualsCSafe(answer, true))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
        else
        {
            return(DidActivity(contact, PredefinedActivityType.POLL_VOTING, null, lastXDays, "ActivityItemID = " + pollId));
        }
    }
    /// <summary>
    /// Returns true if the contact purchased specified product.
    /// </summary>
    /// <param name="contact">Contact which should be checked</param>
    /// <param name="skuName">Name of the product</param>
    /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param>
    public static bool PurchasedProduct(object contact, string skuName, int lastXDays)
    {
        int skuId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.SKU, skuName, CMSContext.CurrentSiteName, true), 0);

        return(DidActivity(contact, PredefinedActivityType.PURCHASEDPRODUCT, null, lastXDays, "ActivityItemID = " + skuId));
    }
    /// <summary>
    /// Returns true if the contact clicked link in specified newsletter.
    /// </summary>
    /// <param name="contact">Contact which should be checked</param>
    /// <param name="newsletterName">Newsletter name</param>
    /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param>
    public static bool ClickedLinkInNewsletter(object contact, string newsletterName, int lastXDays)
    {
        int newsletterId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.NEWSLETTER, newsletterName, CMSContext.CurrentSiteName, true), 0);

        return(DidActivity(contact, PredefinedActivityType.NEWSLETTER_CLICKTHROUGH, null, lastXDays, "ActivityItemID = " + newsletterId));
    }
    /// <summary>
    /// Returns true if the contact subscribed for specific newsletter.
    /// </summary>
    /// <param name="contact">Contact which should be checked</param>
    /// <param name="newsletterName">Newsletter name</param>
    /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param>
    public static bool SubscribedToNewsletter(object contact, string newsletterName, int lastXDays)
    {
        int newsletterId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.NEWSLETTER, newsletterName, CMSContext.CurrentSiteName, true), 0);

        return(DidActivity(contact, PredefinedActivityType.NEWSLETTER_SUBSCRIBING, PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING, lastXDays, "ActivityItemID = " + newsletterId));
    }
    /// <summary>
    /// Returns true if the contact submitted specified form.
    /// </summary>
    /// <param name="contact">Contact which should be checked</param>
    /// <param name="formName">Form name</param>
    /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param>
    public static bool SubmittedForm(object contact, string formName, int lastXDays)
    {
        int formId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.BIZFORM, formName, CMSContext.CurrentSiteName, true), 0);

        return(DidActivity(contact, PredefinedActivityType.BIZFORM_SUBMIT, null, lastXDays, "ActivityItemID = " + formId));
    }