コード例 #1
0
ファイル: setp.aspx.cs プロジェクト: xslonglianxia/DiscuzNT
        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);
        }
コード例 #2
0
ファイル: Spaces.cs プロジェクト: terryxym/DiscuzNT
        /// <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);
        }