public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state)
		{
			if (args.Count != 1)
				throw new InstructionExecutionException("An argument was expected specifying which category code to use to load.", contextToken);
			object o = args[0].Expression.Evaluate(state, args[0].Token);
			if(o == null)
				throw new InstructionExecutionException("The specified argument equates to null. It needs to equate to the forum's category code.", args[0].Token);
			ForumCategory cat = ForumHandler.DataLayer.SelectForumCategoryByCode(o.ToString());
			if(cat == null)
				throw new InstructionExecutionException("The specified argument equates to \"" + o + "\", which is not an existing category code.", args[0].Token);
			Forum forum = new Forum(0, cat.ForumCategoryID, "", "Untitled Forum", "", "", SprocketDate.Now, null,
				Forum.AccessType.ActivatedMembers, Forum.AccessType.ActivatedMembers, Forum.AccessType.AllMembers, null, null, null, null,
				Forum.MarkupType.None, true, true, false, false, false, Forum.DisplayOrderType.TopicLastMessageDate, false);
			return forum;
		}
		void SaveForumSettings()
		{
			if (!SecurityProvider.CurrentUser.HasPermission(ForumPermissionType.ForumCreator))
				throw new Exception("You don't have permission to create, edit or delete forums.");

			Forum forum;
			ForumCategory cat;

			long forumID = long.Parse(Request.Form["forumid"]);
			string categoryCode = Request.Form["categorycode"];

			cat = DataLayer.SelectForumCategoryByCode(categoryCode);
			if (cat == null)
			{
				cat = new ForumCategory(DatabaseManager.GetUniqueID(), SecurityProvider.ClientSpaceID,
					categoryCode, categoryCode, null, SprocketDate.Now, 0, false);
				DataLayer.Store(cat);
			}

			if (forumID == 0)
			{
				forum = new Forum();
				forum.ForumID = DatabaseManager.GetUniqueID();
			}
			else
				forum = dataLayer.SelectForum(forumID);
			if (forum == null)
				return;

			forum.Name = Request.Form["forum-name"].Trim();
			if (forum.Name == "") forum.Name = "Untitled Forum";
			forum.URLToken = Request.Form["url-token"].Trim();
			if (forum.URLToken == "") forum.URLToken = forum.ForumID.ToString();
			forum.ForumCode = Request.Form["forum-code"].Trim();
			forum.ForumCategoryID = cat.ForumCategoryID;
			forum.TopicDisplayOrder = short.Parse(Request.Form["topic-display-order"]);
			forum.MarkupLevel = short.Parse(Request.Form["markuplevel"]);

			string postAccess = Request.Form["post-access"];
			string replyAccess = Request.Form["reply-access"];
			string readAccess = Request.Form["read-access"];

			if (postAccess.StartsWith("_"))
			{
				forum.PostWriteAccess = short.Parse(postAccess.Substring(1));
				forum.PostWriteAccessRoleID = null;
			}
			else
			{
				forum.PostNewTopics = Forum.AccessType.RoleMembers;
				forum.PostWriteAccessRoleID = long.Parse(postAccess);
			}

			if (replyAccess.StartsWith("_"))
			{
				forum.ReplyWriteAccess = short.Parse(replyAccess.Substring(1));
				forum.ReplyWriteAccessRoleID = null;
			}
			else
			{
				forum.WriteReplies = Forum.AccessType.RoleMembers;
				forum.ReplyWriteAccessRoleID = long.Parse(replyAccess);
			}

			if (readAccess.StartsWith("_"))
			{
				forum.ReadAccess = short.Parse(readAccess.Substring(1));
				forum.ReadAccessRoleID = null;
			}
			else
			{
				forum.Read = Forum.AccessType.RoleMembers;
				forum.ReadAccessRoleID = long.Parse(readAccess);
			}

			forum.ModeratorRoleID = long.Parse(Request.Form["moderator-role"]);
			forum.RequireModeration = Request.Form["requires-moderation"] == "1";
			forum.AllowVoting = Request.Form["allow-voting"] == "1";
			forum.AllowImagesInMessages = Request.Form["message-images"] == "1";
			forum.ShowSignatures = Request.Form["show-signatures"] == "1";
			forum.AllowImagesInSignatures = Request.Form["signature-images"] == "1";
			forum.Locked = Request.Form["lock-forum"] == "1";
			forum.DateCreated = SprocketDate.Now;

			Result r = dataLayer.Store(forum);
			if (!r.Succeeded)
				throw new Exception(r.Message);
		}
示例#3
0
 public ForumSummary(IDataReader reader)
 {
     if (reader["AuthorUsername"] != DBNull.Value) authorUsername = (string)reader["AuthorUsername"];
     if (reader["TopicCount"] != DBNull.Value) topicCount = (int)reader["TopicCount"];
     if (reader["ReplyCount"] != DBNull.Value) replyCount = (int)reader["ReplyCount"];
     if (reader["LastReplyTime"] != DBNull.Value) lastReplyTime = (DateTime)reader["LastReplyTime"];
     forum = new Forum(reader);
 }
示例#4
0
 public Forum Clone()
 {
     Forum copy = new Forum();
     copy.forumID = forumID;
     copy.forumCategoryID = forumCategoryID;
     copy.forumCode = forumCode;
     copy.name = name;
     copy.description = description;
     copy.uRLToken = uRLToken;
     copy.dateCreated = dateCreated;
     copy.rank = rank;
     copy.postWriteAccess = postWriteAccess;
     copy.replyWriteAccess = replyWriteAccess;
     copy.readAccess = readAccess;
     copy.postWriteAccessRoleID = postWriteAccessRoleID;
     copy.replyWriteAccessRoleID = replyWriteAccessRoleID;
     copy.readAccessRoleID = readAccessRoleID;
     copy.moderatorRoleID = moderatorRoleID;
     copy.markupLevel = markupLevel;
     copy.showSignatures = showSignatures;
     copy.allowImagesInMessages = allowImagesInMessages;
     copy.allowImagesInSignatures = allowImagesInSignatures;
     copy.requireModeration = requireModeration;
     copy.allowVoting = allowVoting;
     copy.topicDisplayOrder = topicDisplayOrder;
     copy.locked = locked;
     return copy;
 }
示例#5
0
        public void SetMessage(string text, Forum.MarkupType markupType)
        {
            bodySource = text;
            switch (markupType)
            {
                case Forum.MarkupType.None:
                    bodyOutput = HttpUtility.HtmlEncode(text)
                        .Replace(Environment.NewLine, "<br/>")
                        .Replace("\n", "<br/>")
                        ;
                    break;

                default:
                    bodyOutput = text;
                    break;
            }
        }
示例#6
0
 public ForumTopicMessage(long forumTopicMessageID, long forumTopicID, long? authorUserID, string authorName, DateTime dateCreated, string bodySource, ForumModerationState moderationState, Forum.MarkupType markupType)
 {
     this.forumTopicMessageID = forumTopicMessageID;
     this.forumTopicID = forumTopicID;
     this.authorUserID = authorUserID;
     this.authorName = authorName;
     this.dateCreated = dateCreated;
     this.bodySource = bodySource;
     this.moderationState = (short)moderationState;
     this.markupType = (short)markupType;
     SetMessage(bodySource, markupType);
 }