Beispiel #1
0
		public static string TopicLink(int tabId, int moduleId, TopicInfo ti)
		{	
			string sURL;
			var mainSettings = DataCache.MainSettings(moduleId);

			if (string.IsNullOrEmpty(ti.URL) || !mainSettings.URLRewriteEnabled)
			{
				sURL = Utilities.NavigateUrl(tabId, string.Empty, ParamKeys.TopicId + "=" + ti.TopicId);
			}
			else
			{
                var db = new Data.Common();
				sURL = "/" + db.GetUrl(moduleId, -1, -1, ti.TopicId, -1, -1);
			}

			var sHost = Utilities.GetHost();
			if (! (sURL.StartsWith(sHost)))
			{
				if (sHost.EndsWith("/"))
					sHost = sHost.Substring(0, sHost.Length - 1);

				sURL = sHost + sURL;
			}

			return sURL;
		}
Beispiel #2
0
        public static string TopicLink(int tabId, int moduleId, TopicInfo ti)
        {
            string sURL;
            var    mainSettings = DataCache.MainSettings(moduleId);

            if (string.IsNullOrEmpty(ti.URL) || !mainSettings.URLRewriteEnabled)
            {
                sURL = Utilities.NavigateUrl(tabId, string.Empty, ParamKeys.TopicId + "=" + ti.TopicId);
            }
            else
            {
                var db = new Data.Common();
                sURL = "/" + db.GetUrl(moduleId, -1, -1, ti.TopicId, -1, -1);
            }

            var sHost = Utilities.GetHost();

            if (!(sURL.StartsWith(sHost)))
            {
                if (sHost.EndsWith("/"))
                {
                    sHost = sHost.Substring(0, sHost.Length - 1);
                }

                sURL = sHost + sURL;
            }

            return(sURL);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            User forumUser = null;

            if (string.IsNullOrEmpty(ForumIds))
            {
                UserController uc = new UserController();
                forumUser = uc.GetUser(PortalId, ModuleId);
                if (string.IsNullOrEmpty(forumUser.UserForums))
                {
                    ForumController fc = new ForumController();
                    ForumIds = fc.GetForumsForUser(forumUser.UserRoles, PortalId, ModuleId);
                }
                else
                {
                    ForumIds = forumUser.UserForums;
                }
            }
            SettingsInfo _mainSettings = DataCache.MainSettings(ModuleId);

            Data.Common  db       = new Data.Common();
            IDataReader  dr       = db.TagCloud_Get(PortalId, ModuleId, ForumIds, TagCount);
            ControlUtils ctlUtils = new ControlUtils();
            string       sURL     = string.Empty;

            while (dr.Read())
            {
                int    priority = 1;
                string tagName  = string.Empty;
                string css      = string.Empty;
                priority = int.Parse(dr["Priority"].ToString());
                tagName  = dr["TagName"].ToString();
                switch (priority)
                {
                case 1:
                    css = CSSOne;
                    break;

                case 2:
                    css = CSSTwo;
                    break;

                case 3:
                    css = CSSThree;
                    break;
                }
                writer.Write("<span class=\"" + css + "\">");
                writer.Write("<a href=\"");
                sURL = ctlUtils.BuildUrl(TabId, ModuleId, string.Empty, string.Empty, -1, -1, int.Parse(dr["TagID"].ToString()), -1, Utilities.CleanName(tagName), 1, -1, -1);
                writer.Write(sURL);
                writer.Write("\" title=\"" + HttpUtility.HtmlAttributeEncode(tagName) + "\">" + tagName + "</a></span> ");
            }
            dr.Close();
            dr.Dispose();
        }
Beispiel #4
0
        protected override void Render(HtmlTextWriter writer)
        {
            string sHeaderTemplate = string.Empty;
            string sFooterTemplate = string.Empty;

            if (HeaderTemplate != null)
            {
                sHeaderTemplate = HeaderTemplate.Text;
            }
            if (FooterTemplate != null)
            {
                sFooterTemplate = FooterTemplate.Text;
            }
            string sTemplate = "[DISPLAYNAME]";

            Data.Common db = new Data.Common();
            IDataReader dr = db.TopMembers_Get(SiteId, Rows);

            if (ItemTemplate != null)
            {
                sTemplate = ItemTemplate.Text;
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (string.IsNullOrEmpty(CssClass))
            {
                CssClass = "aflist2";
            }
            while (dr.Read())
            {
                string sOut = sTemplate;
                sOut = sOut.Replace("[DISPLAYNAME]", dr["DisplayName"].ToString());
                sb.Append(sOut);
            }
            dr.Close();
            dr.Dispose();
            if (!(string.IsNullOrEmpty(sb.ToString())))
            {
                writer.Write(sHeaderTemplate);
                writer.Write(sb.ToString());
                writer.Write(sFooterTemplate);
            }
        }
Beispiel #5
0
        public static string ReplyLink(int tabId, TopicInfo ti, int userId, int replyId)
        {
            var sURL = Utilities.NavigateUrl(tabId, string.Empty, new [] { ParamKeys.TopicId + "=" + ti.TopicId, ParamKeys.ContentJumpId + "=" + replyId });

            if (string.IsNullOrEmpty(ti.URL) || !Utilities.IsRewriteLoaded())
            {
                return(sURL);
            }

            var db = new Data.Common();

            sURL = db.GetUrl(-1, -1, -1, ti.TopicId, userId, replyId);
            if (!(string.IsNullOrEmpty(sURL)))
            {
                var sHost = Utilities.GetHost();
                if (sURL.StartsWith("/"))
                {
                    sURL = sURL.Substring(1);
                }

                if (!(sHost.EndsWith("/")))
                {
                    sHost += "/";
                }

                sURL = sHost + sURL;
                if (!(sURL.EndsWith("/")))
                {
                    sURL += "/";
                }

                if (replyId > 0)
                {
                    sURL += "#" + replyId.ToString();
                }
            }

            return(sURL);
        }
        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);
        }
Beispiel #7
0
        private void LoadData(int pageId)
        {
            // Get our page size
            _pageSize = OptPageSize;
            if(_pageSize <= 0)
            {
                _pageSize = UserId > 0 ? UserDefaultPageSize : MainSettings.PageSize;
                if (_pageSize < 5)
                    _pageSize = 10;
            }

            // If we are in print mode, set the page size to maxValue
            if (!string.IsNullOrWhiteSpace(Request.QueryString["dnnprintmode"]))
                _pageSize = int.MaxValue;

            // If our pagesize is maxvalue, we can only have one page
            if (_pageSize == int.MaxValue)
                pageId = 1;

            // Get our Row Index
            _rowIndex = (pageId - 1) * _pageSize;

            var ds = DataProvider.Instance().UI_TopicView(PortalId, ModuleId, ForumId, TopicId, UserId, _rowIndex, _pageSize, UserInfo.IsSuperUser, _defaultSort);

            // Test for a proper dataset
            if (ds.Tables.Count < 4 || ds.Tables[0].Rows.Count == 0 || ds.Tables[1].Rows.Count == 0)
                Response.Redirect(Utilities.NavigateUrl(TabId));

            // Load our values
            _drForum = ds.Tables[0].Rows[0];
            _drSecurity = ds.Tables[1].Rows[0];
            _dtTopic = ds.Tables[2];
            _dtAttach = ds.Tables[3];

            // If we don't have any rows to display, redirect
            if (_dtTopic.Rows.Count == 0)
            {
                if(pageId > 1)
                {
                    if (MainSettings.UseShortUrls)
                        Response.Redirect(Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.TopicId + "=" + TopicId }), true);
                    else
                        Response.Redirect(Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId }), true);
                }
                else
                {
                    if (MainSettings.UseShortUrls)
                        Response.Redirect(Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ForumId + "=" + ForumId }), true);
                    else
                        Response.Redirect(Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topics }), true);
                }
            }

            // first make sure we have read permissions, otherwise we need to redirect
            _bRead = Permissions.HasPerm(_drSecurity["CanRead"].ToString(), ForumUser.UserRoles);

            if(!_bRead)
            {
                var settings = Entities.Portals.PortalController.GetCurrentPortalSettings();
                if (settings.LoginTabId > 0)
                    Response.Redirect(Common.Globals.NavigateURL(settings.LoginTabId, "", "returnUrl=" + Request.RawUrl), true);
                else
                    Response.Redirect(Utilities.NavigateUrl(TabId, "", "ctl=login&returnUrl=" + Request.RawUrl), true);
            }

            //bCreate = Permissions.HasPerm(drSecurity["CanCreate"].ToString(), ForumUser.UserRoles);
            _bEdit = Permissions.HasPerm(_drSecurity["CanEdit"].ToString(), ForumUser.UserRoles);
            _bDelete = Permissions.HasPerm(_drSecurity["CanDelete"].ToString(), ForumUser.UserRoles);
            //bReply = Permissions.HasPerm(drSecurity["CanReply"].ToString(), ForumUser.UserRoles);
            //bPoll = Permissions.HasPerm(_drSecurity["CanPoll"].ToString(), ForumUser.UserRoles);
            _bAttach = Permissions.HasPerm(_drSecurity["CanAttach"].ToString(), ForumUser.UserRoles);
            _bSubscribe = Permissions.HasPerm(_drSecurity["CanSubscribe"].ToString(), ForumUser.UserRoles);
            // bModMove = Permissions.HasPerm(_drSecurity["CanModMove"].ToString(), ForumUser.UserRoles);
            // bModSplit = Permissions.HasPerm(_drSecurity["CanModSplit"].ToString(), ForumUser.UserRoles);
            _bModDelete = Permissions.HasPerm(_drSecurity["CanModDelete"].ToString(), ForumUser.UserRoles);
            _bModApprove = Permissions.HasPerm(_drSecurity["CanModApprove"].ToString(), ForumUser.UserRoles);
            _bTrust = Permissions.HasPerm(_drSecurity["CanTrust"].ToString(), ForumUser.UserRoles);
            _bModEdit = Permissions.HasPerm(_drSecurity["CanModEdit"].ToString(), ForumUser.UserRoles);

            _isTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ForumUser.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles));

            _forumName = _drForum["ForumName"].ToString();
            _groupName = _drForum["GroupName"].ToString();
            ForumGroupId = Utilities.SafeConvertInt(_drForum["ForumGroupId"]);
            _topicTemplateId = Utilities.SafeConvertInt(_drForum["TopicTemplateId"]);
            _bAllowRSS = Utilities.SafeConvertBool(_drForum["AllowRSS"]);
            _bLocked = Utilities.SafeConvertBool(_drForum["IsLocked"]);
            _topicType = Utilities.SafeConvertInt(_drForum["TopicType"]);
            _statusId = Utilities.SafeConvertInt(_drForum["StatusId"]);
            _topicSubject = _drForum["Subject"].ToString();
            _topicDescription = Utilities.StripHTMLTag(_drForum["Body"].ToString());
            _tags = _drForum["Tags"].ToString();
            _viewCount = Utilities.SafeConvertInt(_drForum["ViewCount"]);
            _replyCount = Utilities.SafeConvertInt(_drForum["ReplyCount"]);
            _topicAuthorId = Utilities.SafeConvertInt(_drForum["AuthorId"]);
            _topicAuthorDisplayName = _drForum["TopicAuthor"].ToString();
            _topicRating = Utilities.SafeConvertInt(_drForum["TopicRating"]);
            _allowHTML = Utilities.SafeConvertBool(_drForum["AllowHTML"]);
            _allowScript = Utilities.SafeConvertBool(_drForum["AllowScript"]);
            _rowCount = Utilities.SafeConvertInt(_drForum["ReplyCount"]) + 1;
            _nextTopic = Utilities.SafeConvertInt(_drForum["NextTopic"]);
            _prevTopic = Utilities.SafeConvertInt(_drForum["PrevTopic"]);
            _lastPostDate = GetDate(Utilities.SafeConvertDateTime(_drForum["LastPostDate"]));
            _lastPostAuthor.AuthorId = Utilities.SafeConvertInt(_drForum["LastPostAuthorId"]);
            _lastPostAuthor.DisplayName = _drForum["LastPostDisplayName"].ToString();
            _lastPostAuthor.FirstName = _drForum["LastPostFirstName"].ToString();
            _lastPostAuthor.LastName = _drForum["LastPostLastName"].ToString();
            _lastPostAuthor.Username = _drForum["LastPostUserName"].ToString();
            _topicURL = _drForum["URL"].ToString();
            _topicDateCreated = Utilities.GetDate(Utilities.SafeConvertDateTime(_drForum["DateCreated"]), ForumModuleId, TimeZoneOffset);
            _topicData = _drForum["TopicData"].ToString();
            _isSubscribedTopic = UserId > 0 && Utilities.SafeConvertInt(_drForum["IsSubscribedTopic"]) > 0;

            if (Page.IsPostBack)
                return;

            // If a content jump id was passed it, we need to calulate a page and then jump to it with an ancor
            // otherwise, we don't need to do anything

            var contentJumpId = Utilities.SafeConvertInt(Request.Params[ParamKeys.ContentJumpId], -1);
            if (contentJumpId < 0)
                return;

            var sTarget = "#" + contentJumpId;

            var sURL = string.Empty;

            if (MainSettings.URLRewriteEnabled && Request.QueryString["asg"] == null && !string.IsNullOrEmpty(_topicURL))
            {
                var db = new Data.Common();
                sURL = db.GetUrl(ModuleId, ForumGroupId, ForumId, TopicId, UserId, contentJumpId);

                if (!(sURL.StartsWith("/")))
                    sURL = "/" + sURL;

                if (!(sURL.EndsWith("/")))
                    sURL += "/";

                sURL += sTarget;
            }

            if (string.IsNullOrEmpty(sURL))
            {
                var @params = new List<string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=" + Views.Topic };
                if (MainSettings.UseShortUrls)
                    @params = new List<string> { ParamKeys.TopicId + "=" + TopicId };

                var intPages = Convert.ToInt32(Math.Ceiling(_rowCount / (double)_pageSize));
                if (intPages > 1)
                    @params.Add(ParamKeys.PageJumpId + "=" + intPages);

                sURL = Utilities.NavigateUrl(TabId, "", @params.ToArray()) + sTarget;
            }

            if (Request.IsAuthenticated)
                Response.Redirect(sURL, true);

            // Not sure why we're doing this.  I assume it may have something to do with search engines - JB
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", sURL);
        }
Beispiel #8
0
		protected override void Render(HtmlTextWriter writer)
		{
			string sHeaderTemplate = string.Empty;
			string sFooterTemplate = string.Empty;
			if (HeaderTemplate != null)
			{
				sHeaderTemplate = HeaderTemplate.Text;
			}
			if (FooterTemplate != null)
			{
				sFooterTemplate = FooterTemplate.Text;
			}
			string sTemplate = "[DISPLAYNAME]";
			Data.Common db = new Data.Common();
			IDataReader dr = db.TopMembers_Get(SiteId, Rows);
			if (ItemTemplate != null)
			{
				sTemplate = ItemTemplate.Text;
			}
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			if (string.IsNullOrEmpty(CssClass))
			{
				CssClass = "aflist2";
			}
			while (dr.Read())
			{
				string sOut = sTemplate;
				sOut = sOut.Replace("[DISPLAYNAME]", dr["DisplayName"].ToString());
				sb.Append(sOut);
			}
			dr.Close();
			dr.Dispose();
			if (! (string.IsNullOrEmpty(sb.ToString())))
			{
				writer.Write(sHeaderTemplate);
				writer.Write(sb.ToString());
				writer.Write(sFooterTemplate);
			}
		}
Beispiel #9
0
		public static string ReplyLink(int tabId, TopicInfo ti, int userId, int replyId)
		{
			var sURL = Utilities.NavigateUrl(tabId, string.Empty, new [] { ParamKeys.TopicId + "=" + ti.TopicId, ParamKeys.ContentJumpId + "=" + replyId });

			if (string.IsNullOrEmpty(ti.URL) || ! Utilities.IsRewriteLoaded())
				return sURL;

            var db = new Data.Common();
			sURL = db.GetUrl(-1, -1, -1, ti.TopicId, userId, replyId);
			if (! (string.IsNullOrEmpty(sURL)))
			{
				var sHost = Utilities.GetHost();
				if (sURL.StartsWith("/"))
					sURL = sURL.Substring(1);

				if (!(sHost.EndsWith("/")))
					sHost += "/";

				sURL = sHost + sURL;
				if (! (sURL.EndsWith("/")))
					sURL += "/";

				if (replyId > 0)
					sURL += "#" + replyId.ToString();
			}

			return sURL;
		}
Beispiel #10
0
 protected override void Render(HtmlTextWriter writer)
 {
     User forumUser = null;
     if (string.IsNullOrEmpty(ForumIds))
     {
         UserController uc = new UserController();
         forumUser = uc.GetUser(PortalId, ModuleId);
         if (string.IsNullOrEmpty(forumUser.UserForums))
         {
             ForumController fc = new ForumController();
             ForumIds = fc.GetForumsForUser(forumUser.UserRoles, PortalId, ModuleId);
         }
         else
         {
             ForumIds = forumUser.UserForums;
         }
     }
     SettingsInfo _mainSettings = DataCache.MainSettings(ModuleId);
     Data.Common db = new Data.Common();
     IDataReader dr = db.TagCloud_Get(PortalId, ModuleId, ForumIds, TagCount);
     ControlUtils ctlUtils = new ControlUtils();
     string sURL = string.Empty;
     while (dr.Read())
     {
         int priority = 1;
         string tagName = string.Empty;
         string css = string.Empty;
         priority = int.Parse(dr["Priority"].ToString());
         tagName = dr["TagName"].ToString();
         switch (priority)
         {
             case 1:
                 css = CSSOne;
                 break;
             case 2:
                 css = CSSTwo;
                 break;
             case 3:
                 css = CSSThree;
                 break;
         }
         writer.Write("<span class=\"" + css + "\">");
         writer.Write("<a href=\"");
         sURL = ctlUtils.BuildUrl(TabId, ModuleId, string.Empty, string.Empty, -1, -1, int.Parse(dr["TagID"].ToString()), -1, Utilities.CleanName(tagName), 1, -1, -1);
         writer.Write(sURL);
         writer.Write("\" title=\"" + HttpUtility.HtmlAttributeEncode(tagName) + "\">" + tagName + "</a></span> ");
     }
     dr.Close();
     dr.Dispose();
 }
		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);
		}