public moregadgets() { if (this.userid < 1) { HttpContext.Current.Response.Redirect(forumurlnopage + "/login.aspx?reurl=space"); return; } GetOnlineUserInfo(); #if NET1 TabInfoCollection tc = Spaces.GetTabInfoCollectionByUserID(this.userid); #else Discuz.Common.Generic.List <TabInfo> tc = Spaces.GetTabInfoCollectionByUserID(this.userid); #endif currentUserSpaceConfig = Spaces.GetSpaceConfigByUserId(this.userid); int defaultTabId = Spaces.GetDefaultTabId(currentUserSpaceConfig, tc); string html = StaticFileProvider.GetContent(templatePath + "moregadgets.htm"); TemplateEngine te = new TemplateEngine(); te.Init(html, templatePath); te.Put("tabid", defaultTabId); te.Put("forumpath", BaseConfigs.GetForumPath); te.Put("config", currentUserSpaceConfig); te.Put("username", this.olusername); te.Put("userid", this.oluserid); te.Put("userkey", oluserkey); te.Put("forumurlnopage", forumurlnopage); double processtime = new TimeSpan(DateTime.Now.Ticks).Subtract(begints).Duration().TotalSeconds; te.Put("processtime", processtime); html = te.MergeTemplate(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(html); HttpContext.Current.Response.End(); }
private void ChangeThemeAction() { int themeid = DNTRequest.GetQueryInt("themeid", 0); string themepath = DNTRequest.GetQueryString("themepath", true); Spaces.SetTheme(this.userid, themeid, themepath); }
/// <summary> /// 设置模块实例 /// </summary> /// <param name="moduleInfo">模块对象</param> /// <returns>模块基类</returns> public static ModuleBase SetModuleBase(ModuleInfo moduleInfo) { ModuleBase desktopModule = new ModuleBase(); if (moduleInfo.ModuleDefID > 0) { // 重构,是否需要缓存? ModuleDefInfo moduleDef = Spaces.GetModuleDefById(moduleInfo.ModuleDefID); try { Type type = Type.GetType(moduleDef.BussinessController, false, true); desktopModule = (ModuleBase)Activator.CreateInstance(type); } catch (Exception ex) { string a = ex.Message; } desktopModule.ModuleDef = moduleDef; //貌似不需要,重构? } desktopModule.Module = moduleInfo; desktopModule.ModuleID = moduleInfo.ModuleID; if (moduleInfo.ModuleType == ModuleType.Local) { string path = BaseConfigs.GetForumPath + "space/modules/" + moduleInfo.ModuleUrl; string modulefilepath = Utils.GetMapPath(path); try { desktopModule.UserPrefCollection = ModuleXmlHelper.LoadUserPrefs(modulefilepath); desktopModule.ModulePref = ModuleXmlHelper.LoadModulePref(modulefilepath); desktopModule.ModuleContent = ModuleXmlHelper.LoadContent(modulefilepath); } catch (Exception ex) { desktopModule.UserPrefCollection = new UserPrefCollection <UserPref>(); desktopModule.ModulePref = new ModulePref(); desktopModule.ModuleContent = new ModuleContent(); desktopModule.ModuleContent.ContentHtml = ex.Message; desktopModule.ModuleContent.Type = ModuleContentType.HtmlInline; } if (desktopModule.UserPrefCollection == null) { desktopModule.UserPrefCollection = new UserPrefCollection <UserPref>(); } if (desktopModule.ModulePref == null) { desktopModule.ModulePref = new ModulePref(); } if (desktopModule.ModuleContent == null) { desktopModule.ModuleContent = new ModuleContent(); desktopModule.ModuleContent.ContentHtml = "模块" + path + "不存在"; desktopModule.ModuleContent.Type = ModuleContentType.HtmlInline; } } return(desktopModule); }
private void ChangeTemplateAction() { int tabid = DNTRequest.GetQueryInt("t", 0); string template = DNTRequest.GetQueryString("template"); TabInfo tab = Spaces.GetTabById(tabid, this.userid); if (tab.UserID != this.userid) { return; } tab.Template = template; Spaces.UpdateTab(tab); }
public ifr() { HttpContext.Current.Response.ContentType = "text/html"; // if (ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost())) // return; // if (userid < 1) // return; string url = DNTRequest.GetQueryString("url"); int mid = DNTRequest.GetQueryInt("mid", 0); int uid = DNTRequest.GetQueryInt("uid", 0); ModuleInfo moduleinfo = Spaces.GetModuleById(mid, uid); if (moduleinfo == null) { return; } if (url != moduleinfo.ModuleUrl) { return; } UserPrefsSaved ups = new UserPrefsSaved(moduleinfo.UserPref); string path = BaseConfigs.GetForumPath + "space/modules/" + url; string modulefilepath = Utils.GetMapPath(path); ModulePref mp = ModuleXmlHelper.LoadModulePref(modulefilepath); ModuleContent mc = ModuleXmlHelper.LoadContent(modulefilepath); #if NET1 UserPrefCollection upc = ModuleXmlHelper.LoadUserPrefs(modulefilepath); #else UserPrefCollection <UserPref> upc = ModuleXmlHelper.LoadUserPrefs(modulefilepath); #endif StringBuilder registScript = new StringBuilder("<script type=\"text/javascript\">"); foreach (UserPref up in upc) { string userprefvalue = ups.GetValueByName(up.Name); userprefvalue = userprefvalue == string.Empty ? up.DefaultValue : userprefvalue; registScript.AppendFormat(PREF_SCRIPT_FORMAT, mid, up.Name, userprefvalue); } registScript.Append(ModuleXmlHelper.GetModuleRequireScript(mp, mc.Type == ModuleContentType.HtmlInline)); registScript.Append("</script>"); string html = string.Format(IFRAME_HTML, registScript.ToString(), mc.ContentHtml, BaseConfigs.GetForumPath); html = html.Replace("__MODULE_ID__", mid.ToString()).Replace("_IG_", "_DS_"); HttpContext.Current.Response.Write(html); HttpContext.Current.Response.End(); }
private void RenameTabAction() { int tabid = DNTRequest.GetQueryInt("t", 0); string tabname = DNTRequest.GetQueryString("rt_" + tabid); tabname = Utils.UrlDecode(tabname); TabInfo tab = Spaces.GetTabById(tabid, this.userid); if (tab.UserID != this.userid) { return; } tab.TabName = tabname; Spaces.UpdateTab(tab); }
/// <summary> /// 更新自定义面板 /// </summary> private void UpdateCustomizePanel() { int moduleid = DNTRequest.GetInt("cp_module_id", 0); string modulecontent = Utils.UrlDecode(DNTRequest.GetString("cp_module_content")); if (moduleid > 0 && modulecontent != string.Empty) { if (Spaces.ExistCustomizePanelContent(moduleid, this.userid)) { Spaces.UpdateCustomizePanelContent(moduleid, this.userid, modulecontent); } else { Spaces.AddCustomizePanelContent(moduleid, this.userid, modulecontent); } } }
private void AddModuleAction() { int tabid = DNTRequest.GetQueryInt("t", 0); int tabModuleCount = Spaces.GetModulesCountByTabId(tabid, this.userid); if (tabModuleCount > 20) { return; } string url = Utils.UrlDecode(DNTRequest.GetQueryString("x")); Random random = new Random(); int col = random.Next(1, 5);//DNTRequest.GetQueryInt("col", 1); TabInfo tab = Spaces.GetTabById(tabid, this.userid); if (tab == null || tab.UserID != this.userid) { return; } int moduledef = 0; if (url.StartsWith("builtin_")) { moduledef = Spaces.GetModuleDefIdByUrl(url); } ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(url); if (moduledef > 0) { mt = ModuleType.Local; } ModuleInfo moduleinfo = new ModuleInfo(); moduleinfo.ModuleID = Spaces.GetNewModuleId(this.userid); moduleinfo.DisplayOrder = 0; moduleinfo.ModuleDefID = moduledef; moduleinfo.ModuleType = mt; moduleinfo.ModuleUrl = url; moduleinfo.PaneName = "pane" + col; moduleinfo.TabID = tabid; moduleinfo.Uid = this.userid; moduleinfo.Val = 6; Spaces.AddModule(moduleinfo); }
private void MoveAction() { string panename = Utils.UrlDecode(DNTRequest.GetQueryString("panename")); string modules_mp = Utils.UrlDecode(DNTRequest.GetQueryString("modules_mp")); if (!Utils.IsNumericArray(modules_mp.Split(','))) { return; } string[] moduleArray = modules_mp.Split(','); int order = 1; foreach (string mid in moduleArray) { Spaces.UpdateModuleOrder(Convert.ToInt32(mid), this.userid, panename, order); order += 2; } }
private void DelModuleAction() { int moduleid = DNTRequest.GetQueryInt("m", 0); if (moduleid == 0) { return; } int tabid = DNTRequest.GetQueryInt("m_" + moduleid + "_t", 0); ModuleInfo moduleinfo = Spaces.GetModuleById(moduleid, this.userid); if (moduleinfo.TabID != tabid || moduleinfo.Uid != this.userid) { return; } ISpaceCommand isc = Spaces.SetModuleBase(moduleinfo); isc.RemoveModule(); }
/// <summary> /// 添加本地模块 /// </summary> /// <param name="moduleUrl">模块地址</param> /// <param name="userId">用户Id</param> /// <param name="tabId">标签Id</param> /// <param name="col">列Id</param> public static void AddLocalModule(string moduleUrl, int userId, int tabId, int col) { TabInfo tab = Spaces.GetTabById(tabId, userId); if (tab == null || tab.UserID != userId) { return; } int moduledef = 0; if (moduleUrl.StartsWith("builtin_")) { moduledef = Spaces.GetModuleDefIdByUrl(moduleUrl); } ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(moduleUrl); if (moduledef > 0) { mt = ModuleType.Local; } if (mt == ModuleType.Remote || mt == ModuleType.Error) { return; } ModuleInfo moduleinfo = new ModuleInfo(); moduleinfo.ModuleID = Spaces.GetNewModuleId(userId); moduleinfo.DisplayOrder = 0; moduleinfo.ModuleDefID = moduledef; moduleinfo.ModuleType = mt; moduleinfo.ModuleUrl = moduleUrl; moduleinfo.PaneName = "pane" + col; moduleinfo.TabID = tabId; moduleinfo.Uid = userId; moduleinfo.Val = 6; Spaces.AddModule(moduleinfo); }
private void AddTabAction() { int tabcount = Spaces.GetTabCountByUserId(this.userid); int maxdisplayorder = DNTRequest.GetQueryInt("mo", 0); if (tabcount >= 5) { return; } TabInfo tabinfo = new TabInfo(); tabinfo.TabID = Spaces.GetNewTabId(this.userid); tabinfo.DisplayOrder = maxdisplayorder; tabinfo.TabName = "新建页面"; tabinfo.Template = "template_33_33_33.htm"; tabinfo.UserID = this.userid; Spaces.AddTab(tabinfo); //清除config中的默认页面,交给spacepage去处理 Spaces.ClearDefaultTab(this.userid); }
protected override void OnInit(EventArgs e) { //tabid先取config,找到defaulttab,检测defaulttab是否属于这个用户,是就用,不是就取这个用户的tab的最后一个,module必须==1 int module = DNTRequest.GetQueryInt("module", 0); if (module != 1) { return; } string url = DNTRequest.GetQueryString("url"); SpaceConfigInfo spaceconfig = Spaces.GetSpaceConfigByUserId(this.userid); //改为始终为第一是默认,因此需要传递tabid int tabid = DNTRequest.GetInt("tab", 0); #if NET1 TabInfoCollection usertabs = Spaces.GetTabInfoCollectionByUserID(this.userid); #else List <TabInfo> usertabs = Spaces.GetTabInfoCollectionByUserID(this.userid); #endif tabid = IsUserTab(tabid, usertabs) ? tabid : 0; if (tabid == 0) { tabid = usertabs[usertabs.Count - 1].TabID; } TabInfo tab = Spaces.GetTabById(tabid, this.userid); if (tab == null || tab.UserID != this.userid) { return; } int moduledef = 0; string modulepath = BaseConfigs.GetForumPath + "/space/modules/"; if (url.StartsWith("builtin_")) { string file = Utils.GetMapPath(modulepath + url); if (File.Exists(file)) { moduledef = Spaces.GetModuleDefIdByUrl(url); } else { string errmsg = "alert(\"模块文件不存在\")"; ResponseXML(errmsg); return; } } if (moduledef > 0) { ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(url); //异常或者远程,返回xml说未知模块或不支持的模块 if (mt == ModuleType.Error || mt == ModuleType.Remote) { string errmsg = "alert(\"未知模块或不支持的模块\")"; ResponseXML(errmsg); return; } } ResponseXML(string.Format("_add_m(\"x={0}&action=addmodule&t={1}\")", Utils.UrlEncode(url), tabid)); }
public override Common.Generic.List <Discuz.Entity.SpacePostInfo> GetSpacePostsWithSameTag(int tagid, int pageid, int tpp) { return(Spaces.GetSpacePostsWithSameTag(tagid, pageid, tpp)); }
public override int GetSpacePostCountWithSameTag(int tagid) { return(Spaces.GetSpacePostCountWithSameTag(tagid)); }
protected override void OnUserDeleted(int userid) { Spaces.DeleteSpace(userid); }
public setp() { // if (ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost())) // return; string url = DNTRequest.GetString("url"); //choose tab if (userid < 1) { return; } int ct = DNTRequest.GetInt("ct", 0); //choose tab int dt = DNTRequest.GetInt("dt", 0); //delete tab string mt = DNTRequest.GetString("mt"); //move module to tab if (ct > 0) { Spaces.SetDefaultTab(this.userid, ct); } if (dt > 0) { TabInfo tabinfo = Spaces.GetTabById(dt, this.userid); if (tabinfo.UserID == this.userid) { Spaces.DeleteTabById(dt, this.userid); } } if (mt != "") { string[] moduleTab = mt.Split(':'); if (moduleTab.Length != 2) { return; } if (!Utils.IsNumeric(moduleTab[0]) || !Utils.IsNumeric(moduleTab[1])) { return; } Spaces.MoveModule(Utils.StrToInt(moduleTab[0], 0), this.userid, Utils.StrToInt(moduleTab[1], 0)); } string action = DNTRequest.GetString("action"); if (ct == 0 && dt == 0 && mt == "") { switch (action) { case "move": MoveAction(); break; case "renametab": RenameTabAction(); break; case "addtab": AddTabAction(); break; case "changetheme": ChangeThemeAction(); break; case "changetemplate": ChangeTemplateAction(); break; case "addmodule": AddModuleAction(); break; case "delmodule": DelModuleAction(); break; case "updatecustomizepanel": UpdateCustomizePanel(); break; default: DefaultAction(); break; } } // if (action != "renametab" && mt == "") // HttpContext.Current.Response.Redirect(DNTRequest.GetUrlReferrer()); if (url != "") { HttpContext.Current.Response.Redirect(url); } }
private void DefaultAction() { // string url = HttpContext.Current.Request.QueryString["url"].ToString(); // string et = HttpContext.Current.Request.QueryString["et"].ToString(); // string source = HttpContext.Current.Request.QueryString["source"].ToString(); // string pid = HttpContext.Current.Request.QueryString["pid"].ToString(); // string ap = HttpContext.Current.Request.QueryString["ap"].ToString(); // string prefid = HttpContext.Current.Request.QueryString["prefid"].ToString(); int mid = DNTRequest.GetQueryInt("mid", 0); /* * int tabid = DNTRequest.GetQueryInt("m_" + mid + "_t", 0); * TabInfo tab = Spaces.GetTabById(tabid); * if (tab == null || tab.UserID != userid) * { * //非本人模块不可修改 * return; * } */ // string host = HttpContext.Current.Request.QueryString["host"].ToString(); // string h1 = HttpContext.Current.Request.QueryString["h1"].ToString(); // string upPrefix = "m_" + mid + "_up_"; // // Hashtable ht = new Hashtable(); // NameValueCollection nvc = Request.QueryString; // foreach (string s in nvc.Keys) // { // if (s.StartsWith(upPrefix)) // { // ht.Add(s.Replace(upPrefix, string.Empty), nvc[s]); // } // } ModuleInfo module = Spaces.GetModuleById(mid, this.userid); /* if (module == null || module.TabID != tabid) * { * return; * } */ if (module == null || module.Uid != this.userid) { return; } // ModuleBase desktopModule = new ModuleBase(); // //create instance accord to the moduledef // if (module.ModuleDefID > 0) // { // ModuleDefInfo md = Spaces.GetModuleDefByID(module.ModuleDefID); // desktopModule = (ModuleBase)GetInstance(md.BussinessController); // desktopModule.ModuleDef = md; // // // // // //get module xml and isremote //// if (module.ModuleUrl.StartsWith("http://")) //// { //// desktopModule.IsRemote = true; //// } // // //can not support remote module yet. // // // } // desktopModule.Module = module; //SpaceConfigInfo config = Spaces.GetSpaceConfigByUserId(this.userid); ModuleBase desktopModule = Spaces.SetModuleBase(module); desktopModule.UserID = this.userid; //desktopModule.SpaceConfig = config; ISpaceCommand command = desktopModule; command.GetModulePost(HttpContext.Current); }