protected void Page_Load(object sender, EventArgs e) { rqdDropDownFName.Enabled = String.IsNullOrEmpty(txtFName.Text); txtFName.Text = HiddenText; if (!IsPostBack) { ddlForums.Items.Add(new ListItem() { Value = "0", Text = InitialDropDownText }); txtFName.Attributes.Add("placeholder", InitialTextBoxText); ddlForums.ValidationGroup = validation_group; txtFName.ValidationGroup = validation_group; btnSubmit.ValidationGroup = validation_group; rqdDropDownFName.ValidationGroup = validation_group; rqdDiscussion.ValidationGroup = validation_group; rqdSubject.ValidationGroup = validation_group; //Are we on a forum or Group?? Item currItem = Sitecore.Context.Item; if (currItem.TemplateID.ToString().Equals(GroupItem.TemplateId)) { GroupItem grpItem = new GroupItem(currItem); Session["_item"] = grpItem; GroupCardModel grpModel = Groups.GroupCardModelFactory(grpItem); List<ForumModel> frms =currItem.Children.Select(x => Forum.ForumModelFactory(new ForumItem(x))).ToList<ForumModel>(); if (grpModel != null) { ddlForums.DataSource = frms; ddlForums.DataBind(); } } else { if (currItem.TemplateID.ToString().Equals(ForumItem.TemplateId)) { ForumItem frmItem = new ForumItem(currItem); Session["_item"] = frmItem; //Disable forum selection and select ddlForums.Enabled = false; ddlForums.Visible = false; txtFName.Visible = true; txtFName.Text = frmItem.DisplayName; txtFName.Enabled = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.Request.QueryString["groupsearch"] != null) { pnlDefaultSection.Visible = false; pnlSearchSection.Visible = true; } else { if (!IsPostBack) { Item currItem = Sitecore.Context.Item; GroupItem grpItem = new GroupItem(currItem); pnlDefaultSection.Visible = true; pnlSearchSection.Visible = false; if (grpItem != null) { Session["groupitem"] = grpItem; GroupCardModel grpModel = Groups.GroupCardModelFactory(grpItem); List<ForumModel> frms = currItem.Children.Select(x => Forum.ForumModelFactory(new ForumItem(x))).ToList<ForumModel>(); if (grpModel != null) { rptForums.DataSource = frms;//grpModel.Forums; rptForums.DataBind(); lvJumpto.DataSource = frms;//currItem.Children.Select(x => Forum.ForumModelFactory(new ForumItem(x))).ToList<ForumModel>(); //grpModel.Forums; lvJumpto.DataBind(); } } } } }
protected void Page_Load(object sender, EventArgs e) { string _grpSrch = String.Empty; Item currItem = Sitecore.Context.Item; GroupItem grpItem = new GroupItem(currItem); //Retrieve group item id from session if (Page.Request.QueryString != null) { _grpSrch = Page.Request.QueryString["q"]; //Session["group_search"].ToString(); //Perform search Session["group_search"] = null; } //Populate control }
public static Item CreateSitecoreForum(ForumModel frmModel, GroupItem grpItem, Language lang) { Item newItem = null; try { if (frmModel != null && grpItem != null && lang != null) { //Again we need to handle security //In this example we just disable it using (new SecurityDisabler()) { //First get the parent item from the master database Database masterDb = global:: Sitecore.Configuration.Factory.GetDatabase("master"); Item parentItem = masterDb.Items[grpItem.InnerItem.Paths.Path, lang]; //Now we need to get the template from which the item is created (Forum Thread Template) TemplateItem template = masterDb.GetTemplate(ForumModel.TemplateID); //StringBuilder sb = new StringBuilder(ItemName.Trim()); // string newName = ItemName.Replace('.', '_');//.Substring(0, ItemName.LastIndexOf(".")); // if(newName.Contains(".")) // newName=newName.Substring(newName.IndexOf(".") + 1); newItem = masterDb.GetItem(parentItem.Paths.Path + "/" + frmModel.Name, lang); if (newItem == null) { //Now we can add the new item as a child to the parent newItem = parentItem.Add(frmModel.Name, template); } //We can now manipulate the fields and publish as in the previous example //Item item = masterDb.GetItem(newItem); //Begin editing newItem.Editing.BeginEdit(); try { //perform the editing newItem.Fields["GroupID"].Value = frmModel.GroupID; newItem.Fields["ForumID"].Value = frmModel.ForumID; // errorState = true; } catch (Exception ex) { // errorState = false; throw ex; } finally { //Close the editing state newItem.Editing.EndEdit(); } } } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Error with :" + ItemName + " (" + lang.Name + ")\n Details:\n" + ex.Message)); Sitecore.Diagnostics.Error.LogError("Error with :" + frmModel.Name + " (" + lang.Name + ")\n Details:\n" + ex.Message); newItem = null; } return newItem; }
protected void btnJoin_Click(object sender, EventArgs e) { this.ProfileRedirect(Constants.UserPermission.CommunityUser); if (CurrentMember != null) { if (CurrentMember.ScreenName != null) { if (IsMember) { try { Item grpItem = Groups.ConvertGroupIDtoSitecoreItem(GroupID); string itemUrl = grpItem.GetUrl(); Response.Redirect(itemUrl, true); } catch (Exception ex) { Sitecore.Diagnostics.Error.LogError("Error in btnJoin_Click for Join Group Button function.\nError:\n" + ex.Message); } } else { if (TelligentService.JoinGroup(GroupID, CurrentMember.ScreenName)) { //Send Email GroupItem grpItem = new GroupItem(Groups.ConvertGroupIDtoSitecoreItem(GroupID)); GroupCardModel grpModel = Groups.GroupCardModelFactory(grpItem); BaseReply reply = ExactTargetService.InvokeEM9GroupWelcome(new InvokeEM9GroupWelcomeRequest { PreferredLanguage = CurrentMember.PreferredLanguage, GroupLeaderEmail = grpModel.ModeratorEmail, GroupLink = grpItem.GetUrl(), GroupTitle = grpItem.DisplayName, ToEmail = CurrentMember.Email, GroupModerator = new Moderator { groupModBioLink = grpModel.ModeratorBio, groupModImgLink = grpModel.ModeratorAvatarUrl, //owner.Avatar, groupModName = grpModel.ModeratorName }, RequestUrl = Request.Url }); Text = DictionaryConstants.ViewDiscussionsLabel; } } } } }
public static GroupCardModel GroupCardModelFactory(GroupItem grpItem) { Member owner = null; GroupCardModel grpModel = new GroupCardModel(); if ((grpItem != null)) { string address = String.Empty; string xml=String.Empty; try { using (WebClient client = new WebClient()) { client.Headers.Add("Rest-User-Token", TelligentService.TelligentService.TelligentAuth()); address = string.Format(TelligentService.TelligentService.GetApiEndPoint("groups/{0}/members/users.xml?MembershipType=Owner"), grpItem.GroupID.Text); ///Approved?? //data["FriendshipState"] = Constants.TelligentFriendStatus.Approved.ToString(); xml = Encoding.UTF8.GetString(client.DownloadData(address)); } XmlDocument document = new XmlDocument(); document.LoadXml(xml); XmlNode childNode = document.SelectSingleNode("Response/Users"); if (childNode != null) { //Select first owner string username = childNode.FirstChild.SelectSingleNode("Username").InnerText; MembershipManager mem = new MembershipManager(); owner = mem.GetMemberByScreenName(username); if (owner != null) { grpModel.ModeratorAvatarUrl = childNode.FirstChild.SelectSingleNode("AvatarUrl").InnerText; grpModel.ModeratorName = owner.ScreenName; grpModel.ModeratorTitle = Constants.TelligentRoles.Roles[Constants.TelligentRoles.Moderator]; grpModel.Owner = owner; } else //Use default values { grpModel.ModeratorAvatarUrl = childNode.FirstChild.SelectSingleNode("AvatarUrl").InnerText; grpModel.ModeratorName = username; grpModel.ModeratorTitle = Constants.TelligentRoles.Roles[Constants.TelligentRoles.Moderator]; } grpModel.ForumFunc = TelligentService.TelligentService.ReadForumsList; grpModel.GrpItem = grpItem; grpModel.NumOfMembers = int.Parse(childNode.FirstChild.SelectSingleNode("Group/TotalMembers").InnerText); grpModel.Description = childNode.FirstChild.SelectSingleNode("Group/Description").InnerText; grpModel.Title = grpItem.NavigationTitle.Text; //childNode.FirstChild.SelectSingleNode("Group/Name").InnerText; } } catch (Exception ex) { Sitecore.Diagnostics.Error.LogError("Error in GetGroupOwner function.\nError:\n" + ex.Message); grpModel = null; } } return grpModel; }