public static string SendEmail(UserInfo objUser, string SubjectTemplate, string BodyTemplate, PortalSettings objPortalSettings)
        {
            try
            {
                if (!IsValidEmail(objUser.Email))
                {
                    return("InvalidEmail");
                }

                //send email
                DotNetNuke.Services.Tokens.TokenReplace objTokenReplace =
                    new DotNetNuke.Services.Tokens.TokenReplace(
                        DotNetNuke.Services.Tokens.Scope.DefaultSettings,
                        System.Globalization.CultureInfo.CurrentCulture.Name,
                        objPortalSettings,
                        objUser);

                string Subject = objRegExPassword.Replace(SubjectTemplate, objUser.Membership.Password);
                string Body    = objRegExPassword.Replace(BodyTemplate, objUser.Membership.Password);

                Subject = objTokenReplace.ReplaceEnvironmentTokens(Subject);
                Body    = objTokenReplace.ReplaceEnvironmentTokens(Body);

                DotNetNuke.Services.Mail.Mail.SendEmail(objPortalSettings.Email, objUser.Email, Subject, Body);
            }
            catch (Exception Exc)
            {
                Exceptions.LogException(Exc);
                return(Exc.Message);
            }
            return("");
        }
Exemple #2
0
        private void LoadArticle()
        {
            var a = (Article)this.VersionInfoObject;

            if (a != null)
            {
                // VersionInfoObject.IsNew = false;
                if (a.ArticleText.Trim() == string.Empty)
                {
                    this.lblArticleText.Text = Localization.GetString("NothingSaved", this.LocalResourceFile);
                }
                else
                {
                    string articleText = a.ArticleText;
                    articleText = Utility.ReplaceTokens(articleText);

                    var tr = new TokenReplace
                    {
                        AccessingUser = this.UserInfo,
                        DebugMessages = PortalSettings.UserMode != DotNetNuke.Entities.Portals.PortalSettings.Mode.View
                    };

                    articleText = tr.ReplaceEnvironmentTokens(articleText);
                    this.lblArticleText.Text = articleText;
                }

                object m = this.Request.QueryString["modid"];
                if (m != null)
                {
                    if (m.ToString() == this.ModuleId.ToString())
                    {
                        // check if module id querystring is current moduleid
                        if (this.IsAdmin && !this.VersionInfoObject.IsNew)
                        {
                            this.divAdminMenuWrapper.Visible = true;
                            this.divPublishApprovals.Visible = true;
                            this.divApprovalStatus.Visible   = true;
                            if (this.UseApprovals &&
                                Item.GetItemType(this.ItemId, this.PortalId).Equals("ARTICLE", StringComparison.OrdinalIgnoreCase))
                            {
                                this.FillDropDownList();
                            }
                            else
                            {
                                this.ddlApprovalStatus.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        this.divAdminMenuWrapper.Visible = false;
                    }
                }
            }
            else
            {
                this.lblArticleText.Text = Localization.GetString("NothingSaved", this.LocalResourceFile);
            }
        }
        // this module will provide compatibility between DNN versions
        public static string ReplaceGenericTokens(string text)
        {
            var ret             = text;
            var objTokenReplace = new DotNetNuke.Services.Tokens.TokenReplace();

            ret = (string)(objTokenReplace.ReplaceEnvironmentTokens(ret));
            return(ret);
        }
        public static string ReplaceGenericTokensForTest(string text)
        {
            var ret = text;

            // replace tokens that aren't available
            ret = Regex.Replace(ret, "\\[QUERYSTRING:.*?\\]", "1", RegexOptions.IgnoreCase);
            ret = Regex.Replace(ret, "\\[QS:.*?\\]", "1", RegexOptions.IgnoreCase);
            // replace any parameter tokens named date with dates (crude workaround for the time being)
            ret = Regex.Replace(ret, "\\[PARAMETER:.*?DATE.*?\\]", "1966-2-21", RegexOptions.IgnoreCase);
            // replace rest of parameters
            ret = Regex.Replace(ret, "\\[PARAMETER:.*?\\]", "1", RegexOptions.IgnoreCase);

            var objTokenReplace = new DotNetNuke.Services.Tokens.TokenReplace();

            ret = (string)(objTokenReplace.ReplaceEnvironmentTokens(ret));

            return(ret);
        }
        public static string Tokenize(string strContent, DotNetNuke.Entities.Modules.ModuleInfo modInfo, UserInfo user, bool forceDebug, bool bRevertToDnn)
        {
            string cacheKey_Installed = "avt.MyTokens2.Installed";
            string cacheKey_MethodReplace = "avt.MyTokens2.MethodReplace";

            string bMyTokensInstalled = "no";
            System.Reflection.MethodInfo methodReplace = null;

            bool bDebug = forceDebug;
            if (!bDebug) {
                try { bDebug = DotNetNuke.Common.Globals.IsEditMode(); } catch { }
            }

            lock (typeof(DotNetNuke.Services.Tokens.TokenReplace)) {
                // first, determine if MyTokens is installed
                if (HttpRuntime.Cache.Get(cacheKey_Installed) == null) {

                    // check again, maybe current thread was locked by another which did all the work
                    if (HttpRuntime.Cache.Get(cacheKey_Installed) == null) {

                        // it's not in cache, let's determine if it's installed
                        try {
                            Type myTokensRepl = DotNetNuke.Framework.Reflection.CreateType("avt.MyTokens.MyTokensReplacer", true);
                            if (myTokensRepl == null)
                                throw new Exception(); // handled in catch

                            bMyTokensInstalled = "yes";

                            // we now know MyTokens is installed, get ReplaceTokensAll methods
                            methodReplace = myTokensRepl.GetMethod(
                                "ReplaceTokensAll",
                                System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static,
                                null,
                                System.Reflection.CallingConventions.Any,
                                new Type[] {
                                typeof(string),
                                typeof(DotNetNuke.Entities.Users.UserInfo),
                                typeof(bool),
                                typeof(DotNetNuke.Entities.Modules.ModuleInfo)
                            },
                                null
                            );

                            if (methodReplace == null) {
                                // this shouldn't really happen, we know MyTokens is installed
                                throw new Exception();
                            }

                        } catch {
                            bMyTokensInstalled = "no";
                        }

                        // cache values so next time the funciton is called the reflection logic is skipped
                        HttpRuntime.Cache.Insert(cacheKey_Installed, bMyTokensInstalled);
                        if (bMyTokensInstalled == "yes") {
                            HttpRuntime.Cache.Insert(cacheKey_MethodReplace, methodReplace);
                        }
                    }
                }
            }

            bMyTokensInstalled = HttpRuntime.Cache.Get(cacheKey_Installed).ToString();
            if (bMyTokensInstalled == "yes") {
                methodReplace = (System.Reflection.MethodInfo)HttpRuntime.Cache.Get(cacheKey_MethodReplace);
                if (methodReplace == null) {
                    HttpRuntime.Cache.Remove(cacheKey_Installed);
                    return Tokenize(strContent, modInfo, user, forceDebug, bRevertToDnn);
                }
            } else {
                // if it's not installed return string or tokenize with DNN replacer
                if (!bRevertToDnn) {
                    return strContent;
                } else {
                    DotNetNuke.Services.Tokens.TokenReplace dnnTknRepl = new DotNetNuke.Services.Tokens.TokenReplace();
                    dnnTknRepl.AccessingUser = user ?? DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                    dnnTknRepl.DebugMessages = bDebug;
                    if (modInfo != null)
                        dnnTknRepl.ModuleInfo = modInfo;

                    // MyTokens is not installed, execution ends here
                    return dnnTknRepl.ReplaceEnvironmentTokens(strContent);
                }
            }

            // we have MyTokens installed, proceed to token replacement
            return (string)methodReplace.Invoke(
                null,
                new object[] {
                    strContent,
                    user ?? DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(),
                    bDebug,
                    modInfo
                }
            );
        }
        private void LoadArticle()
        {
            var a = (Article)VersionInfoObject;

            if (a != null)
            {
                //VersionInfoObject.IsNew = false;
                if (a.ArticleText.Trim() == string.Empty)
                {
                    lblArticleText.Text = Localization.GetString("NothingSaved", LocalResourceFile);
                }
                else
                {
                    string articleText = a.ArticleText;
                    //removed until we move forward with a newer version of DNN 4.6.2 or greater.
                    //for enterprise licenses you can uncomment the following if you put the Dotnetnuke.dll (4.6.2+) in the engagepublish/references folder and recompile

                    articleText = Utility.ReplaceTokens(articleText);

                    var tr = new DotNetNuke.Services.Tokens.TokenReplace
                    {
                        AccessingUser = UserInfo,
                        DebugMessages = !DotNetNuke.Common.Globals.IsTabPreview()
                    };

                    articleText         = tr.ReplaceEnvironmentTokens(articleText);
                    lblArticleText.Text = articleText;
                }


                object m = Request.QueryString["modid"];
                if (m != null)
                {
                    if (m.ToString() == ModuleId.ToString())
                    {
                        //check if module id querystring is current moduleid
                        if ((IsAdmin && !VersionInfoObject.IsNew))
                        {
                            divAdminMenuWrapper.Visible = true;
                            divPublishApprovals.Visible = true;
                            divApprovalStatus.Visible   = true;
                            if (UseApprovals && Item.GetItemType(ItemId, PortalId).Equals("ARTICLE", StringComparison.OrdinalIgnoreCase))
                            {
                                FillDropDownList();
                            }
                            else
                            {
                                ddlApprovalStatus.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        divAdminMenuWrapper.Visible = false;
                    }
                }
            }
            else
            {
                lblArticleText.Text = Localization.GetString("NothingSaved", LocalResourceFile);
            }
        }
        private void LoadArticle()
        {
            var a = (Article)this.VersionInfoObject;
            if (a != null)
            {
                // VersionInfoObject.IsNew = false;
                if (a.ArticleText.Trim() == string.Empty)
                {
                    this.lblArticleText.Text = Localization.GetString("NothingSaved", this.LocalResourceFile);
                }
                else
                {
                    string articleText = a.ArticleText;
                    articleText = Utility.ReplaceTokens(articleText);

                    var tr = new TokenReplace
                        {
                            AccessingUser = this.UserInfo,
                            DebugMessages = PortalSettings.UserMode != DotNetNuke.Entities.Portals.PortalSettings.Mode.View
                        };

                    articleText = tr.ReplaceEnvironmentTokens(articleText);
                    this.lblArticleText.Text = articleText;
                }

                object m = this.Request.QueryString["modid"];
                if (m != null)
                {
                    if (m.ToString() == this.ModuleId.ToString())
                    {
                        // check if module id querystring is current moduleid
                        if (this.IsAdmin && !this.VersionInfoObject.IsNew)
                        {
                            this.divAdminMenuWrapper.Visible = true;
                            this.divPublishApprovals.Visible = true;
                            this.divApprovalStatus.Visible = true;
                            if (this.UseApprovals &&
                                Item.GetItemType(this.ItemId, this.PortalId).Equals("ARTICLE", StringComparison.OrdinalIgnoreCase))
                            {
                                this.FillDropDownList();
                            }
                            else
                            {
                                this.ddlApprovalStatus.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        this.divAdminMenuWrapper.Visible = false;
                    }
                }
            }
            else
            {
                this.lblArticleText.Text = Localization.GetString("NothingSaved", this.LocalResourceFile);
            }
        }
Exemple #8
0
 public string DNNTokenReplace(Match m)
 {
     DotNetNuke.Services.Tokens.TokenReplace tk = new DotNetNuke.Services.Tokens.TokenReplace();
     tk.ModuleId = transformer.ModuleID;
     return(tk.ReplaceEnvironmentTokens(m.Value));
 }
        public string Tokenize(string strContent, ModuleInfo modInfo)
        {
            bool bMyTokensInstalled = false;
            MethodInfo methodReplace = null;
            MethodInfo methodReplaceWMod = null;

            // first, determine if MyTokens is installed
            if (HttpRuntime.Cache.Get("avt.MyTokens.Installed") != null) {
                bMyTokensInstalled = Convert.ToBoolean(HttpRuntime.Cache.Get("avt.MyTokens.Installed"));
                if (bMyTokensInstalled == true) {
                    methodReplace = (MethodInfo)HttpRuntime.Cache.Get("avt.MyTokens.MethodReplace");
                    methodReplaceWMod = (MethodInfo)HttpRuntime.Cache.Get("avt.MyTokens.MethodReplaceWMod");
                }
            } else {
                // it's not in cache, let's determine if it's installed
                try {
                    Type myTokensRepl = DotNetNuke.Framework.Reflection.CreateType("avt.MyTokens.MyTokensReplacer");
                    if (myTokensRepl == null)
                        throw new Exception(); // handled in catch

                    bMyTokensInstalled = true;

                    // we now know MyTokens is installed, get ReplaceTokensAll methods

                    methodReplace = myTokensRepl.GetMethod(
                        "ReplaceTokensAll",
                        BindingFlags.Public | BindingFlags.Static,
                        null,
                         CallingConventions.Any,
                        new Type[] { 
                            typeof(string), 
                            typeof(DotNetNuke.Entities.Users.UserInfo), 
                            typeof(bool) 
                        },
                        null
                    );

                    methodReplaceWMod = myTokensRepl.GetMethod(
                        "ReplaceTokensAll",
                        BindingFlags.Public | BindingFlags.Static,
                        null,
                         CallingConventions.Any,
                        new Type[] { 
                            typeof(string), 
                            typeof(DotNetNuke.Entities.Users.UserInfo), 
                            typeof(bool),
                            typeof(ModuleInfo)
                        },
                        null
                    );

                    if (methodReplace == null || methodReplaceWMod == null) {
                        // this shouldn't really happen, we know MyTokens is installed
                        throw new Exception();
                    }

                } catch {
                    bMyTokensInstalled = false;
                }

                // cache values so next time the funciton is called the reflection logic is skipped
                HttpRuntime.Cache.Insert("avt.MyTokens.Installed", bMyTokensInstalled);
                if (bMyTokensInstalled) {
                    HttpRuntime.Cache.Insert("avt.MyTokens.MethodReplace", methodReplace);
                    HttpRuntime.Cache.Insert("avt.MyTokens.MethodReplaceWMod", methodReplaceWMod);
                }
            }


            // revert to standard DNN Token Replacement if MyTokens is not installed

            if (!bMyTokensInstalled) {
                DotNetNuke.Services.Tokens.TokenReplace dnnTknRepl = new DotNetNuke.Services.Tokens.TokenReplace();
                dnnTknRepl.AccessingUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                dnnTknRepl.DebugMessages = !DotNetNuke.Common.Globals.IsTabPreview();
                if (modInfo != null)
                    dnnTknRepl.ModuleInfo = modInfo;

                // MyTokens is not installed, execution ends here
                return dnnTknRepl.ReplaceEnvironmentTokens(strContent);
            }

            // we have MyTokens installed, proceed to token replacement
            // Note that we could be using only the second overload and pass null to the ModuleInfo parameter,
            //  but this will break compatibility with integrations made before the second overload was added
            if (modInfo == null) {
                return (string)methodReplace.Invoke(
                    null,
                    new object[] {
                        strContent,
                        DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(),
                        !DotNetNuke.Common.Globals.IsTabPreview()
                    }
                );
            } else {
                return (string)methodReplaceWMod.Invoke(
                    null,
                    new object[] {
                        strContent,
                        DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(),
                        !DotNetNuke.Common.Globals.IsTabPreview(),
                        modInfo
                    }
                );
            }
        }
Exemple #10
0
        static public string Tokenize(string strContent, DotNetNuke.Entities.Modules.ModuleInfo modInfo, UserInfo user, bool forceDebug, bool bRevertToDnn)
        {
            string cacheKey_Installed     = "avt.MyTokens2.Installed";
            string cacheKey_MethodReplace = "avt.MyTokens2.MethodReplace";

            string bMyTokensInstalled = "no";

            System.Reflection.MethodInfo methodReplace = null;

            bool bDebug = forceDebug;

            if (!bDebug)
            {
                try { bDebug = DotNetNuke.Common.Globals.IsEditMode(); } catch { }
            }

            lock (typeof(DotNetNuke.Services.Tokens.TokenReplace)) {
                // first, determine if MyTokens is installed
                if (HttpRuntime.Cache.Get(cacheKey_Installed) == null)
                {
                    // check again, maybe current thread was locked by another which did all the work
                    if (HttpRuntime.Cache.Get(cacheKey_Installed) == null)
                    {
                        // it's not in cache, let's determine if it's installed
                        try {
                            Type myTokensRepl = DotNetNuke.Framework.Reflection.CreateType("avt.MyTokens.MyTokensReplacer", true);
                            if (myTokensRepl == null)
                            {
                                throw new Exception(); // handled in catch
                            }
                            bMyTokensInstalled = "yes";

                            // we now know MyTokens is installed, get ReplaceTokensAll methods
                            methodReplace = myTokensRepl.GetMethod(
                                "ReplaceTokensAll",
                                System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static,
                                null,
                                System.Reflection.CallingConventions.Any,
                                new Type[] {
                                typeof(string),
                                typeof(DotNetNuke.Entities.Users.UserInfo),
                                typeof(bool),
                                typeof(DotNetNuke.Entities.Modules.ModuleInfo)
                            },
                                null
                                );

                            if (methodReplace == null)
                            {
                                // this shouldn't really happen, we know MyTokens is installed
                                throw new Exception();
                            }
                        } catch {
                            bMyTokensInstalled = "no";
                        }

                        // cache values so next time the funciton is called the reflection logic is skipped
                        HttpRuntime.Cache.Insert(cacheKey_Installed, bMyTokensInstalled);
                        if (bMyTokensInstalled == "yes")
                        {
                            HttpRuntime.Cache.Insert(cacheKey_MethodReplace, methodReplace);
                        }
                    }
                }
            }

            bMyTokensInstalled = HttpRuntime.Cache.Get(cacheKey_Installed).ToString();
            if (bMyTokensInstalled == "yes")
            {
                methodReplace = (System.Reflection.MethodInfo)HttpRuntime.Cache.Get(cacheKey_MethodReplace);
                if (methodReplace == null)
                {
                    HttpRuntime.Cache.Remove(cacheKey_Installed);
                    return(Tokenize(strContent, modInfo, user, forceDebug, bRevertToDnn));
                }
            }
            else
            {
                // if it's not installed return string or tokenize with DNN replacer
                if (!bRevertToDnn)
                {
                    return(strContent);
                }
                else
                {
                    DotNetNuke.Services.Tokens.TokenReplace dnnTknRepl = new DotNetNuke.Services.Tokens.TokenReplace();
                    dnnTknRepl.AccessingUser = user ?? DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                    dnnTknRepl.DebugMessages = bDebug;
                    if (modInfo != null)
                    {
                        dnnTknRepl.ModuleInfo = modInfo;
                    }

                    // MyTokens is not installed, execution ends here
                    return(dnnTknRepl.ReplaceEnvironmentTokens(strContent));
                }
            }

            // we have MyTokens installed, proceed to token replacement
            return((string)methodReplace.Invoke(
                       null,
                       new object[] {
                strContent,
                user ?? DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(),
                bDebug,
                modInfo
            }
                       ));
        }
        private void LoadArticle()
        {
            var a = (Article)VersionInfoObject;
            if (a != null)
            {
                //VersionInfoObject.IsNew = false;
                if (a.ArticleText.Trim() == string.Empty)
                {
                    lblArticleText.Text = Localization.GetString("NothingSaved", LocalResourceFile);
                }
                else
                {
                    string articleText = a.ArticleText;
                    //removed until we move forward with a newer version of DNN 4.6.2 or greater.
                    //for enterprise licenses you can uncomment the following if you put the Dotnetnuke.dll (4.6.2+) in the engagepublish/references folder and recompile

                    articleText = Utility.ReplaceTokens(articleText);

                    var tr = new DotNetNuke.Services.Tokens.TokenReplace
                                 {
                                         AccessingUser = UserInfo,
                                         DebugMessages = !DotNetNuke.Common.Globals.IsTabPreview()
                                 };

                    articleText = tr.ReplaceEnvironmentTokens(articleText);
                    lblArticleText.Text = articleText;
                }

            object m = Request.QueryString["modid"];
            if (m != null)
            {
                if (m.ToString() == ModuleId.ToString())
                {
                    //check if module id querystring is current moduleid
                    if ((IsAdmin && !VersionInfoObject.IsNew))
                    {
                        divAdminMenuWrapper.Visible = true;
                        divPublishApprovals.Visible = true;
                        divApprovalStatus.Visible = true;
                        if (UseApprovals && Item.GetItemType(ItemId, PortalId).Equals("ARTICLE", StringComparison.OrdinalIgnoreCase))
                        {
                            FillDropDownList();
                        }
                        else
                        {
                            ddlApprovalStatus.Visible = false;
                        }
                    }
                }
                else
                {
                    divAdminMenuWrapper.Visible = false;
                }
            }
            }
            else
            {
                lblArticleText.Text = Localization.GetString("NothingSaved", LocalResourceFile);
            }
        }