private static CommentStub CreateCommentStub(Comment comment, ThreadUsr threadUsr, GroupUsr groupUsr) { CommentStub c = new CommentStub() { k = comment.K, html = comment.GetHtml(null), script = comment.Script, usrName = comment.Usr.Name, usrPicSrc = comment.Usr.AnyPicPath, usrRollover = comment.Usr.RolloverMouseOverTextNoPic, usrUrl = comment.Usr.Url(), usrK = comment.Usr.K, isNew = comment.GetIsNew(threadUsr), friendlyTimeNoCaps = comment.FriendlyTimeNoCaps, editLinkVisible = Usr.Current != null && (comment.UsrK == Usr.Current.K || Usr.Current.IsAdmin), editedHtml = comment.EditedHtml, deleteLinkVisible = Usr.Current != null && Usr.Current.CanDelete(comment), deleteLinkOnClickConfirmText = Usr.Current == null ? "" : (groupUsr != null && groupUsr.Moderator) ? "You are using your group moderator power to delete this comment.\n\nAre you sure?" : (comment.UsrK != Usr.Current.K) ? "You are using your moderator power to delete this comment.\n\nAre you sure?" : "Are you sure?", threadK = comment.ThreadK }; c.lolHtml = comment.LolUsrListHtml(out c.haveAlreadyLold, Usr.Current != null ? Usr.Current.K : -1); return c; }
private void RejectPrivate(Usr RejectedUsr, GroupUsr RejectedGroupUsr, Usr PerformingUsr, GroupUsr PerformingGroupUsr) { if (RejectedUsr==null) { throw new Exception("InvitedGroupUsr is null!"); } if (RejectedGroupUsr.Status.Equals(GroupUsr.StatusEnum.Request)) RejectedGroupUsr.Status = GroupUsr.StatusEnum.RequestRejected; else if (RejectedGroupUsr.Status.Equals(GroupUsr.StatusEnum.Recommend)) RejectedGroupUsr.Status = GroupUsr.StatusEnum.RecommendRejected; else throw new Exception("Incorrect status to reject!"); RejectedGroupUsr.StatusChangeDateTime = DateTime.Now; RejectedGroupUsr.StatusChangeUsrK=PerformingUsr.K; if (RejectedGroupUsr.Status.Equals(GroupUsr.StatusEnum.RequestRejected)) { Mailer m = new Mailer(); m.UsrRecipient = RejectedUsr; m.Subject = "Your request to join the "+this.FriendlyName+" group has been rejected."; m.Body = "<p>Your request to join the "+this.FriendlyName+" group has been rejected. You can contact a group moderator for more information.</p>"; m.RedirectUrl = this.Url(); m.Send(); } else if (RejectedGroupUsr.Status.Equals(GroupUsr.StatusEnum.RecommendRejected)) { Mailer m = new Mailer(); m.UsrRecipient = RejectedGroupUsr.InviteUsr; m.Subject = "Your recommendation for "+RejectedUsr.NickName+" to join the "+this.FriendlyName+" group has been rejected."; m.Body = "<p>Your recommendation for "+RejectedUsr.LinkEmail()+" to join the "+this.FriendlyName+" group has been rejected. You can contact a group moderator for more information.</p>"; m.RedirectUrl = this.Url(); m.Send(); } RejectedGroupUsr.Update(); }
public bool CanDelete(Comment comment, Thread thread, GroupUsr gu) { if (this.K == comment.UsrK) return true; if ((thread == null || !thread.Private) && this.IsJunior) return true; if (gu != null && gu.Moderator) return true; return false; }
public bool CanGroupRead(Group g, GroupUsr gu) { return (this.IsAdmin || !g.PrivateChat || (gu != null && gu.IsMember)); }
public bool CanGroupNewsAdmin(GroupUsr gu) { return (this.IsAdmin || (gu != null && gu.NewsAdmin)); }
public bool CheckPermissionPost(Usr u, ThreadUsr threadUsr, GroupUsr groupUsr) { if (this.Private) { try { return !threadUsr.Deleted; } catch { return false; } } else { if (this.GroupK > 0) { return u.CanGroupMember(groupUsr); } return true; } }
protected void InvitesDataGridItemCommand(object sender, DataGridCommandEventArgs e) { if (e.CommandName.Equals("reject")) { Group g = new Group(int.Parse(e.CommandArgument.ToString())); GroupUsr gu = new GroupUsr(Usr.Current.K, g.K); if (gu.Status.Equals(GroupUsr.StatusEnum.Invite)) { g.InviteReject(Usr.Current, gu); } BindInvites(); //ContainerPage.AnchorSkip("PanelInvites"); } }
public void Join(Usr u, GroupUsr gu) { bool exists = true; if (gu==null) { exists = false; gu = new GroupUsr(); gu.UsrK=u.K; gu.GroupK=this.K; gu.Owner=false; gu.Moderator=false; gu.NewsAdmin=false; gu.MemberAdmin=false; } else { if (gu.Status.Equals(GroupUsr.StatusEnum.Barred) || gu.Status.Equals(GroupUsr.StatusEnum.RequestRejected)) throw new DsiUserFriendlyException("You can't join this group. You have been barred or denied."); } bool joined = false; bool requested = false; if (this.PrivateGroupPage) { if (exists && (gu.Status.Equals(GroupUsr.StatusEnum.Invite) || gu.Status.Equals(GroupUsr.StatusEnum.InviteRejected) || gu.Status.Equals(GroupUsr.StatusEnum.Exited))) { gu.Status=GroupUsr.StatusEnum.Member; gu.StatusChangeDateTime=DateTime.Now; gu.StatusChangeUsrK=u.K; gu.Update(); joined = true; } else throw new DsiUserFriendlyException("You can't request membership of a private group. You must wait to be invited."); } else if (this.Restriction.Equals(Group.RestrictionEnum.None)) { gu.Status=GroupUsr.StatusEnum.Member; gu.StatusChangeDateTime=DateTime.Now; gu.StatusChangeUsrK=u.K; gu.Update(); joined = true; } else if (this.Restriction.Equals(Group.RestrictionEnum.Member) || this.Restriction.Equals(Group.RestrictionEnum.Moderator)) { if (exists && (gu.Status.Equals(GroupUsr.StatusEnum.Invite) || gu.Status.Equals(GroupUsr.StatusEnum.InviteRejected) || gu.Status.Equals(GroupUsr.StatusEnum.Exited))) { gu.Status=GroupUsr.StatusEnum.Member; gu.StatusChangeDateTime=DateTime.Now; gu.StatusChangeUsrK=u.K; gu.Update(); joined = true; } else if ( !exists || exists && (gu.Status.Equals(GroupUsr.StatusEnum.Recommend) || gu.Status.Equals(GroupUsr.StatusEnum.RecommendRejected))) { gu.Status=GroupUsr.StatusEnum.Request; gu.StatusChangeDateTime=DateTime.Now; gu.StatusChangeUsrK=u.K; gu.Update(); requested = true; } else throw new DsiUserFriendlyException("You can't join this group"); } else if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) throw new DsiUserFriendlyException("You can't join this group - it's membership restriction is set to Custom."); if (joined) { this.UpdateTotalMembers(); SendJoinedEmail(u); if (this.K == Vars.CompetitionGroupK) { Log.Increment(Log.Items.CaptionGroupJoin); } Query qAdmin = new Query(); qAdmin.QueryCondition=new And(this.MemberAdminQ, new Q(GroupUsr.Columns.MemberAdminNewUserEmails,true)); qAdmin.TableElement=Group.UsrMemberJoin; qAdmin.Columns=Usr.EmailColumns; UsrSet usAdmins = new UsrSet(qAdmin); foreach (Usr admin in usAdmins) { Mailer mAdmin = new Mailer(); mAdmin.UsrRecipient=admin; mAdmin.Subject="New group member - "+u.NickName+" has joined "+this.FriendlyName; mAdmin.Body="<p>" + u.LinkEmail() + " has joined the "+ this.FriendlyName+" group.</p>"; mAdmin.Body += "<p><b>Did you know you can turn these emails off?</b> Check out your <a href=\"[LOGIN]\">group membership moderator options</a>.</p>"; mAdmin.RedirectUrl=this.UrlApp("admin","mode","membership"); mAdmin.Send(); } if (!this.PrivateGroupPage && u.FacebookConnected && u.FacebookStoryJoinGroup) { try { FacebookPost.CreateJoinGroup(u, this); } catch { } } } else if (requested) { this.UpdateTotalMembers(); string alertScope="when news is posted"; if (this.EmailOnAllThreads) alertScope="each time anyone posts a new topic"; Mailer m = new Mailer(); m.UsrRecipient=u; m.Subject="Group membership requested - "+this.FriendlyName; m.Body="<p>You've requested to join the "+this.FriendlyName+" group. The group moderator "+ "has been sent an email and will deal with your application shortly.</p>"+ "<p>If you're accepted as a member, you will receive email alerts "+ alertScope+" in this group. If you ever want to exit the group, click the button "+ "on the <a href=\"[LOGIN("+this.Url()+")]\">group homepage</a>.</p>"; m.RedirectUrl=this.Url(); m.Send(); Query qAdmin = new Query(); qAdmin.QueryCondition=this.MemberAdminQ; qAdmin.TableElement=Group.UsrMemberJoin; qAdmin.Columns=Usr.EmailColumns; UsrSet usAdmins = new UsrSet(qAdmin); foreach (Usr admin in usAdmins) { Mailer mAdmin = new Mailer(); mAdmin.UsrRecipient=admin; mAdmin.Subject="Group membership requested - "+u.NickName+" would like to join "+this.FriendlyName; mAdmin.Body="<p>" + u.LinkEmail() + " would like to join the "+ this.FriendlyName+" group. Please deal with this request as soon as possible. You can accept or deny the "+ "request on the <a href=\"[LOGIN]\">group options page</a>.</p>"; mAdmin.RedirectUrl=this.UrlApp("admin","mode","membership"); mAdmin.Send(); } } }
public void MergeAndDelete(Group merge) { if (this.K==merge.K) throw new DsiUserFriendlyException("Can't merge group into itself!"); Cambro.Web.Helpers.WriteAlertHeader(); Cambro.Web.Helpers.WriteAlert("Starting group merge...", true); Cambro.Web.Helpers.WriteAlert("Merging group members...", true); //members Query qGu = new Query(); qGu.QueryCondition=new Q(GroupUsr.Columns.GroupK,merge.K); GroupUsrSet gus = new GroupUsrSet(qGu); int count = 0; foreach (GroupUsr guMerge in gus) { if (count%10==0) Cambro.Web.Helpers.WriteAlert("Merging usr " + guMerge.UsrK + " ("+count+" / "+gus.Count+")..."); try { count++; GroupUsr guMaster = this.GetGroupUsr(guMerge.Usr); if (guMaster == null) { guMaster = new GroupUsr(); guMaster.UsrK = guMerge.UsrK; guMaster.GroupK = this.K; guMaster.Status = guMerge.Status; guMaster.StatusChangeDateTime = guMerge.StatusChangeDateTime; guMaster.StatusChangeUsrK = guMerge.StatusChangeUsrK; guMaster.Owner = guMerge.Owner; guMaster.Moderator = guMerge.Moderator; guMaster.NewsAdmin = guMerge.NewsAdmin; guMaster.MemberAdmin = guMerge.MemberAdmin; guMaster.MemberAdminNewUserEmails = guMerge.MemberAdminNewUserEmails; guMaster.Favourite = guMerge.Favourite; guMaster.InviteMessage = guMerge.InviteMessage; guMaster.InviteUsrK = guMerge.InviteUsrK; guMaster.Update(); guMaster.Usr.UpdateIsGroupModerator(); } else { if (guMaster.StatusPermissionLevel < guMerge.StatusPermissionLevel) { guMaster.Status = guMerge.Status; guMaster.StatusChangeDateTime = guMerge.StatusChangeDateTime; guMaster.StatusChangeUsrK = guMerge.StatusChangeUsrK; guMaster.InviteMessage = guMerge.InviteMessage; guMaster.InviteUsrK = guMerge.InviteUsrK; } if (this.BrandK == 0 || merge.BrandK > 0) { if (guMerge.Owner) guMaster.Owner = true; if (guMerge.Moderator) guMaster.Moderator = true; if (guMerge.NewsAdmin) guMaster.NewsAdmin = true; if (guMerge.MemberAdmin) { guMaster.MemberAdmin = true; guMaster.MemberAdminNewUserEmails = guMerge.MemberAdminNewUserEmails; } } if (guMerge.Favourite) guMaster.Favourite = true; guMaster.Update(); guMaster.Usr.UpdateIsGroupModerator(); } if (guMaster.IsMember) { Mailer m = new Mailer(); m.UsrRecipient = guMerge.Usr; m.Subject = "A group you were in has been merged"; m.Body = "<p><i>" + merge.FriendlyName + "</i> has been merged with <i>" + this.FriendlyName + "</i>. " + "Your membership details have been moved across. If you ever want to exit the group, click the button " + "on the <a href=\"[LOGIN(" + this.Url() + ")]\">group homepage</a>.</p>"; m.RedirectUrl = this.Url(); m.Bulk = true; m.Send(); } if (guMaster.IsMember && CommentAlert.IsEnabled(guMerge.UsrK, guMerge.GroupK, Model.Entities.ObjectType.Group)) CommentAlert.Enable(guMaster.Usr, guMaster.GroupK, Model.Entities.ObjectType.Group); } catch { Cambro.Web.Helpers.WriteAlert("Exception! ... deleting membership for usr " + guMerge.UsrK + " (" + count + " / " + gus.Count + ")..."); guMerge.Delete(); } } Cambro.Web.Helpers.WriteAlert("Done merging usrs..."); //picture if (merge.HasPic && !this.HasPic) { Cambro.Web.Helpers.WriteAlert("Copying picture...", true); try { Utilities.CopyPic(merge, this); } catch { Cambro.Web.Helpers.WriteAlert("Exception while copying picture...", true); } Cambro.Web.Helpers.WriteAlert("Done copying picture...", true); } //recommended events if (this.BrandK == 0) { Cambro.Web.Helpers.WriteAlert("Merging recommended events...", true); Query qEv = new Query(); qEv.QueryCondition = new Q(GroupEvent.Columns.GroupK, merge.K); GroupEventSet ges = new GroupEventSet(qEv); foreach (GroupEvent geMerge in ges) { try { GroupEvent geMaster = new GroupEvent(this.K, geMerge.EventK); } catch (BobNotFound) { GroupEvent geMaster = new GroupEvent(); geMaster.GroupK = this.K; geMaster.EventK = geMerge.EventK; geMaster.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging recommended events..."); } Cambro.Web.Helpers.WriteAlert("Merging top photos...", true); //top photos Query qPh = new Query(); qPh.QueryCondition=new Q(GroupPhoto.Columns.GroupK,merge.K); GroupPhotoSet gps = new GroupPhotoSet(qPh); foreach (GroupPhoto gpMerge in gps) { try { GroupPhoto gpMaster = new GroupPhoto(this.K,gpMerge.PhotoK); if (!gpMaster.ShowOnFrontPage && gpMerge.ShowOnFrontPage) { gpMaster.Caption=gpMerge.Caption; gpMaster.DateTime=gpMerge.DateTime; gpMaster.AddedByUsrK=gpMerge.AddedByUsrK; gpMaster.ShowOnFrontPage=gpMerge.ShowOnFrontPage; gpMaster.Update(); } } catch (BobNotFound) { GroupPhoto gpMaster = new GroupPhoto(); gpMaster.GroupK=this.K; gpMaster.PhotoK=gpMerge.PhotoK; gpMaster.Caption=gpMerge.Caption; gpMaster.DateTime=gpMerge.DateTime; gpMaster.AddedByUsrK=gpMerge.AddedByUsrK; gpMaster.ShowOnFrontPage=gpMerge.ShowOnFrontPage; gpMaster.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging top photos..."); //addedbyusrk's if (true) { Cambro.Web.Helpers.WriteAlert("Updating invited users...", true); Update update = new Update(); update.Changes.Add(new Assign(Usr.Columns.AddedByGroupK, this.K)); update.Table = TablesEnum.Usr; update.Where = new Q(Usr.Columns.AddedByGroupK, merge.K); update.Run(); Cambro.Web.Helpers.WriteAlert("Done updating invited users..."); } Cambro.Web.Helpers.WriteAlert("Merging topics (1/4)...", true); //chats if (merge.PrivateChat != this.PrivateChat || merge.ThemeK != this.ThemeK || merge.MusicTypeK != this.MusicTypeK) { Update update = new Update(); update.Table=TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.PrivateGroup,this.PrivateChat)); update.Changes.Add(new Assign(Thread.Columns.ThemeK, this.ThemeK)); update.Changes.Add(new Assign(Thread.Columns.MusicTypeK, this.MusicTypeK)); update.Where=new Q(Thread.Columns.GroupK,merge.K); update.Run(); } Cambro.Web.Helpers.WriteAlert("Done merging topics (1/4)..."); if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (2/4)...", true); Update update = new Update(); update.Table=TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.UrlFragment,"groups/"+this.UrlName)); update.Changes.Add(new Assign(Thread.Columns.CountryK, this.CountryK)); update.Changes.Add(new Assign(Thread.Columns.PlaceK,this.PlaceK)); update.Where=new And(new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Group),new Q(Thread.Columns.ParentObjectK,merge.K)); update.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (2/4)..."); } if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (3/4)...", true); Update update = new Update(); update.Table=TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.GroupK,this.K)); update.Where=new Q(Thread.Columns.GroupK,merge.K); update.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (3/4)..."); } if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (4/4)...", true); Update update = new Update(); update.Table=TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.ParentObjectK,this.K)); update.Where=new And(new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Group),new Q(Thread.Columns.ParentObjectK,merge.K)); update.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (4/4)..."); } Cambro.Web.Helpers.WriteAlert("Deleting old group...", true); merge.DeleteAll(null); Cambro.Web.Helpers.WriteAlert("Done deleting old group..."); Cambro.Web.Helpers.WriteAlert("Updating stats...", true); this.UpdateTotalComments(null); this.UpdateTotalMembers(); Cambro.Web.Helpers.WriteAlert("Done updating stats..."); Cambro.Web.Helpers.WriteAlert("Finished merging groups.", true); }
public MemberAdminPermissionClass(GroupUsr gu) { if (gu.Status.Equals(StatusEnum.Member)) { Bar = true; } else if (gu.Status.Equals(StatusEnum.Request)) { Accept = true; Reject = true; Bar = true; } else if (gu.Status.Equals(StatusEnum.RequestRejected)) { Accept = true; Bar = true; } else if (gu.Status.Equals(StatusEnum.Invite)) { Bar = true; } else if (gu.Status.Equals(StatusEnum.InviteRejected)) { Bar = true; } else if (gu.Status.Equals(StatusEnum.Exited)) { Bar = true; } else if (gu.Status.Equals(StatusEnum.Barred)) { UnBar = true; } else if (gu.Status.Equals(StatusEnum.Recommend)) { Invite = true; Reject = true; Bar = true; } else if (gu.Status.Equals(StatusEnum.RecommendRejected)) { Invite = true; Bar = true; } }
public GroupUsr ChangeUsr(bool Remove, int UsrK, bool Moderator, bool NewsAdmin, bool MemberAdmin, bool Owner, GroupUsr.StatusEnum Status, DateTime DateTimeAdded, bool UpdateTotalMembers) { bool found = false; GroupUsr gu = new GroupUsr(); try { gu = new GroupUsr(UsrK, this.K); found=true; } catch{} if (found) { if (Remove) { gu.Delete(); if (UpdateTotalMembers) this.UpdateTotalMembers(); } else { gu.Moderator=Moderator || NewsAdmin || MemberAdmin || Owner; gu.NewsAdmin=NewsAdmin || Owner; if (gu.MemberAdmin != (MemberAdmin || Owner)) { gu.MemberAdmin = MemberAdmin || Owner; gu.MemberAdminNewUserEmails = MemberAdmin || Owner; } gu.Owner=Owner; if (!gu.Status.Equals(Status)) { gu.Status=Status; gu.StatusChangeDateTime=DateTimeAdded; gu.StatusChangeUsrK=UsrK; } gu.Update(); gu.Usr.UpdateIsGroupModerator(); if (UpdateTotalMembers) this.UpdateTotalMembers(); } } else { if (Remove) { gu = null; } else { gu.UsrK=UsrK; gu.GroupK=this.K; if (!gu.Status.Equals(Status)) { gu.Status=Status; gu.StatusChangeDateTime=DateTimeAdded; gu.StatusChangeUsrK=UsrK; } gu.Moderator=Moderator || NewsAdmin || MemberAdmin || Owner; gu.NewsAdmin=NewsAdmin || Owner; if (gu.MemberAdmin != (MemberAdmin || Owner)) { gu.MemberAdmin = MemberAdmin || Owner; gu.MemberAdminNewUserEmails = MemberAdmin || Owner; } gu.Owner=Owner; gu.Update(); gu.Usr.UpdateIsGroupModerator(); if (UpdateTotalMembers) this.UpdateTotalMembers(); } } return gu; }
public Return InviteReject(Usr TargetUsr, GroupUsr TargetGroupUsr) { Return r = new Return(); if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) { r.Success=false; r.MessageHtml="The "+this.FriendlyName+" group is a special group - the membership "+ "is automatically controlled. You can't decline an invite to this group."; return r; } if (TargetGroupUsr==null) { r.Success=false; r.MessageHtml="You haven't been invited to the "+this.FriendlyName+" group!"; return r; } else if (TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Invite)) { TargetGroupUsr.Status = GroupUsr.StatusEnum.InviteRejected; TargetGroupUsr.StatusChangeDateTime = DateTime.Now; TargetGroupUsr.StatusChangeUsrK = TargetUsr.K; GroupUsr gu = this.GetGroupUsr(TargetGroupUsr.InviteUsr); if (gu.MemberAdminNewUserEmails) { Mailer m = new Mailer(); m.UsrRecipient = TargetGroupUsr.InviteUsr; m.Subject = "Your invitation for " + TargetUsr.NickName + " to join the " + this.FriendlyName + " group has been rejected."; m.Body = "<p>Your invitation for " + TargetUsr.LinkEmail() + " to join the " + this.FriendlyName + " group has been rejected. " + TargetUsr.LinkEmail() + " did not want to join the group.</p>"; m.RedirectUrl = TargetUsr.Url(); m.Send(); } TargetGroupUsr.Update(); r.Success=true; return r; } else { r.Success=false; r.MessageHtml="You haven't been invited to the "+this.FriendlyName+" group!"; return r; } }
public void UnBar(Usr TargetUsr, GroupUsr TargetGroupUsr, Usr PerformingUsr, GroupUsr PerformingGroupUsr) { if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) throw new DsiUserFriendlyException("Can't unbar from a custom group!"); if (!PerformingUsr.IsAdmin && (PerformingGroupUsr==null || !PerformingGroupUsr.MemberAdmin)) throw new DsiUserFriendlyException("You must be a membership admin of this group to unbar someone!"); if (TargetGroupUsr!=null && TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Barred)) { TargetGroupUsr.Status = GroupUsr.StatusEnum.Invite; TargetGroupUsr.StatusChangeDateTime = DateTime.Now; TargetGroupUsr.StatusChangeUsrK = PerformingUsr.K; Query qAdmin = new Query(); qAdmin.QueryCondition=this.MemberAdminQ; qAdmin.TableElement=Group.UsrMemberJoin; qAdmin.Columns=Usr.EmailColumns; UsrSet usAdmins = new UsrSet(qAdmin); foreach (Usr admin in usAdmins) { Mailer mAdmin = new Mailer(); mAdmin.UsrRecipient=admin; mAdmin.Subject="Member un-barred - "+TargetUsr.NickName+" has been un-barred from the "+ this.FriendlyName+ " group by "+PerformingUsr.NickName; mAdmin.Body="<p>"+TargetUsr.LinkEmail()+" has been un-barred from the "+ this.FriendlyName+ " group by "+PerformingUsr.LinkEmail()+"</p>"; mAdmin.RedirectUrl=this.UrlApp("admin","mode","membership"); mAdmin.Send(); } Mailer m = new Mailer(); m.UsrRecipient = TargetUsr; m.Subject = "You have been un-barred from the the "+this.FriendlyName+" group."; m.Body = "<p>You have been un-barred from the the "+this.FriendlyName+" group. You may join the group by clicking the button on the group homepage. You can contact a group moderator for more information.</p>"; m.RedirectUrl = this.Url(); m.Send(); TargetGroupUsr.Update(); } }
public void Bar(Usr TargetUsr, GroupUsr TargetGroupUsr, Usr PerformingUsr, GroupUsr PerformingGroupUsr) { if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) throw new DsiUserFriendlyException("Can't bar from a custom group!"); if (!PerformingUsr.IsAdmin && (PerformingGroupUsr==null || !PerformingGroupUsr.MemberAdmin)) throw new DsiUserFriendlyException("You must be a membership admin of this group to bar someone!"); if (TargetGroupUsr!=null && TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Barred)) { } else { if (TargetGroupUsr==null) { TargetGroupUsr = new GroupUsr(); TargetGroupUsr.UsrK = TargetUsr.K; TargetGroupUsr.GroupK = this.K; } else if (TargetGroupUsr.Moderator) throw new DsiUserFriendlyException("You can't bar this person - they are a moderator. First remove their moderator status before banning them."); TargetGroupUsr.Status = GroupUsr.StatusEnum.Barred; TargetGroupUsr.StatusChangeDateTime = DateTime.Now; TargetGroupUsr.StatusChangeUsrK = PerformingUsr.K; Query qAdmin = new Query(); qAdmin.QueryCondition=this.MemberAdminQ; qAdmin.TableElement=Group.UsrMemberJoin; qAdmin.Columns=Usr.EmailColumns; UsrSet usAdmins = new UsrSet(qAdmin); foreach (Usr admin in usAdmins) { Mailer mAdmin = new Mailer(); mAdmin.UsrRecipient=admin; mAdmin.Subject="Member barred - "+TargetUsr.NickName+" has been barred from the "+ this.FriendlyName+ " group by "+PerformingUsr.NickName; mAdmin.Body="<p>"+TargetUsr.LinkEmail()+" has been barred from the "+ this.FriendlyName+ " group by "+PerformingUsr.LinkEmail()+"</p>"; mAdmin.RedirectUrl=this.UrlApp("admin","mode","membership"); mAdmin.Send(); } Mailer m = new Mailer(); m.UsrRecipient = TargetUsr; m.Subject = "You have been barred from the the "+this.FriendlyName+" group."; m.Body = "<p>You have been barred from the the "+this.FriendlyName+" group. You can contact a group moderator for more information.</p>"; m.RedirectUrl = this.Url(); m.Send(); TargetGroupUsr.Update(); CommentAlert.Disable(TargetUsr, this.K, Model.Entities.ObjectType.Group); } }
public Return Reject(Usr TargetUsr, GroupUsr TargetGroupUsr, Usr PerformingUsr, GroupUsr PerformingGroupUsr) { Return r = new Return(); if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) { r.Success=false; r.MessageHtml="Can't accept into a custom group!"; return r; } if (!PerformingUsr.IsAdmin && (PerformingGroupUsr==null || !PerformingGroupUsr.IsMember)) { r.Success=false; r.MessageHtml="You must be a member of this group to reject someone!"; return r; } if (TargetGroupUsr==null) { r.Success=false; r.MessageHtml="Can't reject - user hasn't requested membership!"; return r; } else if (TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Request)) { // This person has requested membership // if the current user is a moderator, we must enable the request. if (this.Restriction.Equals(Group.RestrictionEnum.Moderator)) { if (PerformingUsr.CanGroupMemberAdmin(PerformingGroupUsr)) { RejectPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); r.Success=true; return r; } else { r.Success=false; r.MessageHtml="You don't have permission to reject."; return r; } } else { RejectPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); r.Success=true; return r; } } else if (TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Recommend)) { // A previous membership request was denied // if the current user is a moderator, we must enable them straight away. if (PerformingUsr.CanGroupMemberAdmin(PerformingGroupUsr)) { RejectPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); r.Success=true; return r; } else { r.Success=false; r.MessageHtml="You don't have permission to reject."; return r; } } else { r.Success=false; r.MessageHtml="Can't reject - wrong status."; return r; } }
public bool CanViewHomePage(Usr u, GroupUsr gu) { return (!this.PrivateGroupPage || (u!=null && u.IsAdmin) || (gu!=null && (gu.IsMember || gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Invite) || gu.Status.Equals(GroupUsr.StatusEnum.InviteRejected)))); }
public static bool AllowExit(Usr u, Group g, GroupUsr gu) { if (u==null) return false; if (gu!=null && (gu.Moderator || gu.MemberAdmin || gu.NewsAdmin || gu.Owner)) return false; // if (gu!=null && (gu.Status.Equals(GroupUsr.StatusEnum.Member) || gu.Status.Equals(GroupUsr.StatusEnum.Request))) // return true; //removed this Request bit to remove confusing "exit" button when the group membership has been requested. if (gu!=null && gu.Status.Equals(GroupUsr.StatusEnum.Member)) return true; return false; }
public static bool AllowJoinRequest(Usr u, Group g, GroupUsr gu) { if (u==null) return false; if (g.PrivateGroupPage) { if (gu!=null && (gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Invite) || gu.Status.Equals(GroupUsr.StatusEnum.InviteRejected))) return true; } else { if (gu==null || gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Invite) || gu.Status.Equals(GroupUsr.StatusEnum.Recommend) || gu.Status.Equals(GroupUsr.StatusEnum.RecommendRejected) || gu.Status.Equals(GroupUsr.StatusEnum.InviteRejected)) return true; } return false; }
private void InvitePrivate(Usr InvitedUsr, GroupUsr InvitedGroupUsr, Usr InvitingUsr, GroupUsr InvitingGroupUsr, string InviteMessage) { string inviteMessageStripped = Cambro.Web.Helpers.Strip(InviteMessage,true,true,false,true); if (InvitedGroupUsr==null) { InvitedGroupUsr = new GroupUsr(); InvitedGroupUsr.UsrK = InvitedUsr.K; InvitedGroupUsr.GroupK = this.K; } InvitedGroupUsr.Status = GroupUsr.StatusEnum.Invite; InvitedGroupUsr.StatusChangeDateTime = DateTime.Now; InvitedGroupUsr.StatusChangeUsrK = InvitingUsr.K; if (InvitedGroupUsr.InviteUsrK==0) { InvitedGroupUsr.InviteUsrK = InvitingUsr.K; InvitedGroupUsr.InviteMessage = inviteMessageStripped; } else if (InvitedGroupUsr.InviteUsrK != InvitingUsr.K) { //already had an inviting usr InvitingUsr = InvitedGroupUsr.InviteUsr; InvitingGroupUsr = GetGroupUsr(InvitingUsr); InviteMessage = InvitedGroupUsr.InviteMessage; inviteMessageStripped = Cambro.Web.Helpers.Strip(InviteMessage, true, true, false, true); } if (InvitedUsr.AddedByGroupK!=this.K) { string messageString = ""; if (InviteMessage.Length>0) messageString = "</p><p>"+InvitedGroupUsr.InviteUsr.LinkEmail()+" left you this messsage:</p><p><b>"+inviteMessageStripped+"</b></p><p>"; Mailer sm = new Mailer(); sm.UsrRecipient = InvitedUsr; sm.RedirectUrl = this.Url(); sm.Subject = InvitingUsr.NickName + @" has invited you to " + (InvitingGroupUsr!=null && InvitingGroupUsr.Moderator ? InvitingUsr.HisString(false) : "a") + @" group: " + this.FriendlyName; string pic = "<p>"; string picEnd = "</p>"; if (InvitingUsr.HasPic) { pic = @"<table cellspacing=""0"" cellpadding=""0"" border=""0"" style=""margin:10px 5px 5px 1px;""><tr><td valign=""top"" style=""padding:0px 10px 0px 0px;"">"; pic += "<a href=\"[LOGIN(" + InvitingUsr.Url() + ")]\"><img src=\"" + InvitingUsr.PicPath + "\" class=\"BorderBlack All\" width=\"100\" height=\"100\" vspace=\"3\" border=\"0\"></a></td><td valign=\"top\">"; picEnd = "</td></tr></table>"; } string members = ""; if (this.TotalMembers>5) { Query q = new Query(); q.TableElement = Usr.GroupJoin; q.QueryCondition = new And(new Q(Group.Columns.K, this.K), new Q(Usr.Columns.Pic,QueryOperator.NotEqualTo,Guid.Empty)); q.TopRecords=5; q.OrderBy=new OrderBy(OrderBy.OrderDirection.Random); q.Columns=Usr.LinkColumns; UsrSet us = new UsrSet(q); if (us.Count==5) { members = @"<p><b>"+this.FriendlyName+@"</b> has "+this.TotalMembers.ToString("#,##0")+@" members. Here's a few of them:</p>"; members += @"<table cellspacing=""4"" cellpadding=""4"" border=""0"" width=""100%""><tr>"; foreach (Usr uPic in us) { members += "<td width=\"20%\" valign=\"top\"><center><a href=\"[LOGIN(" + uPic.Url() + ")]\"><img src=\"" + uPic.PicPath + "\" width=\"75\" height=\"75\" style=\"margin:0px 0px 5px 0px;\" class=\"BorderBlack All\"><br>" + Cambro.Misc.Utility.Snip(uPic.NickName, 12) + "</a></center></td>"; } members += @"</tr></table>"; } } string inviteMessage = ""; if (Cambro.Web.Helpers.Strip(InviteMessage,true,true,true,true).Length==0) inviteMessage = "Hi!"; else inviteMessage = Cambro.Web.Helpers.Strip(InviteMessage,true,true,false,true).Replace("\n","<br>"); sm.Body=@" "+pic+@" <i style=""font-size:18px;""><b>""</b>"+inviteMessage+@"<b>""</b></i> "+picEnd+@" <p>" + InvitingUsr.LinkEmail() + @" has invited you to " + (InvitingGroupUsr != null && InvitingGroupUsr.Moderator ? InvitingUsr.HisString(false) : "a") + @" group! You can use this to keep in contact with your friends. Here's a quick description of <b>" +this.FriendlyName+@"</b>:</p> <p> <i>"+this.Description+@"</i> </p> "+members+ @" <p align=""center"" style=""margin:10px 0px 8px 0px;""> <a href=""[LOGIN("+this.UrlApp("join")+@")]"" style=""font-size:18px;font-weight:bold;"">Join the group</a> | <a href=""[LOGIN]"" style=""font-size:18px;font-weight:bold;"">decline the invite</a> </p> "; sm.Send(); } InvitedGroupUsr.Update(); }
public static bool AllowInviteReject(Usr u, GroupUsr gu) { if (u==null) return false; if (gu==null) return false; return gu.Status.Equals(GroupUsr.StatusEnum.Invite); }
public bool CanRead(Usr u, GroupUsr gu) { return (!this.PrivateChat || (u!=null && u.IsAdmin) || (gu!=null && gu.IsMember)); }
public bool IsRead(Usr u, GroupUsr gu) { return (!this.PrivateChat || (gu!=null && gu.IsMember)); }
public bool CanGroupModerator(GroupUsr gu) { return (this.IsAdmin || (gu != null && gu.Moderator)); }
public bool CanMember(Usr u, GroupUsr gu) { return (u!=null && u.IsAdmin) || (gu!=null && gu.IsMember); }
public bool CanGroupMember(GroupUsr gu) { return (this.IsAdmin || (gu != null && gu.IsMember)); }
public bool IsMember(Usr usr) { try { GroupUsr gu = new GroupUsr(usr.K, this.K); return gu != null && gu.IsMember; } catch { return false; } }
public void AddToPromotersGroup(GroupUsr gu, Group g) { if (gu == null || !(gu.Status.Equals(GroupUsr.StatusEnum.Member) || gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Barred))) { GroupUsr gu1 = g.ChangeUsr(false, this.K, false, false, false, false, Bobs.GroupUsr.StatusEnum.Member, DateTime.Now, false); gu1.Favourite = true; gu1.Update(); CommentAlert.Enable(this, g.K, Model.Entities.ObjectType.Group); Mailer m = new Mailer(); m.UsrRecipient = this; m.Subject = "We've added you to the private promoters group"; m.RedirectUrl = g.Url(); m.Body = @" <p> Congratulations on activating your promoter account. We've now given you access to the private promoter group, where you can chat with event organisers from all around the world. </p> <p> What we are trying to do with this forum is allow people a space to ask questions, seek advice and share knowledge about promoting events across the world. </p> <p> <b>Please do:</b> </p> <p> * Ask questions <br> * Give answers <br> </p> <p> <b>Please do not: </b> </p> <p> * Spam this forum with promotional messages <br> * Post about your upcoming events, <b>this includes 'industry invites'</b> </p> <p> If you break these rules you will be removed from the group without warning. </p> "; m.Send(); } }
public bool IsMember(GroupUsr gu) { return gu!=null && gu.IsMember; }
protected void MemberAdminOptionsDataGridItemCommand(object sender, DataGridCommandEventArgs e) { if (HasMemberAdmin) { if ( e.CommandName.Equals("accept") || e.CommandName.Equals("invite") || e.CommandName.Equals("reject") || e.CommandName.Equals("bar") || e.CommandName.Equals("unbar")) { GroupUsr gu = new GroupUsr(int.Parse(e.CommandArgument.ToString()), CurrentGroup.K); if (e.CommandName.Equals("accept")) { if (gu.MemberAdminPermission.Accept) { CurrentGroup.Accept(gu.Usr, gu, Usr.Current, CurrentGroupUsr); } } else if (e.CommandName.Equals("invite")) { if (gu.MemberAdminPermission.Invite) { CurrentGroup.Invite( gu.Usr, gu, Usr.Current, CurrentGroupUsr, "", false); } } else if (e.CommandName.Equals("reject")) { if (gu.MemberAdminPermission.Reject) { CurrentGroup.Reject(gu.Usr, gu, Usr.Current, CurrentGroupUsr); } } else if (e.CommandName.Equals("bar")) { if (gu.MemberAdminPermission.Bar) { CurrentGroup.Bar(gu.Usr, gu, Usr.Current, CurrentGroupUsr); } } else if (e.CommandName.Equals("unbar")) { if (gu.MemberAdminPermission.UnBar) { CurrentGroup.UnBar(gu.Usr, gu, Usr.Current, CurrentGroupUsr); } } BindMemberAdminOptionsDataGrid(); ContainerPage.AnchorSkip("MemberOptions"); } } }
public void Accept(Usr TargetUsr, GroupUsr TargetGroupUsr, Usr PerformingUsr, GroupUsr PerformingGroupUsr) { if (this.Restriction.Equals(Group.RestrictionEnum.Custom)) throw new DsiUserFriendlyException("Can't accept into a custom group!"); if (!PerformingUsr.IsAdmin && (PerformingGroupUsr==null || !PerformingGroupUsr.IsMember)) throw new DsiUserFriendlyException("You must be a member of this group to accept!"); if (TargetGroupUsr==null) { // Nothing } else if (TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.Request)) { // This person has requested membership // if the current user is a moderator, we must enable the request. if (this.Restriction.Equals(Group.RestrictionEnum.Moderator)) { if (PerformingUsr.IsAdmin || (PerformingGroupUsr!=null && PerformingGroupUsr.MemberAdmin)) { JoinPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); } } else { JoinPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); } } else if (TargetGroupUsr.Status.Equals(GroupUsr.StatusEnum.RequestRejected)) { // A previous membership request was denied // if the current user is a moderator, we must enable them straight away. if (PerformingUsr.IsAdmin || (PerformingGroupUsr!=null && PerformingGroupUsr.MemberAdmin)) { JoinPrivate(TargetUsr, TargetGroupUsr, PerformingUsr, PerformingGroupUsr); } } }