public string GroupAdminHtml(string action, Brand brand, Group group) { try { GroupUsr gu = null; if (GroupUsrHashtable.ContainsKey(group.K)) gu = (GroupUsr)GroupUsrHashtable[group.K]; else { gu = Usr.Current.GetGroupUsr(group.K); GroupUsrHashtable[group.K] = gu; } bool on = Usr.Current.CanGroupOwner(gu); bool tick = false; switch (action) { case "Location": tick = group.CountryK > 0; break; case "MusicType": tick = group.MusicTypeK > 0; break; case "Details": tick = group.LongDescriptionHtml.Length > 0; break; default: break; } string attributes = ""; if (on) { switch (action) { case "Location": attributes = "href=\"" + group.UrlApp("edit", "mode", "location", "promoterk", CurrentPromoter.K.ToString()) + "\""; break; case "MusicType": attributes = "href=\"" + group.UrlApp("edit", "mode", "musictype", "promoterk", CurrentPromoter.K.ToString()) + "\""; break; case "Details": attributes = "href=\"" + group.UrlApp("edit", "mode", "details", "promoterk", CurrentPromoter.K.ToString()) + "\""; break; default: break; } } else { attributes = "href=\"\" onclick=\"alert('You do not have permission to alter this.\\nPlease contact "; if (CurrentPromoter.PrimaryUsr != null) attributes += CurrentPromoter.PrimaryUsr.NickName + " and ask " + CurrentPromoter.PrimaryUsr.HimString(false); else attributes += CurrentPromoter.ContactName + " and ask them"; attributes += " to make you an owner of the " + brand.UrlName + " regulars group.');return false;\""; } return "<a " + attributes + "><img src=\"" + (tick ? "/gfx/icon-tick.png" : "/gfx/icon-cross.png") + "\" border=\"0\" height=\"21\" width=\"26\" align=\"absmiddle\">change</a>"; } catch { return "[Error]"; } }
void Save(bool RedirectToPic) { if (IsEdit) { string newName = Cambro.Web.Helpers.Strip(NameTextBox.Text); bool changedName = !CurrentGroup.Name.Equals(newName); CurrentGroup.Name = newName; CurrentGroup.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text); CurrentGroup.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text); CurrentGroup.LongDescriptionHtml = IntroHtml.GetHtml(); bool newPrivateChat; if (GroupPagePrivate.Checked) { CurrentGroup.PrivateGroupPage = true; CurrentGroup.PrivateMemberList = true; newPrivateChat = true; } else { CurrentGroup.PrivateGroupPage = false; CurrentGroup.PrivateMemberList = MembersListPrivate.Checked; newPrivateChat = ChatForumPrivate.Checked; } bool changedPrivateChat = newPrivateChat != CurrentGroup.PrivateChat; CurrentGroup.PrivateChat = newPrivateChat; if (MembershipMember.Checked) CurrentGroup.Restriction = Group.RestrictionEnum.Member; else if (MembershipModerator.Checked) CurrentGroup.Restriction = Group.RestrictionEnum.Moderator; else CurrentGroup.Restriction = Group.RestrictionEnum.None; int newTheme; if (ThemesRadioButtonList.SelectedValue.Equals("18")) newTheme = 0; else { Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue)); newTheme = t.K; } bool changedTheme = newTheme != CurrentGroup.ThemeK; CurrentGroup.ThemeK = newTheme; int newCountry; int oldCountry = CurrentGroup.CountryK; if (LocationTypeCountry.Checked || LocationTypePlace.Checked) { Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue)); if (!c.Enabled) throw new Exception("invalid country!"); newCountry = c.K; } else { newCountry = 0; } bool changedCountry = CurrentGroup.CountryK != newCountry; CurrentGroup.CountryK = newCountry; int newPlace; int oldPlace = CurrentGroup.PlaceK; if (LocationTypePlace.Checked) { Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue)); if (!p.Enabled || p.CountryK != CurrentGroup.CountryK) throw new Exception("invalid place!"); newPlace = p.K; } else { newPlace = 0; } bool changedPlace = CurrentGroup.PlaceK != newPlace; CurrentGroup.PlaceK = newPlace; int newMusicType; if (CurrentGroup.ThemeK == 1 || CurrentGroup.ThemeK == 2) { if (!MusicTypesRadioButtonList.SelectedValue.Equals("0")) { MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue)); if (!(mt.ParentK == 0 || mt.ParentK == 1)) throw new Exception("Invalid music type"); newMusicType = mt.K; } else { newMusicType = 0; } } else { newMusicType = 0; } bool changedMusic = CurrentGroup.MusicTypeK != newMusicType; CurrentGroup.MusicTypeK = newMusicType; if (changedName) CurrentGroup.CreateUniqueUrlName(false); Transaction transaction = null;//new Transaction(); try { if (changedPrivateChat) { Update update = new Update(); update.Table = TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.PrivateGroup, CurrentGroup.PrivateChat)); update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K); update.Run(transaction); } if (changedTheme) { Update update = new Update(); update.Table = TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.ThemeK, CurrentGroup.ThemeK)); update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K); update.Run(transaction); } if (changedCountry) { Update update = new Update(); update.Table = TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.CountryK, CurrentGroup.CountryK)); update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K)); update.Run(transaction); } if (changedPlace) { Update update = new Update(); update.Table = TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.PlaceK, CurrentGroup.PlaceK)); update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K)); update.Run(transaction); if (oldPlace > 0) { Place oldP = new Place(oldPlace); oldP.UpdateTotalComments(null); } if (newPlace > 0) { Place newP = new Place(newPlace); newP.UpdateTotalComments(null); } } if (changedMusic) { Update update = new Update(); update.Table = TablesEnum.Thread; update.Changes.Add(new Assign(Thread.Columns.MusicTypeK, CurrentGroup.MusicTypeK)); update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K); update.Run(transaction); } if (changedName) { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Group, CurrentGroup.K, true); job.ExecuteAsynchronously(); } CurrentGroup.Update(transaction); //transaction.Commit(); } catch (Exception ex) { //transaction.Rollback(); throw ex; } finally { //transaction.Close(); } if (RedirectToPic) { if (ContainerPage.Url["promoterk"].IsInt) Response.Redirect(CurrentGroup.UrlApp("edit", "pic", "", "promoterk", ContainerPage.Url["promoterk"])); else Response.Redirect(CurrentGroup.UrlApp("edit", "pic", "")); } else { RedirectSaved(); } } else { GroupSet gsDup = new GroupSet(new Query(new Q(Group.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"]))); if (gsDup.Count != 0) { Response.Redirect(gsDup[0].UrlApp("edit", "pic", "")); } else { Group g = new Group(); g.Name = Cambro.Web.Helpers.Strip(NameTextBox.Text); g.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text); g.LongDescriptionHtml = IntroHtml.GetHtml(); g.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text, true, true, false, true); g.DateTimeCreated = DateTime.Now; g.PrivateGroupPage = GroupPagePrivate.Checked; if (GroupPagePrivate.Checked) { g.PrivateMemberList = true; g.PrivateChat = true; } else { g.PrivateMemberList = MembersListPrivate.Checked; g.PrivateChat = ChatForumPrivate.Checked; } if (MembershipMember.Checked) g.Restriction = Group.RestrictionEnum.Member; else if (MembershipModerator.Checked) g.Restriction = Group.RestrictionEnum.Moderator; else g.Restriction = Group.RestrictionEnum.None; if (ThemesRadioButtonList.SelectedValue.Equals("18")) g.ThemeK = 0; else { Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue)); g.ThemeK = t.K; } if (LocationTypeCountry.Checked || LocationTypePlace.Checked) { Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue)); if (!c.Enabled) throw new Exception("invalid country!"); g.CountryK = c.K; } if (LocationTypePlace.Checked) { Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue)); if (!p.Enabled || p.CountryK != g.CountryK) throw new Exception("invalid place!"); g.PlaceK = p.K; } if (g.ThemeK == 1 || g.ThemeK == 2) { if (!MusicTypesRadioButtonList.SelectedValue.Equals("0")) { MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue)); if (!(mt.ParentK == 0 || mt.ParentK == 1)) throw new Exception("Invalid music type"); g.MusicTypeK = mt.K; } } g.CreateUniqueUrlName(false); g.DuplicateGuid = (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"]; g.EmailOnAllThreads = false; g.Update(); g.ChangeUsr(false, Usr.Current.K, true, true, true, true, Bobs.GroupUsr.StatusEnum.Member, DateTime.Now, true); Response.Redirect(g.UrlApp("edit", "pic", "")); } } }