示例#1
0
        private void cbUpgrade_Callback(object sender, Controls.CallBackEventArgs e)
        {
            string upFilePath = Server.MapPath("~/desktopmodules/activeforums/upgrade4x.txt");
            string err        = "Success";

            try
            {
                if (System.IO.File.Exists(upFilePath))
                {
                    string s = Utilities.GetFileContent(upFilePath);
                    err = DotNetNuke.Entities.Portals.PortalSettings.ExecuteScript(s);
                    System.IO.File.Delete(upFilePath);
                }
            }
            catch (Exception ex)
            {
                if (ex is UnauthorizedAccessException && string.IsNullOrEmpty(err))
                {
                    err = "<span style=\"font-size:14px;font-weight:bold;\">The forum data was upgraded successfully, but you must manually delete the following file:<br /><br />" + upFilePath + "<br /><br />The upgrade is not complete until you delete the file indicated above.</span>";
                }
                else
                {
                    err = "<span style=\"font-size:14px;font-weight:bold;\">Upgrade Failed - Please go to the <a href=\"http://www.activemodules.com/community/helpdesk.aspx\">Active Modules Help Desk</a> to report the error indicated below:<br /><br />" + ex.Message + "</span>";
                }
            }
            LiteralControl lit = new LiteralControl();

            if (string.IsNullOrEmpty(err))
            {
                err = "<script type=\"text/javascript\">LoadView('home');</script>";
            }
            lit.Text = err;
            lit.RenderControl(e.Output);
        }
示例#2
0
 public void cbShell_Callback(object sender, Controls.CallBackEventArgs e)
 {
     try
     {
         string sOptions = string.Empty;
         if (e.Parameters[1] != null)
         {
             sOptions = e.Parameters[1];
         }
         GetControl(e.Parameters[0], sOptions, true);
         if (e.Parameters.Length != 3)
         {
             var stringWriter = new System.IO.StringWriter();
             var htmlWriter   = new HtmlTextWriter(stringWriter);
             plhControlPanel.RenderControl(e.Output);
         }
     }
     catch (Exception ex)
     {
         if (Request.QueryString["cptry"] == null)
         {
             string sURL = EditUrl("", "", "EDIT", "cptry=1");
             Response.Redirect(sURL);
         }
         else
         {
             Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
         }
     }
 }
示例#3
0
        private void agTemplates_Callback(object sender, Controls.CallBackEventArgs e)
        {
            int PageIndex = Convert.ToInt32(e.Parameters[0]);
            int PageSize  = Convert.ToInt32(e.Parameters[1]);
            int RowIndex  = 0;

            if (PageIndex == 0)
            {
                RowIndex = 0;
            }
            else
            {
                RowIndex = (((PageIndex + 1) * PageSize) - PageSize);
            }
            agTemplates.Datasource = DataProvider.Instance().Templates_List(PortalId, ModuleId, 0, RowIndex, PageSize);
            agTemplates.Refresh(e.Output);
        }
示例#4
0
 private void cbForumEditor_Callback(object sender, Controls.CallBackEventArgs e)
 {
     try
     {
         string sOptions = string.Empty;
         if (e.Parameters[1] != null)
         {
             sOptions = e.Parameters[1];
         }
         GetControl(e.Parameters[0], sOptions);
         System.IO.StringWriter stringWriter = new System.IO.StringWriter();
         HtmlTextWriter         htmlWriter   = new HtmlTextWriter(stringWriter);
         plhForumEditor.RenderControl(e.Output);
     }
     catch (Exception ex)
     {
     }
 }
示例#5
0
        private void cbModal_Callback(object sender, Controls.CallBackEventArgs e)
        {
            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "load":
                plhModal.Controls.Clear();
                string ctlPath   = string.Empty;
                string ctrl      = e.Parameters[1].ToLowerInvariant();
                string ctlParams = e.Parameters[2].ToLowerInvariant();
                LoadModal(ctrl, ctlParams);
                break;

            case "clear":
                plhModal.Controls.Clear();
                break;
            }
            plhModal.RenderControl(e.Output);
        }
示例#6
0
        private void cbAction_Callback(object sender, Controls.CallBackEventArgs e)
        {
            string sMsg = "";

            switch (e.Parameters[0].ToLower())
            {
            case "save":
            {
                try
                {
                    //save template
                    TemplateInfo       ti = null;
                    TemplateController tc = new TemplateController();
                    int templateId        = 0;
                    if (e.Parameters[1].ToString() != "")
                    {
                        templateId = Convert.ToInt32(e.Parameters[1]);
                        ti         = tc.Template_Get(templateId, PortalId, ModuleId);
                    }
                    else
                    {
                        ti              = new TemplateInfo();
                        ti.IsSystem     = false;
                        ti.TemplateType = (Templates.TemplateTypes)(Convert.ToInt32(e.Parameters[6]));
                        ti.PortalId     = PortalId;
                        ti.ModuleId     = ModuleId;
                    }
                    ti.Title   = e.Parameters[2].ToString();
                    ti.Subject = e.Parameters[3].ToString();
                    if (ti.TemplateType == Templates.TemplateTypes.Email || ti.TemplateType == Templates.TemplateTypes.ModEmail)
                    {
                        ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + Utilities.StripHTMLTag(e.Parameters[5].ToString()) + "</plaintext></template>";
                    }
                    else
                    {
                        ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + string.Empty + "</plaintext></template>";
                    }

                    ti.Template = ti.Template.Replace("[TRESX:", "[RESX:");
                    templateId  = tc.Template_Save(ti);
                    string ckey = ModuleId + templateId + Convert.ToString(Enum.Parse(typeof(Templates.TemplateTypes), ti.TemplateType.ToString()));
                    DataCache.CacheClear(ckey);
                    sMsg = "Template saved successfully!";
                }
                catch (Exception ex)
                {
                    sMsg = "Error saving template.";
                }

                break;
            }

            case "delete":
            {
                try
                {
                    //delete template
                    TemplateInfo       ti = null;
                    TemplateController tc = new TemplateController();
                    int templateid        = 0;
                    if (e.Parameters[1].ToString() != "")
                    {
                        templateid = Convert.ToInt32(e.Parameters[1]);
                        ti         = tc.Template_Get(templateid, PortalId, ModuleId);
                        if (!(ti.IsSystem == true))
                        {
                            tc.Template_Delete(templateid, PortalId, ModuleId);
                            sMsg = "Template deleted successfully!";
                        }
                        else
                        {
                            sMsg = "Enable to delete system templates";
                        }
                    }
                }
                catch (Exception ex)
                {
                    sMsg = "Error deleting template.";
                }

                break;
            }
            }
            cbActionMessage.InnerText = sMsg;
            cbActionMessage.RenderControl(e.Output);
        }
示例#7
0
        private void agCategories_Callback(object sender, Controls.CallBackEventArgs e)
        {
            try
            {
                if (!(e.Parameters[4] == ""))
                {
                    string sAction = e.Parameters[4].Split(':')[0];

                    switch (sAction.ToUpper())
                    {
                    case "DELETE":
                    {
                        int TagId = Convert.ToInt32(e.Parameters[4].Split(':')[1]);
                        if (SimulateIsNumeric.IsNumeric(TagId))
                        {
                            DataProvider.Instance().Tags_Delete(PortalId, ModuleId, TagId);
                        }
                        break;
                    }

                    case "SAVE":
                    {
                        string[] sParams      = e.Parameters[4].Split(':');
                        string   TagName      = sParams[1].Trim();
                        int      TagId        = 0;
                        int      ForumId      = -1;
                        int      ForumGroupId = -1;
                        if (sParams.Length > 2)
                        {
                            TagId = Convert.ToInt32(sParams[2]);
                        }
                        if (sParams[3].Contains("FORUM"))
                        {
                            ForumId = Convert.ToInt32(sParams[3].Replace("FORUM", string.Empty));
                        }
                        if (sParams[3].Contains("GROUP"))
                        {
                            ForumGroupId = Convert.ToInt32(sParams[3].Replace("GROUP", string.Empty));
                        }

                        if (!(TagName == string.Empty))
                        {
                            DataProvider.Instance().Tags_Save(PortalId, ModuleId, TagId, TagName, 0, 0, 0, -1, true, ForumId, ForumGroupId);
                        }



                        break;
                    }
                    }
                }
                agCategories.DefaultParams = string.Empty;
                int    PageIndex  = Convert.ToInt32(e.Parameters[0]);
                int    PageSize   = Convert.ToInt32(e.Parameters[1]);
                string SortColumn = e.Parameters[2].ToString();
                string Sort       = e.Parameters[3].ToString();
                agCategories.Datasource = DataProvider.Instance().Tags_List(PortalId, ModuleId, true, PageIndex, PageSize, Sort, SortColumn, -1, -1);
                agCategories.Refresh(e.Output);
            }
            catch (Exception ex)
            {
            }
        }
		private void cbSecurityToggle_Callback(object sender, CallBackEventArgs e)
		{
			string action = e.Parameters[0].ToString();
			int pId = PermissionsId;
			string secId = e.Parameters[2].ToString();
			int secType = Convert.ToInt32(e.Parameters[3].ToString());
			string key = e.Parameters[4].ToString();
			string returnId = e.Parameters[5].ToString();
			Data.Common db = new Data.Common();
			string sOut = string.Empty;
			if (action == "delete")
			{
				Permissions.RemoveObjectFromAll(secId, secType, pId);

			}
			else if (action == "addobject")
			{
				if (secType == 1)
				{
					UserController uc = new UserController();
					User ui = uc.GetUser(PortalId, ModuleId, secId);
					if (ui != null)
					{
						secId = ui.UserId.ToString();
					}
					else
					{
						secId = string.Empty;
					}
				}
				else
				{
					if (secId.Contains(":"))
					{
						secType = 2;
					}
				}
				if (! (string.IsNullOrEmpty(secId)))
				{
					string permSet = db.GetPermSet(pId, "View");
					permSet = Permissions.AddPermToSet(secId, secType, permSet);
					db.SavePermSet(pId, "View", permSet);
				}


			}
			else
			{
				string permSet = db.GetPermSet(pId, key);
				if (action == "remove")
				{
					permSet = Permissions.RemovePermFromSet(secId, secType, permSet);
				}
				else
				{
					permSet = Permissions.AddPermToSet(secId, secType, permSet);
				}
				db.SavePermSet(pId, key, permSet);
				sOut = action + "|" + returnId;
			}
			LiteralControl lit = new LiteralControl(sOut);
			lit.RenderControl(e.Output);
		}
示例#9
0
 public void RaiseCallback(object sender, CallBackEventArgs e) // Implements ICallbackEventHandler.RaiseCallback
 {
     OnCallback(e);
 }
示例#10
0
 private void OnCallback(CallBackEventArgs e)
 {
     if (CallbackEvent != null)
         CallbackEvent(this, e);
 }
示例#11
0
        private void handleCB(string[] args)
        {
            try
            {
                if (_validState == 1)
                {
                    using (StringWriter strWriter = new StringWriter())
                    {
                        using (HtmlTextWriter oWriter = new HtmlTextWriter(strWriter, string.Empty))
                        {
                            CallBackEventArgs oArgs = new CallBackEventArgs(oWriter) { Parameter = args[0], Parameters = args };
                            this.OnCallback(oArgs);
                            oWriter.Close();
                        }
                        Context.Response.Clear();
                        Context.Response.ContentType = "text/xml";
                        Context.Response.Write("<CallbackData><![CDATA[");
                        string sTemp = strWriter.ToString();
                        sTemp = sTemp.Replace("//<![CDATA[", string.Empty);
                        sTemp = sTemp.Replace("//]]>", string.Empty);
                        Context.Response.Write(sTemp);
                    }
                    Context.Response.Write("]]></CallbackData>");
                    //Context.Response.Flush()

                    Context.Response.End();


                    //HttpContext.Current.ApplicationInstance.CompleteRequest()
                }
                else if (_validState == -1)
                {
                    throw new Exception("Incomplete Request");
                }
                //Dim strWriter As New StringWriter()
                //Dim oWriter As New HtmlTextWriter(strWriter, String.Empty)
                //Dim oArgs As New CallBackEventArgs(oWriter)
                //oArgs.Parameter = args(0)
                //oArgs.Parameters = args
                //Me.OnCallback(oArgs)
                //oWriter.Close()
                //Context.Response.Clear()
                //Context.Response.ContentType = "text/xml"
                //Context.Response.Write("<CallbackData><![CDATA[")
                //Dim sTemp As String = strWriter.ToString
                //sTemp = sTemp.Replace("//<![CDATA[", String.Empty)
                //sTemp = sTemp.Replace("//]]>", String.Empty)
                //Context.Response.Write(sTemp)
                //Context.Response.Write("]]></CallbackData>")
                //'Context.Response.Flush()
                //Context.Response.End()
                //'HttpContext.Current.ApplicationInstance.CompleteRequest()
            }
            catch (Exception ex)
            {
                if (!((ex) is System.Threading.ThreadAbortException))
                {
                    Context.Response.Clear();
                    Context.Response.ContentType = "text/xml";
                    Context.Response.Write("<CallbackError><![CDATA[" + ex.ToString() + "]]></CallbackError>");
                    Context.Response.End();
                    //HttpContext.Current.ApplicationInstance.CompleteRequest()
                }
            }
        }
示例#12
0
		private void cb_Callback(object sender, CallBackEventArgs e)
		{
			Data.Topics db = new Data.Topics();
			if (e.Parameters.Length > 0)
			{
				int rate = Convert.ToInt32(e.Parameter);
				if (rate >= 1 && rate <= 5)
				{
					RatingValue = db.Topics_AddRating(TopicId, UserId, rate, string.Empty, HttpContext.Current.Request.UserHostAddress.ToString());
				}
			}

			CallBackContent cbContent = new CallBackContent();
			cbContent.Controls.Add(new LiteralControl(RenderRating()));
			cb.Content = cbContent;
			cb.Content.RenderControl(e.Output);
		}
		private void cbSecGrid_Callback(object sender, CallBackEventArgs e)
		{
			BuildNewGrid(Perms, PermissionsId);
			litSecGrid.RenderControl(e.Output);
		}
        private void cbEditorAction_Callback(object sender, Controls.CallBackEventArgs e)
        {
            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "forumsave":
            {
                var fi     = new Forum();
                var fc     = new ForumController();
                var bIsNew = false;
                int forumGroupId;
                var forumSettingsKey = string.Empty;

                if (Utilities.SafeConvertInt(e.Parameters[1]) <= 0)
                {
                    bIsNew     = true;
                    fi.ForumID = -1;
                }
                else
                {
                    fi = fc.Forums_Get(PortalId, ModuleId, Utilities.SafeConvertInt(e.Parameters[1]), UserId, false, false, -1);
                    forumSettingsKey = fi.ForumSettingsKey;
                }

                fi.ModuleId = ModuleId;
                fi.PortalId = PortalId;
                var sParentValue  = e.Parameters[2];
                var parentForumId = 0;

                if (sParentValue.Contains("GROUP"))
                {
                    sParentValue = sParentValue.Replace("GROUP", string.Empty);
                    forumGroupId = Utilities.SafeConvertInt(sParentValue);
                }
                else
                {
                    parentForumId = Utilities.SafeConvertInt(sParentValue.Replace("FORUM", string.Empty));
                    forumGroupId  = fc.Forums_GetGroupId(parentForumId);
                }

                fi.ForumGroupId  = forumGroupId;
                fi.ParentForumId = parentForumId;
                fi.ForumName     = e.Parameters[3];
                fi.ForumDesc     = e.Parameters[4];
                fi.Active        = Utilities.SafeConvertBool(e.Parameters[5]);
                fi.Hidden        = Utilities.SafeConvertBool(e.Parameters[6]);

                fi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                var fkey = string.IsNullOrEmpty(fi.ForumSettingsKey) ? string.Empty : fi.ForumSettingsKey;

                if (Utilities.SafeConvertBool(e.Parameters[8]))
                {
                    var fgc = new ForumGroupController();
                    var fgi = fgc.GetForumGroup(ModuleId, forumGroupId);

                    if (bIsNew)
                    {
                        fi.PermissionsId = fgi.PermissionsId;
                    }
                    else if (fi.ForumSettingsKey != "G:" + forumGroupId)
                    {
                        fi.PermissionsId = fgi.PermissionsId;
                    }

                    fi.ForumSettingsKey = "G:" + forumGroupId;
                }
                else if (bIsNew || fkey.Contains("G:"))
                {
                    fi.ForumSettingsKey = string.Empty;
                    if (fi.InheritSecurity)
                    {
                        fi.PermissionsId = -1;
                    }
                }
                else
                {
                    fi.ForumSettingsKey = "F:" + fi.ForumID;
                }

                if (forumSettingsKey != fkey && fkey.Contains("F:"))
                {
                    bIsNew = true;
                }

                fi.PrefixURL = e.Parameters[9];
                if (!(string.IsNullOrEmpty(fi.PrefixURL)))
                {
                    var db = new Data.Common();
                    if (!(db.CheckForumURL(PortalId, ModuleId, fi.PrefixURL, fi.ForumID, fi.ForumGroupId)))
                    {
                        fi.PrefixURL = string.Empty;
                    }
                }

                var forumId = fc.Forums_Save(PortalId, fi, bIsNew, Utilities.SafeConvertBool(e.Parameters[8]));
                recordId = forumId;
                var securityKey = string.Empty;

                DataCache.ClearForumGroupsCache(ModuleId);

                var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                DataCache.CacheClear(cachekey);

                cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);

                hidEditorResult.Value = forumId.ToString();
                break;
            }

            case "groupsave":
            {
                var bIsNew  = false;
                var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                var fgc     = new ForumGroupController();
                var gi      = (groupId > 0) ? fgc.Groups_Get(ModuleId, groupId) : new ForumGroupInfo();

                var securityKey = string.Empty;
                if (groupId == 0)
                {
                    bIsNew = true;
                }
                else
                {
                    securityKey = "G:" + groupId;
                }

                gi.ModuleId     = ModuleId;
                gi.ForumGroupId = groupId;
                gi.GroupName    = e.Parameters[3];
                gi.Active       = Utilities.SafeConvertBool(e.Parameters[5]);
                gi.Hidden       = Utilities.SafeConvertBool(e.Parameters[6]);

                gi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                gi.PrefixURL = e.Parameters[9];
                if (!(string.IsNullOrEmpty(gi.PrefixURL)))
                {
                    var db = new Data.Common();
                    if (!(db.CheckGroupURL(PortalId, ModuleId, gi.PrefixURL, gi.ForumGroupId)))
                    {
                        gi.PrefixURL = string.Empty;
                    }
                }

                gi.GroupSettingsKey = securityKey;
                var gc = new ForumGroupController();
                groupId  = gc.Groups_Save(PortalId, gi, bIsNew);
                recordId = groupId;

                DataCache.ClearForumGroupsCache(ModuleId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                hidEditorResult.Value = groupId.ToString();

                break;
            }

            case "forumsettingssave":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                var sKey    = "F:" + forumId;
                SaveSettings(sKey, e.Parameters);

                hidEditorResult.Value = forumId.ToString();
                DataCache.CacheClear(forumId.ToString() + "ForumSettings");
                DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId));
                DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId) + "st");
                var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                DataCache.CacheClear(cachekey);
                break;
            }

            case "groupsettingssave":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                var sKey    = "G:" + forumId;
                SaveSettings(sKey, e.Parameters);

                hidEditorResult.Value = forumId.ToString();
                DataCache.CacheClear(forumId.ToString() + "GroupSettings");
                DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId));
                DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId) + "st");

                break;
            }

            case "deleteforum":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                DataProvider.Instance().Forums_Delete(PortalId, ModuleId, forumId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                break;
            }

            case "deletegroup":
            {
                var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                DataProvider.Instance().Groups_Delete(ModuleId, groupId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                break;
            }
            }

            DataCache.CacheClear(string.Format(CacheKeys.ForumList, ModuleId));
            DataCache.ClearAllForumSettingsCache(ModuleId);
            DataCache.CacheClear(ModuleId + "fv");

            hidEditorResult.RenderControl(e.Output);
        }
示例#15
0
 protected virtual void OnCallback(CallBackEventArgs e)
 {
     if (Callback != null)
         Callback(cb, e);
 }
示例#16
0
        private void cbPreview_Callback(object sender, CallBackEventArgs e)
        {
            switch (e.Parameters[0].ToLower())
            {
                case "preview":
                    var message = e.Parameters[1];

                    var topicTemplateID = ForumInfo.TopicTemplateId;
                    message = Utilities.CleanString(PortalId, message, _allowHTML, _editorType, ForumInfo.UseFilter, ForumInfo.AllowScript, ForumModuleId, ImagePath, ForumInfo.AllowEmoticons);
                    message = Utilities.ManageImagePath(message);
                    var uc = new UserController();
                    var up = uc.GetUser(PortalId, ForumModuleId, UserId) ?? new User
                                                                                {
                                                                                    UserId = -1,
                                                                                    UserName = "******",
                                                                                    Profile = {TopicCount = 0, ReplyCount = 0},
                                                                                    DateCreated = DateTime.Now
                                                                                };
                    message = TemplateUtils.PreviewTopic(topicTemplateID, PortalId, ForumModuleId, ForumTabId, ForumInfo, UserId, message, ImagePath, up, DateTime.Now, CurrentUserType, UserId, TimeZoneOffset);
                    hidPreviewText.Value = message;
                    break;
            }
            hidPreviewText.RenderControl(e.Output);
        }
示例#17
0
 public void RaiseCallback(object sender, CallBackEventArgs e) // Implements ICallbackEventHandler.RaiseCallback
 {
     OnCallback(e);
 }