示例#1
0
        public virtual bool AddNewSubForum(String subject, Member m)
        {
            if (m != null && !this.Members.Contains(m))
            {
                return(false);                             // the wanna be moderator is not register
            }
            for (int i = 0; i < this.SubForum.Count; i++)
            {
                if (this.SubForum.ElementAt(i).Name.Equals(subject))
                {
                    return(false);
                }
            }
            SubForum s = new SubForum(subject);

            this.SubForum.Add(s);  // new sub forum include subject and moderator

            if (m != null)
            {
                return(this.promoteMemberToModerate(m, s));
            }
            else
            {
                return(true);
            }
        }
示例#2
0
        public virtual bool IsContain(Post p)
        {
            bool found = false;

            for (int i = 0; i < SubForum.Count && !found; i++)
            {
                found = SubForum.ElementAt(i).IsContain(p);
            }
            return(found);
        }
示例#3
0
 public SubForum GetBySubForumID(Guid p)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         ICriteria cr      = session.CreateCriteria(typeof(SubForum));
         ICriteria cr2     = cr.Add(Restrictions.Eq("Id", p));
         SubForum  product = cr2.UniqueResult <SubForum>();
         return(product);
     }
 }
示例#4
0
 public virtual SubForum GetSubForumByName(String name)
 {
     for (int i = 0; i < SubForum.Count; i++)
     {
         if (SubForum.ElementAt(i).Name.Equals(name))
         {
             return(SubForum.ElementAt(i));
         }
     }
     return(null);
 }
示例#5
0
        public virtual bool promoteMemberToModerate(Member m, SubForum b)
        {
            if (this.Members.Contains(m) && this.policy.CanBeModerate(m, b))
            {
                m.ChangeMemberState(new Moderator(b));


                return(true);
            }
            return(false);
        }
示例#6
0
 public virtual bool DeleteSubForum(SubForum b)
 {
     if (this.SubForum.Contains(b))
     {
         for (int t = 0; t < b.MyThreads.Count; t++)
         {
             b.MyThreads.ElementAt(t).deleteAllSons();
         }
         return(this.SubForum.Remove(b));
     }
     return(false);
 }
示例#7
0
文件: System.cs 项目: shimola/sadna
        public bool promoteMemberToModerator(User u, Member moder, SubForum s)
        {
            bool res = false;

            if (u is Member && ((Member)u).state is Admin && u.forum.SubForumList().Contains(s) && u.forum.Members.Contains(moder))
            {
                res = u.forum.promoteMemberToModerate(moder, s);
                rep.Update <User>(moder);
                rep.Update <Forum>(u.forum);
                rep.Update <SubForum>(s);
            }
            return(res);
        }
示例#8
0
 public bool deleteSubForum(User u, Forum f, SubForum s)
 {
     if (u is Member && (((Member)u).Getstate() is Admin))
     {
         Admin ad = (Admin)((Member)u).Getstate();
         if (ad.getForum() == f)
         {
             bool ans = f.DeleteSubForum(s);
             rep.Update <Forum>(f);
             // rep.Remove<SubForum>(s);
             return(ans);
         }
     }
     return(false);
 }
示例#9
0
        public bool promoteMemberToModerator(User u, Member moder, SubForum s)
        {
            bool   res = false;
            Member mod = ContainId_Member(moder.Id, u.forum);

            if (u is Member && ((Member)u).state is Admin && ContainId(s.Id, u.forum) && mod != null)
            {
                SubForum sub = ContainId_get(s.Id, u.forum);

                res = u.forum.promoteMemberToModerate(mod, sub);
                rep.Update <User>(mod);
                rep.Update <Forum>(u.forum);
                rep.Update <SubForum>(sub);
            }
            return(res);
        }
示例#10
0
文件: System.cs 项目: shimola/sadna
 public bool PublishNewThread(User u, String msg, SubForum s)
 {
     if (u is Member && !msg.Equals("") && u.forum.getSubForum().Contains(s) && u.forum.policy.CanDoConfirmedOperations(((Member)u)))
     {
         Post p = new Post(msg, ((Member)u));
         ((Member)u).AddNewPost(p, null);
         s.AddNewThread(p);
         rep.Update <SubForum>(s);
         rep.Update <User>(u);
         return(true);
     }
     else
     {
         System.Console.Write("cannot add new thread cause the user us not member or empty msg or subforum not found or u is not confirmed");
         return(false);
     }
 }
示例#11
0
        public bool deletePost(User u, Post p)
        {
            IList <SubForum> subs  = u.forum.SubForum;
            SubForum         s     = null;
            Post             toDel = null;

            for (int i = 0; i < subs.Count; i++)
            {
                foreach (Post thread in subs.ElementAt(i).MyThreads)
                {
                    toDel = IsCommentof(p.Id, thread);
                    if (toDel != null)
                    {
                        s = subs.ElementAt(i);
                        break;
                    }
                }
            }
            bool isAdmin = false;

            if ((u is Member))
            {
                Member mem = (Member)u;
                isAdmin = mem.Getstate() is Admin;
            }
            if ((u is Member) && (((Member)u).MemberPosts.Contains(toDel)) || isAdmin)
            {
                bool b = s.removePost(toDel);
                //b |= toDel.kill();
                if (s != null)
                {
                    rep.Update <SubForum>(s);
                }
                rep.Update <User>(toDel.owner);
                rep.Update <Forum>(u.forum);
                rep.Remove <Post>(toDel);
                return(b);
            }
            else
            {
                System.Console.Write("cant delete post  u isnt a member or not own the delete");
                return(false);
            }
        }
示例#12
0
        public bool PublishNewThread(User u, String msg, SubForum s)
        {
            if (u is Member && !msg.Equals("") && ContainId(s.Id, u.forum) && u.forum.policy.CanDoConfirmedOperations(((Member)u)))
            {
                SubForum sub    = ContainId_get(s.Id, u.forum);
                bool     check  = sub.MyThreads.Count > u.forum.policy.minPostsToCheck() && intersection(sub.UsedWords, msg) > u.forum.policy.minWords();
                bool     leggal = u.forum.policy.isLegalMsg(msg);
                check = check || sub.MyThreads.Count <= u.forum.policy.minPostsToCheck();
                if (check && leggal)
                {
                    sub.AddWords(msg);

                    Post p = new Post(msg, ((Member)u));
                    ((Member)u).AddNewPost(p, null);
                    sub.AddNewThread(p);
                    rep.Add <Post>(p);
                    rep.Update <SubForum>(sub);
                    rep.Update <User>(u);
                    return(true);
                }

                else
                {
                    if (!leggal)
                    {
                        try
                        {
                            sendMailToAdmin(this.SuperManager.mail, "the user " + u.Id + " try to publish NOT LEGGAL THREAD :" + msg);
                        }
                        catch { }
                    }
                    return(false);
                }
            }
            else
            {
                System.Console.Write("cannot add new thread cause the user us not member or empty msg or subforum not found or u is not confirmed");
                return(false);
            }
        }
示例#13
0
文件: System.cs 项目: shimola/sadna
        public bool deletePost(User u, Post p)
        {
            IList <SubForum> subs = u.forum.getSubForum();
            SubForum         s    = null;

            for (int i = 0; i < subs.Count; i++)
            {
                if (subs[i].GetMyThreads().Contains(p))
                {
                    s = subs[i];
                    break;
                }
            }
            bool isAdmin = false;

            if ((u is Member))
            {
                Member mem = (Member)u;
                isAdmin = mem.Getstate() is Admin;
            }
            if ((u is Member) && (((Member)u).MemberPosts.Contains(p)) || isAdmin)
            {
                bool b = ((Member)u).delPost(p) && s.removeThread(p);
                if (s != null)
                {
                    rep.Update <SubForum>(s);
                }
                rep.Update <User>(p.owner);
                rep.Update <Forum>(u.forum);
                //                rep.Remove<Post>(p);
                return(b);
            }
            else
            {
                System.Console.Write("cant delete post  u isnt a member or not own the delete");
                return(false);
            }
        }
示例#14
0
 //public Boolean ChangeConstraint(String s){
 // }
 //public Boolean ChangeProperties(String font, String size, String color){}
 public virtual void AddNewModerator(Member m, SubForum s)
 {
     m.ChangeMemberState(new Moderator(s));
 }
示例#15
0
 private SubForumInfo SubForumToInfo(SubForum f)
 {
     return(new SubForumInfo {
         Name = f.Name, id = f.Id
     });
 }
示例#16
0
 public Moderator(SubForum s)
 {
     this.subForum = s;
 }
示例#17
0
 public virtual bool CanBeModerate(Member m, SubForum b)
 {
     return(true);
 }
示例#18
0
文件: Member.cs 项目: amir9979/sadna
 public virtual Post AddNewThread(SubForum s, Post p)
 {
     s.AddNewThread(p);
     this.MemberPosts.Add(p);
     return(p);
 }
示例#19
0
文件: Policy.cs 项目: amir9979/sadna
 public virtual bool CanBeModerate(Member m, SubForum b)
 {
     // if m.type==silver && b.NumOfCurrModertors < maximun moderats
     return(true);   // will change according to specific policy
 }
示例#20
0
文件: System.cs 项目: shimola/sadna
 private SubForumInfo SubForumToInfo(SubForum f)
 {
     return(new  SubForumInfo {
         Name = f.Name, id = Guid2Int(f.Id)
     });
 }