Ejemplo n.º 1
0
        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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        protected void rptAllGroups_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //throw new NotImplementedException();
            if (e.Item != null)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    GroupCardModel  thisItem = ((GroupCardModel)e.Item.DataItem);
                    GroupJoinButton joinBtn  = e.FindControlAs <GroupJoinButton>("BtnJoin");
                    if (joinBtn != null)
                    {
                        if (e.Item.DataItem is GroupCardModel)
                        {
                            var id = thisItem.GroupID;
                            joinBtn.LoadState(id);
                        }
                    }
                    if (IsUserLoggedIn && !String.IsNullOrEmpty(CurrentMember.ScreenName))
                    {
                        HyperLink hrefImageLink = e.FindControlAs <HyperLink>("hrefImageLink");
                        if (hrefImageLink != null)
                        {
                            hrefImageLink.NavigateUrl = thisItem.GrpItem.GetUrl();
                        }

                        HyperLink hrefTitleLink = e.FindControlAs <HyperLink>("hrefTitleLink");
                        if (hrefImageLink != null)
                        {
                            hrefTitleLink.NavigateUrl = thisItem.GrpItem.GetUrl();
                        }
                    }
                    Image imgGroup = e.FindControlAs <Image>("imgGroup");
                    if (imgGroup != null)
                    {
                        imgGroup.ImageUrl = thisItem.ModeratorAvatarUrl ?? "http://placehold.it/150x85";
                    }
                    Literal litSkipThis = e.FindControlAs <Literal>("litSkipThis");
                    if (litSkipThis != null)
                    {
                        litSkipThis.Text = DictionaryConstants.SkipThisLabel; //Skip this
                    }
                    Literal litMembers = e.FindControlAs <Literal>("litMembers");
                    if (litMembers != null)
                    {
                        litMembers.Text = thisItem.NumOfMembers + DictionaryConstants.MembersLabel;
                    }
                    Literal litDiscussions = e.FindControlAs <Literal>("litDiscussions");
                    if (litDiscussions != null)
                    {
                        litDiscussions.Text = thisItem.NumOfDiscussions + DictionaryConstants.PostsLabel;
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        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;
                        }
                    }
                }
            }
        }
        protected void rptMyGroups_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item != null)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    GroupCardModel  thisItem     = ((GroupCardModel)e.Item.DataItem);
                    ThreadModel     recentThread = null;
                    GroupJoinButton joinBtn      = e.FindControlAs <GroupJoinButton>("btnJoin");
                    if (joinBtn != null)
                    {
                        var id = thisItem.GroupID;
                        joinBtn.LoadState(id);
                    }

                    Literal litReplies = e.FindControlAs <Literal>("litRepliesLabel");
                    if (litReplies != null)
                    {
                        litReplies.Text = DictionaryConstants.RepliesLabel;
                    }
                    Literal litPostedByLabel = e.FindControlAs <Literal>("litPostedByLabel");
                    if (litPostedByLabel != null)
                    {
                        litPostedByLabel.Text = DictionaryConstants.PostedByLabel;
                    }

                    HyperLink hrefGroImageLink = e.FindControlAs <HyperLink>("hrefGroupImageLink");
                    if (hrefGroImageLink != null)
                    {
                        hrefGroImageLink.NavigateUrl = thisItem.GrpItem.GetUrl();
                    }

                    Image imgGrpImage = e.FindControlAs <Image>("imgGroupImage");
                    if (imgGrpImage != null)
                    {
                        imgGrpImage.ImageUrl = thisItem.ModeratorAvatarUrl ?? "http://placehold.it/190x107";
                    }

                    if (thisItem.Forums.Count > 0 && thisItem.Forums != null)
                    {
                        var recentThreadlist = (thisItem.Forums
                                                .Where(f => f.Threads.Count > 0 && f.Threads != null)
                                                .Select(x => x.Threads.Where(thread => thread != null)
                                                        .OrderByDescending(t => t.LastPostDate)).FirstOrDefault());


                        if (recentThreadlist != null)
                        {
                            recentThread = recentThreadlist.FirstOrDefault <ThreadModel>();
                        }

                        if (recentThread != null)
                        {
                            HyperLink hrefDiscussionLink = e.FindControlAs <HyperLink>("hrefDiscussionLink");
                            if (hrefDiscussionLink != null)
                            {
                                var threadItem = Threads.ConvertThreadtoSitecoreItem(recentThread.ForumID, recentThread.ThreadID);
                                if (threadItem != null)
                                {
                                    hrefDiscussionLink.NavigateUrl = threadItem.GetUrl();
                                }
                            }
                            Literal litDiscussionExcerpt = e.FindControlAs <Literal>("litDiscussionExcerpt");
                            if (litDiscussionExcerpt != null)
                            {
                                litDiscussionExcerpt.Text = recentThread.Subject;
                            }
                            Literal litNumReplies = e.FindControlAs <Literal>("litNumReplies");
                            if (litNumReplies != null)
                            {
                                litNumReplies.Text = recentThread.ReplyCount;
                            }

                            Literal litPostUserName = e.FindControlAs <Literal>("litPostUserName");
                            if (litPostUserName != null)
                            {
                                litPostUserName.Text = recentThread.LastPostUser;
                            }
                            HyperLink hrefPostUser = e.FindControlAs <HyperLink>("hrefPostUser");
                            if (hrefPostUser != null)
                            {
                                hrefPostUser.NavigateUrl = MembershipHelper.GetPublicProfileUrl(recentThread.LastPostUser);
                            }
                            Literal litPostTime = e.FindControlAs <Literal>("litPostTime");
                            if (litPostTime != null)
                            {
                                litPostTime.Text = recentThread.LastPostTime;
                            }
                        }
                    }
                }
            }
        }